Rockbox as an application: add get_user_file_path().
[kugel-rb.git] / apps / gui / theme_settings.c
bloba975c218cdcfd76283cfc54b1d3fb469909129d8
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Stuart Martin
11 * RTC config saving code (C) 2002 by hessu@hes.iki.fi
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.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
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 "buffer.h"
34 #if CONFIG_TUNER
35 #include "radio.h"
36 #endif
37 #include "skin_engine/skin_engine.h"
38 #include "skin_buffer.h"
39 #include "statusbar-skinned.h"
40 #include "bootchart.h"
42 static char *skin_buffer = NULL;
43 void theme_init_buffer(void)
45 skin_buffer = buffer_alloc(SKIN_BUFFER_SIZE);
49 /* call this after loading a .wps/.rwps or other skin files, so that the
50 * skin buffer is reset properly
52 struct skin_load_setting {
53 char* setting;
54 char* suffix;
55 void (*loadfunc)(enum screen_type screen, const char *buf, bool isfile);
58 static const struct skin_load_setting skins[] = {
59 /* This determins the load order. *sbs must be loaded before any other
60 * skin on that screen */
61 #ifdef HAVE_LCD_BITMAP
62 { global_settings.sbs_file, "sbs", sb_skin_data_load},
63 #endif
64 { global_settings.wps_file, "wps", wps_data_load},
65 #if CONFIG_TUNER
66 { global_settings.fms_file, "fms", fms_data_load},
67 #endif
68 #if defined(HAVE_REMOTE_LCD) && NB_SCREENS > 1
69 { global_settings.rsbs_file, "rsbs", sb_skin_data_load},
70 { global_settings.rwps_file, "rwps", wps_data_load},
71 #if CONFIG_TUNER
72 { global_settings.rfms_file, "rfms", fms_data_load},
73 #endif
74 #endif
77 void settings_apply_skins(void)
79 char buf[MAX_PATH];
80 /* re-initialize the skin buffer before we start reloading skins */
81 enum screen_type screen = SCREEN_MAIN;
82 unsigned int i;
84 skin_buffer_init(skin_buffer, SKIN_BUFFER_SIZE);
85 #ifdef HAVE_LCD_BITMAP
86 skin_backdrop_init();
87 skin_font_init();
88 #endif
89 #if CONFIG_TUNER
90 fms_skin_init();
91 #endif
92 for (i=0; i<ARRAYLEN(skins); i++)
94 #ifdef HAVE_REMOTE_LCD
95 screen = skins[i].suffix[0] == 'r' ? SCREEN_REMOTE : SCREEN_MAIN;
96 #endif
97 CHART2(">skin load ", skins[i].suffix);
98 if (skins[i].setting[0] && skins[i].setting[0] != '-')
100 char path[MAX_PATH];
101 snprintf(buf, sizeof buf, "%s/%s.%s",
102 get_user_file_path(WPS_DIR, false, path, sizeof(path)),
103 skins[i].setting, skins[i].suffix);
104 skins[i].loadfunc(screen, buf, true);
106 else
108 skins[i].loadfunc(screen, NULL, true);
110 CHART2("<skin load ", skins[i].suffix);
112 viewportmanager_theme_changed(THEME_STATUSBAR);
113 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
114 FOR_NB_SCREENS(i)
115 screens[i].backdrop_show(sb_get_backdrop(i));
116 #endif