diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/onplay.c | 10 | ||||
-rw-r--r-- | apps/plugins/lib/mul_id3.c | 72 | ||||
-rw-r--r-- | apps/plugins/properties.c | 82 |
3 files changed, 86 insertions, 78 deletions
diff --git a/apps/onplay.c b/apps/onplay.c index d468c0a545..4f748204df 100644 --- a/apps/onplay.c +++ b/apps/onplay.c | |||
@@ -138,7 +138,7 @@ static bool clipboard_clip(struct clipboard *clip, const char *path, | |||
138 | static int bookmark_load_menu_wrapper(void) | 138 | static int bookmark_load_menu_wrapper(void) |
139 | { | 139 | { |
140 | if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* get rid of parent activity */ | 140 | if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* get rid of parent activity */ |
141 | pop_current_activity_without_refresh(); /* when called from ctxt menu */ | 141 | pop_current_activity_without_refresh(); /* when called from ctxt menu */ |
142 | 142 | ||
143 | return bookmark_load_menu(); | 143 | return bookmark_load_menu(); |
144 | } | 144 | } |
@@ -689,7 +689,7 @@ MENUITEM_FUNCTION(view_cue_item, 0, ID2P(LANG_BROWSE_CUESHEET), | |||
689 | static int browse_id3_wrapper(void) | 689 | static int browse_id3_wrapper(void) |
690 | { | 690 | { |
691 | if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* get rid of parent activity */ | 691 | if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* get rid of parent activity */ |
692 | pop_current_activity_without_refresh(); /* when called from ctxt menu */ | 692 | pop_current_activity_without_refresh(); /* when called from ctxt menu */ |
693 | 693 | ||
694 | if (browse_id3(audio_current_track(), | 694 | if (browse_id3(audio_current_track(), |
695 | playlist_get_display_index(), | 695 | playlist_get_display_index(), |
@@ -806,6 +806,10 @@ static bool onplay_load_plugin(void *param) | |||
806 | if (!prepare_database_sel(param)) | 806 | if (!prepare_database_sel(param)) |
807 | return false; | 807 | return false; |
808 | #endif | 808 | #endif |
809 | |||
810 | if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* get rid of parent activity */ | ||
811 | pop_current_activity_without_refresh(); /* when called from ctxt menu */ | ||
812 | |||
809 | int ret = filetype_load_plugin((const char*)param, selected_file.path); | 813 | int ret = filetype_load_plugin((const char*)param, selected_file.path); |
810 | if (ret == PLUGIN_USB_CONNECTED) | 814 | if (ret == PLUGIN_USB_CONNECTED) |
811 | onplay_result = ONPLAY_RELOAD_DIR; | 815 | onplay_result = ONPLAY_RELOAD_DIR; |
@@ -1299,7 +1303,7 @@ int onplay(char* file, int attr, int from_context, bool hotkey) | |||
1299 | menu_selection = do_menu(menu, NULL, NULL, false); | 1303 | menu_selection = do_menu(menu, NULL, NULL, false); |
1300 | 1304 | ||
1301 | if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* Activity may have been */ | 1305 | if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* Activity may have been */ |
1302 | pop_current_activity(); /* popped already by menu item */ | 1306 | pop_current_activity(); /* popped already by menu item */ |
1303 | 1307 | ||
1304 | 1308 | ||
1305 | if (menu_selection == GO_TO_WPS) | 1309 | if (menu_selection == GO_TO_WPS) |
diff --git a/apps/plugins/lib/mul_id3.c b/apps/plugins/lib/mul_id3.c index c4b511c626..e88bbfe417 100644 --- a/apps/plugins/lib/mul_id3.c +++ b/apps/plugins/lib/mul_id3.c | |||
@@ -196,52 +196,45 @@ static const char *image_exts[] = {"bmp","jpg","jpe","jpeg","png","ppm"}; | |||
196 | /* and videos */ | 196 | /* and videos */ |
197 | static const char *video_exts[] = {"mpg","mpeg","mpv","m2v"}; | 197 | static const char *video_exts[] = {"mpg","mpeg","mpv","m2v"}; |
198 | 198 | ||
199 | static void prn(const char *str, int y) | 199 | static void display_dir_stats_vp(struct dir_stats *stats, struct viewport *vp, |
200 | struct screen *display) | ||
200 | { | 201 | { |
201 | rb->lcd_puts(0, y, str); | 202 | static bool initialized; |
202 | #ifdef HAVE_REMOTE_LCD | ||
203 | rb->lcd_remote_puts(0, y, str); | ||
204 | #endif | ||
205 | } | ||
206 | |||
207 | void display_dir_stats(struct dir_stats *stats) | ||
208 | { | ||
209 | char buf[32]; | ||
210 | int32_t lang_size_unit; | 203 | int32_t lang_size_unit; |
211 | unsigned long display_size = human_size(stats->byte_count, &lang_size_unit); | 204 | unsigned long display_size = human_size(stats->byte_count, &lang_size_unit); |
212 | rb->lcd_clear_display(); | 205 | struct viewport *last_vp = display->set_viewport(vp); |
213 | #ifdef HAVE_REMOTE_LCD | 206 | display->clear_viewport(); |
214 | rb->lcd_remote_clear_display(); | 207 | if (initialized) |
215 | #endif | ||
216 | rb->snprintf(buf, sizeof(buf), "Files: %d (%lu %s)", stats->file_count, | ||
217 | display_size, rb->str(lang_size_unit)); | ||
218 | prn(buf, 0); | ||
219 | rb->snprintf(buf, sizeof(buf), "Audio: %d", stats->audio_file_count); | ||
220 | prn(buf, 1); | ||
221 | if (stats->count_all) | ||
222 | { | 208 | { |
223 | rb->snprintf(buf, sizeof(buf), "Playlists: %d", stats->m3u_file_count); | 209 | display->putsf(0, 0, "Files: %d (%lu %s)", stats->file_count, |
224 | prn(buf, 2); | 210 | display_size, rb->str(lang_size_unit)); |
225 | rb->snprintf(buf, sizeof(buf), "Images: %d", stats->img_file_count); | 211 | display->putsf(0, 1, "Audio: %d", stats->audio_file_count); |
226 | prn(buf, 3); | 212 | if (stats->count_all) |
227 | rb->snprintf(buf, sizeof(buf), "Videos: %d", stats->vid_file_count); | 213 | { |
228 | prn(buf, 4); | 214 | display->putsf(0, 2, "Playlists: %d", stats->m3u_file_count); |
229 | rb->snprintf(buf, sizeof(buf), "Directories: %d", stats->dir_count); | 215 | display->putsf(0, 3, "Images: %d", stats->img_file_count); |
230 | prn(buf, 5); | 216 | display->putsf(0, 4, "Videos: %d", stats->vid_file_count); |
231 | rb->snprintf(buf, sizeof(buf), "Max files in Dir: %d", | 217 | display->putsf(0, 5, "Directories: %d", stats->dir_count); |
232 | stats->max_files_in_dir); | 218 | display->putsf(0, 6, "Max files in Dir: %d", stats->max_files_in_dir); |
233 | prn(buf, 6); | 219 | } |
220 | else | ||
221 | display->putsf(0, 2, "Directories: %d", stats->dir_count); | ||
234 | } | 222 | } |
235 | else | 223 | else |
224 | initialized = true; | ||
225 | |||
226 | display->update_viewport(); | ||
227 | display->set_viewport(last_vp); | ||
228 | } | ||
229 | |||
230 | void display_dir_stats(struct dir_stats *stats) | ||
231 | { | ||
232 | struct viewport vps[NB_SCREENS]; | ||
233 | FOR_NB_SCREENS(i) | ||
236 | { | 234 | { |
237 | rb->snprintf(buf, sizeof(buf), "Directories: %d", stats->dir_count); | 235 | rb->viewport_set_defaults(&vps[i], i); |
238 | prn(buf, 2); | 236 | display_dir_stats_vp(stats, &vps[i], rb->screens[i]); |
239 | } | 237 | } |
240 | rb->lcd_update(); | ||
241 | #ifdef HAVE_REMOTE_LCD | ||
242 | rb->lcd_remote_update(); | ||
243 | #endif | ||
244 | |||
245 | } | 238 | } |
246 | 239 | ||
247 | /* Recursively scans directories in search of files | 240 | /* Recursively scans directories in search of files |
@@ -281,8 +274,7 @@ bool collect_dir_stats(struct dir_stats *stats, bool (*id3_cb)(const char*)) | |||
281 | stats->dir_count++; /* new directory */ | 274 | stats->dir_count++; /* new directory */ |
282 | if (*rb->current_tick - last_displayed > (HZ/2)) | 275 | if (*rb->current_tick - last_displayed > (HZ/2)) |
283 | { | 276 | { |
284 | if (last_displayed) | 277 | display_dir_stats(stats); |
285 | display_dir_stats(stats); | ||
286 | last_displayed = *(rb->current_tick); | 278 | last_displayed = *(rb->current_tick); |
287 | } | 279 | } |
288 | } | 280 | } |
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c index c932474f8c..2f18d94d9f 100644 --- a/apps/plugins/properties.c +++ b/apps/plugins/properties.c | |||
@@ -35,6 +35,7 @@ enum props_types { | |||
35 | 35 | ||
36 | static int props_type; | 36 | static int props_type; |
37 | 37 | ||
38 | static struct gui_synclist properties_lists; | ||
38 | static struct mp3entry id3; | 39 | static struct mp3entry id3; |
39 | static int mul_id3_count; | 40 | static int mul_id3_count; |
40 | static int skipped_count; | 41 | static int skipped_count; |
@@ -53,7 +54,7 @@ static int32_t lang_size_unit; | |||
53 | static struct tm tm; | 54 | static struct tm tm; |
54 | 55 | ||
55 | #define NUM_FILE_PROPERTIES 5 | 56 | #define NUM_FILE_PROPERTIES 5 |
56 | #define NUM_PLAYLIST_PROPERTIES 1 + NUM_FILE_PROPERTIES | 57 | #define NUM_PLAYLIST_PROPERTIES (1 + NUM_FILE_PROPERTIES) |
57 | static const unsigned char* const props_file[] = | 58 | static const unsigned char* const props_file[] = |
58 | { | 59 | { |
59 | ID2P(LANG_PROPERTIES_PATH), str_dirname, | 60 | ID2P(LANG_PROPERTIES_PATH), str_dirname, |
@@ -66,7 +67,7 @@ static const unsigned char* const props_file[] = | |||
66 | }; | 67 | }; |
67 | 68 | ||
68 | #define NUM_DIR_PROPERTIES 4 | 69 | #define NUM_DIR_PROPERTIES 4 |
69 | #define NUM_AUDIODIR_PROPERTIES 1 + NUM_DIR_PROPERTIES | 70 | #define NUM_AUDIODIR_PROPERTIES (1 + NUM_DIR_PROPERTIES) |
70 | static const unsigned char* const props_dir[] = | 71 | static const unsigned char* const props_dir[] = |
71 | { | 72 | { |
72 | ID2P(LANG_PROPERTIES_PATH), str_dirname, | 73 | ID2P(LANG_PROPERTIES_PATH), str_dirname, |
@@ -220,41 +221,40 @@ static int speak_property_selection(int selected_item, void *data) | |||
220 | return 0; | 221 | return 0; |
221 | } | 222 | } |
222 | 223 | ||
223 | static int browse_file_or_dir(struct dir_stats *stats) | 224 | static void setup_properties_list(struct dir_stats *stats) |
224 | { | 225 | { |
225 | struct gui_synclist properties_lists; | 226 | int nb_props; |
226 | int button, nb_items; | ||
227 | |||
228 | if (props_type == PROPS_FILE) | 227 | if (props_type == PROPS_FILE) |
229 | nb_items = NUM_FILE_PROPERTIES; | 228 | nb_props = NUM_FILE_PROPERTIES; |
230 | else if (props_type == PROPS_PLAYLIST) | 229 | else if (props_type == PROPS_PLAYLIST) |
231 | nb_items = NUM_PLAYLIST_PROPERTIES; | 230 | nb_props = NUM_PLAYLIST_PROPERTIES; |
232 | else if (stats->audio_file_count) | ||
233 | nb_items = NUM_AUDIODIR_PROPERTIES; | ||
234 | else | 231 | else |
235 | nb_items = NUM_DIR_PROPERTIES; | 232 | nb_props = NUM_DIR_PROPERTIES; |
236 | 233 | ||
237 | nb_items *= 2; | ||
238 | |||
239 | rb->gui_synclist_init(&properties_lists, &get_props, stats, false, 2, NULL); | 234 | rb->gui_synclist_init(&properties_lists, &get_props, stats, false, 2, NULL); |
240 | rb->gui_synclist_set_title(&properties_lists, | 235 | rb->gui_synclist_set_title(&properties_lists, |
241 | rb->str(props_type == PROPS_DIR ? | 236 | rb->str(props_type == PROPS_DIR ? |
242 | LANG_PROPERTIES_DIRECTORY_PROPERTIES : | 237 | LANG_PROPERTIES_DIRECTORY_PROPERTIES : |
243 | LANG_PROPERTIES_FILE_PROPERTIES), | 238 | LANG_PROPERTIES_FILE_PROPERTIES), |
244 | NOICON); | 239 | NOICON); |
245 | rb->gui_synclist_set_icon_callback(&properties_lists, NULL); | ||
246 | if (rb->global_settings->talk_menu) | 240 | if (rb->global_settings->talk_menu) |
247 | rb->gui_synclist_set_voice_callback(&properties_lists, speak_property_selection); | 241 | rb->gui_synclist_set_voice_callback(&properties_lists, speak_property_selection); |
248 | rb->gui_synclist_set_nb_items(&properties_lists, nb_items); | 242 | rb->gui_synclist_set_nb_items(&properties_lists, nb_props*2); |
249 | rb->gui_synclist_select_item(&properties_lists, 0); | 243 | } |
244 | |||
245 | static int browse_file_or_dir(struct dir_stats *stats) | ||
246 | { | ||
247 | int button; | ||
248 | |||
249 | if (props_type == PROPS_DIR && stats->audio_file_count) | ||
250 | rb->gui_synclist_set_nb_items(&properties_lists, NUM_AUDIODIR_PROPERTIES*2); | ||
250 | rb->gui_synclist_draw(&properties_lists); | 251 | rb->gui_synclist_draw(&properties_lists); |
251 | rb->gui_synclist_speak_item(&properties_lists); | 252 | rb->gui_synclist_speak_item(&properties_lists); |
252 | |||
253 | while(true) | 253 | while(true) |
254 | { | 254 | { |
255 | button = rb->get_action(CONTEXT_LIST, HZ); | 255 | button = rb->get_action(CONTEXT_LIST, HZ); |
256 | /* HZ so the status bar redraws corectly */ | 256 | /* HZ so the status bar redraws corectly */ |
257 | if (rb->gui_synclist_do_button(&properties_lists,&button)) | 257 | if (rb->gui_synclist_do_button(&properties_lists, &button)) |
258 | continue; | 258 | continue; |
259 | switch(button) | 259 | switch(button) |
260 | { | 260 | { |
@@ -356,12 +356,14 @@ static bool assemble_track_info(const char *filename, struct dir_stats *stats) | |||
356 | 356 | ||
357 | enum plugin_status plugin_start(const void* parameter) | 357 | enum plugin_status plugin_start(const void* parameter) |
358 | { | 358 | { |
359 | int ret; | 359 | int ret = 0; |
360 | static struct dir_stats stats; | 360 | static struct dir_stats stats; |
361 | const char *file = parameter; | 361 | const char *file = parameter; |
362 | if(!parameter) | 362 | if(!parameter) |
363 | return PLUGIN_ERROR; | 363 | return PLUGIN_ERROR; |
364 | 364 | ||
365 | FOR_NB_SCREENS(i) | ||
366 | rb->viewportmanager_theme_enable(i, true, NULL); | ||
365 | #ifdef HAVE_TOUCHSCREEN | 367 | #ifdef HAVE_TOUCHSCREEN |
366 | rb->touchscreen_set_mode(rb->global_settings->touch_mode); | 368 | rb->touchscreen_set_mode(rb->global_settings->touch_mode); |
367 | #endif | 369 | #endif |
@@ -374,34 +376,44 @@ enum plugin_status plugin_start(const void* parameter) | |||
374 | 376 | ||
375 | if(!determine_file_or_dir()) | 377 | if(!determine_file_or_dir()) |
376 | { | 378 | { |
377 | /* weird: we couldn't find the entry. This Should Never Happen (TM) */ | ||
378 | rb->splashf(0, "File/Dir not found: %s", file); | 379 | rb->splashf(0, "File/Dir not found: %s", file); |
379 | rb->action_userabort(TIMEOUT_BLOCK); | 380 | rb->action_userabort(TIMEOUT_BLOCK); |
380 | return PLUGIN_OK; | 381 | goto exit; |
381 | } | 382 | } |
382 | 383 | ||
383 | if (props_type == PROPS_FILE && has_pl_extension(file)) | 384 | if (props_type == PROPS_FILE) |
384 | props_type = PROPS_PLAYLIST; | 385 | { |
386 | if (has_pl_extension(file)) | ||
387 | props_type = PROPS_PLAYLIST; | ||
388 | |||
389 | ret = !file_properties(file); | ||
390 | } | ||
385 | 391 | ||
386 | if(!(props_type == PROPS_DIR ? | 392 | if (props_type != PROPS_ID3) /* i.e. not handled by browse_id3 */ |
387 | dir_properties(file, &stats, NULL) : file_properties(file))) | ||
388 | { | 393 | { |
394 | setup_properties_list(&stats); /* Show title during dir scan */ | ||
395 | if (props_type == PROPS_DIR) | ||
396 | ret = !dir_properties(file, &stats, NULL); | ||
397 | } | ||
398 | if (ret) | ||
399 | { | ||
400 | ret = 0; | ||
389 | if (!stats.canceled) | 401 | if (!stats.canceled) |
390 | { | 402 | { |
391 | /* something went wrong (to do: tell user what it was (nesting,...) */ | 403 | /* TODO: describe error */ |
392 | rb->splash(0, ID2P(LANG_PROPERTIES_FAIL)); | 404 | rb->splash(0, ID2P(LANG_PROPERTIES_FAIL)); |
393 | rb->action_userabort(TIMEOUT_BLOCK); | 405 | rb->action_userabort(TIMEOUT_BLOCK); |
394 | } | 406 | } |
395 | return PLUGIN_OK; | 407 | goto exit; |
396 | } | 408 | } |
397 | } | 409 | } |
398 | /* database table selected */ | 410 | /* database table selected */ |
399 | else if (rb->strcmp(file, MAKE_ACT_STR(ACTIVITY_DATABASEBROWSER)) | 411 | else if (rb->strcmp(file, MAKE_ACT_STR(ACTIVITY_DATABASEBROWSER)) |
400 | || !assemble_track_info(NULL, NULL)) | 412 | || !assemble_track_info(NULL, NULL)) |
401 | return PLUGIN_ERROR; | 413 | { |
402 | 414 | ret = -1; | |
403 | FOR_NB_SCREENS(i) | 415 | goto exit; |
404 | rb->viewportmanager_theme_enable(i, true, NULL); | 416 | } |
405 | 417 | ||
406 | if (props_type == PROPS_ID3) | 418 | if (props_type == PROPS_ID3) |
407 | ret = rb->browse_id3(&id3, 0, 0, &tm, 1); /* Track Info for single file */ | 419 | ret = rb->browse_id3(&id3, 0, 0, &tm, 1); /* Track Info for single file */ |
@@ -411,7 +423,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
411 | ret = assemble_track_info(file, &stats) ? /* playlist or folder tracks */ | 423 | ret = assemble_track_info(file, &stats) ? /* playlist or folder tracks */ |
412 | rb->browse_id3(&id3, 0, 0, NULL, mul_id3_count) : | 424 | rb->browse_id3(&id3, 0, 0, NULL, mul_id3_count) : |
413 | (stats.canceled ? 0 : -1); | 425 | (stats.canceled ? 0 : -1); |
414 | 426 | exit: | |
415 | FOR_NB_SCREENS(i) | 427 | FOR_NB_SCREENS(i) |
416 | rb->viewportmanager_theme_undo(i, false); | 428 | rb->viewportmanager_theme_undo(i, false); |
417 | 429 | ||