summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/SOURCES1
-rw-r--r--apps/gui/quickscreen.c4
-rw-r--r--apps/gui/theme_settings.c94
-rw-r--r--apps/gui/viewport.c5
-rw-r--r--apps/iap.c6
-rw-r--r--apps/main.c12
-rw-r--r--apps/menus/main_menu.c3
-rw-r--r--apps/menus/theme_menu.c4
-rw-r--r--apps/settings.c133
-rw-r--r--apps/settings.h2
10 files changed, 146 insertions, 118 deletions
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
84#ifdef HAVE_LCD_BITMAP 84#ifdef HAVE_LCD_BITMAP
85gui/statusbar-skinned.c 85gui/statusbar-skinned.c
86#endif 86#endif
87gui/theme_settings.c
87gui/yesno.c 88gui/yesno.c
88gui/viewport.c 89gui/viewport.c
89 90
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)
400 if (gui_syncquickscreen_run(&qs, button_enter)) 400 if (gui_syncquickscreen_run(&qs, button_enter))
401 { 401 {
402 settings_save(); 402 settings_save();
403 settings_apply(false); 403 settings_apply();
404 /* make sure repeat/shuffle/any other nasty ones get updated */ 404 /* make sure repeat/shuffle/any other nasty ones get updated */
405 if ( oldrepeat != global_settings.repeat_mode && 405 if ( oldrepeat != global_settings.repeat_mode &&
406 (audio_status() & AUDIO_STATUS_PLAY) ) 406 (audio_status() & AUDIO_STATUS_PLAY) )
@@ -437,7 +437,7 @@ bool quick_screen_f3(int button_enter)
437 if (gui_syncquickscreen_run(&qs, button_enter)) 437 if (gui_syncquickscreen_run(&qs, button_enter))
438 { 438 {
439 settings_save(); 439 settings_save();
440 settings_apply(false); 440 settings_apply();
441 } 441 }
442 return(0); 442 return(0);
443} 443}
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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: settings.c 24848 2010-02-22 07:25:13Z jdgordon $
9 *
10 * Copyright (C) 2002 by Stuart Martin
11 * RTC config saving code (C) 2002 by hessu@hes.iki.fi
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22#include <stdio.h>
23#include <stddef.h>
24#include <stdlib.h>
25#include <limits.h>
26#include "inttypes.h"
27#include "config.h"
28#include "action.h"
29#include "crc32.h"
30#include "settings.h"
31#include "wps.h"
32#include "file.h"
33#include "skin_engine/skin_engine.h"
34#include "skin_engine/skin_fonts.h"
35#include "statusbar-skinned.h"
36
37
38
39/* call this after loading a .wps/.rwps or other skin files, so that the
40 * skin buffer is reset properly
41 */
42struct skin_load_setting {
43 char* setting;
44 char* suffix;
45 void (*loadfunc)(enum screen_type screen, const char *buf, bool isfile);
46};
47static struct skin_load_setting skins[] = {
48 /* This determins the load order. *sbs must be loaded before any other
49 * skin on that screen */
50#ifdef HAVE_LCD_BITMAP
51 { global_settings.sbs_file, "sbs", sb_skin_data_load},
52#endif
53 { global_settings.wps_file, "wps", wps_data_load},
54#ifdef HAVE_REMOTE_LCD
55 { global_settings.rsbs_file, "rsbs", sb_skin_data_load},
56 { global_settings.rwps_file, "rwps", wps_data_load},
57#endif
58};
59
60void settings_apply_skins(void)
61{
62 char buf[MAX_PATH];
63 /* re-initialize the skin buffer before we start reloading skins */
64 skin_buffer_init();
65 enum screen_type screen = SCREEN_MAIN;
66 unsigned int i;
67#ifdef HAVE_LCD_BITMAP
68 skin_backdrop_init();
69 skin_font_init();
70 sb_skin_init();
71#endif
72 gui_sync_wps_init();
73 for (i=0; i<sizeof(skins)/sizeof(*skins); i++)
74 {
75#ifdef HAVE_REMOTE_LCD
76 screen = skins[i].suffix[0] == 'r' ? SCREEN_REMOTE : SCREEN_MAIN;
77#endif
78 if (skins[i].setting[0] && skins[i].setting[0] != '-')
79 {
80 snprintf(buf, sizeof buf, WPS_DIR "/%s.%s",
81 skins[i].setting, skins[i].suffix);
82 skins[i].loadfunc(screen, buf, true);
83 }
84 else
85 {
86 skins[i].loadfunc(screen, NULL, true);
87 }
88 }
89 viewportmanager_theme_changed(THEME_STATUSBAR);
90#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
91 FOR_NB_SCREENS(i)
92 screens[i].backdrop_show(sb_get_backdrop(i));
93#endif
94}
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)
110 110
111 if (is_theme_enabled(screen)) 111 if (is_theme_enabled(screen))
112 { 112 {
113 bool first_boot = theme_stack_top[screen] == 0;
113 /* remove the left overs from the previous screen. 114 /* remove the left overs from the previous screen.
114 * could cause a tiny flicker. Redo your screen code if that happens */ 115 * could cause a tiny flicker. Redo your screen code if that happens */
115#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 116#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
116 screens[screen].backdrop_show(sb_get_backdrop(screen)); 117 screens[screen].backdrop_show(sb_get_backdrop(screen));
117#endif 118#endif
118 if (!was_enabled[screen] || force) 119 if (!first_boot && (!was_enabled[screen] || force))
119 { 120 {
120 struct viewport deadspace, user; 121 struct viewport deadspace, user;
121 viewport_set_defaults(&user, screen); 122 viewport_set_defaults(&user, screen);
@@ -161,7 +162,7 @@ static void toggle_theme(enum screen_type screen, bool force)
161 screens[screen].update_viewport(); 162 screens[screen].update_viewport();
162 } 163 }
163 } 164 }
164 send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */ 165 send_event(GUI_EVENT_ACTIONUPDATE, (void*)!first_boot);
165 } 166 }
166 else 167 else
167 { 168 {
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)
420 { 420 {
421 global_settings.playlist_shuffle = 1; 421 global_settings.playlist_shuffle = 1;
422 settings_save(); 422 settings_save();
423 settings_apply(false);
424 if (audio_status() & AUDIO_STATUS_PLAY) 423 if (audio_status() & AUDIO_STATUS_PLAY)
425 playlist_randomise(NULL, current_tick, true); 424 playlist_randomise(NULL, current_tick, true);
426 } 425 }
@@ -428,7 +427,6 @@ void iap_handlepkt(void)
428 { 427 {
429 global_settings.playlist_shuffle = 0; 428 global_settings.playlist_shuffle = 0;
430 settings_save(); 429 settings_save();
431 settings_apply(false);
432 if (audio_status() & AUDIO_STATUS_PLAY) 430 if (audio_status() & AUDIO_STATUS_PLAY)
433 playlist_sort(NULL, true); 431 playlist_sort(NULL, true);
434 } 432 }
@@ -451,7 +449,6 @@ void iap_handlepkt(void)
451 global_settings.repeat_mode = REPEAT_ALL; 449 global_settings.repeat_mode = REPEAT_ALL;
452 450
453 settings_save(); 451 settings_save();
454 settings_apply(false);
455 if (audio_status() & AUDIO_STATUS_PLAY) 452 if (audio_status() & AUDIO_STATUS_PLAY)
456 audio_flush_and_reload_tracks(); 453 audio_flush_and_reload_tracks();
457 } 454 }
@@ -716,7 +713,6 @@ void iap_handlepkt(void)
716 { 713 {
717 global_settings.playlist_shuffle = 1; 714 global_settings.playlist_shuffle = 1;
718 settings_save(); 715 settings_save();
719 settings_apply(false);
720 if (audio_status() & AUDIO_STATUS_PLAY) 716 if (audio_status() & AUDIO_STATUS_PLAY)
721 playlist_randomise(NULL, current_tick, true); 717 playlist_randomise(NULL, current_tick, true);
722 } 718 }
@@ -724,7 +720,6 @@ void iap_handlepkt(void)
724 { 720 {
725 global_settings.playlist_shuffle = 0; 721 global_settings.playlist_shuffle = 0;
726 settings_save(); 722 settings_save();
727 settings_apply(false);
728 if (audio_status() & AUDIO_STATUS_PLAY) 723 if (audio_status() & AUDIO_STATUS_PLAY)
729 playlist_sort(NULL, true); 724 playlist_sort(NULL, true);
730 } 725 }
@@ -762,7 +757,6 @@ void iap_handlepkt(void)
762 if (oldmode != global_settings.repeat_mode) 757 if (oldmode != global_settings.repeat_mode)
763 { 758 {
764 settings_save(); 759 settings_save();
765 settings_apply(false);
766 if (audio_status() & AUDIO_STATUS_PLAY) 760 if (audio_status() & AUDIO_STATUS_PLAY)
767 audio_flush_and_reload_tracks(); 761 audio_flush_and_reload_tracks();
768 } 762 }
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)
325 sb_skin_init(); 325 sb_skin_init();
326 viewportmanager_init(); 326 viewportmanager_init();
327 327
328 gui_sync_wps_init();
329 storage_init(); 328 storage_init();
330 settings_reset(); 329 settings_reset();
331 settings_load(SETTINGS_ALL); 330 settings_load(SETTINGS_ALL);
332 settings_apply(false); 331 settings_apply();
333 init_dircache(true); 332 init_dircache(true);
334 init_dircache(false); 333 init_dircache(false);
335#ifdef HAVE_TAGCACHE 334#ifdef HAVE_TAGCACHE
@@ -368,7 +367,7 @@ static void init(void)
368 audio_init(); 367 audio_init();
369 button_clear_queue(); /* Empty the keyboard buffer */ 368 button_clear_queue(); /* Empty the keyboard buffer */
370 369
371 settings_apply(true); 370 settings_apply_skins();
372} 371}
373 372
374#else 373#else
@@ -455,8 +454,6 @@ static void init(void)
455 sb_skin_init(); 454 sb_skin_init();
456 viewportmanager_init(); 455 viewportmanager_init();
457 456
458 gui_sync_wps_init();
459
460#if CONFIG_CHARGING && (CONFIG_CPU == SH7034) 457#if CONFIG_CHARGING && (CONFIG_CPU == SH7034)
461 /* charger_inserted() can't be used here because power_thread() 458 /* charger_inserted() can't be used here because power_thread()
462 hasn't checked power_input_status() yet */ 459 hasn't checked power_input_status() yet */
@@ -562,7 +559,7 @@ static void init(void)
562#endif 559#endif
563 } 560 }
564 561
565 settings_apply(false); 562 settings_apply();
566 init_dircache(false); 563 init_dircache(false);
567#ifdef HAVE_TAGCACHE 564#ifdef HAVE_TAGCACHE
568 init_tagcache(); 565 init_tagcache();
@@ -627,8 +624,7 @@ static void init(void)
627#ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN 624#ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN
628 check_bootfile(false); /* remember write time and filesize */ 625 check_bootfile(false); /* remember write time and filesize */
629#endif 626#endif
630 627 settings_apply_skins();
631 settings_apply(true);
632} 628}
633 629
634#ifdef CPU_PP 630#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)
76 { 76 {
77 case YESNO_YES: 77 case YESNO_YES:
78 settings_reset(); 78 settings_reset();
79 settings_apply(true);
80 settings_save(); 79 settings_save();
80 settings_apply();
81 settings_apply_skins();
81 break; 82 break;
82 case YESNO_NO: 83 case YESNO_NO:
83 break; 84 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)
96 res = (int)set_color(&screens[SCREEN_MAIN],str(colors[c].lang_id), 96 res = (int)set_color(&screens[SCREEN_MAIN],str(colors[c].lang_id),
97 colors[c].setting, banned_color); 97 colors[c].setting, banned_color);
98 settings_save(); 98 settings_save();
99 settings_apply(false); 99 settings_apply();
100 return res; 100 return res;
101} 101}
102 102
@@ -109,7 +109,7 @@ static int reset_color(void)
109 global_settings.lst_color = LCD_DEFAULT_FG; 109 global_settings.lst_color = LCD_DEFAULT_FG;
110 110
111 settings_save(); 111 settings_save();
112 settings_apply(false); 112 settings_apply();
113 return 0; 113 return 0;
114} 114}
115MENUITEM_FUNCTION(set_bg_col, MENU_FUNC_USEPARAM, ID2P(LANG_BACKGROUND_COLOR), 115MENUITEM_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 @@
68#endif 68#endif
69#include "wps.h" 69#include "wps.h"
70#include "skin_engine/skin_engine.h" 70#include "skin_engine/skin_engine.h"
71#include "skin_engine/skin_fonts.h"
72#include "viewport.h" 71#include "viewport.h"
73#include "statusbar-skinned.h" 72#include "statusbar-skinned.h"
74 73
@@ -360,7 +359,10 @@ bool settings_load_config(const char* file, bool apply)
360 close(fd); 359 close(fd);
361 settings_save(); 360 settings_save();
362 if (apply) 361 if (apply)
363 settings_apply(true); 362 {
363 settings_apply();
364 settings_apply_skins();
365 }
364 return true; 366 return true;
365} 367}
366 368
@@ -739,62 +741,7 @@ void sound_settings_apply(void)
739} 741}
740 742
741 743
742 744void settings_apply(void)
743/* call this after loading a .wps/.rwps or other skin files, so that the
744 * skin buffer is reset properly
745 */
746struct skin_load_setting {
747 char* setting;
748 char* suffix;
749 void (*loadfunc)(enum screen_type screen, const char *buf, bool isfile);
750};
751static struct skin_load_setting skins[] = {
752 /* This determins the load order. *sbs must be loaded before any other
753 * skin on that screen */
754#ifdef HAVE_LCD_BITMAP
755 { global_settings.sbs_file, "sbs", sb_skin_data_load},
756#endif
757 { global_settings.wps_file, "wps", wps_data_load},
758#ifdef HAVE_REMOTE_LCD
759 { global_settings.rsbs_file, "rsbs", sb_skin_data_load},
760 { global_settings.rwps_file, "rwps", wps_data_load},
761#endif
762};
763void settings_apply_skins(void)
764{
765 char buf[MAX_PATH];
766 /* re-initialize the skin buffer before we start reloading skins */
767 skin_buffer_init();
768 enum screen_type screen = SCREEN_MAIN;
769 unsigned int i;
770#ifdef HAVE_LCD_BITMAP
771 skin_backdrop_init();
772 skin_font_init();
773#endif
774 for (i=0; i<sizeof(skins)/sizeof(*skins); i++)
775 {
776#ifdef HAVE_REMOTE_LCD
777 screen = skins[i].suffix[0] == 'r' ? SCREEN_REMOTE : SCREEN_MAIN;
778#endif
779 if (skins[i].setting[0] && skins[i].setting[0] != '-')
780 {
781 snprintf(buf, sizeof buf, WPS_DIR "/%s.%s",
782 skins[i].setting, skins[i].suffix);
783 skins[i].loadfunc(screen, buf, true);
784 }
785 else
786 {
787 skins[i].loadfunc(screen, NULL, true);
788 }
789 }
790 viewportmanager_theme_changed(THEME_STATUSBAR);
791#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
792 FOR_NB_SCREENS(i)
793 screens[i].backdrop_show(sb_get_backdrop(i));
794#endif
795}
796
797void settings_apply(bool read_disk)
798{ 745{
799 746
800 char buf[64]; 747 char buf[64];
@@ -886,55 +833,49 @@ void settings_apply(bool read_disk)
886 audiohw_enable_speaker(global_settings.speaker_enabled); 833 audiohw_enable_speaker(global_settings.speaker_enabled);
887#endif 834#endif
888 835
889 if (read_disk)
890 {
891#ifdef HAVE_LCD_BITMAP 836#ifdef HAVE_LCD_BITMAP
892 /* fonts need to be loaded before the WPS */ 837 /* fonts need to be loaded before the WPS */
893 if ( global_settings.font_file[0]) { 838 if ( global_settings.font_file[0]) {
894 snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", 839 snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
895 global_settings.font_file); 840 global_settings.font_file);
896 if (font_load(NULL, buf) < 0) 841 if (font_load(NULL, buf) < 0)
897 font_reset(NULL);
898 }
899 else
900 font_reset(NULL); 842 font_reset(NULL);
843 }
844 else
845 font_reset(NULL);
901#ifdef HAVE_REMOTE_LCD 846#ifdef HAVE_REMOTE_LCD
902 if ( global_settings.remote_font_file[0]) { 847 if ( global_settings.remote_font_file[0]) {
903 snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", 848 snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
904 global_settings.remote_font_file); 849 global_settings.remote_font_file);
905 if (font_load_remoteui(buf) < 0) 850 if (font_load_remoteui(buf) < 0)
906 font_load_remoteui(NULL);
907 }
908 else
909 font_load_remoteui(NULL); 851 font_load_remoteui(NULL);
852 }
853 else
854 font_load_remoteui(NULL);
910#endif 855#endif
911 if ( global_settings.kbd_file[0]) { 856 if ( global_settings.kbd_file[0]) {
912 snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd", 857 snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd",
913 global_settings.kbd_file); 858 global_settings.kbd_file);
914 load_kbd(buf); 859 load_kbd(buf);
915 } 860 }
916 else 861 else
917 load_kbd(NULL); 862 load_kbd(NULL);
918#endif 863#endif
919 864
920 if ( global_settings.lang_file[0]) { 865 if ( global_settings.lang_file[0]) {
921 snprintf(buf, sizeof buf, LANG_DIR "/%s.lng", 866 snprintf(buf, sizeof buf, LANG_DIR "/%s.lng",
922 global_settings.lang_file); 867 global_settings.lang_file);
923 lang_core_load(buf); 868 lang_core_load(buf);
924 talk_init(); /* use voice of same language */ 869 talk_init(); /* use voice of same language */
925 } 870 }
926
927 /* reload wpses */
928 settings_apply_skins();
929 871
930 /* load the icon set */ 872 /* load the icon set */
931 icons_init(); 873 icons_init();
932 874
933#ifdef HAVE_LCD_COLOR 875#ifdef HAVE_LCD_COLOR
934 if (global_settings.colors_file[0]) 876 if (global_settings.colors_file[0])
935 read_color_theme_file(); 877 read_color_theme_file();
936#endif 878#endif
937 }
938 879
939#ifdef HAVE_LCD_COLOR 880#ifdef HAVE_LCD_COLOR
940 screens[SCREEN_MAIN].set_foreground(global_settings.fg_color); 881 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);
260 */ 260 */
261void settings_apply_skins(void); 261void settings_apply_skins(void);
262 262
263void settings_apply(bool read_disk); 263void settings_apply(void);
264void settings_apply_pm_range(void); 264void settings_apply_pm_range(void);
265void settings_display(void); 265void settings_display(void);
266 266