diff options
-rw-r--r-- | apps/onplay.c | 405 |
1 files changed, 193 insertions, 212 deletions
diff --git a/apps/onplay.c b/apps/onplay.c index 8bb71e1555..1485f2ffab 100644 --- a/apps/onplay.c +++ b/apps/onplay.c | |||
@@ -81,12 +81,7 @@ static bool clipboard_is_copy = false; | |||
81 | {MT_MENU|MENU_HAS_DESC|MENU_EXITAFTERTHISMENU| \ | 81 | {MT_MENU|MENU_HAS_DESC|MENU_EXITAFTERTHISMENU| \ |
82 | MENU_ITEM_COUNT(sizeof( name##_)/sizeof(*name##_)), \ | 82 | MENU_ITEM_COUNT(sizeof( name##_)/sizeof(*name##_)), \ |
83 | { (void*)name##_},{.callback_and_desc = & name##__}}; | 83 | { (void*)name##_},{.callback_and_desc = & name##__}}; |
84 | 84 | ||
85 | #ifdef HAVE_LCD_BITMAP | ||
86 | static void draw_slider(void); | ||
87 | #else | ||
88 | #define draw_slider() | ||
89 | #endif | ||
90 | /* ----------------------------------------------------------------------- */ | 85 | /* ----------------------------------------------------------------------- */ |
91 | /* Displays the bookmark menu options for the user to decide. This is an */ | 86 | /* Displays the bookmark menu options for the user to decide. This is an */ |
92 | /* interface function. */ | 87 | /* interface function. */ |
@@ -94,20 +89,19 @@ static void draw_slider(void); | |||
94 | 89 | ||
95 | static int bookmark_menu_callback(int action, | 90 | static int bookmark_menu_callback(int action, |
96 | const struct menu_item_ex *this_item); | 91 | const struct menu_item_ex *this_item); |
97 | MENUITEM_FUNCTION(bookmark_create_menu_item, 0, | 92 | MENUITEM_FUNCTION(bookmark_create_menu_item, 0, |
98 | ID2P(LANG_BOOKMARK_MENU_CREATE), | 93 | ID2P(LANG_BOOKMARK_MENU_CREATE), |
99 | bookmark_create_menu, NULL, NULL, Icon_Bookmark); | 94 | bookmark_create_menu, NULL, NULL, Icon_Bookmark); |
100 | MENUITEM_FUNCTION(bookmark_load_menu_item, 0, | 95 | MENUITEM_FUNCTION(bookmark_load_menu_item, 0, |
101 | ID2P(LANG_BOOKMARK_MENU_LIST), | 96 | ID2P(LANG_BOOKMARK_MENU_LIST), |
102 | bookmark_load_menu, NULL, | 97 | bookmark_load_menu, NULL, |
103 | bookmark_menu_callback, Icon_Bookmark); | 98 | bookmark_menu_callback, Icon_Bookmark); |
104 | MAKE_ONPLAYMENU(bookmark_menu, ID2P(LANG_BOOKMARK_MENU), bookmark_menu_callback, | 99 | MAKE_ONPLAYMENU(bookmark_menu, ID2P(LANG_BOOKMARK_MENU), |
105 | Icon_Bookmark, &bookmark_create_menu_item, | 100 | bookmark_menu_callback, Icon_Bookmark, |
106 | &bookmark_load_menu_item); | 101 | &bookmark_create_menu_item, &bookmark_load_menu_item); |
107 | static int bookmark_menu_callback(int action, | 102 | static int bookmark_menu_callback(int action, |
108 | const struct menu_item_ex *this_item) | 103 | const struct menu_item_ex *this_item) |
109 | { | 104 | { |
110 | (void)this_item; | ||
111 | switch (action) | 105 | switch (action) |
112 | { | 106 | { |
113 | case ACTION_REQUEST_MENUITEM: | 107 | case ACTION_REQUEST_MENUITEM: |
@@ -135,14 +129,7 @@ static int bookmark_menu_callback(int action, | |||
135 | return action; | 129 | return action; |
136 | } | 130 | } |
137 | 131 | ||
138 | static bool list_viewers(void) | 132 | /* CONTEXT_WPS playlist options */ |
139 | { | ||
140 | int ret = filetype_list_viewers(selected_file); | ||
141 | if (ret == PLUGIN_USB_CONNECTED) | ||
142 | onplay_result = ONPLAY_RELOAD_DIR; | ||
143 | return false; | ||
144 | } | ||
145 | |||
146 | static bool shuffle_playlist(void) | 133 | static bool shuffle_playlist(void) |
147 | { | 134 | { |
148 | playlist_sort(NULL, true); | 135 | playlist_sort(NULL, true); |
@@ -157,6 +144,21 @@ static bool save_playlist(void) | |||
157 | return false; | 144 | return false; |
158 | } | 145 | } |
159 | 146 | ||
147 | MENUITEM_FUNCTION(playlist_viewer_item, 0, ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), | ||
148 | playlist_viewer, NULL, NULL, Icon_Playlist); | ||
149 | MENUITEM_FUNCTION(search_playlist_item, 0, ID2P(LANG_SEARCH_IN_PLAYLIST), | ||
150 | search_playlist, NULL, NULL, Icon_Playlist); | ||
151 | MENUITEM_FUNCTION(playlist_save_item, 0, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), | ||
152 | save_playlist, NULL, NULL, Icon_Playlist); | ||
153 | MENUITEM_FUNCTION(reshuffle_item, 0, ID2P(LANG_SHUFFLE_PLAYLIST), | ||
154 | shuffle_playlist, NULL, NULL, Icon_Playlist); | ||
155 | MAKE_ONPLAYMENU( wps_playlist_menu, ID2P(LANG_PLAYLIST), | ||
156 | NULL, Icon_Playlist, | ||
157 | &playlist_viewer_item, &search_playlist_item, | ||
158 | &playlist_save_item, &reshuffle_item | ||
159 | ); | ||
160 | |||
161 | /* CONTEXT_[TREE|ID3DB] playlist options */ | ||
160 | static bool add_to_playlist(int position, bool queue) | 162 | static bool add_to_playlist(int position, bool queue) |
161 | { | 163 | { |
162 | bool new_playlist = !(audio_status() & AUDIO_STATUS_PLAY); | 164 | bool new_playlist = !(audio_status() & AUDIO_STATUS_PLAY); |
@@ -167,7 +169,7 @@ static bool add_to_playlist(int position, bool queue) | |||
167 | const struct text_message message={lines, 2}; | 169 | const struct text_message message={lines, 2}; |
168 | 170 | ||
169 | splash(0, ID2P(LANG_WAIT)); | 171 | splash(0, ID2P(LANG_WAIT)); |
170 | 172 | ||
171 | if (new_playlist) | 173 | if (new_playlist) |
172 | playlist_create(NULL, NULL); | 174 | playlist_create(NULL, NULL); |
173 | 175 | ||
@@ -193,7 +195,7 @@ static bool add_to_playlist(int position, bool queue) | |||
193 | else if (selected_file_attr & ATTR_DIRECTORY) | 195 | else if (selected_file_attr & ATTR_DIRECTORY) |
194 | { | 196 | { |
195 | bool recurse = false; | 197 | bool recurse = false; |
196 | 198 | ||
197 | if (global_settings.recursive_dir_insert != RECURSE_ASK) | 199 | if (global_settings.recursive_dir_insert != RECURSE_ASK) |
198 | recurse = (bool)global_settings.recursive_dir_insert; | 200 | recurse = (bool)global_settings.recursive_dir_insert; |
199 | else | 201 | else |
@@ -208,7 +210,7 @@ static bool add_to_playlist(int position, bool queue) | |||
208 | else if ((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U) | 210 | else if ((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U) |
209 | playlist_insert_playlist(NULL, selected_file, position, queue); | 211 | playlist_insert_playlist(NULL, selected_file, position, queue); |
210 | } | 212 | } |
211 | 213 | ||
212 | if (new_playlist && (playlist_amount() > 0)) | 214 | if (new_playlist && (playlist_amount() > 0)) |
213 | { | 215 | { |
214 | /* nothing is currently playing so begin playing what we just | 216 | /* nothing is currently playing so begin playing what we just |
@@ -237,84 +239,6 @@ static bool view_playlist(void) | |||
237 | return result; | 239 | return result; |
238 | } | 240 | } |
239 | 241 | ||
240 | static bool cat_add_to_a_playlist(void) | ||
241 | { | ||
242 | return catalog_add_to_a_playlist(selected_file, selected_file_attr, | ||
243 | false, NULL); | ||
244 | } | ||
245 | |||
246 | static bool cat_add_to_a_new_playlist(void) | ||
247 | { | ||
248 | return catalog_add_to_a_playlist(selected_file, selected_file_attr, | ||
249 | true, NULL); | ||
250 | } | ||
251 | |||
252 | |||
253 | static int cat_playlist_callback(int action, | ||
254 | const struct menu_item_ex *this_item); | ||
255 | MENUITEM_FUNCTION(cat_view_lists, 0, ID2P(LANG_CATALOG_VIEW), | ||
256 | catalog_view_playlists, 0, cat_playlist_callback, | ||
257 | Icon_Playlist); | ||
258 | MENUITEM_FUNCTION(cat_add_to_list, 0, ID2P(LANG_CATALOG_ADD_TO), | ||
259 | cat_add_to_a_playlist, 0, NULL, Icon_Playlist); | ||
260 | MENUITEM_FUNCTION(cat_add_to_new, 0, ID2P(LANG_CATALOG_ADD_TO_NEW), | ||
261 | cat_add_to_a_new_playlist, 0, NULL, Icon_Playlist); | ||
262 | MAKE_ONPLAYMENU(cat_playlist_menu, ID2P(LANG_CATALOG), cat_playlist_callback, | ||
263 | Icon_Playlist, &cat_view_lists, &cat_add_to_list, | ||
264 | &cat_add_to_new); | ||
265 | |||
266 | static int cat_playlist_callback(int action, | ||
267 | const struct menu_item_ex *this_item) | ||
268 | { | ||
269 | if (((selected_file_attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) && | ||
270 | ((selected_file_attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) && | ||
271 | ((selected_file_attr & ATTR_DIRECTORY) == 0)) | ||
272 | { | ||
273 | return ACTION_EXIT_MENUITEM; | ||
274 | } | ||
275 | |||
276 | switch (action) | ||
277 | { | ||
278 | case ACTION_REQUEST_MENUITEM: | ||
279 | if (this_item == &cat_view_lists) | ||
280 | { | ||
281 | if (context == CONTEXT_WPS) | ||
282 | return action; | ||
283 | } | ||
284 | else if (selected_file && /* set before calling this menu, | ||
285 | so safe */ | ||
286 | ((audio_status() & AUDIO_STATUS_PLAY && | ||
287 | context == CONTEXT_WPS) || | ||
288 | context == CONTEXT_TREE)) | ||
289 | { | ||
290 | return action; | ||
291 | } | ||
292 | else | ||
293 | return ACTION_EXIT_MENUITEM; | ||
294 | break; | ||
295 | } | ||
296 | return action; | ||
297 | } | ||
298 | |||
299 | |||
300 | /* CONTEXT_WPS playlist options */ | ||
301 | MENUITEM_FUNCTION(playlist_viewer_item, 0, | ||
302 | ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), playlist_viewer, | ||
303 | NULL, NULL, Icon_Playlist); | ||
304 | MENUITEM_FUNCTION(search_playlist_item, 0, | ||
305 | ID2P(LANG_SEARCH_IN_PLAYLIST), search_playlist, | ||
306 | NULL, NULL, Icon_Playlist); | ||
307 | MENUITEM_FUNCTION(playlist_save_item, 0, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), | ||
308 | save_playlist, NULL, NULL, Icon_Playlist); | ||
309 | MENUITEM_FUNCTION(reshuffle_item, 0, ID2P(LANG_SHUFFLE_PLAYLIST), | ||
310 | shuffle_playlist, NULL, NULL, Icon_Playlist); | ||
311 | MAKE_ONPLAYMENU( wps_playlist_menu, ID2P(LANG_PLAYLIST), | ||
312 | NULL, Icon_Playlist, | ||
313 | &playlist_viewer_item, &search_playlist_item, | ||
314 | &playlist_save_item, &reshuffle_item | ||
315 | ); | ||
316 | |||
317 | /* CONTEXT_[TREE|ID3DB] playlist options */ | ||
318 | static int playlist_insert_func(void *param) | 242 | static int playlist_insert_func(void *param) |
319 | { | 243 | { |
320 | if (((intptr_t)param == PLAYLIST_REPLACE) && !warn_on_pl_erase()) | 244 | if (((intptr_t)param == PLAYLIST_REPLACE) && !warn_on_pl_erase()) |
@@ -322,14 +246,15 @@ static int playlist_insert_func(void *param) | |||
322 | add_to_playlist((intptr_t)param, false); | 246 | add_to_playlist((intptr_t)param, false); |
323 | return 0; | 247 | return 0; |
324 | } | 248 | } |
249 | |||
325 | static int playlist_queue_func(void *param) | 250 | static int playlist_queue_func(void *param) |
326 | { | 251 | { |
327 | add_to_playlist((intptr_t)param, true); | 252 | add_to_playlist((intptr_t)param, true); |
328 | return 0; | 253 | return 0; |
329 | } | 254 | } |
255 | |||
330 | static int treeplaylist_wplayback_callback(int action, | 256 | static int treeplaylist_wplayback_callback(int action, |
331 | const struct menu_item_ex* | 257 | const struct menu_item_ex* this_item) |
332 | this_item) | ||
333 | { | 258 | { |
334 | (void)this_item; | 259 | (void)this_item; |
335 | switch (action) | 260 | switch (action) |
@@ -337,7 +262,7 @@ static int treeplaylist_wplayback_callback(int action, | |||
337 | case ACTION_REQUEST_MENUITEM: | 262 | case ACTION_REQUEST_MENUITEM: |
338 | if (audio_status() & AUDIO_STATUS_PLAY) | 263 | if (audio_status() & AUDIO_STATUS_PLAY) |
339 | return action; | 264 | return action; |
340 | else | 265 | else |
341 | return ACTION_EXIT_MENUITEM; | 266 | return ACTION_EXIT_MENUITEM; |
342 | break; | 267 | break; |
343 | } | 268 | } |
@@ -359,12 +284,12 @@ MENUITEM_FUNCTION(i_last_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT_LAST), | |||
359 | treeplaylist_wplayback_callback, Icon_Playlist); | 284 | treeplaylist_wplayback_callback, Icon_Playlist); |
360 | MENUITEM_FUNCTION(i_shuf_pl_item, MENU_FUNC_USEPARAM, | 285 | MENUITEM_FUNCTION(i_shuf_pl_item, MENU_FUNC_USEPARAM, |
361 | ID2P(LANG_INSERT_SHUFFLED), playlist_insert_func, | 286 | ID2P(LANG_INSERT_SHUFFLED), playlist_insert_func, |
362 | (intptr_t*)PLAYLIST_INSERT_SHUFFLED, treeplaylist_callback, | 287 | (intptr_t*)PLAYLIST_INSERT_SHUFFLED, |
363 | Icon_Playlist); | 288 | treeplaylist_callback, Icon_Playlist); |
364 | MENUITEM_FUNCTION(i_last_shuf_pl_item, MENU_FUNC_USEPARAM, | 289 | MENUITEM_FUNCTION(i_last_shuf_pl_item, MENU_FUNC_USEPARAM, |
365 | ID2P(LANG_INSERT_LAST_SHUFFLED), playlist_insert_func, | 290 | ID2P(LANG_INSERT_LAST_SHUFFLED), playlist_insert_func, |
366 | (intptr_t*)PLAYLIST_INSERT_LAST_SHUFFLED, treeplaylist_callback, | 291 | (intptr_t*)PLAYLIST_INSERT_LAST_SHUFFLED, |
367 | Icon_Playlist); | 292 | treeplaylist_callback, Icon_Playlist); |
368 | /* queue items */ | 293 | /* queue items */ |
369 | MENUITEM_FUNCTION(q_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE), | 294 | MENUITEM_FUNCTION(q_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_QUEUE), |
370 | playlist_queue_func, (intptr_t*)PLAYLIST_INSERT, | 295 | playlist_queue_func, (intptr_t*)PLAYLIST_INSERT, |
@@ -387,27 +312,25 @@ MENUITEM_FUNCTION(q_last_shuf_pl_item, MENU_FUNC_USEPARAM, | |||
387 | MENUITEM_FUNCTION(replace_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_REPLACE), | 312 | MENUITEM_FUNCTION(replace_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_REPLACE), |
388 | playlist_insert_func, (intptr_t*)PLAYLIST_REPLACE, | 313 | playlist_insert_func, (intptr_t*)PLAYLIST_REPLACE, |
389 | treeplaylist_wplayback_callback, Icon_Playlist); | 314 | treeplaylist_wplayback_callback, Icon_Playlist); |
390 | /* others */ | ||
391 | 315 | ||
316 | /* others */ | ||
392 | MENUITEM_FUNCTION(view_playlist_item, 0, ID2P(LANG_VIEW), | 317 | MENUITEM_FUNCTION(view_playlist_item, 0, ID2P(LANG_VIEW), |
393 | view_playlist, NULL, | 318 | view_playlist, NULL, |
394 | treeplaylist_callback, Icon_Playlist); | 319 | treeplaylist_callback, Icon_Playlist); |
395 | 320 | ||
396 | MAKE_ONPLAYMENU( tree_playlist_menu, ID2P(LANG_PLAYLIST), | 321 | MAKE_ONPLAYMENU( tree_playlist_menu, ID2P(LANG_PLAYLIST), |
397 | treeplaylist_callback, Icon_Playlist, | 322 | treeplaylist_callback, Icon_Playlist, |
398 | 323 | ||
399 | /* view */ | 324 | /* view */ |
400 | &view_playlist_item, | 325 | &view_playlist_item, |
401 | 326 | ||
402 | /* insert */ | 327 | /* insert */ |
403 | &i_pl_item, &i_first_pl_item, | 328 | &i_pl_item, &i_first_pl_item, &i_last_pl_item, |
404 | &i_last_pl_item, &i_shuf_pl_item, | 329 | &i_shuf_pl_item, &i_last_shuf_pl_item, |
405 | &i_last_shuf_pl_item, | ||
406 | |||
407 | /* queue */ | 330 | /* queue */ |
331 | |||
408 | &q_pl_item, &q_first_pl_item, &q_last_pl_item, | 332 | &q_pl_item, &q_first_pl_item, &q_last_pl_item, |
409 | &q_shuf_pl_item, | 333 | &q_shuf_pl_item, &q_last_shuf_pl_item, |
410 | &q_last_shuf_pl_item, | ||
411 | 334 | ||
412 | /* replace */ | 335 | /* replace */ |
413 | &replace_pl_item | 336 | &replace_pl_item |
@@ -415,47 +338,44 @@ MAKE_ONPLAYMENU( tree_playlist_menu, ID2P(LANG_PLAYLIST), | |||
415 | static int treeplaylist_callback(int action, | 338 | static int treeplaylist_callback(int action, |
416 | const struct menu_item_ex *this_item) | 339 | const struct menu_item_ex *this_item) |
417 | { | 340 | { |
418 | (void)this_item; | ||
419 | switch (action) | 341 | switch (action) |
420 | { | 342 | { |
421 | case ACTION_REQUEST_MENUITEM: | 343 | case ACTION_REQUEST_MENUITEM: |
422 | if (this_item == &tree_playlist_menu) | 344 | if (this_item == &tree_playlist_menu) |
423 | { | 345 | { |
424 | if (((selected_file_attr & FILE_ATTR_MASK) == | 346 | if (((selected_file_attr & FILE_ATTR_MASK) == |
425 | FILE_ATTR_AUDIO) || | 347 | FILE_ATTR_AUDIO) || |
426 | ((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U)|| | 348 | ((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U)|| |
427 | (selected_file_attr & ATTR_DIRECTORY)) | 349 | (selected_file_attr & ATTR_DIRECTORY)) |
428 | { | 350 | { |
429 | return action; | 351 | return action; |
430 | } | 352 | } |
431 | else | 353 | else |
432 | return ACTION_EXIT_MENUITEM; | 354 | return ACTION_EXIT_MENUITEM; |
433 | } | 355 | } |
434 | else if (this_item == &view_playlist_item) | 356 | else if (this_item == &view_playlist_item) |
435 | { | 357 | { |
436 | if ((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U && | 358 | if ((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U && |
437 | context == CONTEXT_TREE) | 359 | context == CONTEXT_TREE) |
360 | { | ||
438 | return action; | 361 | return action; |
439 | else | 362 | } |
363 | else | ||
440 | return ACTION_EXIT_MENUITEM; | 364 | return ACTION_EXIT_MENUITEM; |
441 | } | 365 | } |
442 | else if (this_item == &i_shuf_pl_item) | 366 | else if (this_item == &i_shuf_pl_item) |
443 | { | 367 | { |
444 | if (audio_status() & AUDIO_STATUS_PLAY) | 368 | if ((audio_status() & AUDIO_STATUS_PLAY) || |
445 | { | 369 | (selected_file_attr & ATTR_DIRECTORY) || |
446 | return action; | 370 | ((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U)) |
447 | } | ||
448 | else if ((this_item == &i_shuf_pl_item) && | ||
449 | ((selected_file_attr & ATTR_DIRECTORY) || | ||
450 | ((selected_file_attr & FILE_ATTR_MASK) == | ||
451 | FILE_ATTR_M3U))) | ||
452 | { | 371 | { |
453 | return action; | 372 | return action; |
454 | } | 373 | } |
455 | return ACTION_EXIT_MENUITEM; | 374 | else |
375 | return ACTION_EXIT_MENUITEM; | ||
456 | } | 376 | } |
457 | else if (this_item == &i_last_shuf_pl_item || | 377 | else if (this_item == &i_last_shuf_pl_item || |
458 | this_item == &q_last_shuf_pl_item) | 378 | this_item == &q_last_shuf_pl_item) |
459 | { | 379 | { |
460 | if ((playlist_amount() > 0) && | 380 | if ((playlist_amount() > 0) && |
461 | (audio_status() & AUDIO_STATUS_PLAY) && | 381 | (audio_status() & AUDIO_STATUS_PLAY) && |
@@ -472,6 +392,86 @@ static int treeplaylist_callback(int action, | |||
472 | return action; | 392 | return action; |
473 | } | 393 | } |
474 | 394 | ||
395 | |||
396 | /* playlist catalog options */ | ||
397 | static bool cat_add_to_a_playlist(void) | ||
398 | { | ||
399 | return catalog_add_to_a_playlist(selected_file, selected_file_attr, | ||
400 | false, NULL); | ||
401 | } | ||
402 | |||
403 | static bool cat_add_to_a_new_playlist(void) | ||
404 | { | ||
405 | return catalog_add_to_a_playlist(selected_file, selected_file_attr, | ||
406 | true, NULL); | ||
407 | } | ||
408 | |||
409 | static int cat_playlist_callback(int action, | ||
410 | const struct menu_item_ex *this_item); | ||
411 | MENUITEM_FUNCTION(cat_view_lists, 0, ID2P(LANG_CATALOG_VIEW), | ||
412 | catalog_view_playlists, 0, | ||
413 | cat_playlist_callback, Icon_Playlist); | ||
414 | MENUITEM_FUNCTION(cat_add_to_list, 0, ID2P(LANG_CATALOG_ADD_TO), | ||
415 | cat_add_to_a_playlist, 0, NULL, Icon_Playlist); | ||
416 | MENUITEM_FUNCTION(cat_add_to_new, 0, ID2P(LANG_CATALOG_ADD_TO_NEW), | ||
417 | cat_add_to_a_new_playlist, 0, NULL, Icon_Playlist); | ||
418 | MAKE_ONPLAYMENU(cat_playlist_menu, ID2P(LANG_CATALOG), | ||
419 | cat_playlist_callback, Icon_Playlist, | ||
420 | &cat_view_lists, &cat_add_to_list, &cat_add_to_new); | ||
421 | |||
422 | static int cat_playlist_callback(int action, | ||
423 | const struct menu_item_ex *this_item) | ||
424 | { | ||
425 | if (((selected_file_attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) && | ||
426 | ((selected_file_attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) && | ||
427 | ((selected_file_attr & ATTR_DIRECTORY) == 0)) | ||
428 | { | ||
429 | return ACTION_EXIT_MENUITEM; | ||
430 | } | ||
431 | |||
432 | switch (action) | ||
433 | { | ||
434 | case ACTION_REQUEST_MENUITEM: | ||
435 | if (this_item == &cat_view_lists) | ||
436 | { | ||
437 | if (context == CONTEXT_WPS) | ||
438 | return action; | ||
439 | } | ||
440 | else if (selected_file && /* set before calling this menu, | ||
441 | so safe */ | ||
442 | ((audio_status() & AUDIO_STATUS_PLAY && | ||
443 | context == CONTEXT_WPS) || | ||
444 | context == CONTEXT_TREE)) | ||
445 | { | ||
446 | return action; | ||
447 | } | ||
448 | else | ||
449 | return ACTION_EXIT_MENUITEM; | ||
450 | break; | ||
451 | } | ||
452 | return action; | ||
453 | } | ||
454 | |||
455 | #ifdef HAVE_LCD_BITMAP | ||
456 | static void draw_slider(void) | ||
457 | { | ||
458 | int i; | ||
459 | FOR_NB_SCREENS(i) | ||
460 | { | ||
461 | struct viewport vp; | ||
462 | int slider_height = 2*screens[i].getcharheight(); | ||
463 | viewport_set_defaults(&vp, i); | ||
464 | screens[i].set_viewport(&vp); | ||
465 | show_busy_slider(&screens[i], 1, vp.height - slider_height, | ||
466 | vp.width-2, slider_height-1); | ||
467 | screens[i].update_viewport(); | ||
468 | screens[i].set_viewport(NULL); | ||
469 | } | ||
470 | } | ||
471 | #else | ||
472 | #define draw_slider() | ||
473 | #endif | ||
474 | |||
475 | /* helper function to remove a non-empty directory */ | 475 | /* helper function to remove a non-empty directory */ |
476 | static int remove_dir(char* dirname, int len) | 476 | static int remove_dir(char* dirname, int len) |
477 | { | 477 | { |
@@ -492,8 +492,9 @@ static int remove_dir(char* dirname, int len) | |||
492 | break; | 492 | break; |
493 | 493 | ||
494 | dirname[dirlen] ='\0'; | 494 | dirname[dirlen] ='\0'; |
495 | /* inform the user which dir we're deleting */ | ||
495 | splash(0, dirname); | 496 | splash(0, dirname); |
496 | 497 | ||
497 | /* append name to current directory */ | 498 | /* append name to current directory */ |
498 | snprintf(dirname+dirlen, len-dirlen, "/%s", entry->d_name); | 499 | snprintf(dirname+dirlen, len-dirlen, "/%s", entry->d_name); |
499 | if (entry->attribute & ATTR_DIRECTORY) | 500 | if (entry->attribute & ATTR_DIRECTORY) |
@@ -502,15 +503,13 @@ static int remove_dir(char* dirname, int len) | |||
502 | !strcmp((char *)entry->d_name, "..")) | 503 | !strcmp((char *)entry->d_name, "..")) |
503 | continue; /* skip these */ | 504 | continue; /* skip these */ |
504 | 505 | ||
505 | /* inform the user which dir we're deleting */ | ||
506 | |||
507 | result = remove_dir(dirname, len); /* recursion */ | 506 | result = remove_dir(dirname, len); /* recursion */ |
508 | if (result) | 507 | if (result) |
509 | break; /* or better continue, delete what we can? */ | 508 | break; /* or better continue, delete what we can? */ |
510 | } | 509 | } |
511 | else | 510 | else |
512 | { /* remove a file */ | 511 | { /* remove a file */ |
513 | draw_slider(); | 512 | draw_slider(); |
514 | result = remove(dirname); | 513 | result = remove(dirname); |
515 | } | 514 | } |
516 | if(ACTION_STD_CANCEL == get_action(CONTEXT_STD,TIMEOUT_NOBLOCK)) | 515 | if(ACTION_STD_CANCEL == get_action(CONTEXT_STD,TIMEOUT_NOBLOCK)) |
@@ -553,7 +552,7 @@ static bool delete_handler(bool is_dir) | |||
553 | 552 | ||
554 | if(gui_syncyesno_run(&message, &yes_message, NULL)!=YESNO_YES) | 553 | if(gui_syncyesno_run(&message, &yes_message, NULL)!=YESNO_YES) |
555 | return false; | 554 | return false; |
556 | 555 | ||
557 | splash(0, str(LANG_DELETING)); | 556 | splash(0, str(LANG_DELETING)); |
558 | 557 | ||
559 | int res; | 558 | int res; |
@@ -574,7 +573,6 @@ static bool delete_handler(bool is_dir) | |||
574 | return (res == 0); | 573 | return (res == 0); |
575 | } | 574 | } |
576 | 575 | ||
577 | |||
578 | static bool delete_file(void) | 576 | static bool delete_file(void) |
579 | { | 577 | { |
580 | return delete_handler(false); | 578 | return delete_handler(false); |
@@ -585,23 +583,6 @@ static bool delete_dir(void) | |||
585 | return delete_handler(true); | 583 | return delete_handler(true); |
586 | } | 584 | } |
587 | 585 | ||
588 | #if LCD_DEPTH > 1 | ||
589 | static bool set_backdrop(void) | ||
590 | { | ||
591 | /* load the image */ | ||
592 | if(sb_set_backdrop(SCREEN_MAIN, selected_file)) { | ||
593 | splash(HZ, str(LANG_BACKDROP_LOADED)); | ||
594 | set_file(selected_file, (char *)global_settings.backdrop_file, | ||
595 | MAX_FILENAME); | ||
596 | return true; | ||
597 | } else { | ||
598 | splash(HZ, str(LANG_BACKDROP_FAILED)); | ||
599 | return false; | ||
600 | } | ||
601 | return true; | ||
602 | } | ||
603 | #endif | ||
604 | |||
605 | static bool rename_file(void) | 586 | static bool rename_file(void) |
606 | { | 587 | { |
607 | char newname[MAX_PATH]; | 588 | char newname[MAX_PATH]; |
@@ -631,8 +612,7 @@ static bool create_dir(void) | |||
631 | cwd = getcwd(NULL, 0); | 612 | cwd = getcwd(NULL, 0); |
632 | memset(dirname, 0, sizeof dirname); | 613 | memset(dirname, 0, sizeof dirname); |
633 | 614 | ||
634 | snprintf(dirname, sizeof dirname, "%s/", | 615 | snprintf(dirname, sizeof dirname, "%s/", cwd[1] ? cwd : ""); |
635 | cwd[1] ? cwd : ""); | ||
636 | 616 | ||
637 | pathlen = strlen(dirname); | 617 | pathlen = strlen(dirname); |
638 | rc = kbd_input(dirname + pathlen, (sizeof dirname)-pathlen); | 618 | rc = kbd_input(dirname + pathlen, (sizeof dirname)-pathlen); |
@@ -651,14 +631,6 @@ static bool create_dir(void) | |||
651 | return true; | 631 | return true; |
652 | } | 632 | } |
653 | 633 | ||
654 | static bool properties(void) | ||
655 | { | ||
656 | if(PLUGIN_USB_CONNECTED == filetype_load_plugin("properties", | ||
657 | selected_file)) | ||
658 | onplay_result = ONPLAY_RELOAD_DIR; | ||
659 | return false; | ||
660 | } | ||
661 | |||
662 | /* Store the current selection in the clipboard */ | 634 | /* Store the current selection in the clipboard */ |
663 | static bool clipboard_clip(bool copy) | 635 | static bool clipboard_clip(bool copy) |
664 | { | 636 | { |
@@ -680,23 +652,6 @@ static bool clipboard_copy(void) | |||
680 | return clipboard_clip(true); | 652 | return clipboard_clip(true); |
681 | } | 653 | } |
682 | 654 | ||
683 | #ifdef HAVE_LCD_BITMAP | ||
684 | static void draw_slider(void) | ||
685 | { | ||
686 | int i; | ||
687 | FOR_NB_SCREENS(i) | ||
688 | { | ||
689 | struct viewport vp; | ||
690 | viewport_set_defaults(&vp, i); | ||
691 | screens[i].set_viewport(&vp); | ||
692 | show_busy_slider(&screens[i], vp.x, | ||
693 | (vp.y+vp.height)-2*screens[i].getcharheight(), | ||
694 | vp.width, 2*screens[i].getcharheight()-1); | ||
695 | screens[i].update(); | ||
696 | } | ||
697 | } | ||
698 | #endif | ||
699 | |||
700 | /* Paste a file to a new directory. Will overwrite always. */ | 655 | /* Paste a file to a new directory. Will overwrite always. */ |
701 | static bool clipboard_pastefile(const char *src, const char *target, bool copy) | 656 | static bool clipboard_pastefile(const char *src, const char *target, bool copy) |
702 | { | 657 | { |
@@ -862,6 +817,7 @@ static bool clipboard_pastedirectory(char *src, int srclen, char *target, | |||
862 | } | 817 | } |
863 | else | 818 | else |
864 | { /* copy/move a file */ | 819 | { /* copy/move a file */ |
820 | draw_slider(); | ||
865 | result = clipboard_pastefile(src, target, copy); | 821 | result = clipboard_pastefile(src, target, copy); |
866 | } | 822 | } |
867 | } | 823 | } |
@@ -925,7 +881,7 @@ static bool clipboard_paste(void) | |||
925 | { | 881 | { |
926 | strlcpy(srcpath, clipboard_selection, sizeof(srcpath)); | 882 | strlcpy(srcpath, clipboard_selection, sizeof(srcpath)); |
927 | strlcpy(targetpath, target, sizeof(targetpath)); | 883 | strlcpy(targetpath, target, sizeof(targetpath)); |
928 | 884 | ||
929 | success = clipboard_pastedirectory(srcpath, sizeof(srcpath), | 885 | success = clipboard_pastedirectory(srcpath, sizeof(srcpath), |
930 | target, sizeof(targetpath), clipboard_is_copy); | 886 | target, sizeof(targetpath), clipboard_is_copy); |
931 | 887 | ||
@@ -959,12 +915,11 @@ static bool clipboard_paste(void) | |||
959 | return true; | 915 | return true; |
960 | } | 916 | } |
961 | 917 | ||
962 | static int onplaymenu_callback(int action,const struct menu_item_ex *this_item); | ||
963 | #ifdef HAVE_TAGCACHE | 918 | #ifdef HAVE_TAGCACHE |
964 | static int set_rating_inline(void) | 919 | static int set_rating_inline(void) |
965 | { | 920 | { |
966 | struct mp3entry* id3 = audio_current_track(); | 921 | struct mp3entry* id3 = audio_current_track(); |
967 | if (id3 && id3->tagcache_idx && global_settings.runtimedb) | 922 | if (id3 && id3->tagcache_idx && global_settings.runtimedb) |
968 | { | 923 | { |
969 | set_int_ex(str(LANG_MENU_SET_RATING), "", UNIT_INT, (void*)(&id3->rating), | 924 | set_int_ex(str(LANG_MENU_SET_RATING), "", UNIT_INT, (void*)(&id3->rating), |
970 | NULL, 1, 0, 10, NULL, NULL); | 925 | NULL, 1, 0, 10, NULL, NULL); |
@@ -987,8 +942,8 @@ static int ratingitem_callback(int action,const struct menu_item_ex *this_item) | |||
987 | } | 942 | } |
988 | return action; | 943 | return action; |
989 | } | 944 | } |
990 | MENUITEM_FUNCTION(rating_item, 0, ID2P(LANG_MENU_SET_RATING), | 945 | MENUITEM_FUNCTION(rating_item, 0, ID2P(LANG_MENU_SET_RATING), |
991 | set_rating_inline, NULL, | 946 | set_rating_inline, NULL, |
992 | ratingitem_callback, Icon_Questionmark); | 947 | ratingitem_callback, Icon_Questionmark); |
993 | #endif | 948 | #endif |
994 | 949 | ||
@@ -1041,13 +996,50 @@ MENUITEM_FUNCTION(delete_file_item, 0, ID2P(LANG_DELETE), | |||
1041 | delete_file, NULL, clipboard_callback, Icon_NOICON); | 996 | delete_file, NULL, clipboard_callback, Icon_NOICON); |
1042 | MENUITEM_FUNCTION(delete_dir_item, 0, ID2P(LANG_DELETE_DIR), | 997 | MENUITEM_FUNCTION(delete_dir_item, 0, ID2P(LANG_DELETE_DIR), |
1043 | delete_dir, NULL, clipboard_callback, Icon_NOICON); | 998 | delete_dir, NULL, clipboard_callback, Icon_NOICON); |
1044 | MENUITEM_FUNCTION(properties_item, 0, ID2P(LANG_PROPERTIES), | ||
1045 | properties, NULL, clipboard_callback, Icon_NOICON); | ||
1046 | MENUITEM_FUNCTION(create_dir_item, 0, ID2P(LANG_CREATE_DIR), | 999 | MENUITEM_FUNCTION(create_dir_item, 0, ID2P(LANG_CREATE_DIR), |
1047 | create_dir, NULL, clipboard_callback, Icon_NOICON); | 1000 | create_dir, NULL, clipboard_callback, Icon_NOICON); |
1001 | |||
1002 | /* other items */ | ||
1003 | static bool list_viewers(void) | ||
1004 | { | ||
1005 | int ret = filetype_list_viewers(selected_file); | ||
1006 | if (ret == PLUGIN_USB_CONNECTED) | ||
1007 | onplay_result = ONPLAY_RELOAD_DIR; | ||
1008 | return false; | ||
1009 | } | ||
1010 | |||
1011 | static bool onplay_load_plugin(void *param) | ||
1012 | { | ||
1013 | int ret = filetype_load_plugin((const char*)param, selected_file); | ||
1014 | if (ret == PLUGIN_USB_CONNECTED) | ||
1015 | onplay_result = ONPLAY_RELOAD_DIR; | ||
1016 | return false; | ||
1017 | } | ||
1018 | |||
1048 | MENUITEM_FUNCTION(list_viewers_item, 0, ID2P(LANG_ONPLAY_OPEN_WITH), | 1019 | MENUITEM_FUNCTION(list_viewers_item, 0, ID2P(LANG_ONPLAY_OPEN_WITH), |
1049 | list_viewers, NULL, clipboard_callback, Icon_NOICON); | 1020 | list_viewers, NULL, clipboard_callback, Icon_NOICON); |
1021 | MENUITEM_FUNCTION(properties_item, MENU_FUNC_USEPARAM, ID2P(LANG_PROPERTIES), | ||
1022 | onplay_load_plugin, (void *)"properties", | ||
1023 | clipboard_callback, Icon_NOICON); | ||
1024 | MENUITEM_FUNCTION(add_to_faves_item, MENU_FUNC_USEPARAM, ID2P(LANG_ADD_TO_FAVES), | ||
1025 | onplay_load_plugin, (void *)"shortcuts_append", | ||
1026 | clipboard_callback, Icon_NOICON); | ||
1027 | |||
1050 | #if LCD_DEPTH > 1 | 1028 | #if LCD_DEPTH > 1 |
1029 | static bool set_backdrop(void) | ||
1030 | { | ||
1031 | /* load the image */ | ||
1032 | if(sb_set_backdrop(SCREEN_MAIN, selected_file)) { | ||
1033 | splash(HZ, str(LANG_BACKDROP_LOADED)); | ||
1034 | set_file(selected_file, (char *)global_settings.backdrop_file, | ||
1035 | MAX_FILENAME); | ||
1036 | return true; | ||
1037 | } else { | ||
1038 | splash(HZ, str(LANG_BACKDROP_FAILED)); | ||
1039 | return false; | ||
1040 | } | ||
1041 | return true; | ||
1042 | } | ||
1051 | MENUITEM_FUNCTION(set_backdrop_item, 0, ID2P(LANG_SET_AS_BACKDROP), | 1043 | MENUITEM_FUNCTION(set_backdrop_item, 0, ID2P(LANG_SET_AS_BACKDROP), |
1052 | set_backdrop, NULL, clipboard_callback, Icon_NOICON); | 1044 | set_backdrop, NULL, clipboard_callback, Icon_NOICON); |
1053 | #endif | 1045 | #endif |
@@ -1062,16 +1054,6 @@ static bool set_recdir(void) | |||
1062 | MENUITEM_FUNCTION(set_recdir_item, 0, ID2P(LANG_SET_AS_REC_DIR), | 1054 | MENUITEM_FUNCTION(set_recdir_item, 0, ID2P(LANG_SET_AS_REC_DIR), |
1063 | set_recdir, NULL, clipboard_callback, Icon_Recording); | 1055 | set_recdir, NULL, clipboard_callback, Icon_Recording); |
1064 | #endif | 1056 | #endif |
1065 | static bool add_to_faves(void) | ||
1066 | { | ||
1067 | if(PLUGIN_USB_CONNECTED == filetype_load_plugin("shortcuts_append", | ||
1068 | selected_file)) | ||
1069 | onplay_result = ONPLAY_RELOAD_DIR; | ||
1070 | return false; | ||
1071 | } | ||
1072 | MENUITEM_FUNCTION(add_to_faves_item, 0, ID2P(LANG_ADD_TO_FAVES), | ||
1073 | add_to_faves, NULL, clipboard_callback, Icon_NOICON); | ||
1074 | |||
1075 | 1057 | ||
1076 | static int clipboard_callback(int action,const struct menu_item_ex *this_item) | 1058 | static int clipboard_callback(int action,const struct menu_item_ex *this_item) |
1077 | { | 1059 | { |
@@ -1092,19 +1074,19 @@ static int clipboard_callback(int action,const struct menu_item_ex *this_item) | |||
1092 | return (clipboard_selection[0] != 0) ? | 1074 | return (clipboard_selection[0] != 0) ? |
1093 | action : ACTION_EXIT_MENUITEM; | 1075 | action : ACTION_EXIT_MENUITEM; |
1094 | } | 1076 | } |
1095 | else if (this_item == &create_dir_item) | 1077 | else if (this_item == &create_dir_item) |
1096 | { | 1078 | { |
1097 | /* always visible */ | 1079 | /* always visible */ |
1098 | return action; | 1080 | return action; |
1099 | } | 1081 | } |
1100 | else if ((this_item == &properties_item) || | 1082 | else if ((this_item == &rename_file_item) || |
1101 | (this_item == &rename_file_item) || | ||
1102 | (this_item == &clipboard_cut_item) || | 1083 | (this_item == &clipboard_cut_item) || |
1103 | (this_item == &clipboard_copy_item) || | 1084 | (this_item == &clipboard_copy_item) || |
1085 | (this_item == &properties_item) || | ||
1104 | (this_item == &add_to_faves_item) | 1086 | (this_item == &add_to_faves_item) |
1105 | ) | 1087 | ) |
1106 | { | 1088 | { |
1107 | /* requires an actual file */ | 1089 | /* requires an actual file */ |
1108 | return (selected_file) ? action : ACTION_EXIT_MENUITEM; | 1090 | return (selected_file) ? action : ACTION_EXIT_MENUITEM; |
1109 | } | 1091 | } |
1110 | #if LCD_DEPTH > 1 | 1092 | #if LCD_DEPTH > 1 |
@@ -1137,11 +1119,11 @@ static int clipboard_callback(int action,const struct menu_item_ex *this_item) | |||
1137 | else if (selected_file | 1119 | else if (selected_file |
1138 | #ifdef HAVE_MULTIVOLUME | 1120 | #ifdef HAVE_MULTIVOLUME |
1139 | /* no rename+delete for volumes */ | 1121 | /* no rename+delete for volumes */ |
1140 | && !(selected_file_attr & ATTR_VOLUME) | 1122 | && !(selected_file_attr & ATTR_VOLUME) |
1141 | #endif | 1123 | #endif |
1142 | ) | 1124 | ) |
1143 | { | 1125 | { |
1144 | if ((this_item == &delete_file_item) || | 1126 | if ((this_item == &delete_file_item) || |
1145 | (this_item == &list_viewers_item)) | 1127 | (this_item == &list_viewers_item)) |
1146 | { | 1128 | { |
1147 | return action; | 1129 | return action; |
@@ -1152,15 +1134,15 @@ static int clipboard_callback(int action,const struct menu_item_ex *this_item) | |||
1152 | } | 1134 | } |
1153 | return action; | 1135 | return action; |
1154 | } | 1136 | } |
1155 | /* used when onplay() is called in the CONTEXT_WPS context */ | ||
1156 | 1137 | ||
1157 | 1138 | static int onplaymenu_callback(int action,const struct menu_item_ex *this_item); | |
1158 | MAKE_ONPLAYMENU( wps_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE), | 1139 | /* used when onplay() is called in the CONTEXT_WPS context */ |
1140 | MAKE_ONPLAYMENU( wps_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE), | ||
1159 | onplaymenu_callback, Icon_Audio, | 1141 | onplaymenu_callback, Icon_Audio, |
1160 | &wps_playlist_menu, &cat_playlist_menu, | 1142 | &wps_playlist_menu, &cat_playlist_menu, |
1161 | &sound_settings, &playback_settings, | 1143 | &sound_settings, &playback_settings, |
1162 | #ifdef HAVE_TAGCACHE | 1144 | #ifdef HAVE_TAGCACHE |
1163 | &rating_item, | 1145 | &rating_item, |
1164 | #endif | 1146 | #endif |
1165 | &bookmark_menu, &browse_id3_item, &list_viewers_item, | 1147 | &bookmark_menu, &browse_id3_item, &list_viewers_item, |
1166 | &delete_file_item, &view_cue_item, | 1148 | &delete_file_item, &view_cue_item, |
@@ -1169,7 +1151,7 @@ MAKE_ONPLAYMENU( wps_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE), | |||
1169 | #endif | 1151 | #endif |
1170 | ); | 1152 | ); |
1171 | /* used when onplay() is not called in the CONTEXT_WPS context */ | 1153 | /* used when onplay() is not called in the CONTEXT_WPS context */ |
1172 | MAKE_ONPLAYMENU( tree_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE), | 1154 | MAKE_ONPLAYMENU( tree_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE), |
1173 | onplaymenu_callback, Icon_file_view_menu, | 1155 | onplaymenu_callback, Icon_file_view_menu, |
1174 | &tree_playlist_menu, &cat_playlist_menu, | 1156 | &tree_playlist_menu, &cat_playlist_menu, |
1175 | &rename_file_item, &clipboard_cut_item, &clipboard_copy_item, | 1157 | &rename_file_item, &clipboard_cut_item, &clipboard_copy_item, |
@@ -1185,7 +1167,6 @@ MAKE_ONPLAYMENU( tree_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE), | |||
1185 | ); | 1167 | ); |
1186 | static int onplaymenu_callback(int action,const struct menu_item_ex *this_item) | 1168 | static int onplaymenu_callback(int action,const struct menu_item_ex *this_item) |
1187 | { | 1169 | { |
1188 | (void)this_item; | ||
1189 | switch (action) | 1170 | switch (action) |
1190 | { | 1171 | { |
1191 | case ACTION_TREE_STOP: | 1172 | case ACTION_TREE_STOP: |