| 41 xmlnode *root_node, *sub_node, *sub_sub_node; |
42 xmlnode *root_node, *sub_node, *sub_sub_node; |
| 42 gchar *filename, *filename_full, *data; |
43 gchar *filename, *filename_full, *data; |
| 43 const gchar *icon_theme = NULL, *tmp; |
44 const gchar *icon_theme = NULL, *tmp; |
| 44 gboolean sucess = TRUE; |
45 gboolean sucess = TRUE; |
| 45 GdkColor *bgcolor, *expanded_bgcolor, *collapsed_bgcolor, *buddy_bgcolor1, *buddy_bgcolor2; |
46 GdkColor *bgcolor, *expanded_bgcolor, *collapsed_bgcolor, *buddy_bgcolor1, *buddy_bgcolor2; |
| |
47 GdkColor color; |
| 46 FontColorPair *expanded, *collapsed, *online, *away, *offline, *message, *status; |
48 FontColorPair *expanded, *collapsed, *online, *away, *offline, *message, *status; |
| 47 gdouble transparency; |
49 gdouble transparency; |
| 48 PidginBlistLayout *layout = g_new0(PidginBlistLayout, 1); |
50 PidginBlistLayout *layout; |
| 49 GDir *gdir; |
51 GDir *gdir; |
| 50 PidginBlistTheme *theme; |
52 PidginBlistTheme *theme; |
| 51 |
53 |
| 52 /* Find the theme file */ |
54 /* Find the theme file */ |
| 53 gdir = g_dir_open(dir, 0, NULL); |
55 gdir = g_dir_open(dir, 0, NULL); |
| 65 filename_full = g_build_filename(dir, filename, NULL); |
67 filename_full = g_build_filename(dir, filename, NULL); |
| 66 |
68 |
| 67 root_node = xmlnode_from_file(dir, filename, "blist themes", "blist-loader"); |
69 root_node = xmlnode_from_file(dir, filename, "blist themes", "blist-loader"); |
| 68 g_return_val_if_fail(root_node != NULL, NULL); |
70 g_return_val_if_fail(root_node != NULL, NULL); |
| 69 |
71 |
| 70 /* colors */ |
72 /* init all structs and colors */ |
| 71 bgcolor = g_new0(GdkColor, 1); |
73 bgcolor = g_new0(GdkColor, 1); |
| 72 expanded_bgcolor = g_new0(GdkColor, 1); |
74 expanded_bgcolor = g_new0(GdkColor, 1); |
| 73 collapsed_bgcolor = g_new0(GdkColor, 1); |
75 collapsed_bgcolor = g_new0(GdkColor, 1); |
| 74 buddy_bgcolor1 = g_new0(GdkColor, 1); |
76 buddy_bgcolor1 = g_new0(GdkColor, 1); |
| 75 buddy_bgcolor2 = g_new0(GdkColor, 1); |
77 buddy_bgcolor2 = g_new0(GdkColor, 1); |
| 76 |
78 |
| 77 /* font color pairs */ |
79 layout = g_new0(PidginBlistLayout, 1); |
| |
80 |
| 78 expanded = g_new0(FontColorPair, 1); |
81 expanded = g_new0(FontColorPair, 1); |
| 79 expanded->color = g_new0(GdkColor, 1); |
|
| 80 collapsed = g_new0(FontColorPair, 1); |
82 collapsed = g_new0(FontColorPair, 1); |
| 81 collapsed->color = g_new0(GdkColor, 1); |
|
| 82 online = g_new0(FontColorPair, 1); |
83 online = g_new0(FontColorPair, 1); |
| 83 online->color = g_new0(GdkColor, 1); |
|
| 84 away = g_new0(FontColorPair, 1); |
84 away = g_new0(FontColorPair, 1); |
| 85 away->color = g_new0(GdkColor, 1); |
|
| 86 offline = g_new0(FontColorPair, 1); |
85 offline = g_new0(FontColorPair, 1); |
| 87 offline->color = g_new0(GdkColor, 1); |
86 message = g_new0(FontColorPair, 1); |
| 88 message = g_new0(FontColorPair, 1); |
|
| 89 message->color = g_new0(GdkColor, 1); |
|
| 90 status = g_new0(FontColorPair, 1); |
87 status = g_new0(FontColorPair, 1); |
| 91 status->color = g_new0(GdkColor, 1); |
|
| 92 |
88 |
| 93 /* Parse the tree */ |
89 /* Parse the tree */ |
| 94 sub_node = xmlnode_get_child(root_node, "description"); |
90 sub_node = xmlnode_get_child(root_node, "description"); |
| 95 data = xmlnode_get_data(sub_node); |
91 data = xmlnode_get_data(sub_node); |
| 96 |
92 |
| 114 if ((sucess = sucess && (sub_node = xmlnode_get_child(root_node, "groups")) != NULL |
110 if ((sucess = sucess && (sub_node = xmlnode_get_child(root_node, "groups")) != NULL |
| 115 && (sub_sub_node = xmlnode_get_child(sub_node, "expanded")) != NULL)) { |
111 && (sub_sub_node = xmlnode_get_child(sub_node, "expanded")) != NULL)) { |
| 116 |
112 |
| 117 expanded->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); |
113 expanded->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); |
| 118 |
114 |
| 119 if ((tmp = xmlnode_get_attrib(sub_sub_node, "color")) != NULL && gdk_color_parse(tmp, expanded->color)) |
115 if ((tmp = xmlnode_get_attrib(sub_sub_node, "text_color")) != NULL && gdk_color_parse(tmp, &color)) |
| 120 gdk_colormap_alloc_color(gdk_colormap_get_system(), expanded->color, FALSE, TRUE); |
116 expanded->color = g_strdup(tmp); |
| 121 else { |
117 else expanded->color = DEFAULT_TEXT_COLOR; |
| 122 g_free(expanded->color); |
|
| 123 expanded->color = NULL; |
|
| 124 } |
|
| 125 |
118 |
| 126 |
119 |
| 127 if ((tmp = xmlnode_get_attrib(sub_sub_node, "background")) != NULL && gdk_color_parse(tmp, expanded_bgcolor)) |
120 if ((tmp = xmlnode_get_attrib(sub_sub_node, "background")) != NULL && gdk_color_parse(tmp, expanded_bgcolor)) |
| 128 gdk_colormap_alloc_color(gdk_colormap_get_system(), expanded_bgcolor, FALSE, TRUE); |
121 gdk_colormap_alloc_color(gdk_colormap_get_system(), expanded_bgcolor, FALSE, TRUE); |
| 129 else { |
122 else { |
| 133 } |
126 } |
| 134 |
127 |
| 135 if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "collapsed")) != NULL)) { |
128 if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "collapsed")) != NULL)) { |
| 136 collapsed->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); |
129 collapsed->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); |
| 137 |
130 |
| 138 if((tmp = xmlnode_get_attrib(sub_sub_node, "color")) != NULL && gdk_color_parse(tmp, collapsed->color)) |
131 if((tmp = xmlnode_get_attrib(sub_sub_node, "text_color")) != NULL && gdk_color_parse(tmp, &color)) |
| 139 gdk_colormap_alloc_color(gdk_colormap_get_system(), collapsed->color, FALSE, TRUE); |
132 collapsed->color = g_strdup(tmp); |
| 140 else { |
133 else collapsed->color = DEFAULT_TEXT_COLOR; |
| 141 g_free(collapsed->color); |
134 |
| 142 collapsed->color = NULL; |
|
| 143 } |
|
| 144 if ((tmp = xmlnode_get_attrib(sub_sub_node, "background")) != NULL && gdk_color_parse(tmp, collapsed_bgcolor)) |
135 if ((tmp = xmlnode_get_attrib(sub_sub_node, "background")) != NULL && gdk_color_parse(tmp, collapsed_bgcolor)) |
| 145 gdk_colormap_alloc_color(gdk_colormap_get_system(), collapsed_bgcolor, FALSE, TRUE); |
136 gdk_colormap_alloc_color(gdk_colormap_get_system(), collapsed_bgcolor, FALSE, TRUE); |
| 146 else { |
137 else { |
| 147 g_free(collapsed_bgcolor); |
138 g_free(collapsed_bgcolor); |
| 148 collapsed_bgcolor = NULL; |
139 collapsed_bgcolor = NULL; |
| 151 |
142 |
| 152 /* <buddys> */ |
143 /* <buddys> */ |
| 153 if ((sucess = sucess && (sub_node = xmlnode_get_child(root_node, "buddys")) != NULL && |
144 if ((sucess = sucess && (sub_node = xmlnode_get_child(root_node, "buddys")) != NULL && |
| 154 (sub_sub_node = xmlnode_get_child(sub_node, "placement")) != NULL)) { |
145 (sub_sub_node = xmlnode_get_child(sub_node, "placement")) != NULL)) { |
| 155 |
146 |
| 156 layout->buddy_icon = atoi(xmlnode_get_attrib(sub_sub_node, "status_icon")); |
147 layout->status_icon = atoi(xmlnode_get_attrib(sub_sub_node, "status_icon")); |
| 157 layout->text = atoi(xmlnode_get_attrib(sub_sub_node, "name")); |
148 layout->text = atoi(xmlnode_get_attrib(sub_sub_node, "name")); |
| 158 layout->buddy_icon = atoi(xmlnode_get_attrib(sub_sub_node, "buddy_icon")); |
149 layout->emblem = atoi(xmlnode_get_attrib(sub_sub_node, "emblem")); |
| 159 layout->protocol_icon = atoi(xmlnode_get_attrib(sub_sub_node, "protocol_icon")); |
150 layout->protocol_icon = atoi(xmlnode_get_attrib(sub_sub_node, "protocol_icon")); |
| 160 layout->emblem = atoi(xmlnode_get_attrib(sub_sub_node, "emblem")); |
151 layout->buddy_icon = atoi(xmlnode_get_attrib(sub_sub_node, "buddy_icon")); |
| 161 layout->show_status = atoi(xmlnode_get_attrib(sub_sub_node, "status_icon")) != 0; |
152 layout->show_status = atoi(xmlnode_get_attrib(sub_sub_node, "status_icon")) != 0; |
| 162 } |
153 } |
| 163 |
154 |
| 164 if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "background")) != NULL)) { |
155 if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "background")) != NULL)) { |
| 165 |
156 |
| 178 } |
169 } |
| 179 } |
170 } |
| 180 |
171 |
| 181 if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "online_text")) != NULL)) { |
172 if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "online_text")) != NULL)) { |
| 182 online->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); |
173 online->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); |
| 183 if(gdk_color_parse(xmlnode_get_attrib(sub_sub_node, "color"), online->color)) |
174 if(gdk_color_parse(xmlnode_get_attrib(sub_sub_node, "color"), &color)) |
| 184 gdk_colormap_alloc_color(gdk_colormap_get_system(), online->color, FALSE, TRUE); |
175 online->color = g_strdup(tmp); |
| 185 else { |
176 else online->color = DEFAULT_TEXT_COLOR; |
| 186 g_free(online->color); |
|
| 187 online->color = NULL; |
|
| 188 } |
|
| 189 } |
177 } |
| 190 |
178 |
| 191 if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "away_text")) != NULL)) { |
179 if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "away_text")) != NULL)) { |
| 192 away->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); |
180 away->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); |
| 193 if(gdk_color_parse(xmlnode_get_attrib(sub_sub_node, "color"), away->color)) |
181 if(gdk_color_parse(xmlnode_get_attrib(sub_sub_node, "color"), &color)) |
| 194 gdk_colormap_alloc_color(gdk_colormap_get_system(), away->color, FALSE, TRUE); |
182 away->color = g_strdup(tmp); |
| 195 else { |
183 else away->color = DEFAULT_TEXT_COLOR; |
| 196 g_free(away->color); |
|
| 197 away->color = NULL; |
|
| 198 } |
|
| 199 } |
184 } |
| 200 |
185 |
| 201 if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "offline_text")) != NULL)) { |
186 if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "offline_text")) != NULL)) { |
| 202 offline->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); |
187 offline->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); |
| 203 if(gdk_color_parse(xmlnode_get_attrib(sub_sub_node, "color"), offline->color)) |
188 if(gdk_color_parse(xmlnode_get_attrib(sub_sub_node, "color"), &color)) |
| 204 gdk_colormap_alloc_color(gdk_colormap_get_system(), offline->color, FALSE, TRUE); |
189 online->color = g_strdup(tmp); |
| 205 else { |
190 else online->color = DEFAULT_TEXT_COLOR; |
| 206 g_free(offline->color); |
|
| 207 online->color = NULL; |
|
| 208 } |
|
| 209 } |
191 } |
| 210 |
192 |
| 211 if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "message_text")) != NULL)) { |
193 if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "message_text")) != NULL)) { |
| 212 message->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); |
194 message->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); |
| 213 if(gdk_color_parse(xmlnode_get_attrib(sub_sub_node, "color"), message->color)) |
195 if(gdk_color_parse(xmlnode_get_attrib(sub_sub_node, "color"), &color)) |
| 214 gdk_colormap_alloc_color(gdk_colormap_get_system(), message->color, FALSE, TRUE); |
196 message->color = g_strdup(tmp); |
| 215 else { |
197 else message->color = DEFAULT_TEXT_COLOR; |
| 216 g_free(message->color); |
|
| 217 message->color = NULL; |
|
| 218 } |
|
| 219 } |
198 } |
| 220 |
199 |
| 221 if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "status_text")) != NULL)) { |
200 if ((sucess = sucess && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "status_text")) != NULL)) { |
| 222 status->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); |
201 status->font = g_strdup(xmlnode_get_attrib(sub_sub_node, "font")); |
| 223 if(gdk_color_parse(xmlnode_get_attrib(sub_sub_node, "color"), status->color)) |
202 if(gdk_color_parse(xmlnode_get_attrib(sub_sub_node, "color"), &color)) |
| 224 gdk_colormap_alloc_color(gdk_colormap_get_system(), status->color, FALSE, TRUE); |
203 status->color = g_strdup(tmp); |
| 225 else { |
204 else status->color = DEFAULT_TEXT_COLOR; |
| 226 g_free(status->color); |
|
| 227 status->color = NULL; |
|
| 228 } |
|
| 229 } |
205 } |
| 230 |
206 |
| 231 /* name is required for theme manager */ |
207 /* name is required for theme manager */ |
| 232 sucess = sucess && xmlnode_get_attrib(root_node, "name") != NULL; |
208 sucess = sucess && xmlnode_get_attrib(root_node, "name") != NULL; |
| 233 |
209 |