diff options
Diffstat (limited to 'apps/settings.c')
-rw-r--r-- | apps/settings.c | 133 |
1 files changed, 37 insertions, 96 deletions
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 | 744 | void 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 | */ | ||
746 | struct skin_load_setting { | ||
747 | char* setting; | ||
748 | char* suffix; | ||
749 | void (*loadfunc)(enum screen_type screen, const char *buf, bool isfile); | ||
750 | }; | ||
751 | static 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 | }; | ||
763 | void 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 | |||
797 | void 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); |