FS#11195, plus. Simplified hotkey struct, thanks alle!

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25581 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jeffrey Goode 2010-04-11 00:32:16 +00:00
parent 66fa127262
commit ef30d7ef71
3 changed files with 14 additions and 22 deletions

View file

@ -414,9 +414,9 @@ static void view_hotkey_info(void)
info.hide_selection = true;
info.scroll_all = true;
simplelist_addline(SIMPLELIST_ADD_LINE, str(LANG_HOTKEY_VIEW_WPS),
str(get_hotkey_desc_id(global_settings.hotkey_wps)));
get_hotkey_desc(global_settings.hotkey_wps));
simplelist_addline(SIMPLELIST_ADD_LINE, str(LANG_HOTKEY_VIEW_FILE_BROWSER),
str(get_hotkey_desc_id(global_settings.hotkey_tree)));
get_hotkey_desc(global_settings.hotkey_tree));
simplelist_show_list(&info);
}

View file

@ -1218,8 +1218,7 @@ struct hotkey_assignment {
int item; /* Bit or'd hotkey_action and HOTKEY_CTX_x */
struct menu_func func; /* Function to run if this entry is selected */
int return_code; /* What to return after the function is run */
const struct menu_item_ex *menu_addr;
int lang_id; /* How to present the item to the user */
const struct menu_item_ex *menu_addr; /* Must be a MENUITEM_FUNCTION */
};
#define HOTKEY_FUNC(func, param) {{(void *)func}, param}
@ -1228,49 +1227,42 @@ struct hotkey_assignment {
static struct hotkey_assignment hotkey_items[] = {
{ HOTKEY_VIEW_PLAYLIST | HOTKEY_CTX_WPS,
HOTKEY_FUNC(NULL, NULL),
ONPLAY_PLAYLIST, &view_cur_playlist,
LANG_VIEW_DYNAMIC_PLAYLIST },
ONPLAY_PLAYLIST, &view_cur_playlist },
{ HOTKEY_SHOW_TRACK_INFO| HOTKEY_CTX_WPS,
HOTKEY_FUNC(browse_id3, NULL),
ONPLAY_RELOAD_DIR, &browse_id3_item,
LANG_MENU_SHOW_ID3_INFO },
ONPLAY_RELOAD_DIR, &browse_id3_item },
#ifdef HAVE_PITCHSCREEN
{ HOTKEY_PITCHSCREEN | HOTKEY_CTX_WPS,
HOTKEY_FUNC(gui_syncpitchscreen_run, NULL),
ONPLAY_RELOAD_DIR, &pitch_screen_item,
LANG_PITCH },
ONPLAY_RELOAD_DIR, &pitch_screen_item },
#endif
{ HOTKEY_OPEN_WITH | HOTKEY_CTX_WPS | HOTKEY_CTX_TREE,
HOTKEY_FUNC(open_with, NULL),
ONPLAY_RELOAD_DIR, &list_viewers_item,
LANG_ONPLAY_OPEN_WITH },
ONPLAY_RELOAD_DIR, &list_viewers_item },
{ HOTKEY_DELETE | HOTKEY_CTX_WPS | HOTKEY_CTX_TREE,
HOTKEY_FUNC(delete_item, NULL),
ONPLAY_RELOAD_DIR, &delete_file_item,
LANG_DELETE },
ONPLAY_RELOAD_DIR, &delete_file_item },
{ HOTKEY_DELETE | HOTKEY_CTX_TREE,
HOTKEY_FUNC(delete_item, NULL),
ONPLAY_RELOAD_DIR, &delete_dir_item,
LANG_DELETE },
ONPLAY_RELOAD_DIR, &delete_dir_item },
{ HOTKEY_INSERT | HOTKEY_CTX_TREE,
HOTKEY_FUNC(playlist_insert_func, (intptr_t*)PLAYLIST_INSERT),
ONPLAY_START_PLAY, &i_pl_item,
LANG_INSERT },
ONPLAY_START_PLAY, &i_pl_item },
};
static const int num_hotkey_items = sizeof(hotkey_items) / sizeof(hotkey_items[0]);
/* Return the language ID for the input function */
int get_hotkey_desc_id(int hk_func)
char* get_hotkey_desc(int hk_func)
{
int i;
for (i = 0; i < num_hotkey_items; i++)
{
if ((hotkey_items[i].item & HOTKEY_ACTION_MASK) == hk_func)
return hotkey_items[i].lang_id;
return P2STR(hotkey_items[i].menu_addr->callback_and_desc->desc);
}
return LANG_HOTKEY_NOT_SET;
return str(LANG_HOTKEY_NOT_SET);
}
/* Execute the hotkey function, if listed for this screen */

View file

@ -32,7 +32,7 @@ enum {
};
#ifdef HAVE_HOTKEY
int get_hotkey_desc_id(int hk_func);
char* get_hotkey_desc(int hk_func);
#endif
#endif