Mercurial > pidgin
comparison finch/libgnt/gntstyle.c @ 19171:9f7587b86b0d
propagate from branch 'tmpbranch' (head e6743aa2d424749cd40350df703d079ef61fd5ce)
to branch 'im.pidgin.soc.2007.finchfeat' (head a87f346863ddc48e5705c2c555c7ed842325a9a3)
author | Eric Polino <aluink@pidgin.im> |
---|---|
date | Sun, 22 Jul 2007 01:28:19 +0000 |
parents | c6282dc3fb9f dcb1d1af30a1 |
children | 33201366bcd4 |
comparison
equal
deleted
inserted
replaced
19170:315fd66bb08f | 19171:9f7587b86b0d |
---|---|
47 } | 47 } |
48 | 48 |
49 char *gnt_style_get_from_name(const char *group, const char *key) | 49 char *gnt_style_get_from_name(const char *group, const char *key) |
50 { | 50 { |
51 #if GLIB_CHECK_VERSION(2,6,0) | 51 #if GLIB_CHECK_VERSION(2,6,0) |
52 const char *prg = g_get_prgname(); | |
53 if ((group == NULL || *group == '\0') && prg && | |
54 g_key_file_has_group(gkfile, prg)) | |
55 group = prg; | |
56 if (!group) | |
57 group = "general"; | |
52 return g_key_file_get_value(gkfile, group, key, NULL); | 58 return g_key_file_get_value(gkfile, group, key, NULL); |
53 #endif | 59 #endif |
54 } | 60 } |
55 | 61 |
56 gboolean gnt_style_get_bool(GntStyle style, gboolean def) | 62 gboolean gnt_style_get_bool(GntStyle style, gboolean def) |
57 { | 63 { |
58 int i; | |
59 const char * str; | 64 const char * str; |
60 | 65 |
61 if (bool_styles[style] != -1) | 66 if (bool_styles[style] != -1) |
62 return bool_styles[style]; | 67 return bool_styles[style]; |
63 | 68 |
64 str = gnt_style_get(style); | 69 str = gnt_style_get(style); |
65 | 70 |
71 bool_styles[style] = str ? gnt_style_parse_bool(str) : def; | |
72 return bool_styles[style]; | |
73 } | |
74 | |
75 gboolean gnt_style_parse_bool(const char *str) | |
76 { | |
77 gboolean def = FALSE; | |
78 int i; | |
79 | |
66 if (str) | 80 if (str) |
67 { | 81 { |
68 if (strcmp(str, "false") == 0) | 82 if (g_ascii_strcasecmp(str, "false") == 0) |
69 def = FALSE; | 83 def = FALSE; |
70 else if (strcmp(str, "true") == 0) | 84 else if (g_ascii_strcasecmp(str, "true") == 0) |
71 def = TRUE; | 85 def = TRUE; |
72 else if (sscanf(str, "%d", &i) == 1) | 86 else if (sscanf(str, "%d", &i) == 1) |
73 { | 87 { |
74 if (i) | 88 if (i) |
75 def = TRUE; | 89 def = TRUE; |
76 else | 90 else |
77 def = FALSE; | 91 def = FALSE; |
78 } | 92 } |
79 } | 93 } |
80 | 94 return def; |
81 bool_styles[style] = def; | |
82 return bool_styles[style]; | |
83 } | 95 } |
84 | 96 |
85 static void | 97 static void |
86 refine(char *text) | 98 refine(char *text) |
87 { | 99 { |
132 | 144 |
133 for (i = 1; i < MAX_WORKSPACES; ++i) { | 145 for (i = 1; i < MAX_WORKSPACES; ++i) { |
134 int j; | 146 int j; |
135 GntWS *ws; | 147 GntWS *ws; |
136 gchar **titles; | 148 gchar **titles; |
137 char *group = calloc(12, 1); | 149 char group[32]; |
138 g_sprintf(group, "Workspace-%d", i); | 150 g_snprintf(group, sizeof(group), "Workspace-%d", i); |
139 name = g_key_file_get_value(gkfile, group, "name", NULL); | 151 name = g_key_file_get_value(gkfile, group, "name", NULL); |
140 if (!name) | 152 if (!name) |
141 return; | 153 return; |
142 | 154 |
143 ws = gnt_ws_new(name); | 155 ws = gnt_ws_new(name); |
155 if (titles) { | 167 if (titles) { |
156 for (j = 0; j < c; ++j) | 168 for (j = 0; j < c; ++j) |
157 g_hash_table_replace(wm->title_places, g_strdup(titles[j]), ws); | 169 g_hash_table_replace(wm->title_places, g_strdup(titles[j]), ws); |
158 g_strfreev(titles); | 170 g_strfreev(titles); |
159 } | 171 } |
160 g_free(group); | |
161 } | 172 } |
162 #endif | 173 #endif |
163 } | 174 } |
164 void gnt_style_read_actions(GType type, GntBindableClass *klass) | 175 void gnt_style_read_actions(GType type, GntBindableClass *klass) |
165 { | 176 { |