summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/lang/english.lang84
-rw-r--r--apps/lang/russian.lang84
-rw-r--r--apps/plugins/main_menu_config.c66
3 files changed, 222 insertions, 12 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index b86feaf300..da0f21b9c7 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -15639,3 +15639,87 @@ id: VOICE_BAT_BENCH_KEYS
15639 lowmem: none 15639 lowmem: none
15640 </voice> 15640 </voice>
15641</phrase> 15641</phrase>
15642<phrase>
15643 id: LANG_TOGGLE_ITEM
15644 desc: in main_menu_config
15645 user: core
15646 <source>
15647 *: "Toggle Item"
15648 </source>
15649 <dest>
15650 *: "Toggle Item"
15651 </dest>
15652 <voice>
15653 *: "Toggle Item"
15654 </voice>
15655</phrase>
15656<phrase>
15657 id: LANG_MOVE_ITEM_UP
15658 desc: in main_menu_config
15659 user: core
15660 <source>
15661 *: "Move Item Up"
15662 </source>
15663 <dest>
15664 *: "Move Item Up"
15665 </dest>
15666 <voice>
15667 *: "Move Item Up"
15668 </voice>
15669</phrase>
15670<phrase>
15671 id: LANG_MOVE_ITEM_DOWN
15672 desc: in main_menu_config
15673 user: core
15674 <source>
15675 *: "Move Item Down"
15676 </source>
15677 <dest>
15678 *: "Move Item Down"
15679 </dest>
15680 <voice>
15681 *: "Move Item Down"
15682 </voice>
15683</phrase>
15684<phrase>
15685 id: LANG_LOAD_DEFAULT_CONFIGURATION
15686 desc: in main_menu_config
15687 user: core
15688 <source>
15689 *: "Load Default Configuration"
15690 </source>
15691 <dest>
15692 *: "Load Default Configuration"
15693 </dest>
15694 <voice>
15695 *: "Load Default Configuration"
15696 </voice>
15697</phrase>
15698<phrase>
15699 id: LANG_SAVE_EXIT
15700 desc: in main_menu_config
15701 user: core
15702 <source>
15703 *: "Save and Exit"
15704 </source>
15705 <dest>
15706 *: "Save and Exit"
15707 </dest>
15708 <voice>
15709 *: "Save and Exit"
15710 </voice>
15711</phrase>
15712<phrase>
15713 id: LANG_MAIN_MENU_ORDER
15714 desc: main_menu_config plugin title
15715 user: core
15716 <source>
15717 *: "Rockbox Main Menu Order"
15718 </source>
15719 <dest>
15720 *: "Rockbox Main Menu Order"
15721 </dest>
15722 <voice>
15723 *: ""
15724 </voice>
15725</phrase>
diff --git a/apps/lang/russian.lang b/apps/lang/russian.lang
index 632b0a1e1e..9d289580b5 100644
--- a/apps/lang/russian.lang
+++ b/apps/lang/russian.lang
@@ -13700,3 +13700,87 @@
13700 charging: "Задержка перед возобновлением" 13700 charging: "Задержка перед возобновлением"
13701 </voice> 13701 </voice>
13702</phrase> 13702</phrase>
13703<phrase>
13704 id: LANG_TOGGLE_ITEM
13705 desc: in main_menu_config
13706 user: core
13707 <source>
13708 *: "Toggle Item"
13709 </source>
13710 <dest>
13711 *: "Сменить Статус"
13712 </dest>
13713 <voice>
13714 *: "Сменить Статус"
13715 </voice>
13716</phrase>
13717<phrase>
13718 id: LANG_MOVE_ITEM_UP
13719 desc: in main_menu_config
13720 user: core
13721 <source>
13722 *: "Move Item Up"
13723 </source>
13724 <dest>
13725 *: "Переместить вверх"
13726 </dest>
13727 <voice>
13728 *: "Переместить вверх"
13729 </voice>
13730</phrase>
13731<phrase>
13732 id: LANG_MOVE_ITEM_DOWN
13733 desc: in main_menu_config
13734 user: core
13735 <source>
13736 *: "Move Item Down"
13737 </source>
13738 <dest>
13739 *: "Переместить Вниз"
13740 </dest>
13741 <voice>
13742 *: "Переместить Вниз"
13743 </voice>
13744</phrase>
13745<phrase>
13746 id: LANG_LOAD_DEFAULT_CONFIGURATION
13747 desc: in main_menu_config
13748 user: core
13749 <source>
13750 *: "Load Default Configuration"
13751 </source>
13752 <dest>
13753 *: "Загрузить Исходную Конфигурацию"
13754 </dest>
13755 <voice>
13756 *: "Загрузить Исходную Конфигурацию"
13757 </voice>
13758</phrase>
13759<phrase>
13760 id: LANG_SAVE_EXIT
13761 desc: in main_menu_config
13762 user: core
13763 <source>
13764 *: "Save and Exit"
13765 </source>
13766 <dest>
13767 *: "Сохранить и Выйти"
13768 </dest>
13769 <voice>
13770 *: "Сохранить и Выйти"
13771 </voice>
13772</phrase>
13773<phrase>
13774 id: LANG_MAIN_MENU_ORDER
13775 desc: main_menu_config plugin title
13776 user: core
13777 <source>
13778 *: "Rockbox Main Menu Order"
13779 </source>
13780 <dest>
13781 *: "Настройка Главного Меню Rockbox"
13782 </dest>
13783 <voice>
13784 *: ""
13785 </voice>
13786</phrase>
diff --git a/apps/plugins/main_menu_config.c b/apps/plugins/main_menu_config.c
index 1015da7a40..f66165e63d 100644
--- a/apps/plugins/main_menu_config.c
+++ b/apps/plugins/main_menu_config.c
@@ -28,6 +28,7 @@ static int menu_item_count;
28#define MAX_ITEMS 16 28#define MAX_ITEMS 16
29struct items 29struct items
30{ 30{
31 unsigned char *name;
31 char string[MAX_ITEM_NAME]; 32 char string[MAX_ITEM_NAME];
32 bool enabled; 33 bool enabled;
33}; 34};
@@ -41,8 +42,9 @@ static const char * menu_get_name(int selected_item, void * data,
41 (void)data; 42 (void)data;
42 (void)buffer; 43 (void)buffer;
43 (void)buffer_len; 44 (void)buffer_len;
44 45 unsigned char *p = menu_items[selected_item].name;
45 return menu_items[selected_item].string; 46 int id = P2ID(p);
47 return (id != -1) ? rb->str(id) : p;
46} 48}
47 49
48static enum themable_icons menu_get_icon(int selected_item, void * data) 50static enum themable_icons menu_get_icon(int selected_item, void * data)
@@ -52,6 +54,16 @@ static enum themable_icons menu_get_icon(int selected_item, void * data)
52 return menu_items[selected_item].enabled ? Icon_Config : Icon_NOICON; 54 return menu_items[selected_item].enabled ? Icon_Config : Icon_NOICON;
53} 55}
54 56
57static unsigned char *item_name(int n)
58{
59 const struct menu_item_ex *item = menu_table[n].item;
60 return (item->flags & MENU_HAS_DESC) ?
61 item->callback_and_desc->desc :
62 (rb->strcmp("wps", menu_table[n].string) ?
63 (unsigned char *)menu_table[n].string :
64 ID2P(LANG_RESUME_PLAYBACK));
65}
66
55void load_from_cfg(void) 67void load_from_cfg(void)
56{ 68{
57 char config_str[128]; 69 char config_str[128];
@@ -60,20 +72,21 @@ void load_from_cfg(void)
60 int i = 0; 72 int i = 0;
61 bool found = false; 73 bool found = false;
62 74
75 config_str[0] = '\0';
63 rb->root_menu_write_to_cfg(NULL, config_str, sizeof(config_str)); 76 rb->root_menu_write_to_cfg(NULL, config_str, sizeof(config_str));
64 77
65 token = rb->strtok_r(config_str, ", ", &save); 78 token = rb->strtok_r(config_str, ", ", &save);
66 79
67 while (token) 80 while (token)
68 { 81 {
69 i = 0; 82 for (i = 0, found = false; i < menu_item_count; i++)
70 found = false;
71 for (i = 0, found = false; i < menu_item_count && !found; i++)
72 { 83 {
73 found = rb->strcmp(token, menu_table[i].string) == 0; 84 found = rb->strcmp(token, menu_table[i].string) == 0;
85 if (found) break;
74 } 86 }
75 if (found) 87 if (found)
76 { 88 {
89 menu_items[done].name = item_name(i);
77 rb->strcpy(menu_items[done].string, token); 90 rb->strcpy(menu_items[done].string, token);
78 menu_items[done].enabled = true; 91 menu_items[done].enabled = true;
79 done++; 92 done++;
@@ -93,6 +106,7 @@ void load_from_cfg(void)
93 106
94 if (!found) 107 if (!found)
95 { 108 {
109 menu_items[done].name = item_name(i);
96 rb->strcpy(menu_items[done].string, menu_table[i].string); 110 rb->strcpy(menu_items[done].string, menu_table[i].string);
97 menu_items[done].enabled = false; 111 menu_items[done].enabled = false;
98 done++; 112 done++;
@@ -120,18 +134,36 @@ static void save_to_cfg(void)
120 134
121static void swap_items(int a, int b) 135static void swap_items(int a, int b)
122{ 136{
137 unsigned char *name;
123 char temp[MAX_ITEM_NAME]; 138 char temp[MAX_ITEM_NAME];
124 bool enabled; 139 bool enabled;
125 140
141 name = menu_items[a].name;
126 rb->strcpy(temp, menu_items[a].string); 142 rb->strcpy(temp, menu_items[a].string);
127 enabled = menu_items[a].enabled; 143 enabled = menu_items[a].enabled;
144 menu_items[a].name = menu_items[b].name;
128 rb->strcpy(menu_items[a].string, 145 rb->strcpy(menu_items[a].string,
129 menu_items[b].string); 146 menu_items[b].string);
130 menu_items[a].enabled = menu_items[b].enabled; 147 menu_items[a].enabled = menu_items[b].enabled;
148 menu_items[b].name = name;
131 rb->strcpy(menu_items[b].string, temp); 149 rb->strcpy(menu_items[b].string, temp);
132 menu_items[b].enabled = enabled; 150 menu_items[b].enabled = enabled;
133} 151}
134 152
153static int menu_speak_item(int selected_item, void *data)
154{
155 (void) data;
156 int id = P2ID(menu_items[selected_item].name);
157
158 if (id != -1)
159 {
160 rb->talk_id(id, false);
161 rb->talk_id(menu_items[selected_item].enabled ? LANG_ON : LANG_OFF, true);
162 }
163
164 return 0;
165}
166
135/* this is the plugin entry point */ 167/* this is the plugin entry point */
136enum plugin_status plugin_start(const void* parameter) 168enum plugin_status plugin_start(const void* parameter)
137{ 169{
@@ -144,13 +176,16 @@ enum plugin_status plugin_start(const void* parameter)
144 load_from_cfg(); 176 load_from_cfg();
145 177
146 rb->gui_synclist_init(&list, menu_get_name, NULL, false, 1, NULL); 178 rb->gui_synclist_init(&list, menu_get_name, NULL, false, 1, NULL);
179 if (rb->global_settings->talk_menu)
180 rb->gui_synclist_set_voice_callback(&list, menu_speak_item);
147 rb->gui_synclist_set_icon_callback(&list, menu_get_icon); 181 rb->gui_synclist_set_icon_callback(&list, menu_get_icon);
148 rb->gui_synclist_set_nb_items(&list, menu_item_count); 182 rb->gui_synclist_set_nb_items(&list, menu_item_count);
149 rb->gui_synclist_set_title(&list, "Rockbox Main Menu Order", Icon_Rockbox); 183 rb->gui_synclist_set_title(&list, rb->str(LANG_MAIN_MENU_ORDER), Icon_Rockbox);
184 rb->gui_synclist_draw(&list);
185 rb->gui_synclist_speak_item(&list);
150 186
151 while (!done) 187 while (!done)
152 { 188 {
153 rb->gui_synclist_draw(&list);
154 cur_sel = rb->gui_synclist_get_sel_pos(&list); 189 cur_sel = rb->gui_synclist_get_sel_pos(&list);
155 action = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); 190 action = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
156 if (rb->gui_synclist_do_button(&list,&action,LIST_WRAP_UNLESS_HELD)) 191 if (rb->gui_synclist_do_button(&list,&action,LIST_WRAP_UNLESS_HELD))
@@ -161,10 +196,12 @@ enum plugin_status plugin_start(const void* parameter)
161 case ACTION_STD_OK: 196 case ACTION_STD_OK:
162 { 197 {
163 MENUITEM_STRINGLIST(menu, "Main Menu Editor", NULL, 198 MENUITEM_STRINGLIST(menu, "Main Menu Editor", NULL,
164 "Toggle Item", 199 ID2P(LANG_TOGGLE_ITEM),
165 "Move Item Up", "Move Item down", 200 ID2P(LANG_MOVE_ITEM_UP),
166 "----------", 201 ID2P(LANG_MOVE_ITEM_DOWN),
167 "Load Default Configuration", "Exit"); 202 "----------",
203 ID2P(LANG_LOAD_DEFAULT_CONFIGURATION),
204 ID2P(LANG_SAVE_EXIT));
168 switch (rb->do_menu(&menu, NULL, NULL, false)) 205 switch (rb->do_menu(&menu, NULL, NULL, false))
169 { 206 {
170 case 0: 207 case 0:
@@ -191,6 +228,11 @@ enum plugin_status plugin_start(const void* parameter)
191 rb->settings_save(); 228 rb->settings_save();
192 break; 229 break;
193 } 230 }
231 if (!done)
232 {
233 rb->gui_synclist_draw(&list);
234 rb->gui_synclist_speak_item(&list);
235 }
194 break; 236 break;
195 } 237 }
196 case ACTION_STD_CANCEL: 238 case ACTION_STD_CANCEL: