summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Goode <jeffg7@gmail.com>2010-04-08 01:43:50 +0000
committerJeffrey Goode <jeffg7@gmail.com>2010-04-08 01:43:50 +0000
commitaccc046cbd76d55a60b18b39dcf82fe1032034d8 (patch)
tree05f760518257d163fc55207fd08c3df02e41efd3
parent3b5eff719a2d4c129feec731d32da05758f58072 (diff)
Hotkey: better settings handling, fewer saved variables, localizable hotkey info list
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25529 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/lang/english.lang32
-rw-r--r--apps/menus/settings_menu.c27
-rw-r--r--apps/onplay.c40
-rw-r--r--apps/onplay.h4
-rw-r--r--apps/settings.h4
-rw-r--r--apps/settings_list.c10
6 files changed, 84 insertions, 33 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index bd37e2d451..3a7f071bfd 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -13479,3 +13479,35 @@
hotkey: "View Hotkey Settings"
</voice>
</phrase>
+<phrase>
+ id: LANG_WPS
+ desc: hotkey info menu
+ user: core
+ <source>
+ *: none
+ hotkey: "WPS: %s"
+ </source>
+ <dest>
+ *: none
+ hotkey: "WPS: %s"
+ </dest>
+ <voice>
+ *: none
+ </voice>
+</phrase>
+<phrase>
+ id: LANG_FILE_BROWSER
+ desc: hotkey info menu
+ user: core
+ <source>
+ *: none
+ hotkey: "File Browser: %s"
+ </source>
+ <dest>
+ *: none
+ hotkey: "File Browser: %s"
+ </dest>
+ <voice>
+ *: none
+ </voice>
+</phrase>
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index 383efd312c..4a8a04f609 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -50,6 +50,7 @@
#ifdef HAVE_HOTKEY
#include "list.h"
#include "settings_list.h"
+#include "onplay.h"
#endif
/***********************************/
@@ -413,32 +414,26 @@ static void view_hotkey_info(void)
info.hide_selection = true;
info.scroll_all = true;
simplelist_set_line_count(2);
- simplelist_addline(0, "WPS: %s",
- str(global_settings.hotkey_wps_desc_id));
- simplelist_addline(1, "Tree: %s",
- str(global_settings.hotkey_tree_desc_id));
+ simplelist_addline(0, str(LANG_WPS),
+ str(get_hotkey_desc_id(global_settings.hotkey_wps)));
+ simplelist_addline(1, str(LANG_FILE_BROWSER),
+ str(get_hotkey_desc_id(global_settings.hotkey_tree)));
simplelist_show_list(&info);
}
/* reset hotkey settings to their defaults */
static void reset_hotkey_settings(void)
{
- void *vars[] = {
- &global_settings.hotkey_tree,
- &global_settings.hotkey_tree_desc_id,
- &global_settings.hotkey_wps,
- &global_settings.hotkey_wps_desc_id,
- };
- const int num_settings = sizeof(vars) / sizeof(vars[0]);
- int i;
-
- for (i = 0; i < num_settings; i++)
{
const struct settings_list *setting =
- find_setting(vars[i], NULL);
+ find_setting(&global_settings.hotkey_wps, NULL);
+ reset_setting(setting, setting->setting);
+ }
+ {
+ const struct settings_list *setting =
+ find_setting(&global_settings.hotkey_tree, NULL);
reset_setting(setting, setting->setting);
}
-
settings_save();
splash(HZ, str(LANG_RESET_DONE_CLEAR));
}
diff --git a/apps/onplay.c b/apps/onplay.c
index 43c228ca5c..d177fac2c4 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -1208,6 +1208,7 @@ struct hotkey_assignment {
struct menu_func func;
int return_code;
const struct menu_item_ex *menu_addr;
+ int lang_id;
};
#define HOTKEY_FUNC(func, param) {{(void *)func}, param}
@@ -1227,31 +1228,51 @@ enum hotkey_settings {
static struct hotkey_assignment hotkey_items[] = {
{ HOTKEY_VIEW_PLAYLIST | HOT_WPS,
HOTKEY_FUNC(NULL, NULL),
- ONPLAY_PLAYLIST, &view_cur_playlist },
+ ONPLAY_PLAYLIST, &view_cur_playlist,
+ LANG_VIEW_DYNAMIC_PLAYLIST },
{ HOTKEY_SHOW_TRACK_INFO| HOT_WPS,
HOTKEY_FUNC(browse_id3, NULL),
- ONPLAY_RELOAD_DIR, &browse_id3_item },
+ ONPLAY_RELOAD_DIR, &browse_id3_item,
+ LANG_MENU_SHOW_ID3_INFO },
#ifdef HAVE_PITCHSCREEN
{ HOTKEY_PITCHSCREEN | HOT_WPS,
HOTKEY_FUNC(gui_syncpitchscreen_run, NULL),
- ONPLAY_RELOAD_DIR, &pitch_screen_item },
+ ONPLAY_RELOAD_DIR, &pitch_screen_item,
+ LANG_PITCH },
#endif
{ HOTKEY_OPEN_WITH | HOT_WPS | HOT_TREE,
HOTKEY_FUNC(open_with, NULL),
- ONPLAY_RELOAD_DIR, &list_viewers_item },
+ ONPLAY_RELOAD_DIR, &list_viewers_item,
+ LANG_ONPLAY_OPEN_WITH },
{ HOTKEY_DELETE | HOT_WPS | HOT_TREE,
HOTKEY_FUNC(delete_item, NULL),
- ONPLAY_RELOAD_DIR, &delete_file_item },
+ ONPLAY_RELOAD_DIR, &delete_file_item,
+ LANG_DELETE },
{ HOTKEY_DELETE | HOT_TREE,
HOTKEY_FUNC(delete_item, NULL),
- ONPLAY_RELOAD_DIR, &delete_dir_item },
+ ONPLAY_RELOAD_DIR, &delete_dir_item,
+ LANG_DELETE },
{ HOTKEY_INSERT | HOT_TREE,
HOTKEY_FUNC(playlist_insert_func, (intptr_t*)PLAYLIST_INSERT),
- ONPLAY_START_PLAY, &i_pl_item },
+ ONPLAY_START_PLAY, &i_pl_item,
+ LANG_INSERT },
};
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)
+{
+ int i;
+ for (i = 0; i < num_hotkey_items; i++)
+ {
+ if ((hotkey_items[i].item & HOT_MASK) == hk_func)
+ return hotkey_items[i].lang_id;
+ }
+
+ return LANG_HOTKEY_NOT_SET;
+}
+
/* Execute the hotkey function, if listed for this screen */
static int execute_hotkey(bool is_wps)
{
@@ -1294,9 +1315,7 @@ static void set_hotkey(bool is_wps)
struct hotkey_assignment *this_item;
const int context = is_wps ? HOT_WPS : HOT_TREE;
int *hk_func = is_wps ? &global_settings.hotkey_wps :
- &global_settings.hotkey_tree,
- *hk_desc = is_wps ? &global_settings.hotkey_wps_desc_id :
- &global_settings.hotkey_tree_desc_id;
+ &global_settings.hotkey_tree;
int this_hk,
this_id;
bool match_found = false;
@@ -1336,7 +1355,6 @@ static void set_hotkey(bool is_wps)
{
/* store the hotkey settings */
*hk_func = this_hk;
- *hk_desc = this_id;
settings_save();
}
diff --git a/apps/onplay.h b/apps/onplay.h
index 4eb7c823b8..027ddedc8f 100644
--- a/apps/onplay.h
+++ b/apps/onplay.h
@@ -31,4 +31,8 @@ enum {
ONPLAY_PLAYLIST,
};
+#ifdef HAVE_HOTKEY
+int get_hotkey_desc_id(int hk_func);
+#endif
+
#endif
diff --git a/apps/settings.h b/apps/settings.h
index 029f056da7..723dfba176 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -817,10 +817,10 @@ struct user_settings
#endif
#ifdef HAVE_HOTKEY
+ /* hotkey assignments - acceptable values are in
+ hotkey_settings enum in onplay.c */
int hotkey_wps;
- int hotkey_wps_desc_id;
int hotkey_tree;
- int hotkey_tree_desc_id;
#endif
};
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 2492178577..86ad12f96f 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -1662,10 +1662,12 @@ const struct settings_list settings[] = {
#endif
#ifdef HAVE_HOTKEY
- CHOICE_SETTING(0, hotkey_wps, 0, 1, "hotkey wps", 0, NULL, 0),
- CHOICE_SETTING(0, hotkey_wps_desc_id, 0, LANG_VIEW_DYNAMIC_PLAYLIST, "hotkey wps desc id", 0, NULL, 0),
- CHOICE_SETTING(0, hotkey_tree, 0, 0, "hotkey tree", 0, NULL, 0),
- CHOICE_SETTING(0, hotkey_tree_desc_id, 0, LANG_OFF, "hotkey tree desc id", 0, NULL, 0),
+ CHOICE_SETTING(0, hotkey_wps, -1, 1, "hotkey wps",
+ "off,view playlist,show track info,pitchscreen,open with,delete,insert",
+ NULL, 7, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ CHOICE_SETTING(0, hotkey_tree, -1, 0, "hotkey tree",
+ "off,view playlist,show track info,pitchscreen,open with,delete,insert",
+ NULL, 7, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
#endif
};