diff --git a/apps/SOURCES b/apps/SOURCES index 39159d639b..069e619451 100644 --- a/apps/SOURCES +++ b/apps/SOURCES @@ -84,6 +84,7 @@ gui/statusbar.c #ifdef HAVE_LCD_BITMAP gui/statusbar-skinned.c #endif +gui/theme_settings.c gui/yesno.c gui/viewport.c diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index d092f0b04a..1a22f69341 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c @@ -400,7 +400,7 @@ bool quick_screen_quick(int button_enter) if (gui_syncquickscreen_run(&qs, button_enter)) { settings_save(); - settings_apply(false); + settings_apply(); /* make sure repeat/shuffle/any other nasty ones get updated */ if ( oldrepeat != global_settings.repeat_mode && (audio_status() & AUDIO_STATUS_PLAY) ) @@ -437,7 +437,7 @@ bool quick_screen_f3(int button_enter) if (gui_syncquickscreen_run(&qs, button_enter)) { settings_save(); - settings_apply(false); + settings_apply(); } return(0); } diff --git a/apps/gui/theme_settings.c b/apps/gui/theme_settings.c new file mode 100644 index 0000000000..23e7a5bbaf --- /dev/null +++ b/apps/gui/theme_settings.c @@ -0,0 +1,94 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: settings.c 24848 2010-02-22 07:25:13Z jdgordon $ + * + * Copyright (C) 2002 by Stuart Martin + * RTC config saving code (C) 2002 by hessu@hes.iki.fi + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include +#include +#include +#include +#include "inttypes.h" +#include "config.h" +#include "action.h" +#include "crc32.h" +#include "settings.h" +#include "wps.h" +#include "file.h" +#include "skin_engine/skin_engine.h" +#include "skin_engine/skin_fonts.h" +#include "statusbar-skinned.h" + + + +/* call this after loading a .wps/.rwps or other skin files, so that the + * skin buffer is reset properly + */ +struct skin_load_setting { + char* setting; + char* suffix; + void (*loadfunc)(enum screen_type screen, const char *buf, bool isfile); +}; +static struct skin_load_setting skins[] = { + /* This determins the load order. *sbs must be loaded before any other + * skin on that screen */ +#ifdef HAVE_LCD_BITMAP + { global_settings.sbs_file, "sbs", sb_skin_data_load}, +#endif + { global_settings.wps_file, "wps", wps_data_load}, +#ifdef HAVE_REMOTE_LCD + { global_settings.rsbs_file, "rsbs", sb_skin_data_load}, + { global_settings.rwps_file, "rwps", wps_data_load}, +#endif +}; + +void settings_apply_skins(void) +{ + char buf[MAX_PATH]; + /* re-initialize the skin buffer before we start reloading skins */ + skin_buffer_init(); + enum screen_type screen = SCREEN_MAIN; + unsigned int i; +#ifdef HAVE_LCD_BITMAP + skin_backdrop_init(); + skin_font_init(); + sb_skin_init(); +#endif + gui_sync_wps_init(); + for (i=0; i 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 + FOR_NB_SCREENS(i) + screens[i].backdrop_show(sb_get_backdrop(i)); +#endif +} diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index 6e4d9913c4..9b35c86c17 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c @@ -110,12 +110,13 @@ static void toggle_theme(enum screen_type screen, bool force) if (is_theme_enabled(screen)) { + bool first_boot = theme_stack_top[screen] == 0; /* remove the left overs from the previous screen. * could cause a tiny flicker. Redo your screen code if that happens */ #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 screens[screen].backdrop_show(sb_get_backdrop(screen)); #endif - if (!was_enabled[screen] || force) + if (!first_boot && (!was_enabled[screen] || force)) { struct viewport deadspace, user; viewport_set_defaults(&user, screen); @@ -161,7 +162,7 @@ static void toggle_theme(enum screen_type screen, bool force) screens[screen].update_viewport(); } } - send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */ + send_event(GUI_EVENT_ACTIONUPDATE, (void*)!first_boot); } else { diff --git a/apps/iap.c b/apps/iap.c index 741ff9fb0c..3075db90fa 100644 --- a/apps/iap.c +++ b/apps/iap.c @@ -420,7 +420,6 @@ void iap_handlepkt(void) { global_settings.playlist_shuffle = 1; settings_save(); - settings_apply(false); if (audio_status() & AUDIO_STATUS_PLAY) playlist_randomise(NULL, current_tick, true); } @@ -428,7 +427,6 @@ void iap_handlepkt(void) { global_settings.playlist_shuffle = 0; settings_save(); - settings_apply(false); if (audio_status() & AUDIO_STATUS_PLAY) playlist_sort(NULL, true); } @@ -451,7 +449,6 @@ void iap_handlepkt(void) global_settings.repeat_mode = REPEAT_ALL; settings_save(); - settings_apply(false); if (audio_status() & AUDIO_STATUS_PLAY) audio_flush_and_reload_tracks(); } @@ -716,7 +713,6 @@ void iap_handlepkt(void) { global_settings.playlist_shuffle = 1; settings_save(); - settings_apply(false); if (audio_status() & AUDIO_STATUS_PLAY) playlist_randomise(NULL, current_tick, true); } @@ -724,7 +720,6 @@ void iap_handlepkt(void) { global_settings.playlist_shuffle = 0; settings_save(); - settings_apply(false); if (audio_status() & AUDIO_STATUS_PLAY) playlist_sort(NULL, true); } @@ -762,7 +757,6 @@ void iap_handlepkt(void) if (oldmode != global_settings.repeat_mode) { settings_save(); - settings_apply(false); if (audio_status() & AUDIO_STATUS_PLAY) audio_flush_and_reload_tracks(); } diff --git a/apps/main.c b/apps/main.c index 6d2609b486..187f0cdd96 100644 --- a/apps/main.c +++ b/apps/main.c @@ -325,11 +325,10 @@ static void init(void) sb_skin_init(); viewportmanager_init(); - gui_sync_wps_init(); storage_init(); settings_reset(); settings_load(SETTINGS_ALL); - settings_apply(false); + settings_apply(); init_dircache(true); init_dircache(false); #ifdef HAVE_TAGCACHE @@ -368,7 +367,7 @@ static void init(void) audio_init(); button_clear_queue(); /* Empty the keyboard buffer */ - settings_apply(true); + settings_apply_skins(); } #else @@ -455,8 +454,6 @@ static void init(void) sb_skin_init(); viewportmanager_init(); - gui_sync_wps_init(); - #if CONFIG_CHARGING && (CONFIG_CPU == SH7034) /* charger_inserted() can't be used here because power_thread() hasn't checked power_input_status() yet */ @@ -562,7 +559,7 @@ static void init(void) #endif } - settings_apply(false); + settings_apply(); init_dircache(false); #ifdef HAVE_TAGCACHE init_tagcache(); @@ -627,8 +624,7 @@ static void init(void) #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN check_bootfile(false); /* remember write time and filesize */ #endif - - settings_apply(true); + settings_apply_skins(); } #ifdef CPU_PP diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index 783490284c..2d3a65a7b2 100644 --- a/apps/menus/main_menu.c +++ b/apps/menus/main_menu.c @@ -76,8 +76,9 @@ static int reset_settings(void) { case YESNO_YES: settings_reset(); - settings_apply(true); settings_save(); + settings_apply(); + settings_apply_skins(); break; case YESNO_NO: break; diff --git a/apps/menus/theme_menu.c b/apps/menus/theme_menu.c index b3abb77869..ee1970ee44 100644 --- a/apps/menus/theme_menu.c +++ b/apps/menus/theme_menu.c @@ -96,7 +96,7 @@ static int set_color_func(void* color) res = (int)set_color(&screens[SCREEN_MAIN],str(colors[c].lang_id), colors[c].setting, banned_color); settings_save(); - settings_apply(false); + settings_apply(); return res; } @@ -109,7 +109,7 @@ static int reset_color(void) global_settings.lst_color = LCD_DEFAULT_FG; settings_save(); - settings_apply(false); + settings_apply(); return 0; } MENUITEM_FUNCTION(set_bg_col, MENU_FUNC_USEPARAM, ID2P(LANG_BACKGROUND_COLOR), diff --git a/apps/settings.c b/apps/settings.c index a8e4cf24a8..ffefa3157c 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -68,7 +68,6 @@ #endif #include "wps.h" #include "skin_engine/skin_engine.h" -#include "skin_engine/skin_fonts.h" #include "viewport.h" #include "statusbar-skinned.h" @@ -360,7 +359,10 @@ bool settings_load_config(const char* file, bool apply) close(fd); settings_save(); if (apply) - settings_apply(true); + { + settings_apply(); + settings_apply_skins(); + } return true; } @@ -739,62 +741,7 @@ void sound_settings_apply(void) } - -/* call this after loading a .wps/.rwps or other skin files, so that the - * skin buffer is reset properly - */ -struct skin_load_setting { - char* setting; - char* suffix; - void (*loadfunc)(enum screen_type screen, const char *buf, bool isfile); -}; -static struct skin_load_setting skins[] = { - /* This determins the load order. *sbs must be loaded before any other - * skin on that screen */ -#ifdef HAVE_LCD_BITMAP - { global_settings.sbs_file, "sbs", sb_skin_data_load}, -#endif - { global_settings.wps_file, "wps", wps_data_load}, -#ifdef HAVE_REMOTE_LCD - { global_settings.rsbs_file, "rsbs", sb_skin_data_load}, - { global_settings.rwps_file, "rwps", wps_data_load}, -#endif -}; -void settings_apply_skins(void) -{ - char buf[MAX_PATH]; - /* re-initialize the skin buffer before we start reloading skins */ - skin_buffer_init(); - enum screen_type screen = SCREEN_MAIN; - unsigned int i; -#ifdef HAVE_LCD_BITMAP - skin_backdrop_init(); - skin_font_init(); -#endif - for (i=0; i 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 - FOR_NB_SCREENS(i) - screens[i].backdrop_show(sb_get_backdrop(i)); -#endif -} - -void settings_apply(bool read_disk) +void settings_apply(void) { char buf[64]; @@ -886,55 +833,49 @@ void settings_apply(bool read_disk) audiohw_enable_speaker(global_settings.speaker_enabled); #endif - if (read_disk) - { #ifdef HAVE_LCD_BITMAP - /* fonts need to be loaded before the WPS */ - if ( global_settings.font_file[0]) { - snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", - global_settings.font_file); - if (font_load(NULL, buf) < 0) - font_reset(NULL); - } - else + /* fonts need to be loaded before the WPS */ + if ( global_settings.font_file[0]) { + snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", + global_settings.font_file); + if (font_load(NULL, buf) < 0) font_reset(NULL); + } + else + font_reset(NULL); #ifdef HAVE_REMOTE_LCD - if ( global_settings.remote_font_file[0]) { - snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", - global_settings.remote_font_file); - if (font_load_remoteui(buf) < 0) - font_load_remoteui(NULL); - } - else + if ( global_settings.remote_font_file[0]) { + snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", + global_settings.remote_font_file); + if (font_load_remoteui(buf) < 0) font_load_remoteui(NULL); + } + else + font_load_remoteui(NULL); #endif - if ( global_settings.kbd_file[0]) { - snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd", - global_settings.kbd_file); - load_kbd(buf); - } - else - load_kbd(NULL); + if ( global_settings.kbd_file[0]) { + snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd", + global_settings.kbd_file); + load_kbd(buf); + } + else + load_kbd(NULL); #endif - if ( global_settings.lang_file[0]) { - snprintf(buf, sizeof buf, LANG_DIR "/%s.lng", - global_settings.lang_file); - lang_core_load(buf); - talk_init(); /* use voice of same language */ - } + if ( global_settings.lang_file[0]) { + snprintf(buf, sizeof buf, LANG_DIR "/%s.lng", + global_settings.lang_file); + lang_core_load(buf); + talk_init(); /* use voice of same language */ + } - /* reload wpses */ - settings_apply_skins(); - - /* load the icon set */ - icons_init(); + /* load the icon set */ + icons_init(); #ifdef HAVE_LCD_COLOR - if (global_settings.colors_file[0]) - read_color_theme_file(); + if (global_settings.colors_file[0]) + read_color_theme_file(); #endif - } #ifdef HAVE_LCD_COLOR screens[SCREEN_MAIN].set_foreground(global_settings.fg_color); diff --git a/apps/settings.h b/apps/settings.h index 7c40c09908..bba33366ae 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -260,7 +260,7 @@ void sound_settings_apply(void); */ void settings_apply_skins(void); -void settings_apply(bool read_disk); +void settings_apply(void); void settings_apply_pm_range(void); void settings_display(void);