summaryrefslogtreecommitdiff
path: root/apps/plugins/properties.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/properties.c')
-rw-r--r--apps/plugins/properties.c82
1 files changed, 47 insertions, 35 deletions
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
36static int props_type; 36static int props_type;
37 37
38static struct gui_synclist properties_lists;
38static struct mp3entry id3; 39static struct mp3entry id3;
39static int mul_id3_count; 40static int mul_id3_count;
40static int skipped_count; 41static int skipped_count;
@@ -53,7 +54,7 @@ static int32_t lang_size_unit;
53static struct tm tm; 54static 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)
57static const unsigned char* const props_file[] = 58static 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)
70static const unsigned char* const props_dir[] = 71static 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
223static int browse_file_or_dir(struct dir_stats *stats) 224static 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
245static 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
357enum plugin_status plugin_start(const void* parameter) 357enum 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 426exit:
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