diff options
Diffstat (limited to 'apps/onplay.c')
-rw-r--r-- | apps/onplay.c | 104 |
1 files changed, 72 insertions, 32 deletions
diff --git a/apps/onplay.c b/apps/onplay.c index ae25ae37d0..0c8afd9a0b 100644 --- a/apps/onplay.c +++ b/apps/onplay.c | |||
@@ -93,7 +93,8 @@ static bool clipboard_is_copy = false; | |||
93 | /* interface function. */ | 93 | /* interface function. */ |
94 | /* ----------------------------------------------------------------------- */ | 94 | /* ----------------------------------------------------------------------- */ |
95 | 95 | ||
96 | static int bookmark_menu_callback(int action,const struct menu_item_ex *this_item); | 96 | static int bookmark_menu_callback(int action, |
97 | const struct menu_item_ex *this_item); | ||
97 | MENUITEM_FUNCTION(bookmark_create_menu_item, 0, | 98 | MENUITEM_FUNCTION(bookmark_create_menu_item, 0, |
98 | ID2P(LANG_BOOKMARK_MENU_CREATE), | 99 | ID2P(LANG_BOOKMARK_MENU_CREATE), |
99 | bookmark_create_menu, NULL, NULL, Icon_Bookmark); | 100 | bookmark_create_menu, NULL, NULL, Icon_Bookmark); |
@@ -103,7 +104,8 @@ MENUITEM_FUNCTION(bookmark_load_menu_item, 0, | |||
103 | bookmark_menu_callback, Icon_Bookmark); | 104 | bookmark_menu_callback, Icon_Bookmark); |
104 | MAKE_MENU(bookmark_menu, ID2P(LANG_BOOKMARK_MENU), bookmark_menu_callback, | 105 | MAKE_MENU(bookmark_menu, ID2P(LANG_BOOKMARK_MENU), bookmark_menu_callback, |
105 | Icon_Bookmark, &bookmark_create_menu_item, &bookmark_load_menu_item); | 106 | Icon_Bookmark, &bookmark_create_menu_item, &bookmark_load_menu_item); |
106 | static int bookmark_menu_callback(int action,const struct menu_item_ex *this_item) | 107 | static int bookmark_menu_callback(int action, |
108 | const struct menu_item_ex *this_item) | ||
107 | { | 109 | { |
108 | (void)this_item; | 110 | (void)this_item; |
109 | switch (action) | 111 | switch (action) |
@@ -243,9 +245,11 @@ static bool cat_add_to_a_new_playlist(void) | |||
243 | } | 245 | } |
244 | 246 | ||
245 | 247 | ||
246 | static int cat_playlist_callback(int action,const struct menu_item_ex *this_item); | 248 | static int cat_playlist_callback(int action, |
249 | const struct menu_item_ex *this_item); | ||
247 | MENUITEM_FUNCTION(cat_view_lists, 0, ID2P(LANG_CATALOG_VIEW), | 250 | MENUITEM_FUNCTION(cat_view_lists, 0, ID2P(LANG_CATALOG_VIEW), |
248 | catalog_view_playlists, 0, cat_playlist_callback, Icon_Playlist); | 251 | catalog_view_playlists, 0, cat_playlist_callback, |
252 | Icon_Playlist); | ||
249 | MENUITEM_FUNCTION(cat_add_to_list, 0, ID2P(LANG_CATALOG_ADD_TO), | 253 | MENUITEM_FUNCTION(cat_add_to_list, 0, ID2P(LANG_CATALOG_ADD_TO), |
250 | cat_add_to_a_playlist, 0, NULL, Icon_Playlist); | 254 | cat_add_to_a_playlist, 0, NULL, Icon_Playlist); |
251 | MENUITEM_FUNCTION(cat_add_to_new, 0, ID2P(LANG_CATALOG_ADD_TO_NEW), | 255 | MENUITEM_FUNCTION(cat_add_to_new, 0, ID2P(LANG_CATALOG_ADD_TO_NEW), |
@@ -254,7 +258,8 @@ MAKE_MENU( cat_playlist_menu, ID2P(LANG_CATALOG), cat_playlist_callback, | |||
254 | Icon_Playlist, &cat_view_lists, | 258 | Icon_Playlist, &cat_view_lists, |
255 | &cat_add_to_list, &cat_add_to_new ); | 259 | &cat_add_to_list, &cat_add_to_new ); |
256 | 260 | ||
257 | static int cat_playlist_callback(int action,const struct menu_item_ex *this_item) | 261 | static int cat_playlist_callback(int action, |
262 | const struct menu_item_ex *this_item) | ||
258 | { | 263 | { |
259 | switch (action) | 264 | switch (action) |
260 | { | 265 | { |
@@ -264,7 +269,8 @@ static int cat_playlist_callback(int action,const struct menu_item_ex *this_item | |||
264 | if (context == CONTEXT_WPS) | 269 | if (context == CONTEXT_WPS) |
265 | return action; | 270 | return action; |
266 | } | 271 | } |
267 | else if (selected_file && /* set before calling this menu, so safe */ | 272 | else if (selected_file && /* set before calling this menu, |
273 | so safe */ | ||
268 | ((audio_status() & AUDIO_STATUS_PLAY && | 274 | ((audio_status() & AUDIO_STATUS_PLAY && |
269 | context == CONTEXT_WPS) || | 275 | context == CONTEXT_WPS) || |
270 | context == CONTEXT_TREE)) | 276 | context == CONTEXT_TREE)) |
@@ -308,7 +314,8 @@ static int playlist_queue_func(void *param) | |||
308 | return 0; | 314 | return 0; |
309 | } | 315 | } |
310 | static int treeplaylist_wplayback_callback(int action, | 316 | static int treeplaylist_wplayback_callback(int action, |
311 | const struct menu_item_ex *this_item) | 317 | const struct menu_item_ex* |
318 | this_item) | ||
312 | { | 319 | { |
313 | (void)this_item; | 320 | (void)this_item; |
314 | switch (action) | 321 | switch (action) |
@@ -327,18 +334,22 @@ static int treeplaylist_callback(int action, | |||
327 | const struct menu_item_ex *this_item); | 334 | const struct menu_item_ex *this_item); |
328 | 335 | ||
329 | /* insert items */ | 336 | /* insert items */ |
337 | MENUITEM_FUNCTION(i_pl_item_no_play, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT), | ||
338 | playlist_insert_func, (intptr_t*)PLAYLIST_INSERT_LAST, | ||
339 | treeplaylist_callback, Icon_Playlist); | ||
330 | MENUITEM_FUNCTION(i_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT), | 340 | MENUITEM_FUNCTION(i_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT), |
331 | playlist_insert_func, (intptr_t*)PLAYLIST_INSERT, | 341 | playlist_insert_func, (intptr_t*)PLAYLIST_INSERT, |
332 | treeplaylist_callback, Icon_Playlist); | 342 | treeplaylist_wplayback_callback, Icon_Playlist); |
333 | MENUITEM_FUNCTION(i_first_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT_FIRST), | 343 | MENUITEM_FUNCTION(i_first_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT_FIRST), |
334 | playlist_insert_func, (intptr_t*)PLAYLIST_INSERT_FIRST, | 344 | playlist_insert_func, (intptr_t*)PLAYLIST_INSERT_FIRST, |
335 | treeplaylist_wplayback_callback, Icon_Playlist); | 345 | treeplaylist_wplayback_callback, Icon_Playlist); |
336 | MENUITEM_FUNCTION(i_last_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT_LAST), | 346 | MENUITEM_FUNCTION(i_last_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT_LAST), |
337 | playlist_insert_func, (intptr_t*)PLAYLIST_INSERT_LAST, | 347 | playlist_insert_func, (intptr_t*)PLAYLIST_INSERT_LAST, |
338 | treeplaylist_wplayback_callback, Icon_Playlist); | 348 | treeplaylist_wplayback_callback, Icon_Playlist); |
339 | MENUITEM_FUNCTION(i_shuf_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT_SHUFFLED), | 349 | MENUITEM_FUNCTION(i_shuf_pl_item, MENU_FUNC_USEPARAM, |
340 | playlist_insert_func, (intptr_t*)PLAYLIST_INSERT_SHUFFLED, | 350 | ID2P(LANG_INSERT_SHUFFLED), playlist_insert_func, |
341 | treeplaylist_callback, Icon_Playlist); | 351 | (intptr_t*)PLAYLIST_INSERT_SHUFFLED, treeplaylist_callback, |
352 | Icon_Playlist); | ||
342 | /* queue items */ | 353 | /* queue items */ |
343 | MENUITEM_FUNCTION(q_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE), | 354 | MENUITEM_FUNCTION(q_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE), |
344 | playlist_queue_func, (intptr_t*)PLAYLIST_INSERT, | 355 | playlist_queue_func, (intptr_t*)PLAYLIST_INSERT, |
@@ -349,8 +360,9 @@ MENUITEM_FUNCTION(q_first_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE_FIRST), | |||
349 | MENUITEM_FUNCTION(q_last_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE_LAST), | 360 | MENUITEM_FUNCTION(q_last_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE_LAST), |
350 | playlist_queue_func, (intptr_t*)PLAYLIST_INSERT_LAST, | 361 | playlist_queue_func, (intptr_t*)PLAYLIST_INSERT_LAST, |
351 | treeplaylist_wplayback_callback, Icon_Playlist); | 362 | treeplaylist_wplayback_callback, Icon_Playlist); |
352 | MENUITEM_FUNCTION(q_shuf_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE_SHUFFLED), | 363 | MENUITEM_FUNCTION(q_shuf_pl_item, MENU_FUNC_USEPARAM, |
353 | playlist_queue_func, (intptr_t*)PLAYLIST_INSERT_SHUFFLED, | 364 | ID2P(LANG_QUEUE_SHUFFLED), playlist_queue_func, |
365 | (intptr_t*)PLAYLIST_INSERT_SHUFFLED, | ||
354 | treeplaylist_wplayback_callback, Icon_Playlist); | 366 | treeplaylist_wplayback_callback, Icon_Playlist); |
355 | /* replace playlist */ | 367 | /* replace playlist */ |
356 | MENUITEM_FUNCTION(replace_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_REPLACE), | 368 | MENUITEM_FUNCTION(replace_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_REPLACE), |
@@ -363,11 +375,19 @@ MENUITEM_FUNCTION(view_playlist_item, 0, ID2P(LANG_VIEW), | |||
363 | treeplaylist_callback, Icon_Playlist); | 375 | treeplaylist_callback, Icon_Playlist); |
364 | 376 | ||
365 | MAKE_ONPLAYMENU( tree_playlist_menu, ID2P(LANG_PLAYLIST_MENU), | 377 | MAKE_ONPLAYMENU( tree_playlist_menu, ID2P(LANG_PLAYLIST_MENU), |
366 | treeplaylist_callback, Icon_Playlist, &view_playlist_item, | 378 | treeplaylist_callback, Icon_Playlist, |
379 | |||
380 | /* view */ | ||
381 | &view_playlist_item, | ||
382 | |||
367 | /* insert */ | 383 | /* insert */ |
368 | &i_pl_item, &i_first_pl_item, &i_last_pl_item, &i_shuf_pl_item, | 384 | &i_pl_item_no_play, &i_pl_item, &i_first_pl_item, |
385 | &i_last_pl_item, &i_shuf_pl_item, | ||
386 | |||
369 | /* queue */ | 387 | /* queue */ |
370 | &q_pl_item, &q_first_pl_item, &q_last_pl_item, &q_shuf_pl_item, | 388 | &q_pl_item, &q_first_pl_item, &q_last_pl_item, |
389 | &q_shuf_pl_item, | ||
390 | |||
371 | /* replace */ | 391 | /* replace */ |
372 | &replace_pl_item | 392 | &replace_pl_item |
373 | ); | 393 | ); |
@@ -380,7 +400,8 @@ static int treeplaylist_callback(int action, | |||
380 | case ACTION_REQUEST_MENUITEM: | 400 | case ACTION_REQUEST_MENUITEM: |
381 | if (this_item == &tree_playlist_menu) | 401 | if (this_item == &tree_playlist_menu) |
382 | { | 402 | { |
383 | if (((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO) || | 403 | if (((selected_file_attr & FILE_ATTR_MASK) == |
404 | FILE_ATTR_AUDIO) || | ||
384 | ((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U)|| | 405 | ((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U)|| |
385 | (selected_file_attr & ATTR_DIRECTORY)) | 406 | (selected_file_attr & ATTR_DIRECTORY)) |
386 | { | 407 | { |
@@ -397,8 +418,15 @@ static int treeplaylist_callback(int action, | |||
397 | else | 418 | else |
398 | return ACTION_EXIT_MENUITEM; | 419 | return ACTION_EXIT_MENUITEM; |
399 | } | 420 | } |
400 | if (this_item == &i_pl_item) | 421 | else if (this_item == &i_pl_item_no_play) |
401 | return action; | 422 | { |
423 | if (!(audio_status() & AUDIO_STATUS_PLAY)) | ||
424 | { | ||
425 | return action; | ||
426 | } | ||
427 | else | ||
428 | return ACTION_EXIT_MENUITEM; | ||
429 | } | ||
402 | else if (this_item == &i_shuf_pl_item) | 430 | else if (this_item == &i_shuf_pl_item) |
403 | { | 431 | { |
404 | 432 | ||
@@ -539,7 +567,8 @@ static bool set_backdrop(void) | |||
539 | /* load the image */ | 567 | /* load the image */ |
540 | if(load_main_backdrop(selected_file)) { | 568 | if(load_main_backdrop(selected_file)) { |
541 | gui_syncsplash(HZ, str(LANG_BACKDROP_LOADED)); | 569 | gui_syncsplash(HZ, str(LANG_BACKDROP_LOADED)); |
542 | set_file(selected_file, (char *)global_settings.backdrop_file, MAX_FILENAME); | 570 | set_file(selected_file, (char *)global_settings.backdrop_file, |
571 | MAX_FILENAME); | ||
543 | show_main_backdrop(); | 572 | show_main_backdrop(); |
544 | return true; | 573 | return true; |
545 | } else { | 574 | } else { |
@@ -642,7 +671,8 @@ static bool clipboard_pastefile(const char *src, const char *target, bool copy) | |||
642 | /* See if we can get the plugin buffer for the file copy buffer */ | 671 | /* See if we can get the plugin buffer for the file copy buffer */ |
643 | buffer = (char *) plugin_get_buffer(&buffersize); | 672 | buffer = (char *) plugin_get_buffer(&buffersize); |
644 | if (buffer == NULL || buffersize < 512) { | 673 | if (buffer == NULL || buffersize < 512) { |
645 | /* Not large enough, try for a disk sector worth of stack instead */ | 674 | /* Not large enough, try for a disk sector worth of stack |
675 | instead */ | ||
646 | buffersize = 512; | 676 | buffersize = 512; |
647 | buffer = (char *) __builtin_alloca(buffersize); | 677 | buffer = (char *) __builtin_alloca(buffersize); |
648 | } | 678 | } |
@@ -651,7 +681,8 @@ static bool clipboard_pastefile(const char *src, const char *target, bool copy) | |||
651 | return false; | 681 | return false; |
652 | } | 682 | } |
653 | 683 | ||
654 | buffersize &= ~0x1ff; /* Round buffer size to multiple of sector size */ | 684 | buffersize &= ~0x1ff; /* Round buffer size to multiple of sector |
685 | size */ | ||
655 | 686 | ||
656 | src_fd = open(src, O_RDONLY); | 687 | src_fd = open(src, O_RDONLY); |
657 | 688 | ||
@@ -705,7 +736,8 @@ static bool clipboard_pastefile(const char *src, const char *target, bool copy) | |||
705 | #ifdef HAVE_MULTIVOLUME | 736 | #ifdef HAVE_MULTIVOLUME |
706 | if (!result) { | 737 | if (!result) { |
707 | if (errno == EXDEV) { | 738 | if (errno == EXDEV) { |
708 | /* Failed because cross volume rename doesn't work. Copy instead */ | 739 | /* Failed because cross volume rename doesn't work. Copy |
740 | instead */ | ||
709 | result = clipboard_pastefile(src, target, true); | 741 | result = clipboard_pastefile(src, target, true); |
710 | 742 | ||
711 | if (result) { | 743 | if (result) { |
@@ -719,8 +751,10 @@ static bool clipboard_pastefile(const char *src, const char *target, bool copy) | |||
719 | return result; | 751 | return result; |
720 | } | 752 | } |
721 | 753 | ||
722 | /* Paste a directory to a new location. Designed to be called by clipboard_paste */ | 754 | /* Paste a directory to a new location. Designed to be called by |
723 | static bool clipboard_pastedirectory(char *src, int srclen, char *target, int targetlen, bool copy) | 755 | clipboard_paste */ |
756 | static bool clipboard_pastedirectory(char *src, int srclen, char *target, | ||
757 | int targetlen, bool copy) | ||
724 | { | 758 | { |
725 | DIR *srcdir; | 759 | DIR *srcdir; |
726 | int srcdirlen = strlen(src); | 760 | int srcdirlen = strlen(src); |
@@ -740,7 +774,8 @@ static bool clipboard_pastedirectory(char *src, int srclen, char *target, int ta | |||
740 | #ifdef HAVE_MULTIVOLUME | 774 | #ifdef HAVE_MULTIVOLUME |
741 | if (!result && errno == EXDEV) { | 775 | if (!result && errno == EXDEV) { |
742 | /* Try a copy as we're going across devices */ | 776 | /* Try a copy as we're going across devices */ |
743 | result = clipboard_pastedirectory(src, srclen, target, targetlen, true); | 777 | result = clipboard_pastedirectory(src, srclen, target, |
778 | targetlen, true); | ||
744 | 779 | ||
745 | /* If it worked, remove the source directory */ | 780 | /* If it worked, remove the source directory */ |
746 | if (result) { | 781 | if (result) { |
@@ -776,7 +811,8 @@ static bool clipboard_pastedirectory(char *src, int srclen, char *target, int ta | |||
776 | 811 | ||
777 | /* append name to current directory */ | 812 | /* append name to current directory */ |
778 | snprintf(src+srcdirlen, srclen-srcdirlen, "/%s", entry->d_name); | 813 | snprintf(src+srcdirlen, srclen-srcdirlen, "/%s", entry->d_name); |
779 | snprintf(target+targetdirlen, targetlen-targetdirlen, "/%s", entry->d_name); | 814 | snprintf(target+targetdirlen, targetlen-targetdirlen, "/%s", |
815 | entry->d_name); | ||
780 | 816 | ||
781 | DEBUGF("Copy %s to %s\n", src, target); | 817 | DEBUGF("Copy %s to %s\n", src, target); |
782 | 818 | ||
@@ -786,7 +822,8 @@ static bool clipboard_pastedirectory(char *src, int srclen, char *target, int ta | |||
786 | !strcmp((char *)entry->d_name, "..")) | 822 | !strcmp((char *)entry->d_name, "..")) |
787 | continue; /* skip these */ | 823 | continue; /* skip these */ |
788 | 824 | ||
789 | result = clipboard_pastedirectory(src, srclen, target, targetlen, copy); /* recursion */ | 825 | result = clipboard_pastedirectory(src, srclen, target, targetlen, |
826 | copy); /* recursion */ | ||
790 | } | 827 | } |
791 | else | 828 | else |
792 | { /* copy/move a file */ | 829 | { /* copy/move a file */ |
@@ -841,7 +878,8 @@ static bool clipboard_paste(void) | |||
841 | char targetpath[MAX_PATH]; | 878 | char targetpath[MAX_PATH]; |
842 | if (!strncmp(clipboard_selection, target, strlen(clipboard_selection))) | 879 | if (!strncmp(clipboard_selection, target, strlen(clipboard_selection))) |
843 | { | 880 | { |
844 | /* Do not allow the user to paste a directory into a dir they are copying */ | 881 | /* Do not allow the user to paste a directory into a dir they are |
882 | copying */ | ||
845 | success = 0; | 883 | success = 0; |
846 | } | 884 | } |
847 | else | 885 | else |
@@ -853,7 +891,8 @@ static bool clipboard_paste(void) | |||
853 | target, sizeof(targetpath), clipboard_is_copy); | 891 | target, sizeof(targetpath), clipboard_is_copy); |
854 | } | 892 | } |
855 | } else { | 893 | } else { |
856 | success = clipboard_pastefile(clipboard_selection, target, clipboard_is_copy); | 894 | success = clipboard_pastefile(clipboard_selection, target, |
895 | clipboard_is_copy); | ||
857 | } | 896 | } |
858 | 897 | ||
859 | /* Did it work? */ | 898 | /* Did it work? */ |
@@ -935,7 +974,8 @@ static bool view_cue(void) | |||
935 | } | 974 | } |
936 | return false; | 975 | return false; |
937 | } | 976 | } |
938 | static int view_cue_item_callback(int action,const struct menu_item_ex *this_item) | 977 | static int view_cue_item_callback(int action, |
978 | const struct menu_item_ex *this_item) | ||
939 | { | 979 | { |
940 | (void)this_item; | 980 | (void)this_item; |
941 | struct mp3entry* id3 = audio_current_track(); | 981 | struct mp3entry* id3 = audio_current_track(); |
@@ -1088,7 +1128,7 @@ int onplay(char* file, int attr, int from) | |||
1088 | { | 1128 | { |
1089 | int menu_result; | 1129 | int menu_result; |
1090 | int selected_item = 0; /* this is a bit of a hack to reopen | 1130 | int selected_item = 0; /* this is a bit of a hack to reopen |
1091 | the menu if certain items are selected */ | 1131 | the menu if certain items are selected */ |
1092 | onplay_result = ONPLAY_OK; | 1132 | onplay_result = ONPLAY_OK; |
1093 | context = from; | 1133 | context = from; |
1094 | selected_file = file; | 1134 | selected_file = file; |