diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 19 | ||||
-rw-r--r-- | apps/plugins/shortcuts/shortcuts_view.c | 74 |
2 files changed, 70 insertions, 23 deletions
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index d1da10ee09..91062f8f11 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c | |||
@@ -533,19 +533,28 @@ static void free_all_slide_prio(int prio); | |||
533 | static bool check_database(bool prompt) | 533 | static bool check_database(bool prompt) |
534 | { | 534 | { |
535 | bool needwarn = true; | 535 | bool needwarn = true; |
536 | int spin = 5; | ||
537 | |||
536 | struct tagcache_stat *stat = rb->tagcache_get_stat(); | 538 | struct tagcache_stat *stat = rb->tagcache_get_stat(); |
539 | |||
537 | while ( !(stat->initialized && stat->ready) ) | 540 | while ( !(stat->initialized && stat->ready) ) |
538 | { | 541 | { |
539 | if (needwarn) | 542 | if (--spin > 0) |
543 | { | ||
544 | rb->sleep(HZ/5); | ||
545 | } | ||
546 | else if (needwarn) | ||
547 | { | ||
548 | needwarn = false; | ||
540 | rb->splash(0, ID2P(LANG_TAGCACHE_BUSY)); | 549 | rb->splash(0, ID2P(LANG_TAGCACHE_BUSY)); |
541 | if (!prompt) | 550 | } |
551 | else if (!prompt) | ||
542 | return false; | 552 | return false; |
543 | else if (rb->action_userabort(HZ/5)) | 553 | else if (rb->action_userabort(HZ/5)) |
544 | return false; | 554 | return false; |
545 | 555 | ||
546 | needwarn = false; | ||
547 | stat = rb->tagcache_get_stat(); | ||
548 | rb->yield(); | 556 | rb->yield(); |
557 | stat = rb->tagcache_get_stat(); | ||
549 | } | 558 | } |
550 | return true; | 559 | return true; |
551 | } | 560 | } |
@@ -3841,7 +3850,7 @@ enum plugin_status plugin_start(const void *parameter) | |||
3841 | 3850 | ||
3842 | void * buf; | 3851 | void * buf; |
3843 | size_t buf_size; | 3852 | size_t buf_size; |
3844 | bool prompt = (parameter && ((char *) parameter)[0] == ACTIVITY_MAINMENU); | 3853 | bool prompt = (parameter && (((char *) parameter)[0] == ACTIVITY_MAINMENU)); |
3845 | 3854 | ||
3846 | if (!check_database(prompt)) | 3855 | if (!check_database(prompt)) |
3847 | { | 3856 | { |
diff --git a/apps/plugins/shortcuts/shortcuts_view.c b/apps/plugins/shortcuts/shortcuts_view.c index cfc9d8d746..f4c4b58bc1 100644 --- a/apps/plugins/shortcuts/shortcuts_view.c +++ b/apps/plugins/shortcuts/shortcuts_view.c | |||
@@ -22,7 +22,7 @@ | |||
22 | 22 | ||
23 | #include "shortcuts.h" | 23 | #include "shortcuts.h" |
24 | 24 | ||
25 | 25 | #define LOOP_EXIT 1 | |
26 | 26 | ||
27 | enum sc_list_action_type | 27 | enum sc_list_action_type |
28 | { | 28 | { |
@@ -35,7 +35,6 @@ enum sc_list_action_type | |||
35 | 35 | ||
36 | static char *link_filename; | 36 | static char *link_filename; |
37 | static bool user_file; | 37 | static bool user_file; |
38 | static bool usb_connected = false; | ||
39 | 38 | ||
40 | enum sc_list_action_type draw_sc_list(struct gui_synclist *gui_sc); | 39 | enum sc_list_action_type draw_sc_list(struct gui_synclist *gui_sc); |
41 | 40 | ||
@@ -43,10 +42,10 @@ enum sc_list_action_type draw_sc_list(struct gui_synclist *gui_sc); | |||
43 | static const char* build_sc_list(int selected_item, void *data, | 42 | static const char* build_sc_list(int selected_item, void *data, |
44 | char *buffer, size_t buffer_len); | 43 | char *buffer, size_t buffer_len); |
45 | 44 | ||
46 | /* Returns true iff we should leave the main loop */ | 45 | /* Returns LOOP_EXIT iff we should leave the main loop */ |
47 | bool list_sc(void); | 46 | int list_sc(void); |
48 | 47 | ||
49 | bool goto_entry(char *file_or_dir); | 48 | int goto_entry(char *file_or_dir); |
50 | bool ends_with(char *str, char *suffix); | 49 | bool ends_with(char *str, char *suffix); |
51 | 50 | ||
52 | 51 | ||
@@ -104,7 +103,7 @@ static const char* build_sc_list(int selected_item, void *data, | |||
104 | } | 103 | } |
105 | 104 | ||
106 | 105 | ||
107 | bool list_sc(void) | 106 | int list_sc(void) |
108 | { | 107 | { |
109 | int selected_item = 0; | 108 | int selected_item = 0; |
110 | enum sc_list_action_type action = SCLA_NONE; | 109 | enum sc_list_action_type action = SCLA_NONE; |
@@ -122,8 +121,7 @@ bool list_sc(void) | |||
122 | /* Draw the prepared widget to the LCD now */ | 121 | /* Draw the prepared widget to the LCD now */ |
123 | action = draw_sc_list(&gui_sc); | 122 | action = draw_sc_list(&gui_sc); |
124 | if (action == SCLA_USB) { | 123 | if (action == SCLA_USB) { |
125 | usb_connected = true; | 124 | return PLUGIN_USB_CONNECTED; |
126 | return true; | ||
127 | } | 125 | } |
128 | 126 | ||
129 | /* which item do we action? */ | 127 | /* which item do we action? */ |
@@ -132,7 +130,7 @@ bool list_sc(void) | |||
132 | if (!is_valid_index(&sc_file, selected_item)) { | 130 | if (!is_valid_index(&sc_file, selected_item)) { |
133 | /* This should never happen */ | 131 | /* This should never happen */ |
134 | rb->splash(HZ*2, "Bad entry selected!"); | 132 | rb->splash(HZ*2, "Bad entry selected!"); |
135 | return true; | 133 | return PLUGIN_ERROR; |
136 | } | 134 | } |
137 | 135 | ||
138 | /* perform the following actions if the user "selected" | 136 | /* perform the following actions if the user "selected" |
@@ -145,13 +143,13 @@ bool list_sc(void) | |||
145 | rb->splashf(HZ, "Deleting %s", sc_file.entries[selected_item].disp); | 143 | rb->splashf(HZ, "Deleting %s", sc_file.entries[selected_item].disp); |
146 | remove_entry(&sc_file, selected_item); | 144 | remove_entry(&sc_file, selected_item); |
147 | dump_sc_file(&sc_file, link_filename); | 145 | dump_sc_file(&sc_file, link_filename); |
148 | return (sc_file.entry_cnt == 0); | 146 | return (sc_file.entry_cnt == 0)? LOOP_EXIT : PLUGIN_OK; |
149 | default: | 147 | default: |
150 | return true; | 148 | return LOOP_EXIT; |
151 | } | 149 | } |
152 | } | 150 | } |
153 | 151 | ||
154 | 152 | #if 0 | |
155 | bool goto_entry(char *file_or_dir) | 153 | bool goto_entry(char *file_or_dir) |
156 | { | 154 | { |
157 | DEBUGF("Trying to go to '%s'...\n", file_or_dir); | 155 | DEBUGF("Trying to go to '%s'...\n", file_or_dir); |
@@ -181,7 +179,46 @@ bool goto_entry(char *file_or_dir) | |||
181 | rb->set_current_file(file_or_dir); | 179 | rb->set_current_file(file_or_dir); |
182 | return true; | 180 | return true; |
183 | } | 181 | } |
182 | #endif | ||
183 | |||
184 | int goto_entry(char *file_or_dir) | ||
185 | { | ||
186 | DEBUGF("Trying to go to '%s'...\n", file_or_dir); | ||
187 | |||
188 | bool is_dir = ends_with(file_or_dir, PATH_SEPARATOR); | ||
189 | bool exists; | ||
190 | char *what; | ||
191 | if (is_dir) { | ||
192 | what = "Directory"; | ||
193 | exists = rb->dir_exists(file_or_dir); | ||
194 | } else { | ||
195 | what = "File"; | ||
196 | exists = rb->file_exists(file_or_dir); | ||
197 | } | ||
184 | 198 | ||
199 | if (!exists) { | ||
200 | rb->splashf(HZ*2, "%s %s no longer exists on disk", what, file_or_dir); | ||
201 | return PLUGIN_ERROR; | ||
202 | } | ||
203 | |||
204 | int len = rb->strlen(file_or_dir); | ||
205 | if(!is_dir && len > 5 && rb->strcasecmp(&(file_or_dir[len-5]), ".rock") == 0) | ||
206 | { | ||
207 | return rb->plugin_open(file_or_dir, NULL); | ||
208 | } | ||
209 | else | ||
210 | { | ||
211 | /* Set the browsers dirfilter to the global setting | ||
212 | * This is required in case the plugin was launched | ||
213 | * from the plugins browser, in which case the | ||
214 | * dirfilter is set to only display .rock files */ | ||
215 | rb->set_dirfilter(rb->global_settings->dirfilter); | ||
216 | |||
217 | /* Change directory to the entry selected by the user */ | ||
218 | rb->set_current_file(file_or_dir); | ||
219 | } | ||
220 | return PLUGIN_OK; | ||
221 | } | ||
185 | 222 | ||
186 | bool ends_with(char *string, char *suffix) | 223 | bool ends_with(char *string, char *suffix) |
187 | { | 224 | { |
@@ -195,7 +232,7 @@ bool ends_with(char *string, char *suffix) | |||
195 | 232 | ||
196 | enum plugin_status plugin_start(const void* void_parameter) | 233 | enum plugin_status plugin_start(const void* void_parameter) |
197 | { | 234 | { |
198 | bool leave_loop; | 235 | int ret; |
199 | 236 | ||
200 | /* This is a viewer, so a parameter must have been specified */ | 237 | /* This is a viewer, so a parameter must have been specified */ |
201 | if (void_parameter == NULL) { | 238 | if (void_parameter == NULL) { |
@@ -219,8 +256,7 @@ enum plugin_status plugin_start(const void* void_parameter) | |||
219 | /* if there's only one entry in the user .link file, | 256 | /* if there's only one entry in the user .link file, |
220 | * go straight to it without displaying the menu | 257 | * go straight to it without displaying the menu |
221 | * thus allowing 'quick links' */ | 258 | * thus allowing 'quick links' */ |
222 | goto_entry(sc_file.entries[0].path); | 259 | return goto_entry(sc_file.entries[0].path); |
223 | return PLUGIN_OK; | ||
224 | } | 260 | } |
225 | 261 | ||
226 | FOR_NB_SCREENS(i) | 262 | FOR_NB_SCREENS(i) |
@@ -228,11 +264,13 @@ enum plugin_status plugin_start(const void* void_parameter) | |||
228 | 264 | ||
229 | do { | 265 | do { |
230 | /* Display a menu to choose between the entries */ | 266 | /* Display a menu to choose between the entries */ |
231 | leave_loop = list_sc(); | 267 | ret = list_sc(); |
232 | } while (!leave_loop); | 268 | } while (ret == PLUGIN_OK); |
269 | if (ret == LOOP_EXIT) | ||
270 | ret = PLUGIN_OK; | ||
233 | 271 | ||
234 | FOR_NB_SCREENS(i) | 272 | FOR_NB_SCREENS(i) |
235 | rb->viewportmanager_theme_undo(i, false); | 273 | rb->viewportmanager_theme_undo(i, false); |
236 | 274 | ||
237 | return usb_connected ? PLUGIN_USB_CONNECTED : PLUGIN_OK; | 275 | return ret; |
238 | } | 276 | } |