summaryrefslogtreecommitdiff
path: root/apps/gui/statusbar-skinned.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/statusbar-skinned.c')
-rw-r--r--apps/gui/statusbar-skinned.c103
1 files changed, 82 insertions, 21 deletions
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c
index 168b17fa38..8eb082d50f 100644
--- a/apps/gui/statusbar-skinned.c
+++ b/apps/gui/statusbar-skinned.c
@@ -27,6 +27,9 @@
27#include "appevents.h" 27#include "appevents.h"
28#include "screens.h" 28#include "screens.h"
29#include "screen_access.h" 29#include "screen_access.h"
30#include "strlcpy.h"
31#include "skin_parser.h"
32#include "skin_buffer.h"
30#include "skin_engine/skin_engine.h" 33#include "skin_engine/skin_engine.h"
31#include "skin_engine/wps_internals.h" 34#include "skin_engine/wps_internals.h"
32#include "viewport.h" 35#include "viewport.h"
@@ -45,26 +48,55 @@ static struct wps_sync_data sb_skin_sync_data = { .do_full_update = false
45 48
46/* initial setup of wps_data */ 49/* initial setup of wps_data */
47static int update_delay = DEFAULT_UPDATE_DELAY; 50static int update_delay = DEFAULT_UPDATE_DELAY;
48 51struct wps_token *found_token;
49bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type screen) 52static int set_title_worker(char* title, enum themable_icons icon,
53 struct wps_data *data, struct skin_element *root)
50{ 54{
51 int i; 55 int retval = 0;
52 bool retval = false; 56 struct skin_element *element = root;
53 for(i=0; i<sb_skin_data[screen].num_tokens; i++) 57 while (element)
54 { 58 {
55 if (sb_skin_data[screen].tokens[i].type == WPS_TOKEN_LIST_TITLE_TEXT) 59 struct wps_token *token = NULL;
60 if (element->type == CONDITIONAL)
61 {
62 struct conditional *cond = (struct conditional *)element->data;
63 token = cond->token;
64 }
65 else if (element->type == TAG)
66 {
67 token = (struct wps_token *)element->data;
68 }
69 if (token)
56 { 70 {
57 sb_skin_data[screen].tokens[i].value.data = title; 71 if (token->type == SKIN_TOKEN_LIST_TITLE_TEXT)
58 retval = true; 72 {
73 found_token = token;
74 token->value.data = title;
75 retval = 1;
76 }
77 else if (token->type == SKIN_TOKEN_LIST_TITLE_ICON)
78 {
79 /* Icon_NOICON == -1 which the skin engine wants at position 1, so + 2 */
80 token->value.i = icon+2;
81 }
59 } 82 }
60 else if (sb_skin_data[screen].tokens[i].type == WPS_TOKEN_LIST_TITLE_ICON) 83 if (element->children_count)
61 { 84 {
62 /* Icon_NOICON == -1 which the skin engine wants at position 1, so + 2 */ 85 int i;
63 sb_skin_data[screen].tokens[i].value.i = icon+2; 86 for (i=0; i<element->children_count; i++)
87 retval |= set_title_worker(title, icon, data, element->children[i]);
64 } 88 }
89 element = element->next;
65 } 90 }
66 return retval; 91 return retval;
67} 92}
93
94bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type screen)
95{
96 bool retval = set_title_worker(title, icon, &sb_skin_data[screen],
97 sb_skin_data[screen].tree) > 0;
98 return retval;
99}
68 100
69 101
70void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile) 102void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile)
@@ -75,18 +107,22 @@ void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile)
75 success = buf && skin_data_load(screen, data, buf, isfile); 107 success = buf && skin_data_load(screen, data, buf, isfile);
76 108
77 if (success) 109 if (success)
78 { /* hide the sb's default viewport because it has nasty effect with stuff 110 {
111 /* hide the sb's default viewport because it has nasty effect with stuff
79 * not part of the statusbar, 112 * not part of the statusbar,
80 * hence .sbs's without any other vps are unsupported*/ 113 * hence .sbs's without any other vps are unsupported*/
81 struct skin_viewport *vp = find_viewport(VP_DEFAULT_LABEL, data); 114 struct skin_viewport *vp = find_viewport(VP_DEFAULT_LABEL, data);
82 struct skin_token_list *next_vp = data->viewports->next; 115 struct skin_element *next_vp = data->tree->next;
83 116
84 if (!next_vp) 117 if (vp)
85 { /* no second viewport, let parsing fail */ 118 {
86 success = false; 119 if (!next_vp)
120 { /* no second viewport, let parsing fail */
121 success = false;
122 }
123 /* hide this viewport, forever */
124 vp->hidden_flags = VP_NEVER_VISIBLE;
87 } 125 }
88 /* hide this viewport, forever */
89 vp->hidden_flags = VP_NEVER_VISIBLE;
90 sb_set_info_vp(screen, VP_INFO_LABEL|VP_DEFAULT_LABEL); 126 sb_set_info_vp(screen, VP_INFO_LABEL|VP_DEFAULT_LABEL);
91 } 127 }
92 128
@@ -135,7 +171,7 @@ bool sb_set_backdrop(enum screen_type screen, char* filename)
135 else 171 else
136#endif 172#endif
137 buf_size = LCD_BACKDROP_BYTES; 173 buf_size = LCD_BACKDROP_BYTES;
138 sb_skin[screen].data->backdrop = skin_buffer_alloc(buf_size); 174 sb_skin[screen].data->backdrop = (char*)skin_buffer_alloc(buf_size);
139 if (!sb_skin[screen].data->backdrop) 175 if (!sb_skin[screen].data->backdrop)
140 return false; 176 return false;
141 } 177 }
@@ -150,6 +186,8 @@ void sb_skin_update(enum screen_type screen, bool force)
150{ 186{
151 static long next_update[NB_SCREENS] = {0}; 187 static long next_update[NB_SCREENS] = {0};
152 int i = screen; 188 int i = screen;
189 if (!sb_skin_data[screen].wps_loaded)
190 return;
153 if (TIME_AFTER(current_tick, next_update[i]) || force) 191 if (TIME_AFTER(current_tick, next_update[i]) || force)
154 { 192 {
155#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) 193#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
@@ -158,7 +196,7 @@ void sb_skin_update(enum screen_type screen, bool force)
158 if (lcd_active() || (i != SCREEN_MAIN)) 196 if (lcd_active() || (i != SCREEN_MAIN))
159#endif 197#endif
160 skin_update(&sb_skin[i], force? 198 skin_update(&sb_skin[i], force?
161 WPS_REFRESH_ALL : WPS_REFRESH_NON_STATIC); 199 SKIN_REFRESH_ALL : SKIN_REFRESH_NON_STATIC);
162 next_update[i] = current_tick + update_delay; /* don't update too often */ 200 next_update[i] = current_tick + update_delay; /* don't update too often */
163 sb_skin[SCREEN_MAIN].sync_data->do_full_update = false; 201 sb_skin[SCREEN_MAIN].sync_data->do_full_update = false;
164 } 202 }
@@ -216,7 +254,30 @@ void sb_create_from_settings(enum screen_type screen)
216 254
217 if (ptr2[0] && ptr2[0] != '-') /* from ui viewport setting */ 255 if (ptr2[0] && ptr2[0] != '-') /* from ui viewport setting */
218 { 256 {
257 char *comma = ptr;
258 int param_count = 0;
219 len = snprintf(ptr, remaining, "%%ax%%Vi(-,%s)\n", ptr2); 259 len = snprintf(ptr, remaining, "%%ax%%Vi(-,%s)\n", ptr2);
260 /* The config put the colours at the end of the viewport,
261 * they need to be stripped for the skin code though */
262 do {
263 param_count++;
264 comma = strchr(comma+1, ',');
265
266 } while (comma && param_count < 6);
267 if (comma)
268 {
269 char *end = comma;
270 char fg[8], bg[8];
271 int i = 0;
272 comma++;
273 while (*comma != ',')
274 fg[i++] = *comma++;
275 fg[i] = '\0'; comma++; i=0;
276 while (*comma != ')')
277 bg[i++] = *comma++;
278 bg[i] = '\0';
279 len += snprintf(end, remaining-len, ") %%Vf(%s) %%Vb(%s)\n", fg, bg);
280 }
220 } 281 }
221 else 282 else
222 { 283 {