Mercurial > pidgin
annotate finch/libgnt/gntstyle.c @ 18199:1bb3b07a6879
Detect wide character non-support at compile time, if possible.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 19 Jun 2007 21:47:22 +0000 |
parents | 7e0bd339533c |
children | adcb44a07a2d 1cb69ea47a6e |
rev | line source |
---|---|
18049
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
1 /** |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
2 * GNT - The GLib Ncurses Toolkit |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
3 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
4 * GNT is the legal property of its developers, whose names are too numerous |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
6 * source distribution. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
7 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
8 * This library is free software; you can redistribute it and/or modify |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
11 * (at your option) any later version. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
12 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
16 * GNU General Public License for more details. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
17 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
21 */ |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
22 |
15817 | 23 #include "gntstyle.h" |
24 #include "gntcolors.h" | |
17698
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
25 #include "gntws.h" |
15817 | 26 |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
27 #include <glib.h> |
15817 | 28 #include <ctype.h> |
17704
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
29 #include <glib/gprintf.h> |
18085
afd96f97c50a
Get rid of a little compile error
Mark Doliner <mark@kingant.net>
parents:
18069
diff
changeset
|
30 #include <stdlib.h> |
15817 | 31 #include <string.h> |
32 | |
17703
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
17698
diff
changeset
|
33 #define MAX_WORKSPACES 99 |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
17698
diff
changeset
|
34 |
15817 | 35 #if GLIB_CHECK_VERSION(2,6,0) |
36 static GKeyFile *gkfile; | |
37 #endif | |
38 | |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
39 static GHashTable *unknowns; |
15817 | 40 static char * str_styles[GNT_STYLES]; |
41 static int int_styles[GNT_STYLES]; | |
42 static int bool_styles[GNT_STYLES]; | |
43 | |
44 const char *gnt_style_get(GntStyle style) | |
45 { | |
46 return str_styles[style]; | |
47 } | |
48 | |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
49 const char *gnt_style_get_from_name(const char *name) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
50 { |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
51 return g_hash_table_lookup(unknowns, name); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
52 } |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
53 |
15817 | 54 gboolean gnt_style_get_bool(GntStyle style, gboolean def) |
55 { | |
56 int i; | |
57 const char * str; | |
58 | |
59 if (bool_styles[style] != -1) | |
60 return bool_styles[style]; | |
61 | |
62 str = gnt_style_get(style); | |
63 | |
64 if (str) | |
65 { | |
66 if (strcmp(str, "false") == 0) | |
67 def = FALSE; | |
68 else if (strcmp(str, "true") == 0) | |
69 def = TRUE; | |
70 else if (sscanf(str, "%d", &i) == 1) | |
71 { | |
72 if (i) | |
73 def = TRUE; | |
74 else | |
75 def = FALSE; | |
76 } | |
77 } | |
78 | |
79 bool_styles[style] = def; | |
80 return bool_styles[style]; | |
81 } | |
82 | |
83 static void | |
84 refine(char *text) | |
85 { | |
86 char *s = text, *t = text; | |
87 | |
88 while (*s) | |
89 { | |
90 if (*s == '^' && *(s + 1) == '[') | |
91 { | |
92 *t = '\033'; /* escape */ | |
93 s++; | |
94 } | |
95 else if (*s == '\\') | |
96 { | |
97 if (*(s + 1) == '\0') | |
98 *t = ' '; | |
99 else | |
100 { | |
101 s++; | |
102 if (*s == 'r' || *s == 'n') | |
103 *t = '\r'; | |
104 else if (*s == 't') | |
105 *t = '\t'; | |
106 else | |
107 *t = *s; | |
108 } | |
109 } | |
110 else | |
111 *t = *s; | |
112 t++; | |
113 s++; | |
114 } | |
115 *t = '\0'; | |
116 } | |
117 | |
118 static char * | |
119 parse_key(const char *key) | |
120 { | |
121 return (char *)gnt_key_translate(key); | |
122 } | |
123 | |
17698
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
124 void gnt_style_read_workspaces(GntWM *wm) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
125 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
126 #if GLIB_CHECK_VERSION(2,6,0) |
17703
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
17698
diff
changeset
|
127 int i; |
17698
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
128 gchar *name; |
17704
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
129 gsize c; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
130 |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
131 for (i = 1; i < MAX_WORKSPACES; ++i) { |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
132 int j; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
133 GntWS *ws; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
134 gchar **titles; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
135 char *group = calloc(12, 1); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
136 g_sprintf(group, "Workspace-%d", i); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
137 name = g_key_file_get_value(gkfile, group, "name", NULL); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
138 if (!name) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
139 return; |
17698
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
140 |
18076
da183b86a3ef
Update for the new api.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18069
diff
changeset
|
141 ws = gnt_ws_new(name); |
17704
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
142 gnt_wm_add_workspace(wm, ws); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
143 g_free(name); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
144 |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
145 titles = g_key_file_get_string_list(gkfile, group, "window-names", &c, NULL); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
146 if (titles) { |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
147 for (j = 0; j < c; ++j) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
148 g_hash_table_replace(wm->name_places, g_strdup(titles[j]), ws); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
149 g_strfreev(titles); |
17698
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
150 } |
17704
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
151 |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
152 titles = g_key_file_get_string_list(gkfile, group, "window-titles", &c, NULL); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
153 if (titles) { |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
154 for (j = 0; j < c; ++j) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
155 g_hash_table_replace(wm->title_places, g_strdup(titles[j]), ws); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
156 g_strfreev(titles); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
157 } |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
17703
diff
changeset
|
158 g_free(group); |
17698
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
159 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
160 #endif |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
161 } |
15817 | 162 void gnt_style_read_actions(GType type, GntBindableClass *klass) |
163 { | |
164 #if GLIB_CHECK_VERSION(2,6,0) | |
165 char *name; | |
166 GError *error = NULL; | |
167 | |
168 name = g_strdup_printf("%s::binding", g_type_name(type)); | |
169 | |
170 if (g_key_file_has_group(gkfile, name)) | |
171 { | |
172 gsize len = 0; | |
173 char **keys; | |
174 | |
175 keys = g_key_file_get_keys(gkfile, name, &len, &error); | |
176 if (error) | |
177 { | |
178 g_printerr("GntStyle: %s\n", error->message); | |
179 g_error_free(error); | |
180 g_free(name); | |
181 return; | |
182 } | |
183 | |
184 while (len--) | |
185 { | |
186 char *key, *action; | |
187 | |
188 key = g_strdup(keys[len]); | |
189 action = g_key_file_get_string(gkfile, name, keys[len], &error); | |
190 | |
191 if (error) | |
192 { | |
193 g_printerr("GntStyle: %s\n", error->message); | |
194 g_error_free(error); | |
195 error = NULL; | |
196 } | |
197 else | |
198 { | |
199 const char *keycode = parse_key(key); | |
200 if (keycode == NULL) { | |
201 g_printerr("GntStyle: Invalid key-binding %s\n", key); | |
202 } else { | |
203 gnt_bindable_register_binding(klass, action, keycode, NULL); | |
204 } | |
205 } | |
206 g_free(key); | |
207 g_free(action); | |
208 } | |
209 g_strfreev(keys); | |
210 } | |
211 g_free(name); | |
212 #endif | |
213 } | |
214 | |
215 void gnt_styles_get_keyremaps(GType type, GHashTable *hash) | |
216 { | |
217 #if GLIB_CHECK_VERSION(2,6,0) | |
218 char *name; | |
219 GError *error = NULL; | |
220 | |
221 name = g_strdup_printf("%s::remap", g_type_name(type)); | |
222 | |
223 if (g_key_file_has_group(gkfile, name)) | |
224 { | |
225 gsize len = 0; | |
226 char **keys; | |
227 | |
228 keys = g_key_file_get_keys(gkfile, name, &len, &error); | |
229 if (error) | |
230 { | |
231 g_printerr("GntStyle: %s\n", error->message); | |
232 g_error_free(error); | |
233 g_free(name); | |
234 return; | |
235 } | |
236 | |
237 while (len--) | |
238 { | |
239 char *key, *replace; | |
240 | |
241 key = g_strdup(keys[len]); | |
242 replace = g_key_file_get_string(gkfile, name, keys[len], &error); | |
243 | |
244 if (error) | |
245 { | |
246 g_printerr("GntStyle: %s\n", error->message); | |
247 g_error_free(error); | |
248 error = NULL; | |
249 g_free(key); | |
250 } | |
251 else | |
252 { | |
253 refine(key); | |
254 refine(replace); | |
255 g_hash_table_insert(hash, key, replace); | |
256 } | |
257 } | |
258 g_strfreev(keys); | |
259 } | |
260 | |
261 g_free(name); | |
262 #endif | |
263 } | |
264 | |
265 #if GLIB_CHECK_VERSION(2,6,0) | |
266 static void | |
267 read_general_style(GKeyFile *kfile) | |
268 { | |
269 GError *error = NULL; | |
270 gsize nkeys; | |
271 char **keys = g_key_file_get_keys(kfile, "general", &nkeys, &error); | |
272 int i; | |
273 struct | |
274 { | |
275 const char *style; | |
276 GntStyle en; | |
277 } styles[] = {{"shadow", GNT_STYLE_SHADOW}, | |
278 {"customcolor", GNT_STYLE_COLOR}, | |
279 {"mouse", GNT_STYLE_MOUSE}, | |
280 {"wm", GNT_STYLE_WM}, | |
281 {"remember_position", GNT_STYLE_REMPOS}, | |
282 {NULL, 0}}; | |
283 | |
284 if (error) | |
285 { | |
286 g_printerr("GntStyle: %s\n", error->message); | |
287 g_error_free(error); | |
288 } | |
289 else | |
290 { | |
291 for (i = 0; styles[i].style; i++) | |
292 { | |
293 str_styles[styles[i].en] = | |
15964 | 294 g_key_file_get_string(kfile, "general", styles[i].style, NULL); |
15817 | 295 } |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
296 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
297 for (i = 0; i < nkeys; i++) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
298 g_hash_table_replace(unknowns, g_strdup(keys[i]), |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
299 g_strdup(g_key_file_get_string(kfile, "general", keys[i], NULL))); |
15817 | 300 } |
301 g_strfreev(keys); | |
302 } | |
303 #endif | |
304 | |
305 void gnt_style_read_configure_file(const char *filename) | |
306 { | |
307 #if GLIB_CHECK_VERSION(2,6,0) | |
308 GError *error = NULL; | |
309 gkfile = g_key_file_new(); | |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
310 unknowns = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
15817 | 311 |
312 if (!g_key_file_load_from_file(gkfile, filename, G_KEY_FILE_NONE, &error)) | |
313 { | |
314 g_printerr("GntStyle: %s\n", error->message); | |
315 g_error_free(error); | |
316 return; | |
317 } | |
318 gnt_colors_parse(gkfile); | |
319 read_general_style(gkfile); | |
320 #endif | |
321 } | |
322 | |
323 void gnt_init_styles() | |
324 { | |
325 int i; | |
326 for (i = 0; i < GNT_STYLES; i++) | |
327 { | |
328 str_styles[i] = NULL; | |
329 int_styles[i] = -1; | |
330 bool_styles[i] = -1; | |
331 } | |
332 } | |
333 | |
334 void gnt_uninit_styles() | |
335 { | |
336 int i; | |
337 for (i = 0; i < GNT_STYLES; i++) | |
338 g_free(str_styles[i]); | |
339 | |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
340 g_hash_table_destroy(unknowns); |
15817 | 341 #if GLIB_CHECK_VERSION(2,6,0) |
342 g_key_file_free(gkfile); | |
343 #endif | |
344 } | |
345 |