Mercurial > pidgin
annotate finch/libgnt/gntstyle.c @ 18395:ed470f35ceab
We don't want to be using MAXPATHLEN except for backwards compatibility.
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 01 Jul 2007 01:10:21 +0000 |
parents | 65ed0916d3bc |
children | 9f029b7208f1 c6282dc3fb9f |
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 | |
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 | |
18317
8aff2d3d6820
Plug a memory leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18312
diff
changeset
|
48 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 |
15817 | 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 | |
17698
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) |
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
|
128 int i; |
17698
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
129 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
|
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:
17703
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:
17703
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:
17703
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:
17703
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:
17703
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:
17703
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:
17703
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:
17703
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:
17703
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:
17703
diff
changeset
|
140 return; |
17698
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); |
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
|
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:
17703
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:
17703
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:
17703
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:
17703
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:
17703
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:
17703
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:
17703
diff
changeset
|
150 g_strfreev(titles); |
17698
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
151 } |
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
|
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:
17703
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:
17703
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:
17703
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:
17703
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:
17703
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:
17703
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:
17703
diff
changeset
|
159 g_free(group); |
17698
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 } |
15817 | 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; | |
18362
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
272 const char *prgname = g_get_prgname(); |
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
273 char **keys = NULL; |
15817 | 274 int i; |
275 struct | |
276 { | |
277 const char *style; | |
278 GntStyle en; | |
279 } styles[] = {{"shadow", GNT_STYLE_SHADOW}, | |
280 {"customcolor", GNT_STYLE_COLOR}, | |
281 {"mouse", GNT_STYLE_MOUSE}, | |
282 {"wm", GNT_STYLE_WM}, | |
283 {"remember_position", GNT_STYLE_REMPOS}, | |
284 {NULL, 0}}; | |
285 | |
18362
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
286 if (prgname && *prgname) |
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
287 keys = g_key_file_get_keys(kfile, prgname, &nkeys, NULL); |
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
288 |
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
289 if (keys == NULL) { |
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
290 prgname = "general"; |
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
291 keys = g_key_file_get_keys(kfile, prgname, &nkeys, &error); |
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
292 } |
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
293 |
15817 | 294 if (error) |
295 { | |
296 g_printerr("GntStyle: %s\n", error->message); | |
297 g_error_free(error); | |
298 } | |
299 else | |
300 { | |
301 for (i = 0; styles[i].style; i++) | |
302 { | |
303 str_styles[styles[i].en] = | |
18362
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
304 g_key_file_get_string(kfile, prgname, styles[i].style, NULL); |
15817 | 305 } |
306 } | |
307 g_strfreev(keys); | |
308 } | |
309 #endif | |
310 | |
311 void gnt_style_read_configure_file(const char *filename) | |
312 { | |
313 #if GLIB_CHECK_VERSION(2,6,0) | |
314 GError *error = NULL; | |
315 gkfile = g_key_file_new(); | |
316 | |
18312
adcb44a07a2d
This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18091
diff
changeset
|
317 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
|
318 G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error)) |
15817 | 319 { |
320 g_printerr("GntStyle: %s\n", error->message); | |
321 g_error_free(error); | |
322 return; | |
323 } | |
324 gnt_colors_parse(gkfile); | |
325 read_general_style(gkfile); | |
326 #endif | |
327 } | |
328 | |
329 void gnt_init_styles() | |
330 { | |
331 int i; | |
332 for (i = 0; i < GNT_STYLES; i++) | |
333 { | |
334 str_styles[i] = NULL; | |
335 int_styles[i] = -1; | |
336 bool_styles[i] = -1; | |
337 } | |
338 } | |
339 | |
340 void gnt_uninit_styles() | |
341 { | |
342 int i; | |
343 for (i = 0; i < GNT_STYLES; i++) | |
344 g_free(str_styles[i]); | |
345 | |
346 #if GLIB_CHECK_VERSION(2,6,0) | |
347 g_key_file_free(gkfile); | |
348 #endif | |
349 } | |
350 |