summaryrefslogtreecommitdiff
path: root/apps/onplay.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/onplay.c')
-rw-r--r--apps/onplay.c121
1 files changed, 21 insertions, 100 deletions
diff --git a/apps/onplay.c b/apps/onplay.c
index 82a8bddae7..c9ec565a0c 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -270,8 +270,7 @@ static int treeplaylist_callback(int action,
270 const struct menu_item_ex *this_item); 270 const struct menu_item_ex *this_item);
271 271
272/* insert items */ 272/* insert items */
273MENUITEM_FUNCTION(i_pl_item, MENU_FUNC_USEPARAM | MENU_FUNC_HOTKEYABLE, 273MENUITEM_FUNCTION(i_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT),
274 ID2P(LANG_INSERT),
275 playlist_insert_func, (intptr_t*)PLAYLIST_INSERT, 274 playlist_insert_func, (intptr_t*)PLAYLIST_INSERT,
276 NULL, Icon_Playlist); 275 NULL, Icon_Playlist);
277MENUITEM_FUNCTION(i_first_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT_FIRST), 276MENUITEM_FUNCTION(i_first_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT_FIRST),
@@ -960,12 +959,10 @@ MENUITEM_FUNCTION(view_cue_item, 0, ID2P(LANG_BROWSE_CUESHEET),
960 view_cue, NULL, view_cue_item_callback, Icon_NOICON); 959 view_cue, NULL, view_cue_item_callback, Icon_NOICON);
961 960
962/* CONTEXT_WPS items */ 961/* CONTEXT_WPS items */
963MENUITEM_FUNCTION(browse_id3_item, MENU_FUNC_HOTKEYABLE, 962MENUITEM_FUNCTION(browse_id3_item, 0, ID2P(LANG_MENU_SHOW_ID3_INFO),
964 ID2P(LANG_MENU_SHOW_ID3_INFO),
965 browse_id3, NULL, NULL, Icon_NOICON); 963 browse_id3, NULL, NULL, Icon_NOICON);
966#ifdef HAVE_PITCHSCREEN 964#ifdef HAVE_PITCHSCREEN
967MENUITEM_FUNCTION(pitch_screen_item, MENU_FUNC_HOTKEYABLE, 965MENUITEM_FUNCTION(pitch_screen_item, 0, ID2P(LANG_PITCH),
968 ID2P(LANG_PITCH),
969 gui_syncpitchscreen_run, NULL, NULL, Icon_Audio); 966 gui_syncpitchscreen_run, NULL, NULL, Icon_Audio);
970#endif 967#endif
971 968
@@ -979,9 +976,9 @@ MENUITEM_FUNCTION(clipboard_copy_item, 0, ID2P(LANG_COPY),
979 clipboard_copy, NULL, clipboard_callback, Icon_NOICON); 976 clipboard_copy, NULL, clipboard_callback, Icon_NOICON);
980MENUITEM_FUNCTION(clipboard_paste_item, 0, ID2P(LANG_PASTE), 977MENUITEM_FUNCTION(clipboard_paste_item, 0, ID2P(LANG_PASTE),
981 clipboard_paste, NULL, clipboard_callback, Icon_NOICON); 978 clipboard_paste, NULL, clipboard_callback, Icon_NOICON);
982MENUITEM_FUNCTION(delete_file_item, MENU_FUNC_HOTKEYABLE, ID2P(LANG_DELETE), 979MENUITEM_FUNCTION(delete_file_item, 0, ID2P(LANG_DELETE),
983 delete_file_dir, NULL, clipboard_callback, Icon_NOICON); 980 delete_file_dir, NULL, clipboard_callback, Icon_NOICON);
984MENUITEM_FUNCTION(delete_dir_item, MENU_FUNC_HOTKEYABLE, ID2P(LANG_DELETE_DIR), 981MENUITEM_FUNCTION(delete_dir_item, 0, ID2P(LANG_DELETE_DIR),
985 delete_file_dir, NULL, clipboard_callback, Icon_NOICON); 982 delete_file_dir, NULL, clipboard_callback, Icon_NOICON);
986MENUITEM_FUNCTION(create_dir_item, 0, ID2P(LANG_CREATE_DIR), 983MENUITEM_FUNCTION(create_dir_item, 0, ID2P(LANG_CREATE_DIR),
987 create_dir, NULL, clipboard_callback, Icon_NOICON); 984 create_dir, NULL, clipboard_callback, Icon_NOICON);
@@ -1003,8 +1000,7 @@ static bool onplay_load_plugin(void *param)
1003 return false; 1000 return false;
1004} 1001}
1005 1002
1006MENUITEM_FUNCTION(list_viewers_item, MENU_FUNC_HOTKEYABLE, 1003MENUITEM_FUNCTION(list_viewers_item, 0, ID2P(LANG_ONPLAY_OPEN_WITH),
1007 ID2P(LANG_ONPLAY_OPEN_WITH),
1008 list_viewers, NULL, clipboard_callback, Icon_NOICON); 1004 list_viewers, NULL, clipboard_callback, Icon_NOICON);
1009MENUITEM_FUNCTION(properties_item, MENU_FUNC_USEPARAM, ID2P(LANG_PROPERTIES), 1005MENUITEM_FUNCTION(properties_item, MENU_FUNC_USEPARAM, ID2P(LANG_PROPERTIES),
1010 onplay_load_plugin, (void *)"properties", 1006 onplay_load_plugin, (void *)"properties",
@@ -1199,75 +1195,61 @@ static bool open_with(void)
1199 return list_viewers(); 1195 return list_viewers();
1200} 1196}
1201 1197
1202extern const struct menu_item_ex *selected_menu_item;
1203extern bool hotkey_settable_menu;
1204
1205#define HOTKEY_ACTION_MASK 0x0FF /* Mask to apply to get the action (enum) */ 1198#define HOTKEY_ACTION_MASK 0x0FF /* Mask to apply to get the action (enum) */
1206#define HOTKEY_CTX_WPS 0x100 /* Mask to apply to check whether it's for WPS */ 1199#define HOTKEY_CTX_WPS 0x100 /* Mask to apply to check whether it's for WPS */
1207#define HOTKEY_CTX_TREE 0x200 /* Mask to apply to check whether it's for the tree */ 1200#define HOTKEY_CTX_TREE 0x200 /* Mask to apply to check whether it's for the tree */
1208 1201
1209/* Any desired hotkey functions go here... */
1210enum hotkey_action {
1211 HOTKEY_OFF = 0,
1212 HOTKEY_VIEW_PLAYLIST = 1,
1213 HOTKEY_SHOW_TRACK_INFO,
1214 HOTKEY_PITCHSCREEN,
1215 HOTKEY_OPEN_WITH,
1216 HOTKEY_DELETE,
1217 HOTKEY_INSERT,
1218};
1219
1220struct hotkey_assignment { 1202struct hotkey_assignment {
1221 int item; /* Bit or'd hotkey_action and HOTKEY_CTX_x */ 1203 int item; /* Bit or'd hotkey_action and HOTKEY_CTX_x */
1222 struct menu_func func; /* Function to run if this entry is selected */ 1204 struct menu_func func; /* Function to run if this entry is selected */
1223 int return_code; /* What to return after the function is run */ 1205 int return_code; /* What to return after the function is run */
1224 const struct menu_item_ex *menu_addr; /* Must have non-dynamic text, */ 1206 int lang_id; /* Language ID */
1225 /* i.e. have the flag MENU_HAS_DESC. E.g. be a MENUITEM_FUNCTION */
1226 /* For all possibilities see menu.h. */
1227}; 1207};
1228 1208
1229#define HOTKEY_FUNC(func, param) {{(void *)func}, param} 1209#define HOTKEY_FUNC(func, param) {{(void *)func}, param}
1230 1210
1231/* ... and here. Order is not important. */ 1211/* Any desired hotkey functions go here, in the enum in onplay.h,
1212 and in the settings menu in settings_list.c. The order here
1213 is not important. */
1232static struct hotkey_assignment hotkey_items[] = { 1214static struct hotkey_assignment hotkey_items[] = {
1233 { HOTKEY_VIEW_PLAYLIST | HOTKEY_CTX_WPS, 1215 { HOTKEY_VIEW_PLAYLIST | HOTKEY_CTX_WPS,
1234 HOTKEY_FUNC(NULL, NULL), 1216 HOTKEY_FUNC(NULL, NULL),
1235 ONPLAY_PLAYLIST, &view_cur_playlist }, 1217 ONPLAY_PLAYLIST, LANG_VIEW_DYNAMIC_PLAYLIST },
1236 { HOTKEY_SHOW_TRACK_INFO| HOTKEY_CTX_WPS, 1218 { HOTKEY_SHOW_TRACK_INFO| HOTKEY_CTX_WPS,
1237 HOTKEY_FUNC(browse_id3, NULL), 1219 HOTKEY_FUNC(browse_id3, NULL),
1238 ONPLAY_RELOAD_DIR, &browse_id3_item }, 1220 ONPLAY_RELOAD_DIR, LANG_MENU_SHOW_ID3_INFO },
1239#ifdef HAVE_PITCHSCREEN 1221#ifdef HAVE_PITCHSCREEN
1240 { HOTKEY_PITCHSCREEN | HOTKEY_CTX_WPS, 1222 { HOTKEY_PITCHSCREEN | HOTKEY_CTX_WPS,
1241 HOTKEY_FUNC(gui_syncpitchscreen_run, NULL), 1223 HOTKEY_FUNC(gui_syncpitchscreen_run, NULL),
1242 ONPLAY_RELOAD_DIR, &pitch_screen_item }, 1224 ONPLAY_RELOAD_DIR, LANG_PITCH },
1243#endif 1225#endif
1244 { HOTKEY_OPEN_WITH | HOTKEY_CTX_WPS | HOTKEY_CTX_TREE, 1226 { HOTKEY_OPEN_WITH | HOTKEY_CTX_WPS | HOTKEY_CTX_TREE,
1245 HOTKEY_FUNC(open_with, NULL), 1227 HOTKEY_FUNC(open_with, NULL),
1246 ONPLAY_RELOAD_DIR, &list_viewers_item }, 1228 ONPLAY_RELOAD_DIR, LANG_ONPLAY_OPEN_WITH },
1247 { HOTKEY_DELETE | HOTKEY_CTX_WPS | HOTKEY_CTX_TREE, 1229 { HOTKEY_DELETE | HOTKEY_CTX_WPS | HOTKEY_CTX_TREE,
1248 HOTKEY_FUNC(delete_item, NULL), 1230 HOTKEY_FUNC(delete_item, NULL),
1249 ONPLAY_RELOAD_DIR, &delete_file_item }, 1231 ONPLAY_RELOAD_DIR, LANG_DELETE },
1250 { HOTKEY_DELETE | HOTKEY_CTX_TREE, 1232 { HOTKEY_DELETE | HOTKEY_CTX_TREE,
1251 HOTKEY_FUNC(delete_item, NULL), 1233 HOTKEY_FUNC(delete_item, NULL),
1252 ONPLAY_RELOAD_DIR, &delete_dir_item }, 1234 ONPLAY_RELOAD_DIR, LANG_DELETE },
1253 { HOTKEY_INSERT | HOTKEY_CTX_TREE, 1235 { HOTKEY_INSERT | HOTKEY_CTX_TREE,
1254 HOTKEY_FUNC(playlist_insert_func, (intptr_t*)PLAYLIST_INSERT), 1236 HOTKEY_FUNC(playlist_insert_func, (intptr_t*)PLAYLIST_INSERT),
1255 ONPLAY_START_PLAY, &i_pl_item }, 1237 ONPLAY_START_PLAY, LANG_INSERT },
1256}; 1238};
1257 1239
1258static const int num_hotkey_items = sizeof(hotkey_items) / sizeof(hotkey_items[0]); 1240static const int num_hotkey_items = sizeof(hotkey_items) / sizeof(hotkey_items[0]);
1259 1241
1260/* Return the language ID for the input function */ 1242/* Return the language ID for the input function */
1261const char* get_hotkey_desc(int hk_func) 1243int get_hotkey_lang_id(int hk_func)
1262{ 1244{
1263 int i; 1245 int i;
1264 for (i = 0; i < num_hotkey_items; i++) 1246 for (i = 0; i < num_hotkey_items; i++)
1265 { 1247 {
1266 if ((hotkey_items[i].item & HOTKEY_ACTION_MASK) == hk_func) 1248 if ((hotkey_items[i].item & HOTKEY_ACTION_MASK) == hk_func)
1267 return P2STR(hotkey_items[i].menu_addr->callback_and_desc->desc); 1249 return hotkey_items[i].lang_id;
1268 } 1250 }
1269 1251
1270 return str(LANG_HOTKEY_NOT_SET); 1252 return LANG_OFF;
1271} 1253}
1272 1254
1273/* Execute the hotkey function, if listed for this screen */ 1255/* Execute the hotkey function, if listed for this screen */
@@ -1300,60 +1282,9 @@ static int execute_hotkey(bool is_wps)
1300 } 1282 }
1301 } 1283 }
1302 1284
1303 /* no valid hotkey set */ 1285 /* no valid hotkey set, ignore hotkey */
1304 splash(HZ, ID2P(LANG_HOTKEY_NOT_SET));
1305 return ONPLAY_RELOAD_DIR; 1286 return ONPLAY_RELOAD_DIR;
1306} 1287}
1307
1308/* Set the hotkey to the current context menu function, if listed */
1309static void set_hotkey(bool is_wps)
1310{
1311 int i;
1312 struct hotkey_assignment *this_item;
1313 const int context = is_wps ? HOTKEY_CTX_WPS : HOTKEY_CTX_TREE;
1314 int *hk_func = is_wps ? &global_settings.hotkey_wps :
1315 &global_settings.hotkey_tree;
1316 int this_hk;
1317 char *this_desc;
1318 bool match_found = false;
1319
1320 /* search assignment struct for a function that matches the current menu item */
1321 for (i = 0; i < num_hotkey_items; i++)
1322 {
1323 this_item = &hotkey_items[i];
1324 if ((this_item->item & context) &&
1325 (this_item->menu_addr == selected_menu_item))
1326 {
1327 this_hk = this_item->item & HOTKEY_ACTION_MASK;
1328 this_desc = P2STR((selected_menu_item->callback_and_desc)->desc);
1329 match_found = true;
1330 break;
1331 }
1332 }
1333
1334 /* ignore the hotkey if no match found or no change to setting */
1335 if (!match_found || (this_hk == *hk_func)) return;
1336
1337 char line1_buf[100],
1338 line2_buf[100];
1339 char *line1 = line1_buf,
1340 *line2 = line2_buf;
1341 char **line1_ptr = &line1,
1342 **line2_ptr = &line2;
1343 const struct text_message message={(const char **)line1_ptr, 1};
1344 const struct text_message yes_message={(const char **)line2_ptr, 1};
1345
1346 snprintf(line1, sizeof(line1_buf), str(LANG_SET_HOTKEY_QUESTION), this_desc);
1347 snprintf(line2, sizeof(line2_buf), str(LANG_HOTKEY_ASSIGNED), this_desc);
1348
1349 /* confirm the hotkey setting change */
1350 if(gui_syncyesno_run(&message, &yes_message, NULL)==YESNO_YES)
1351 {
1352 /* store the hotkey settings */
1353 *hk_func = this_hk;
1354 settings_save();
1355 }
1356}
1357#endif /* HOTKEY */ 1288#endif /* HOTKEY */
1358 1289
1359int onplay(char* file, int attr, int from, bool hotkey) 1290int onplay(char* file, int attr, int from, bool hotkey)
@@ -1367,7 +1298,6 @@ int onplay(char* file, int attr, int from, bool hotkey)
1367#ifdef HAVE_HOTKEY 1298#ifdef HAVE_HOTKEY
1368 if (hotkey) 1299 if (hotkey)
1369 return execute_hotkey(context == CONTEXT_WPS); 1300 return execute_hotkey(context == CONTEXT_WPS);
1370 hotkey_settable_menu = true;
1371#else 1301#else
1372 (void)hotkey; 1302 (void)hotkey;
1373#endif 1303#endif
@@ -1376,17 +1306,8 @@ int onplay(char* file, int attr, int from, bool hotkey)
1376 else 1306 else
1377 menu = &tree_onplay_menu; 1307 menu = &tree_onplay_menu;
1378 menu_selection = do_menu(menu, NULL, NULL, false); 1308 menu_selection = do_menu(menu, NULL, NULL, false);
1379#ifdef HAVE_HOTKEY
1380 hotkey_settable_menu = false;
1381 switch (menu_selection)
1382 {
1383 case MENU_SELECTED_HOTKEY:
1384 set_hotkey(context == CONTEXT_WPS);
1385 return ONPLAY_RELOAD_DIR;
1386#else
1387 switch (menu_selection) 1309 switch (menu_selection)
1388 { 1310 {
1389#endif
1390 case GO_TO_WPS: 1311 case GO_TO_WPS:
1391 return ONPLAY_START_PLAY; 1312 return ONPLAY_START_PLAY;
1392 case GO_TO_ROOT: 1313 case GO_TO_ROOT: