From f4fbc1bcebaca17b251fc8ef8729f317147dd9b0 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sat, 11 Dec 2021 12:45:59 +0000 Subject: tagtree: Support user override config file Allow users to create an alternative tagnavi config file named "tagnavi_user.config" in the .rockbox directory. If present, it will be used instead of the default tagnavi.config, allowing the default menu to be completely redefined. This makes it much easier to maintain customizations which remove or modify parts of the default config -- since the default config is shipped in the Rockbox zips, a customized tagnavi.config would have to be saved with manual intervention on each & every update. Change-Id: I509177fab0e01fc0db0bc4407a3a92bbff5fa481 --- apps/tagnavi.config | 8 ++++++-- apps/tagtree.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/apps/tagnavi.config b/apps/tagnavi.config index b9d50c5c9b..74dfb1d1d9 100644 --- a/apps/tagnavi.config +++ b/apps/tagnavi.config @@ -2,8 +2,12 @@ # ^ Version header must be the first line of every file # Tag Browser configuration file, do not edit as changes will be lost! -# Instead, you can modify "/.rockbox/tagnavi_custom.config" which will never -# get overwritten automatically. +# Instead, copy this file to "/.rockbox/tagnavi_user.config" and edit +# that, so your changes will not be overwritten automatically. +# +# If you only want to add menus and don't need to modify the default +# ones, you can edit "/.rockbox/tagnavi_custom.config" instead, which +# is included by this file and will not be overwritten automatically. # Basic format declarations %format "fmt_title" "%s - %02d:%02d (%s)" basename Lm Ls filename ? title == "" diff --git a/apps/tagtree.c b/apps/tagtree.c index 454875ded2..74f0021d6a 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c @@ -58,7 +58,8 @@ #define str_or_empty(x) (x ? x : "(NULL)") -#define FILE_SEARCH_INSTRUCTIONS ROCKBOX_DIR "/tagnavi.config" +#define TAGNAVI_DEFAULT_CONFIG ROCKBOX_DIR "/tagnavi.config" +#define TAGNAVI_USER_CONFIG ROCKBOX_DIR "/tagnavi_user.config" static int tagtree_play_folder(struct tree_context* c); @@ -1262,7 +1263,14 @@ void tagtree_init(void) if (tagtree_handle < 0) panicf("tagtree OOM"); - if (!parse_menu(FILE_SEARCH_INSTRUCTIONS)) + /* Use the user tagnavi config if present, otherwise use the default. */ + const char* tagnavi_file; + if(file_exists(TAGNAVI_USER_CONFIG)) + tagnavi_file = TAGNAVI_USER_CONFIG; + else + tagnavi_file = TAGNAVI_DEFAULT_CONFIG; + + if (!parse_menu(tagnavi_file)) { tagtree_unload(NULL); return; -- cgit v1.2.3