diff options
Diffstat (limited to 'apps/gui/statusbar-skinned.c')
-rw-r--r-- | apps/gui/statusbar-skinned.c | 82 |
1 files changed, 24 insertions, 58 deletions
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c index 2139bd698a..a5c751b804 100644 --- a/apps/gui/statusbar-skinned.c +++ b/apps/gui/statusbar-skinned.c | |||
@@ -42,73 +42,39 @@ | |||
42 | 42 | ||
43 | /* initial setup of wps_data */ | 43 | /* initial setup of wps_data */ |
44 | static int update_delay = DEFAULT_UPDATE_DELAY; | 44 | static int update_delay = DEFAULT_UPDATE_DELAY; |
45 | static int set_title_worker(char* title, enum themable_icons icon, | 45 | |
46 | struct wps_data *data, struct skin_element *root) | 46 | static bool sbs_has_title[NB_SCREENS]; |
47 | static char* sbs_title[NB_SCREENS]; | ||
48 | static enum themable_icons sbs_icon[NB_SCREENS]; | ||
49 | |||
50 | bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type screen) | ||
47 | { | 51 | { |
48 | int retval = 0; | 52 | sbs_title[screen] = title; |
49 | struct skin_element *element = root; | 53 | /* Icon_NOICON == -1 which the skin engine wants at position 1, so + 2 */ |
50 | while (element) | 54 | sbs_icon[screen] = icon + 2; |
51 | { | 55 | return sbs_has_title[screen]; |
52 | struct wps_token *token = NULL; | ||
53 | if (element->type == CONDITIONAL) | ||
54 | { | ||
55 | struct conditional *cond = (struct conditional *)element->data; | ||
56 | token = cond->token; | ||
57 | } | ||
58 | else if (element->type == TAG) | ||
59 | { | ||
60 | token = (struct wps_token *)element->data; | ||
61 | } | ||
62 | if (token) | ||
63 | { | ||
64 | if (token->type == SKIN_TOKEN_LIST_TITLE_TEXT) | ||
65 | { | ||
66 | token->value.data = title; | ||
67 | retval = 1; | ||
68 | } | ||
69 | else if (token->type == SKIN_TOKEN_LIST_TITLE_ICON) | ||
70 | { | ||
71 | /* Icon_NOICON == -1 which the skin engine wants at position 1, so + 2 */ | ||
72 | token->value.i = icon+2; | ||
73 | } | ||
74 | else if (element->params_count) | ||
75 | { | ||
76 | int i; | ||
77 | for (i=0; i<element->params_count; i++) | ||
78 | { | ||
79 | if (element->params[i].type == CODE) | ||
80 | retval |= set_title_worker(title, icon, data, | ||
81 | element->params[i].data.code); | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | if (element->children_count) | ||
86 | { | ||
87 | int i; | ||
88 | for (i=0; i<element->children_count; i++) | ||
89 | retval |= set_title_worker(title, icon, data, element->children[i]); | ||
90 | } | ||
91 | element = element->next; | ||
92 | } | ||
93 | return retval; | ||
94 | } | 56 | } |
95 | 57 | ||
96 | bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type screen) | 58 | void sb_skin_has_title(enum screen_type screen) |
97 | { | 59 | { |
98 | struct wps_data *data = skin_get_gwps(CUSTOM_STATUSBAR, screen)->data; | 60 | sbs_has_title[screen] = true; |
99 | bool retval = data->wps_loaded && | 61 | } |
100 | set_title_worker(title, icon, data, data->tree) > 0; | 62 | |
101 | return retval; | 63 | const char* sb_get_title(enum screen_type screen) |
64 | { | ||
65 | return sbs_has_title[screen] ? sbs_title[screen] : NULL; | ||
66 | } | ||
67 | enum themable_icons sb_get_icon(enum screen_type screen) | ||
68 | { | ||
69 | return sbs_has_title[screen] ? sbs_icon[screen] : Icon_NOICON + 2; | ||
102 | } | 70 | } |
103 | 71 | ||
104 | int sb_preproccess(enum screen_type screen, struct wps_data *data) | 72 | int sb_preproccess(enum screen_type screen, struct wps_data *data) |
105 | { | 73 | { |
106 | (void)data; | 74 | (void)data; |
107 | /* We need to disable the theme here or else viewport_set_defaults() | 75 | int i; |
108 | * (which is called in the viewport tag parser) will crash because | 76 | FOR_NB_SCREENS(i) |
109 | * the theme is enabled but sb_set_info_vp() isnt set untill after the sbs | 77 | sbs_has_title[i] = false; |
110 | * is parsed. This only affects the default viewport which is ignored | ||
111 | * int he sbs anyway */ | ||
112 | viewportmanager_theme_enable(screen, false, NULL); | 78 | viewportmanager_theme_enable(screen, false, NULL); |
113 | return 1; | 79 | return 1; |
114 | } | 80 | } |