Mercurial > pidgin.yaz
annotate finch/libgnt/gntstyle.c @ 18313:cf2fbfa205b1
merge of '44c5b35ad7903bcaed23711b5dbf0b7fcb261b47'
and '45d61331479a783d9d6f26cee95a544336427125'
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 27 Jun 2007 18:23:13 +0000 |
parents | adcb44a07a2d |
children | 8aff2d3d6820 b25cb0775be3 |
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 |
15818 | 23 #include "gntstyle.h" |
24 #include "gntcolors.h" | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
25 #include "gntws.h" |
15818 | 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> |
15818 | 28 #include <ctype.h> |
16473
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:
16472
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> |
15818 | 31 #include <string.h> |
32 | |
16472
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16414
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:
16414
diff
changeset
|
34 |
15818 | 35 #if GLIB_CHECK_VERSION(2,6,0) |
36 static GKeyFile *gkfile; | |
37 #endif | |
38 | |
39 static char * str_styles[GNT_STYLES]; | |
40 static int int_styles[GNT_STYLES]; | |
41 static int bool_styles[GNT_STYLES]; | |
42 | |
43 const char *gnt_style_get(GntStyle style) | |
44 { | |
45 return str_styles[style]; | |
46 } | |
47 | |
18312
adcb44a07a2d
This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18091
diff
changeset
|
48 const char *gnt_style_get_from_name(const char *group, const char *key) |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
49 { |
18312
adcb44a07a2d
This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18091
diff
changeset
|
50 #if GLIB_CHECK_VERSION(2,6,0) |
adcb44a07a2d
This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18091
diff
changeset
|
51 return g_key_file_get_value(gkfile, group, key, NULL); |
adcb44a07a2d
This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18091
diff
changeset
|
52 #endif |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
53 } |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
54 |
15818 | 55 gboolean gnt_style_get_bool(GntStyle style, gboolean def) |
56 { | |
57 int i; | |
58 const char * str; | |
59 | |
60 if (bool_styles[style] != -1) | |
61 return bool_styles[style]; | |
62 | |
63 str = gnt_style_get(style); | |
64 | |
65 if (str) | |
66 { | |
67 if (strcmp(str, "false") == 0) | |
68 def = FALSE; | |
69 else if (strcmp(str, "true") == 0) | |
70 def = TRUE; | |
71 else if (sscanf(str, "%d", &i) == 1) | |
72 { | |
73 if (i) | |
74 def = TRUE; | |
75 else | |
76 def = FALSE; | |
77 } | |
78 } | |
79 | |
80 bool_styles[style] = def; | |
81 return bool_styles[style]; | |
82 } | |
83 | |
84 static void | |
85 refine(char *text) | |
86 { | |
87 char *s = text, *t = text; | |
88 | |
89 while (*s) | |
90 { | |
91 if (*s == '^' && *(s + 1) == '[') | |
92 { | |
93 *t = '\033'; /* escape */ | |
94 s++; | |
95 } | |
96 else if (*s == '\\') | |
97 { | |
98 if (*(s + 1) == '\0') | |
99 *t = ' '; | |
100 else | |
101 { | |
102 s++; | |
103 if (*s == 'r' || *s == 'n') | |
104 *t = '\r'; | |
105 else if (*s == 't') | |
106 *t = '\t'; | |
107 else | |
108 *t = *s; | |
109 } | |
110 } | |
111 else | |
112 *t = *s; | |
113 t++; | |
114 s++; | |
115 } | |
116 *t = '\0'; | |
117 } | |
118 | |
119 static char * | |
120 parse_key(const char *key) | |
121 { | |
122 return (char *)gnt_key_translate(key); | |
123 } | |
124 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
125 void gnt_style_read_workspaces(GntWM *wm) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
126 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
127 #if GLIB_CHECK_VERSION(2,6,0) |
16472
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16414
diff
changeset
|
128 int i; |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
129 gchar *name; |
16473
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:
16472
diff
changeset
|
130 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:
16472
diff
changeset
|
131 |
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:
16472
diff
changeset
|
132 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:
16472
diff
changeset
|
133 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:
16472
diff
changeset
|
134 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:
16472
diff
changeset
|
135 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:
16472
diff
changeset
|
136 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:
16472
diff
changeset
|
137 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:
16472
diff
changeset
|
138 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:
16472
diff
changeset
|
139 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:
16472
diff
changeset
|
140 return; |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
141 |
18076
da183b86a3ef
Update for the new api.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18069
diff
changeset
|
142 ws = gnt_ws_new(name); |
16473
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:
16472
diff
changeset
|
143 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:
16472
diff
changeset
|
144 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:
16472
diff
changeset
|
145 |
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:
16472
diff
changeset
|
146 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:
16472
diff
changeset
|
147 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:
16472
diff
changeset
|
148 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:
16472
diff
changeset
|
149 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:
16472
diff
changeset
|
150 g_strfreev(titles); |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
151 } |
16473
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:
16472
diff
changeset
|
152 |
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:
16472
diff
changeset
|
153 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:
16472
diff
changeset
|
154 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:
16472
diff
changeset
|
155 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:
16472
diff
changeset
|
156 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:
16472
diff
changeset
|
157 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:
16472
diff
changeset
|
158 } |
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:
16472
diff
changeset
|
159 g_free(group); |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
160 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
161 #endif |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
162 } |
15818 | 163 void gnt_style_read_actions(GType type, GntBindableClass *klass) |
164 { | |
165 #if GLIB_CHECK_VERSION(2,6,0) | |
166 char *name; | |
167 GError *error = NULL; | |
168 | |
169 name = g_strdup_printf("%s::binding", g_type_name(type)); | |
170 | |
171 if (g_key_file_has_group(gkfile, name)) | |
172 { | |
173 gsize len = 0; | |
174 char **keys; | |
175 | |
176 keys = g_key_file_get_keys(gkfile, name, &len, &error); | |
177 if (error) | |
178 { | |
179 g_printerr("GntStyle: %s\n", error->message); | |
180 g_error_free(error); | |
181 g_free(name); | |
182 return; | |
183 } | |
184 | |
185 while (len--) | |
186 { | |
187 char *key, *action; | |
188 | |
189 key = g_strdup(keys[len]); | |
190 action = g_key_file_get_string(gkfile, name, keys[len], &error); | |
191 | |
192 if (error) | |
193 { | |
194 g_printerr("GntStyle: %s\n", error->message); | |
195 g_error_free(error); | |
196 error = NULL; | |
197 } | |
198 else | |
199 { | |
200 const char *keycode = parse_key(key); | |
201 if (keycode == NULL) { | |
202 g_printerr("GntStyle: Invalid key-binding %s\n", key); | |
203 } else { | |
204 gnt_bindable_register_binding(klass, action, keycode, NULL); | |
205 } | |
206 } | |
207 g_free(key); | |
208 g_free(action); | |
209 } | |
210 g_strfreev(keys); | |
211 } | |
212 g_free(name); | |
213 #endif | |
214 } | |
215 | |
216 void gnt_styles_get_keyremaps(GType type, GHashTable *hash) | |
217 { | |
218 #if GLIB_CHECK_VERSION(2,6,0) | |
219 char *name; | |
220 GError *error = NULL; | |
221 | |
222 name = g_strdup_printf("%s::remap", g_type_name(type)); | |
223 | |
224 if (g_key_file_has_group(gkfile, name)) | |
225 { | |
226 gsize len = 0; | |
227 char **keys; | |
228 | |
229 keys = g_key_file_get_keys(gkfile, name, &len, &error); | |
230 if (error) | |
231 { | |
232 g_printerr("GntStyle: %s\n", error->message); | |
233 g_error_free(error); | |
234 g_free(name); | |
235 return; | |
236 } | |
237 | |
238 while (len--) | |
239 { | |
240 char *key, *replace; | |
241 | |
242 key = g_strdup(keys[len]); | |
243 replace = g_key_file_get_string(gkfile, name, keys[len], &error); | |
244 | |
245 if (error) | |
246 { | |
247 g_printerr("GntStyle: %s\n", error->message); | |
248 g_error_free(error); | |
249 error = NULL; | |
250 g_free(key); | |
251 } | |
252 else | |
253 { | |
254 refine(key); | |
255 refine(replace); | |
256 g_hash_table_insert(hash, key, replace); | |
257 } | |
258 } | |
259 g_strfreev(keys); | |
260 } | |
261 | |
262 g_free(name); | |
263 #endif | |
264 } | |
265 | |
266 #if GLIB_CHECK_VERSION(2,6,0) | |
267 static void | |
268 read_general_style(GKeyFile *kfile) | |
269 { | |
270 GError *error = NULL; | |
271 gsize nkeys; | |
272 char **keys = g_key_file_get_keys(kfile, "general", &nkeys, &error); | |
273 int i; | |
274 struct | |
275 { | |
276 const char *style; | |
277 GntStyle en; | |
278 } styles[] = {{"shadow", GNT_STYLE_SHADOW}, | |
279 {"customcolor", GNT_STYLE_COLOR}, | |
280 {"mouse", GNT_STYLE_MOUSE}, | |
281 {"wm", GNT_STYLE_WM}, | |
282 {"remember_position", GNT_STYLE_REMPOS}, | |
283 {NULL, 0}}; | |
284 | |
285 if (error) | |
286 { | |
287 g_printerr("GntStyle: %s\n", error->message); | |
288 g_error_free(error); | |
289 } | |
290 else | |
291 { | |
292 for (i = 0; styles[i].style; i++) | |
293 { | |
294 str_styles[styles[i].en] = | |
15964 | 295 g_key_file_get_string(kfile, "general", styles[i].style, NULL); |
15818 | 296 } |
297 } | |
298 g_strfreev(keys); | |
299 } | |
300 #endif | |
301 | |
302 void gnt_style_read_configure_file(const char *filename) | |
303 { | |
304 #if GLIB_CHECK_VERSION(2,6,0) | |
305 GError *error = NULL; | |
306 gkfile = g_key_file_new(); | |
307 | |
18312
adcb44a07a2d
This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18091
diff
changeset
|
308 if (!g_key_file_load_from_file(gkfile, filename, |
adcb44a07a2d
This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18091
diff
changeset
|
309 G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error)) |
15818 | 310 { |
311 g_printerr("GntStyle: %s\n", error->message); | |
312 g_error_free(error); | |
313 return; | |
314 } | |
315 gnt_colors_parse(gkfile); | |
316 read_general_style(gkfile); | |
317 #endif | |
318 } | |
319 | |
320 void gnt_init_styles() | |
321 { | |
322 int i; | |
323 for (i = 0; i < GNT_STYLES; i++) | |
324 { | |
325 str_styles[i] = NULL; | |
326 int_styles[i] = -1; | |
327 bool_styles[i] = -1; | |
328 } | |
329 } | |
330 | |
331 void gnt_uninit_styles() | |
332 { | |
333 int i; | |
334 for (i = 0; i < GNT_STYLES; i++) | |
335 g_free(str_styles[i]); | |
336 | |
337 #if GLIB_CHECK_VERSION(2,6,0) | |
338 g_key_file_free(gkfile); | |
339 #endif | |
340 } | |
341 |