A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

Settings menu: add main menu customization

Lets you launch the main_menu_config plugin
from Settings, so that it remains accessible,
even after all other menu items have been
hidden.

Includes minor changes to the main menu config
plugin, so that it better fits in with the rest
of the settings menus:

* Keep theme enabled
* Autosave
* Add "On" or "Off" suffix to each item, to prevent
confusion when Icon_Config is blank, as is the case
with certain iconsets
* Update current selection after swapping items
* Prefix spoken selection with row number for enhanced
clarity when swapping items
* Change title to LANG_MAIN_MENU
* ACTION_STD_OK to toggle an item's visibility
* ACTION_STD_CONTEXT to access options for reordering
menu items, or for reverting to the default menu
* Ask for confirmation before reverting

Change-Id: I74240b94243224c76e23ef8f3a0559bd8ba28df0

+97 -63
+7 -7
apps/lang/english.lang
··· 14152 14152 </phrase> 14153 14153 <phrase> 14154 14154 id: LANG_TOGGLE_ITEM 14155 - desc: in main_menu_config 14155 + desc: deprecated 14156 14156 user: core 14157 14157 <source> 14158 - *: "Toggle Item" 14158 + *: "" 14159 14159 </source> 14160 14160 <dest> 14161 - *: "Toggle Item" 14161 + *: "" 14162 14162 </dest> 14163 14163 <voice> 14164 - *: "Toggle Item" 14164 + *: "" 14165 14165 </voice> 14166 14166 </phrase> 14167 14167 <phrase> ··· 14222 14222 </phrase> 14223 14223 <phrase> 14224 14224 id: LANG_MAIN_MENU_ORDER 14225 - desc: main_menu_config plugin title 14225 + desc: deprecated 14226 14226 user: core 14227 14227 <source> 14228 - *: "Rockbox Main Menu Order" 14228 + *: "" 14229 14229 </source> 14230 14230 <dest> 14231 - *: "Rockbox Main Menu Order" 14231 + *: "" 14232 14232 </dest> 14233 14233 <voice> 14234 14234 *: ""
+10
apps/menus/main_menu.c
··· 495 495 /* INFO MENU */ 496 496 /***********************************/ 497 497 498 + static int main_menu_config(void) 499 + { 500 + plugin_load(PLUGIN_APPS_DIR "/main_menu_config.rock", NULL); 501 + return 0; 502 + } 503 + 504 + MENUITEM_FUNCTION(main_menu_config_item, 0, ID2P(LANG_MAIN_MENU), 505 + main_menu_config, NULL, Icon_Rockbox); 506 + 498 507 /***********************************/ 499 508 /* MAIN MENU */ 500 509 ··· 509 518 #if CONFIG_RTC 510 519 &timedate_item, 511 520 #endif 521 + &main_menu_config_item, 512 522 &manage_settings, 513 523 ); 514 524 /* MAIN MENU */
+2 -1
apps/plugin.c
··· 860 860 861 861 /* for some plugins, the SBS can be left enabled */ 862 862 const char *sepch = strrchr(plugin, PATH_SEPCH); 863 - bool theme_enabled = sepch && !strcmp("properties.rock", sepch + 1); 863 + bool theme_enabled = sepch && (!strcmp("properties.rock", sepch + 1) || 864 + !strcmp("main_menu_config.rock", sepch + 1)); 864 865 865 866 if (current_plugin_handle) 866 867 {
+56 -31
apps/plugins/main_menu_config.c
··· 40 40 char * buffer, size_t buffer_len) 41 41 { 42 42 (void)data; 43 - (void)buffer; 44 - (void)buffer_len; 45 43 unsigned char *p = menu_items[selected_item].name; 46 44 int id = P2ID(p); 47 - return (id != -1) ? rb->str(id) : p; 45 + 46 + rb->snprintf(buffer, buffer_len, "%s: %s", (id != -1) ? rb->str(id) : p, 47 + menu_items[selected_item].enabled ? 48 + rb->str(LANG_ON) : rb->str(LANG_OFF)); 49 + 50 + return buffer; 48 51 } 49 52 50 53 static enum themable_icons menu_get_icon(int selected_item, void * data) ··· 157 160 158 161 if (id != -1) 159 162 { 160 - rb->talk_id(id, false); 163 + rb->talk_number(selected_item + 1, false); 164 + rb->talk_id(id, true); 161 165 rb->talk_id(menu_items[selected_item].enabled ? LANG_ON : LANG_OFF, true); 162 166 } 163 167 ··· 172 176 rb->global_settings->show_icons = true; 173 177 struct gui_synclist list; 174 178 bool done = false; 179 + bool changed = false; 175 180 int action, cur_sel; 176 181 177 182 menu_table = rb->root_menu_get_options(&menu_item_count); ··· 182 187 rb->gui_synclist_set_voice_callback(&list, menu_speak_item); 183 188 rb->gui_synclist_set_icon_callback(&list, menu_get_icon); 184 189 rb->gui_synclist_set_nb_items(&list, menu_item_count); 185 - rb->gui_synclist_set_title(&list, rb->str(LANG_MAIN_MENU_ORDER), Icon_Rockbox); 186 - rb->gui_synclist_draw(&list); 190 + rb->gui_synclist_set_title(&list, rb->str(LANG_MAIN_MENU), Icon_Rockbox); 187 191 rb->gui_synclist_speak_item(&list); 188 192 189 193 while (!done) 190 194 { 195 + rb->gui_synclist_draw(&list); 191 196 cur_sel = rb->gui_synclist_get_sel_pos(&list); 192 - action = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); 197 + action = rb->get_action(CONTEXT_LIST, HZ/10); 193 198 if (rb->gui_synclist_do_button(&list, &action)) 194 199 continue; 195 200 196 201 switch (action) 197 202 { 198 203 case ACTION_STD_OK: 204 + menu_items[cur_sel].enabled = !menu_items[cur_sel].enabled; 205 + rb->gui_synclist_speak_item(&list); 206 + changed = true; 207 + break; 208 + case ACTION_STD_CONTEXT: 199 209 { 200 - MENUITEM_STRINGLIST(menu, "Main Menu Editor", NULL, 201 - ID2P(LANG_TOGGLE_ITEM), 210 + MENUITEM_STRINGLIST(menu, ID2P(LANG_MAIN_MENU), NULL, 202 211 ID2P(LANG_MOVE_ITEM_UP), 203 212 ID2P(LANG_MOVE_ITEM_DOWN), 204 - "----------", 205 - ID2P(LANG_LOAD_DEFAULT_CONFIGURATION), 206 - ID2P(LANG_SAVE_EXIT)); 213 + ID2P(LANG_LOAD_DEFAULT_CONFIGURATION)); 207 214 switch (rb->do_menu(&menu, NULL, NULL, false)) 208 215 { 209 216 case 0: 210 - menu_items[cur_sel].enabled = !menu_items[cur_sel].enabled; 211 - break; 212 - case 1: 213 217 if (cur_sel == 0) 218 + { 219 + rb->splash(HZ, ID2P(LANG_FAILED)); 214 220 break; 221 + } 215 222 swap_items(cur_sel, cur_sel - 1); 223 + rb->gui_synclist_select_item(&list, cur_sel - 1); /* speaks */ 224 + changed = true; 216 225 break; 217 - case 2: 226 + case 1: 218 227 if (cur_sel + 1 == menu_item_count) 228 + { 229 + rb->splash(HZ, ID2P(LANG_FAILED)); 219 230 break; 231 + } 220 232 swap_items(cur_sel, cur_sel + 1); 233 + rb->gui_synclist_select_item(&list, cur_sel + 1); /* speaks */ 234 + changed = true; 221 235 break; 222 - case 4: 223 - rb->root_menu_set_default(&rb->global_settings->root_menu_customized, NULL); 224 - load_from_cfg(); 225 - break; 226 - case 5: 227 - done = true; 228 - save_to_cfg(); 229 - rb->global_settings->root_menu_customized = true; 230 - rb->settings_save(); 231 - break; 236 + case 2:; 237 + static const char *lines[] = 238 + {ID2P(LANG_RESET_ASK), ID2P(LANG_LOAD_DEFAULT_CONFIGURATION)}; 239 + static const struct text_message message={lines, 2}; 240 + 241 + switch(rb->gui_syncyesno_run(&message, NULL, NULL)) 242 + { 243 + case YESNO_YES: 244 + rb->root_menu_set_default(&rb->global_settings->root_menu_customized, NULL); 245 + load_from_cfg(); 246 + break; 247 + default: 248 + rb->splash(HZ, ID2P(LANG_CANCEL)); 249 + break; 250 + } 251 + /* fall-through */ 252 + default: 253 + rb->gui_synclist_speak_item(&list); 232 254 } 233 - if (!done) 234 - { 235 - rb->gui_synclist_draw(&list); 236 - rb->gui_synclist_speak_item(&list); 237 - } 255 + rb->gui_synclist_set_title(&list, rb->str(LANG_MAIN_MENU), Icon_Rockbox); 238 256 break; 239 257 } 240 258 case ACTION_STD_CANCEL: ··· 243 261 } 244 262 } 245 263 264 + if (changed) 265 + { 266 + save_to_cfg(); 267 + rb->global_settings->root_menu_customized = true; 268 + rb->settings_save(); 269 + } 246 270 rb->global_settings->show_icons = show_icons; 271 + 247 272 return PLUGIN_OK; 248 273 }
+5 -8
manual/advanced_topics/main.tex
··· 5 5 6 6 \subsection{\label{ref:CustomisingTheMainMenu}Customising The Main Menu} 7 7 8 - It is possible to customise the main menu, i.e. to reorder or to hide some 9 - of its items (only the main menu can be customised, submenus can not). 10 - To accomplish this, load a \fname{.cfg} file (as described in 11 - \reference{ref:manage_settings}) containing the following line: 8 + The easiest way to reorder or to hide menu items is via the settings menu 9 + (see \reference{ref:main_menu_config}). 10 + 11 + To accomplish this using a text editor instead, load a \fname{.cfg} file 12 + (as described in \reference{ref:manage_settings}) containing the following line: 12 13 \config{root~menu~order:items}, where ``items'' is a comma separated list 13 14 (no spaces around the commas!) of the following 14 15 words: \config{bookmarks}, \config{files}, \opt{tagcache}{\config{database}, }% ··· 31 32 32 33 To reset the menu items to the default, use \config{root~menu~order:-} (i.e. 33 34 use a hyphen instead of ``items''). 34 - 35 - This configuration entry can only be created and edited with a text editor or 36 - the Main Menu Config Plugin (see \reference{ref:main_menu_config}). 37 - It is not possible to change this setting via the settings menu. 38 35 39 36 \subsection{\label{ref:CustomisingThePlayername}Customising The Playername} 40 37
+16
manual/main_menu/main.tex
··· 141 141 \reference{ref:Recordingsettings}. 142 142 } 143 143 144 + \subsection{Main Menu} 145 + {\label{ref:main_menu_config}} 146 + Allows you to hide or reorder items from the main menu. 147 + 148 + Press \ActionStdOk{} to toggle an item's visibility. 149 + 150 + Press \ActionStdContext{} to access the following options: 151 + \begin{description} 152 + \item[Move Item Up] Swap selected menu item with the previous one 153 + \item[Move Item down] Swap selected menu item with the next one 154 + \item[Load Default Configuration] Discard all customization 155 + \end{description} 156 + 157 + For an advanced description of the associated configuration entry, 158 + see \reference{ref:CustomisingTheMainMenu}. 159 + 144 160 \subsection{Manage Settings} 145 161 The \setting{Manage Settings} option allows the saving and re-loading of user 146 162 configuration settings, browsing the hard drive for alternate firmwares, and finally
+1 -16
manual/plugins/main_menu_config.tex
··· 1 1 \subsection{Main Menu Configuration} 2 - {\label{ref:main_menu_config}} 3 - 4 - This plugin helps you customizing the main menu (i.e. reorder or hide menu 5 - items). It changes the appropriate configuration file as described in 6 - \reference{ref:CustomisingTheMainMenu}. 7 - 8 - When you start the plugin, the available main menu items will be displayed. 9 - By pressing \ActionStdOk{} you open a menu with the following options: 10 - \begin{description} 11 - \item[Toggle Item] Hide the selected menu item or make it visible again 12 - \item[Move Item Up] Swap the selected menu item with the previous one 13 - \item[Move Item down] Swap the selected menu item with the next one 14 - \item[Load Default Configuration] Discards all customization 15 - \item[Exit] Save your changes to the configuration file and exit the plugin 16 - \end{description} 17 - You can leave the plugin without saving by pressing \ActionStdCancel{}. 2 + see \reference{ref:main_menu_config}