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