Mercurial > pidgin
comparison finch/libgnt/gntstyle.c @ 18045:08e93462f189
Update the irssi WM to allow tiling the conversation windows.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 06 Jun 2007 14:34:58 +0000 |
parents | 8a54f74fecdf |
children | 1cedd520cd18 |
comparison
equal
deleted
inserted
replaced
18044:37469ac119b6 | 18045:08e93462f189 |
---|---|
1 #include "gntstyle.h" | 1 #include "gntstyle.h" |
2 #include "gntcolors.h" | 2 #include "gntcolors.h" |
3 | 3 |
4 #include <glib.h> | |
4 #include <ctype.h> | 5 #include <ctype.h> |
5 #include <string.h> | 6 #include <string.h> |
6 | 7 |
7 #if GLIB_CHECK_VERSION(2,6,0) | 8 #if GLIB_CHECK_VERSION(2,6,0) |
8 static GKeyFile *gkfile; | 9 static GKeyFile *gkfile; |
9 #endif | 10 #endif |
10 | 11 |
12 static GHashTable *unknowns; | |
11 static char * str_styles[GNT_STYLES]; | 13 static char * str_styles[GNT_STYLES]; |
12 static int int_styles[GNT_STYLES]; | 14 static int int_styles[GNT_STYLES]; |
13 static int bool_styles[GNT_STYLES]; | 15 static int bool_styles[GNT_STYLES]; |
14 | 16 |
15 const char *gnt_style_get(GntStyle style) | 17 const char *gnt_style_get(GntStyle style) |
16 { | 18 { |
17 return str_styles[style]; | 19 return str_styles[style]; |
20 } | |
21 | |
22 const char *gnt_style_get_from_name(const char *name) | |
23 { | |
24 return g_hash_table_lookup(unknowns, name); | |
18 } | 25 } |
19 | 26 |
20 gboolean gnt_style_get_bool(GntStyle style, gboolean def) | 27 gboolean gnt_style_get_bool(GntStyle style, gboolean def) |
21 { | 28 { |
22 int i; | 29 int i; |
219 for (i = 0; styles[i].style; i++) | 226 for (i = 0; styles[i].style; i++) |
220 { | 227 { |
221 str_styles[styles[i].en] = | 228 str_styles[styles[i].en] = |
222 g_key_file_get_string(kfile, "general", styles[i].style, NULL); | 229 g_key_file_get_string(kfile, "general", styles[i].style, NULL); |
223 } | 230 } |
231 | |
232 for (i = 0; i < nkeys; i++) | |
233 g_hash_table_replace(unknowns, g_strdup(keys[i]), | |
234 g_strdup(g_key_file_get_string(kfile, "general", keys[i], NULL))); | |
224 } | 235 } |
225 g_strfreev(keys); | 236 g_strfreev(keys); |
226 } | 237 } |
227 #endif | 238 #endif |
228 | 239 |
229 void gnt_style_read_configure_file(const char *filename) | 240 void gnt_style_read_configure_file(const char *filename) |
230 { | 241 { |
231 #if GLIB_CHECK_VERSION(2,6,0) | 242 #if GLIB_CHECK_VERSION(2,6,0) |
232 GError *error = NULL; | 243 GError *error = NULL; |
233 gkfile = g_key_file_new(); | 244 gkfile = g_key_file_new(); |
245 unknowns = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
234 | 246 |
235 if (!g_key_file_load_from_file(gkfile, filename, G_KEY_FILE_NONE, &error)) | 247 if (!g_key_file_load_from_file(gkfile, filename, G_KEY_FILE_NONE, &error)) |
236 { | 248 { |
237 g_printerr("GntStyle: %s\n", error->message); | 249 g_printerr("GntStyle: %s\n", error->message); |
238 g_error_free(error); | 250 g_error_free(error); |
258 { | 270 { |
259 int i; | 271 int i; |
260 for (i = 0; i < GNT_STYLES; i++) | 272 for (i = 0; i < GNT_STYLES; i++) |
261 g_free(str_styles[i]); | 273 g_free(str_styles[i]); |
262 | 274 |
275 g_hash_table_destroy(unknowns); | |
263 #if GLIB_CHECK_VERSION(2,6,0) | 276 #if GLIB_CHECK_VERSION(2,6,0) |
264 g_key_file_free(gkfile); | 277 g_key_file_free(gkfile); |
265 #endif | 278 #endif |
266 } | 279 } |
267 | 280 |