summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeruaki Kawashima <teru@rockbox.org>2010-02-15 13:04:09 +0000
committerTeruaki Kawashima <teru@rockbox.org>2010-02-15 13:04:09 +0000
commit9bea3493828db1cafa54a8dafd3488e371dc7b41 (patch)
tree46ac0feef762e71b30466860fb03d1e26c681f2a
parent57461d7c4f612bed0e8cd9644a0689dbfe56d684 (diff)
downloadrockbox-9bea3493828db1cafa54a8dafd3488e371dc7b41.tar.gz
rockbox-9bea3493828db1cafa54a8dafd3488e371dc7b41.zip
onplay.c: optimize a little bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24666 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/onplay.c98
1 files changed, 43 insertions, 55 deletions
diff --git a/apps/onplay.c b/apps/onplay.c
index 1485f2ffab..da3900ddc8 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -275,7 +275,7 @@ static int treeplaylist_callback(int action,
275/* insert items */ 275/* insert items */
276MENUITEM_FUNCTION(i_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT), 276MENUITEM_FUNCTION(i_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT),
277 playlist_insert_func, (intptr_t*)PLAYLIST_INSERT, 277 playlist_insert_func, (intptr_t*)PLAYLIST_INSERT,
278 treeplaylist_callback, Icon_Playlist); 278 NULL, Icon_Playlist);
279MENUITEM_FUNCTION(i_first_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT_FIRST), 279MENUITEM_FUNCTION(i_first_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT_FIRST),
280 playlist_insert_func, (intptr_t*)PLAYLIST_INSERT_FIRST, 280 playlist_insert_func, (intptr_t*)PLAYLIST_INSERT_FIRST,
281 treeplaylist_wplayback_callback, Icon_Playlist); 281 treeplaylist_wplayback_callback, Icon_Playlist);
@@ -350,8 +350,6 @@ static int treeplaylist_callback(int action,
350 { 350 {
351 return action; 351 return action;
352 } 352 }
353 else
354 return ACTION_EXIT_MENUITEM;
355 } 353 }
356 else if (this_item == &view_playlist_item) 354 else if (this_item == &view_playlist_item)
357 { 355 {
@@ -360,8 +358,6 @@ static int treeplaylist_callback(int action,
360 { 358 {
361 return action; 359 return action;
362 } 360 }
363 else
364 return ACTION_EXIT_MENUITEM;
365 } 361 }
366 else if (this_item == &i_shuf_pl_item) 362 else if (this_item == &i_shuf_pl_item)
367 { 363 {
@@ -371,8 +367,6 @@ static int treeplaylist_callback(int action,
371 { 367 {
372 return action; 368 return action;
373 } 369 }
374 else
375 return ACTION_EXIT_MENUITEM;
376 } 370 }
377 else if (this_item == &i_last_shuf_pl_item || 371 else if (this_item == &i_last_shuf_pl_item ||
378 this_item == &q_last_shuf_pl_item) 372 this_item == &q_last_shuf_pl_item)
@@ -384,9 +378,8 @@ static int treeplaylist_callback(int action,
384 { 378 {
385 return action; 379 return action;
386 } 380 }
387 else
388 return ACTION_EXIT_MENUITEM;
389 } 381 }
382 return ACTION_EXIT_MENUITEM;
390 break; 383 break;
391 } 384 }
392 return action; 385 return action;
@@ -422,9 +415,10 @@ MAKE_ONPLAYMENU(cat_playlist_menu, ID2P(LANG_CATALOG),
422static int cat_playlist_callback(int action, 415static int cat_playlist_callback(int action,
423 const struct menu_item_ex *this_item) 416 const struct menu_item_ex *this_item)
424{ 417{
425 if (((selected_file_attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) && 418 if (!selected_file ||
426 ((selected_file_attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) && 419 (((selected_file_attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) &&
427 ((selected_file_attr & ATTR_DIRECTORY) == 0)) 420 ((selected_file_attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) &&
421 ((selected_file_attr & ATTR_DIRECTORY) == 0)))
428 { 422 {
429 return ACTION_EXIT_MENUITEM; 423 return ACTION_EXIT_MENUITEM;
430 } 424 }
@@ -434,12 +428,9 @@ static int cat_playlist_callback(int action,
434 case ACTION_REQUEST_MENUITEM: 428 case ACTION_REQUEST_MENUITEM:
435 if (this_item == &cat_view_lists) 429 if (this_item == &cat_view_lists)
436 { 430 {
437 if (context == CONTEXT_WPS) 431 return action;
438 return action;
439 } 432 }
440 else if (selected_file && /* set before calling this menu, 433 else if (((audio_status() & AUDIO_STATUS_PLAY &&
441 so safe */
442 ((audio_status() & AUDIO_STATUS_PLAY &&
443 context == CONTEXT_WPS) || 434 context == CONTEXT_WPS) ||
444 context == CONTEXT_TREE)) 435 context == CONTEXT_TREE))
445 { 436 {
@@ -1046,8 +1037,7 @@ MENUITEM_FUNCTION(set_backdrop_item, 0, ID2P(LANG_SET_AS_BACKDROP),
1046#ifdef HAVE_RECORDING 1037#ifdef HAVE_RECORDING
1047static bool set_recdir(void) 1038static bool set_recdir(void)
1048{ 1039{
1049 strlcpy(global_settings.rec_directory, 1040 strlcpy(global_settings.rec_directory, selected_file, MAX_FILENAME+1);
1050 selected_file, MAX_FILENAME+1);
1051 settings_save(); 1041 settings_save();
1052 return false; 1042 return false;
1053} 1043}
@@ -1066,9 +1056,16 @@ static int clipboard_callback(int action,const struct menu_item_ex *this_item)
1066 this_item == &delete_dir_item || 1056 this_item == &delete_dir_item ||
1067 this_item == &clipboard_cut_item) ) 1057 this_item == &clipboard_cut_item) )
1068 return ACTION_EXIT_MENUITEM; 1058 return ACTION_EXIT_MENUITEM;
1059 /* no rename+delete for volumes */
1060 if ((selected_file_attr & ATTR_VOLUME) &&
1061 (this_item == &delete_file_item ||
1062 this_item == &list_viewers_item))
1063 return ACTION_EXIT_MENUITEM;
1069#endif 1064#endif
1065#ifdef HAVE_TAGCACHE
1070 if (context == CONTEXT_ID3DB) 1066 if (context == CONTEXT_ID3DB)
1071 return ACTION_EXIT_MENUITEM; 1067 return ACTION_EXIT_MENUITEM;
1068#endif
1072 if (this_item == &clipboard_paste_item) 1069 if (this_item == &clipboard_paste_item)
1073 { /* visible if there is something to paste */ 1070 { /* visible if there is something to paste */
1074 return (clipboard_selection[0] != 0) ? 1071 return (clipboard_selection[0] != 0) ?
@@ -1079,20 +1076,35 @@ static int clipboard_callback(int action,const struct menu_item_ex *this_item)
1079 /* always visible */ 1076 /* always visible */
1080 return action; 1077 return action;
1081 } 1078 }
1082 else if ((this_item == &rename_file_item) || 1079 else if (selected_file)
1083 (this_item == &clipboard_cut_item) ||
1084 (this_item == &clipboard_copy_item) ||
1085 (this_item == &properties_item) ||
1086 (this_item == &add_to_faves_item)
1087 )
1088 { 1080 {
1089 /* requires an actual file */ 1081 /* requires an actual file */
1090 return (selected_file) ? action : ACTION_EXIT_MENUITEM; 1082 if (this_item == &rename_file_item ||
1091 } 1083 this_item == &clipboard_cut_item ||
1084 this_item == &clipboard_copy_item ||
1085 this_item == &properties_item ||
1086 this_item == &add_to_faves_item)
1087 {
1088 return action;
1089 }
1090 else if ((selected_file_attr & ATTR_DIRECTORY))
1091 {
1092 /* only for directories */
1093 if (this_item == &delete_dir_item
1094#ifdef HAVE_RECORDING
1095 || this_item == &set_recdir_item
1096#endif
1097 )
1098 return action;
1099 }
1100 else if (this_item == &delete_file_item ||
1101 this_item == &list_viewers_item)
1102 {
1103 /* only for files */
1104 return action;
1105 }
1092#if LCD_DEPTH > 1 1106#if LCD_DEPTH > 1
1093 else if (this_item == &set_backdrop_item) 1107 else if (this_item == &set_backdrop_item)
1094 {
1095 if (selected_file)
1096 { 1108 {
1097 char *suffix = strrchr(selected_file, '.'); 1109 char *suffix = strrchr(selected_file, '.');
1098 if (suffix) 1110 if (suffix)
@@ -1103,31 +1115,7 @@ static int clipboard_callback(int action,const struct menu_item_ex *this_item)
1103 } 1115 }
1104 } 1116 }
1105 } 1117 }
1106 return ACTION_EXIT_MENUITEM;
1107 }
1108#endif
1109 else if ((selected_file_attr & ATTR_DIRECTORY))
1110 {
1111 if ((this_item == &delete_dir_item)
1112 )
1113 return action;
1114#ifdef HAVE_RECORDING
1115 else if (this_item == &set_recdir_item)
1116 return action;
1117#endif
1118 }
1119 else if (selected_file
1120#ifdef HAVE_MULTIVOLUME
1121 /* no rename+delete for volumes */
1122 && !(selected_file_attr & ATTR_VOLUME)
1123#endif 1118#endif
1124 )
1125 {
1126 if ((this_item == &delete_file_item) ||
1127 (this_item == &list_viewers_item))
1128 {
1129 return action;
1130 }
1131 } 1119 }
1132 return ACTION_EXIT_MENUITEM; 1120 return ACTION_EXIT_MENUITEM;
1133 break; 1121 break;
@@ -1201,6 +1189,6 @@ int onplay(char* file, int attr, int from)
1201 case GO_TO_MAINMENU: 1189 case GO_TO_MAINMENU:
1202 return ONPLAY_MAINMENU; 1190 return ONPLAY_MAINMENU;
1203 default: 1191 default:
1204 return context == CONTEXT_WPS ? ONPLAY_OK : ONPLAY_RELOAD_DIR; 1192 return onplay_result;
1205 } 1193 }
1206} 1194}