From d09f97880a51d915feae563248b1bdcbcd845156 Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Sun, 10 Apr 2011 13:25:47 +0000 Subject: [PATCH] Support loading backdrops from anywhere in the filesystem. Fixes FS#12041 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29700 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/skin_engine/skin_backdrops.c | 14 +++++--------- apps/onplay.c | 15 +++------------ apps/settings.h | 2 +- apps/settings_list.c | 2 +- 4 files changed, 10 insertions(+), 23 deletions(-) diff --git a/apps/gui/skin_engine/skin_backdrops.c b/apps/gui/skin_engine/skin_backdrops.c index 3e04beaae0..12950a666c 100644 --- a/apps/gui/skin_engine/skin_backdrops.c +++ b/apps/gui/skin_engine/skin_backdrops.c @@ -113,10 +113,7 @@ bool skin_backdrops_preload(void) if (screen == SCREEN_MAIN && global_settings.backdrop_file[0] && global_settings.backdrop_file[0] != '-' && filename[0] == '-') { - char* temp = filename+2; /* slightly hacky to get a buffer */ - size_t size = sizeof(backdrops[i].name) - 2; - snprintf(temp, size, BACKDROP_DIR "/%s.bmp", global_settings.backdrop_file); - filename = temp; + filename = global_settings.backdrop_file; } if (*filename && *filename != '-') { @@ -156,7 +153,6 @@ void skin_backdrop_unload(int backdrop_id) void skin_backdrop_load_setting(void) { int i; - char filename[MAX_PATH]; for(i=0;i 1 static bool set_backdrop(void) { - /* load the image - if(sb_set_backdrop(SCREEN_MAIN, selected_file)) { - splash(HZ, str(LANG_BACKDROP_LOADED)); - set_file(selected_file, (char *)global_settings.backdrop_file, - MAX_FILENAME); - return true; - } else { - splash(HZ, str(LANG_BACKDROP_FAILED)); - return false; - }*/ - set_file(selected_file, (char *)global_settings.backdrop_file, - MAX_FILENAME); + strlcpy(global_settings.backdrop_file, selected_file, + sizeof(global_settings.backdrop_file)); + settings_save(); skin_backdrop_load_setting(); return true; } diff --git a/apps/settings.h b/apps/settings.h index 0734cf0668..7dca65ad9a 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -588,7 +588,7 @@ struct user_settings #endif /* HAVE_TAGCACHE */ #if LCD_DEPTH > 1 - unsigned char backdrop_file[MAX_FILENAME+1]; /* backdrop bitmap file */ + unsigned char backdrop_file[MAX_PATHNAME+1]; /* backdrop bitmap file */ #endif #ifdef HAVE_LCD_COLOR diff --git a/apps/settings_list.c b/apps/settings_list.c index 7f2cf38072..bd4a473389 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -1587,7 +1587,7 @@ const struct settings_list settings[] = { TEXT_SETTING(0,lang_file,"lang","",LANG_DIR "/",".lng"), #if LCD_DEPTH > 1 TEXT_SETTING(F_THEMESETTING,backdrop_file,"backdrop", - DEFAULT_BACKDROP, BACKDROP_DIR "/", ".bmp"), + DEFAULT_BACKDROP, NULL, NULL), #endif #ifdef HAVE_LCD_BITMAP TEXT_SETTING(0,kbd_file,"kbd","-",ROCKBOX_DIR "/",".kbd"),