split the theme settings apply() sutff out of settings_apply(). this should fix splashes not being loc'ed, statusbar over the splash (fixed in sim, not on my mini2g though), and the supposed boot time slowdown.

What this also does is remove a bunch of unnecessary settings_Apply()'s from the ipod accessory code, and causes all non-skin settings to get applied each time (this includes font and langs which we wernt doing to stop disk access)


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24922 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2010-02-26 08:01:41 +00:00
parent c396e4161a
commit 4c6b3551b5
10 changed files with 146 additions and 118 deletions

View file

@ -84,6 +84,7 @@ gui/statusbar.c
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
gui/statusbar-skinned.c gui/statusbar-skinned.c
#endif #endif
gui/theme_settings.c
gui/yesno.c gui/yesno.c
gui/viewport.c gui/viewport.c

View file

@ -400,7 +400,7 @@ bool quick_screen_quick(int button_enter)
if (gui_syncquickscreen_run(&qs, button_enter)) if (gui_syncquickscreen_run(&qs, button_enter))
{ {
settings_save(); settings_save();
settings_apply(false); settings_apply();
/* make sure repeat/shuffle/any other nasty ones get updated */ /* make sure repeat/shuffle/any other nasty ones get updated */
if ( oldrepeat != global_settings.repeat_mode && if ( oldrepeat != global_settings.repeat_mode &&
(audio_status() & AUDIO_STATUS_PLAY) ) (audio_status() & AUDIO_STATUS_PLAY) )
@ -437,7 +437,7 @@ bool quick_screen_f3(int button_enter)
if (gui_syncquickscreen_run(&qs, button_enter)) if (gui_syncquickscreen_run(&qs, button_enter))
{ {
settings_save(); settings_save();
settings_apply(false); settings_apply();
} }
return(0); return(0);
} }

94
apps/gui/theme_settings.c Normal file
View file

@ -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 <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <limits.h>
#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<sizeof(skins)/sizeof(*skins); i++)
{
#ifdef HAVE_REMOTE_LCD
screen = skins[i].suffix[0] == 'r' ? SCREEN_REMOTE : SCREEN_MAIN;
#endif
if (skins[i].setting[0] && skins[i].setting[0] != '-')
{
snprintf(buf, sizeof buf, WPS_DIR "/%s.%s",
skins[i].setting, skins[i].suffix);
skins[i].loadfunc(screen, buf, true);
}
else
{
skins[i].loadfunc(screen, NULL, true);
}
}
viewportmanager_theme_changed(THEME_STATUSBAR);
#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
FOR_NB_SCREENS(i)
screens[i].backdrop_show(sb_get_backdrop(i));
#endif
}

View file

@ -110,12 +110,13 @@ static void toggle_theme(enum screen_type screen, bool force)
if (is_theme_enabled(screen)) if (is_theme_enabled(screen))
{ {
bool first_boot = theme_stack_top[screen] == 0;
/* remove the left overs from the previous screen. /* remove the left overs from the previous screen.
* could cause a tiny flicker. Redo your screen code if that happens */ * could cause a tiny flicker. Redo your screen code if that happens */
#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
screens[screen].backdrop_show(sb_get_backdrop(screen)); screens[screen].backdrop_show(sb_get_backdrop(screen));
#endif #endif
if (!was_enabled[screen] || force) if (!first_boot && (!was_enabled[screen] || force))
{ {
struct viewport deadspace, user; struct viewport deadspace, user;
viewport_set_defaults(&user, screen); viewport_set_defaults(&user, screen);
@ -161,7 +162,7 @@ static void toggle_theme(enum screen_type screen, bool force)
screens[screen].update_viewport(); screens[screen].update_viewport();
} }
} }
send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */ send_event(GUI_EVENT_ACTIONUPDATE, (void*)!first_boot);
} }
else else
{ {

View file

@ -420,7 +420,6 @@ void iap_handlepkt(void)
{ {
global_settings.playlist_shuffle = 1; global_settings.playlist_shuffle = 1;
settings_save(); settings_save();
settings_apply(false);
if (audio_status() & AUDIO_STATUS_PLAY) if (audio_status() & AUDIO_STATUS_PLAY)
playlist_randomise(NULL, current_tick, true); playlist_randomise(NULL, current_tick, true);
} }
@ -428,7 +427,6 @@ void iap_handlepkt(void)
{ {
global_settings.playlist_shuffle = 0; global_settings.playlist_shuffle = 0;
settings_save(); settings_save();
settings_apply(false);
if (audio_status() & AUDIO_STATUS_PLAY) if (audio_status() & AUDIO_STATUS_PLAY)
playlist_sort(NULL, true); playlist_sort(NULL, true);
} }
@ -451,7 +449,6 @@ void iap_handlepkt(void)
global_settings.repeat_mode = REPEAT_ALL; global_settings.repeat_mode = REPEAT_ALL;
settings_save(); settings_save();
settings_apply(false);
if (audio_status() & AUDIO_STATUS_PLAY) if (audio_status() & AUDIO_STATUS_PLAY)
audio_flush_and_reload_tracks(); audio_flush_and_reload_tracks();
} }
@ -716,7 +713,6 @@ void iap_handlepkt(void)
{ {
global_settings.playlist_shuffle = 1; global_settings.playlist_shuffle = 1;
settings_save(); settings_save();
settings_apply(false);
if (audio_status() & AUDIO_STATUS_PLAY) if (audio_status() & AUDIO_STATUS_PLAY)
playlist_randomise(NULL, current_tick, true); playlist_randomise(NULL, current_tick, true);
} }
@ -724,7 +720,6 @@ void iap_handlepkt(void)
{ {
global_settings.playlist_shuffle = 0; global_settings.playlist_shuffle = 0;
settings_save(); settings_save();
settings_apply(false);
if (audio_status() & AUDIO_STATUS_PLAY) if (audio_status() & AUDIO_STATUS_PLAY)
playlist_sort(NULL, true); playlist_sort(NULL, true);
} }
@ -762,7 +757,6 @@ void iap_handlepkt(void)
if (oldmode != global_settings.repeat_mode) if (oldmode != global_settings.repeat_mode)
{ {
settings_save(); settings_save();
settings_apply(false);
if (audio_status() & AUDIO_STATUS_PLAY) if (audio_status() & AUDIO_STATUS_PLAY)
audio_flush_and_reload_tracks(); audio_flush_and_reload_tracks();
} }

View file

@ -325,11 +325,10 @@ static void init(void)
sb_skin_init(); sb_skin_init();
viewportmanager_init(); viewportmanager_init();
gui_sync_wps_init();
storage_init(); storage_init();
settings_reset(); settings_reset();
settings_load(SETTINGS_ALL); settings_load(SETTINGS_ALL);
settings_apply(false); settings_apply();
init_dircache(true); init_dircache(true);
init_dircache(false); init_dircache(false);
#ifdef HAVE_TAGCACHE #ifdef HAVE_TAGCACHE
@ -368,7 +367,7 @@ static void init(void)
audio_init(); audio_init();
button_clear_queue(); /* Empty the keyboard buffer */ button_clear_queue(); /* Empty the keyboard buffer */
settings_apply(true); settings_apply_skins();
} }
#else #else
@ -455,8 +454,6 @@ static void init(void)
sb_skin_init(); sb_skin_init();
viewportmanager_init(); viewportmanager_init();
gui_sync_wps_init();
#if CONFIG_CHARGING && (CONFIG_CPU == SH7034) #if CONFIG_CHARGING && (CONFIG_CPU == SH7034)
/* charger_inserted() can't be used here because power_thread() /* charger_inserted() can't be used here because power_thread()
hasn't checked power_input_status() yet */ hasn't checked power_input_status() yet */
@ -562,7 +559,7 @@ static void init(void)
#endif #endif
} }
settings_apply(false); settings_apply();
init_dircache(false); init_dircache(false);
#ifdef HAVE_TAGCACHE #ifdef HAVE_TAGCACHE
init_tagcache(); init_tagcache();
@ -627,8 +624,7 @@ static void init(void)
#ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN
check_bootfile(false); /* remember write time and filesize */ check_bootfile(false); /* remember write time and filesize */
#endif #endif
settings_apply_skins();
settings_apply(true);
} }
#ifdef CPU_PP #ifdef CPU_PP

View file

@ -76,8 +76,9 @@ static int reset_settings(void)
{ {
case YESNO_YES: case YESNO_YES:
settings_reset(); settings_reset();
settings_apply(true);
settings_save(); settings_save();
settings_apply();
settings_apply_skins();
break; break;
case YESNO_NO: case YESNO_NO:
break; break;

View file

@ -96,7 +96,7 @@ static int set_color_func(void* color)
res = (int)set_color(&screens[SCREEN_MAIN],str(colors[c].lang_id), res = (int)set_color(&screens[SCREEN_MAIN],str(colors[c].lang_id),
colors[c].setting, banned_color); colors[c].setting, banned_color);
settings_save(); settings_save();
settings_apply(false); settings_apply();
return res; return res;
} }
@ -109,7 +109,7 @@ static int reset_color(void)
global_settings.lst_color = LCD_DEFAULT_FG; global_settings.lst_color = LCD_DEFAULT_FG;
settings_save(); settings_save();
settings_apply(false); settings_apply();
return 0; return 0;
} }
MENUITEM_FUNCTION(set_bg_col, MENU_FUNC_USEPARAM, ID2P(LANG_BACKGROUND_COLOR), MENUITEM_FUNCTION(set_bg_col, MENU_FUNC_USEPARAM, ID2P(LANG_BACKGROUND_COLOR),

View file

@ -68,7 +68,6 @@
#endif #endif
#include "wps.h" #include "wps.h"
#include "skin_engine/skin_engine.h" #include "skin_engine/skin_engine.h"
#include "skin_engine/skin_fonts.h"
#include "viewport.h" #include "viewport.h"
#include "statusbar-skinned.h" #include "statusbar-skinned.h"
@ -360,7 +359,10 @@ bool settings_load_config(const char* file, bool apply)
close(fd); close(fd);
settings_save(); settings_save();
if (apply) if (apply)
settings_apply(true); {
settings_apply();
settings_apply_skins();
}
return true; return true;
} }
@ -739,62 +741,7 @@ void sound_settings_apply(void)
} }
void 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<sizeof(skins)/sizeof(*skins); i++)
{
#ifdef HAVE_REMOTE_LCD
screen = skins[i].suffix[0] == 'r' ? SCREEN_REMOTE : SCREEN_MAIN;
#endif
if (skins[i].setting[0] && skins[i].setting[0] != '-')
{
snprintf(buf, sizeof buf, WPS_DIR "/%s.%s",
skins[i].setting, skins[i].suffix);
skins[i].loadfunc(screen, buf, true);
}
else
{
skins[i].loadfunc(screen, NULL, true);
}
}
viewportmanager_theme_changed(THEME_STATUSBAR);
#if LCD_DEPTH > 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)
{ {
char buf[64]; char buf[64];
@ -886,55 +833,49 @@ void settings_apply(bool read_disk)
audiohw_enable_speaker(global_settings.speaker_enabled); audiohw_enable_speaker(global_settings.speaker_enabled);
#endif #endif
if (read_disk)
{
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
/* fonts need to be loaded before the WPS */ /* fonts need to be loaded before the WPS */
if ( global_settings.font_file[0]) { if ( global_settings.font_file[0]) {
snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
global_settings.font_file); global_settings.font_file);
if (font_load(NULL, buf) < 0) if (font_load(NULL, buf) < 0)
font_reset(NULL);
}
else
font_reset(NULL); font_reset(NULL);
}
else
font_reset(NULL);
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
if ( global_settings.remote_font_file[0]) { if ( global_settings.remote_font_file[0]) {
snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
global_settings.remote_font_file); global_settings.remote_font_file);
if (font_load_remoteui(buf) < 0) if (font_load_remoteui(buf) < 0)
font_load_remoteui(NULL);
}
else
font_load_remoteui(NULL); font_load_remoteui(NULL);
}
else
font_load_remoteui(NULL);
#endif #endif
if ( global_settings.kbd_file[0]) { if ( global_settings.kbd_file[0]) {
snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd", snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd",
global_settings.kbd_file); global_settings.kbd_file);
load_kbd(buf); load_kbd(buf);
} }
else else
load_kbd(NULL); load_kbd(NULL);
#endif #endif
if ( global_settings.lang_file[0]) { if ( global_settings.lang_file[0]) {
snprintf(buf, sizeof buf, LANG_DIR "/%s.lng", snprintf(buf, sizeof buf, LANG_DIR "/%s.lng",
global_settings.lang_file); global_settings.lang_file);
lang_core_load(buf); lang_core_load(buf);
talk_init(); /* use voice of same language */ talk_init(); /* use voice of same language */
} }
/* reload wpses */ /* load the icon set */
settings_apply_skins(); icons_init();
/* load the icon set */
icons_init();
#ifdef HAVE_LCD_COLOR #ifdef HAVE_LCD_COLOR
if (global_settings.colors_file[0]) if (global_settings.colors_file[0])
read_color_theme_file(); read_color_theme_file();
#endif #endif
}
#ifdef HAVE_LCD_COLOR #ifdef HAVE_LCD_COLOR
screens[SCREEN_MAIN].set_foreground(global_settings.fg_color); screens[SCREEN_MAIN].set_foreground(global_settings.fg_color);

View file

@ -260,7 +260,7 @@ void sound_settings_apply(void);
*/ */
void settings_apply_skins(void); void settings_apply_skins(void);
void settings_apply(bool read_disk); void settings_apply(void);
void settings_apply_pm_range(void); void settings_apply_pm_range(void);
void settings_display(void); void settings_display(void);