Lines 2-132
Link Here
|
2 |
# include "config.h" |
2 |
# include "config.h" |
3 |
#endif |
3 |
#endif |
4 |
|
4 |
|
5 |
#include "conf.h" |
5 |
#include <sys/stat.h> |
|
|
6 |
#include <cstdio> |
7 |
#include <cstring> |
8 |
#include <cstdlib> |
9 |
#include <cerrno> |
10 |
#include <string> |
11 |
|
12 |
#include <glib.h> |
13 |
#include <glib/gi18n.h> |
14 |
|
6 |
#include "stardict.h" |
15 |
#include "stardict.h" |
7 |
|
16 |
|
8 |
// Notice: once you changed this file, try to change src/win32/winconf.cpp too. |
17 |
#include "conf.h" |
9 |
|
18 |
|
10 |
AppConf::AppConf() |
19 |
std::auto_ptr<AppConf> conf; |
11 |
{ |
20 |
|
12 |
gconf_client = gconf_client_get_default (); |
21 |
inline void free_list(GSList *l){ |
13 |
if (gconf_client == NULL) { |
22 |
if(l!=NULL){ |
14 |
g_warning (_("Cannot connect to gconf.")); |
23 |
g_slist_foreach(l, (GFunc)g_free, NULL); |
|
|
24 |
g_slist_free(l); |
15 |
} |
25 |
} |
16 |
else { |
26 |
} |
17 |
gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/dictionary/scan_selection", dictionary_scan_selection_changed_cb, NULL, NULL, NULL); |
27 |
|
18 |
gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/dictionary/only_scan_while_modifier_key", dictionary_only_scan_while_modifier_key_changed_cb, NULL, NULL, NULL); |
28 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
19 |
gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/dictionary/hide_floatwin_when_modifier_key_released", dictionary_hide_floatwin_when_modifier_key_released_changed_cb, NULL, NULL, NULL); |
29 |
|
20 |
gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/dictionary/scan_modifier_key", dictionary_scan_modifier_key_changed_cb, NULL, NULL, NULL); |
30 |
const char STRING_SEP = (const char) 0xff; |
21 |
gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/dictionary/enable_sound_event", dictionary_enable_sound_event_changed_cb, NULL, NULL, NULL); |
31 |
|
22 |
gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/main_window/search_website_list", main_window_searchwebsite_list_changed_cb, NULL, NULL, NULL); |
32 |
//--------------------------------------------------------------------------------- |
23 |
gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/main_window/hide_list", main_window_hide_list_changed_cb, NULL, NULL, NULL); |
33 |
static GSList * Str2List(gchar *str) |
24 |
gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/notification_area_icon/query_in_floatwin", notification_area_icon_show_in_floatwin_changed_cb, NULL, NULL, NULL); |
34 |
{ |
25 |
gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/floating_window/pronounce_when_popup", floatwin_pronounce_when_popup_changed_cb, NULL, NULL, NULL); |
35 |
GSList *list = NULL; |
26 |
gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/floating_window/max_window_width", floatwin_max_window_width_changed_cb, NULL, NULL, NULL); |
36 |
gchar *p; |
27 |
gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/floating_window/max_window_height", floatwin_max_window_height_changed_cb, NULL, NULL, NULL); |
37 |
while ((p = strchr(str, STRING_SEP))!=NULL) { |
28 |
gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/floating_window/lock", floatwin_lock_changed_cb, NULL, NULL, NULL); |
38 |
list = g_slist_append(list, g_strndup(str, p - str)); |
29 |
gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/floating_window/lock_x", floatwin_lock_x_changed_cb, NULL, NULL, NULL); |
39 |
str = p+1; |
30 |
gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/floating_window/lock_y", floatwin_lock_y_changed_cb, NULL, NULL, NULL); |
|
|
31 |
} |
40 |
} |
|
|
41 |
if (str[0]) |
42 |
list = g_slist_append(list, g_strdup(str)); |
43 |
return list; |
32 |
} |
44 |
} |
33 |
|
45 |
|
34 |
AppConf::~AppConf() |
46 |
//--------------------------------------------------------------------------------- |
|
|
47 |
ConfigLine *ConfigSection::CreateString(const gchar * key, const gchar * value) |
35 |
{ |
48 |
{ |
36 |
if (!gconf_client) |
49 |
ConfigLine *line; |
37 |
return; |
50 |
line = (ConfigLine *)g_malloc0(sizeof(ConfigLine)); |
38 |
g_object_unref (gconf_client); |
51 |
line->key = g_strchug(g_strchomp(g_strdup (key))); |
|
|
52 |
line->value = g_strchug(g_strchomp(g_strdup (value))); |
53 |
this->lines = g_list_append(this->lines, line); |
54 |
|
55 |
return line; |
39 |
} |
56 |
} |
|
|
57 |
//--------------------------------------------------------------------------------- |
58 |
ConfigLine *ConfigSection::FindString(const gchar * key) |
59 |
{ |
60 |
ConfigLine *line; |
61 |
GList *list; |
40 |
|
62 |
|
41 |
void AppConf::EnableNotify() |
63 |
list = this->lines; |
|
|
64 |
while (list){ |
65 |
line = (ConfigLine *) list->data; |
66 |
if (!strcasecmp (line->key, key)) |
67 |
return line; |
68 |
list = g_list_next (list); |
69 |
} |
70 |
return NULL; |
71 |
} |
72 |
//--------------------------------------------------------------------------------- |
73 |
#endif |
74 |
|
75 |
// |
76 |
//TBaseConf methods |
77 |
// |
78 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
79 |
|
80 |
ConfigSection *TBaseConf::CreateSection(const gchar * name) |
42 |
{ |
81 |
{ |
43 |
if (!gconf_client) |
82 |
ConfigSection *section; |
44 |
return; |
83 |
section = (ConfigSection *)g_malloc0(sizeof(ConfigSection)); |
45 |
gconf_client_add_dir(gconf_client, "/apps/stardict", GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); |
84 |
section->name = g_strdup(name); |
|
|
85 |
this->sections = g_list_append(this->sections, section); |
86 |
|
87 |
return section; |
46 |
} |
88 |
} |
|
|
89 |
//--------------------------------------------------------------------------------- |
90 |
ConfigSection *TBaseConf::FindSection(const gchar * name) |
91 |
{ |
92 |
ConfigSection *section; |
93 |
GList *list; |
47 |
|
94 |
|
48 |
void AppConf::DisableNotify() |
95 |
list = this->sections; |
|
|
96 |
while (list){ |
97 |
section = (ConfigSection *) list->data; |
98 |
if (!strcasecmp (section->name, name)) |
99 |
return section; |
100 |
list = g_list_next (list); |
101 |
} |
102 |
return NULL; |
103 |
} |
104 |
#endif |
105 |
|
106 |
TBaseConf::TBaseConf(const gchar *conf_path) |
107 |
{ |
108 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
109 |
sections=NULL; |
110 |
cfgfilename=NULL; |
111 |
Open(conf_path); |
112 |
#else |
113 |
cfgfilename=g_strdup(conf_path); |
114 |
if ((gconf_client = gconf_client_get_default())==NULL) |
115 |
g_warning(_("Cannot connect to gconf.")); |
116 |
else |
117 |
gconf_client_add_dir(gconf_client, conf_path, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); |
118 |
#endif |
119 |
} |
120 |
//--------------------------------------------------------------------------------- |
121 |
TBaseConf::~TBaseConf() |
49 |
{ |
122 |
{ |
|
|
123 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
124 |
ConfigSection *section; |
125 |
ConfigLine *line; |
126 |
GList *section_list, *line_list; |
127 |
|
128 |
g_free(this->cfgfilename); |
129 |
section_list=this->sections; |
130 |
while (section_list) { |
131 |
section = (ConfigSection *) section_list->data; |
132 |
g_free (section->name); |
133 |
|
134 |
line_list = section->lines; |
135 |
while (line_list) { |
136 |
line = (ConfigLine *) line_list->data; |
137 |
g_free (line->key); |
138 |
g_free (line->value); |
139 |
g_free (line); |
140 |
line_list = g_list_next(line_list); |
141 |
} |
142 |
g_list_free (section->lines); |
143 |
g_free (section); |
144 |
|
145 |
section_list = g_list_next(section_list); |
146 |
} |
147 |
g_list_free(this->sections); |
148 |
this->sections = NULL; |
149 |
this->cfgfilename = NULL; |
150 |
#else |
50 |
if (!gconf_client) |
151 |
if (!gconf_client) |
51 |
return; |
152 |
return; |
52 |
gconf_client_remove_dir(gconf_client, "/apps/stardict", NULL); |
153 |
gconf_client_remove_dir(gconf_client, cfgfilename, NULL); |
|
|
154 |
g_object_unref(gconf_client); |
155 |
g_free(cfgfilename); |
156 |
#endif |
53 |
} |
157 |
} |
|
|
158 |
//--------------------------------------------------------------------------------- |
159 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
160 |
bool TBaseConf::Open(const gchar * filename) |
161 |
{ |
162 |
FILE *file; |
163 |
gchar *buffer, **lines, *tmp; |
164 |
gint i; |
165 |
struct stat stats; |
166 |
ConfigSection *section = NULL; |
167 |
if (NULL==filename) |
168 |
return false; |
169 |
g_free(this->cfgfilename); |
170 |
this->cfgfilename = g_strdup(filename); |
54 |
|
171 |
|
55 |
void AppConf::read_bool(const gchar *key, gboolean *val, gboolean def) |
172 |
if (stat(filename, &stats) == -1) |
|
|
173 |
return false; |
174 |
|
175 |
if (!(file = fopen (filename, "rb"))) |
176 |
return false; |
177 |
|
178 |
|
179 |
buffer = (gchar *)g_malloc (stats.st_size + 1); |
180 |
fread(buffer, 1, stats.st_size, file); |
181 |
fclose(file); |
182 |
buffer[stats.st_size] = '\0'; |
183 |
|
184 |
lines = g_strsplit(buffer, "\n", 0); |
185 |
g_free(buffer); |
186 |
i = 0; |
187 |
while (lines[i]) { |
188 |
if (lines[i][0] == '[') { |
189 |
if ((tmp = strchr(lines[i], ']'))) { |
190 |
*tmp = '\0'; |
191 |
section = CreateSection(&lines[i][1]); |
192 |
} |
193 |
} else if(lines[i][0] != '#' && section) { |
194 |
if ((tmp = strchr (lines[i], '='))) { |
195 |
*tmp = '\0'; |
196 |
tmp++; |
197 |
section->CreateString(lines[i], tmp); |
198 |
} |
199 |
} |
200 |
i++; |
201 |
} |
202 |
g_strfreev(lines); |
203 |
|
204 |
return true; |
205 |
} |
206 |
//--------------------------------------------------------------------------------- |
207 |
bool TBaseConf::Write(const gchar * filename) |
56 |
{ |
208 |
{ |
57 |
if (!gconf_client) |
209 |
FILE *file; |
58 |
*val = def; |
210 |
GList *section_list, *line_list; |
|
|
211 |
ConfigSection *section; |
212 |
ConfigLine *line; |
213 |
if (NULL==filename) |
214 |
return false; |
215 |
if (!(file = fopen (filename, "wb"))) { |
216 |
g_warning(N_("Can not open: %s - %s\n"), filename, strerror(errno)); |
217 |
return false; |
218 |
} |
219 |
section_list = this->sections; |
220 |
while (section_list) { |
221 |
section = (ConfigSection *) section_list->data; |
222 |
if (section->lines) { |
223 |
fprintf(file, "[%s]\n", section->name); |
224 |
line_list = section->lines; |
225 |
while (line_list) { |
226 |
line = (ConfigLine *)line_list->data; |
227 |
fprintf(file, "%s=%s\n", line->key, line->value); |
228 |
line_list = g_list_next(line_list); |
229 |
} |
230 |
fprintf(file, "\n"); |
231 |
} |
232 |
section_list = g_list_next(section_list); |
233 |
} |
234 |
fclose(file); |
235 |
return true; |
236 |
} |
237 |
//--------------------------------------------------------------------------------- |
238 |
#endif |
239 |
bool TBaseConf::ReadBool(const gchar *section, const gchar *key, gboolean *value, gboolean def) |
240 |
{ |
241 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
242 |
gchar *str; |
243 |
|
244 |
if (!ReadString(section, key, &str)) { |
245 |
*value = def; |
246 |
return false; |
247 |
} |
248 |
|
249 |
if (!strcmp (str, "0")) |
250 |
*value=FALSE; |
59 |
else |
251 |
else |
60 |
*val = gconf_client_get_bool(gconf_client, key, NULL); |
252 |
*value=TRUE; |
|
|
253 |
|
254 |
g_free(str); |
255 |
#else |
256 |
if (!gconf_client) { |
257 |
*value=def; |
258 |
return false; |
259 |
} |
260 |
|
261 |
gchar *real_key=g_strdup_printf("%s/%s", section, key); |
262 |
*value=gconf_client_get_bool(gconf_client, real_key, NULL); |
263 |
g_free(real_key); |
264 |
#endif |
265 |
return true; |
61 |
} |
266 |
} |
|
|
267 |
//--------------------------------------------------------------------------------- |
268 |
bool TBaseConf::ReadInt(const gchar *section, const gchar *key, gint *value, gint def) |
269 |
{ |
270 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
271 |
gchar *str; |
62 |
|
272 |
|
63 |
void AppConf::write_bool(const gchar *key, gboolean val) |
273 |
if (!ReadString(section, key, &str)) { |
|
|
274 |
*value = def; |
275 |
return false; |
276 |
} |
277 |
*value = atoi(str); |
278 |
g_free(str); |
279 |
#else |
280 |
if (!gconf_client) { |
281 |
*value=def; |
282 |
return false; |
283 |
} |
284 |
|
285 |
gchar *real_key=g_strdup_printf("%s/%s", section, key); |
286 |
*value=gconf_client_get_int(gconf_client, real_key, NULL); |
287 |
g_free(real_key); |
288 |
#endif |
289 |
return true; |
290 |
} |
291 |
//--------------------------------------------------------------------------------- |
292 |
bool TBaseConf::ReadString(const gchar *section, const gchar *key, gchar **value) |
64 |
{ |
293 |
{ |
|
|
294 |
*value=NULL; |
295 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
296 |
ConfigSection *sect; |
297 |
ConfigLine *line; |
298 |
|
299 |
if (!(sect = FindSection(section))) |
300 |
return false; |
301 |
if (!(line = sect->FindString(key))) |
302 |
return false; |
303 |
*value = g_strdup(line->value); |
304 |
#else |
65 |
if (!gconf_client) |
305 |
if (!gconf_client) |
66 |
return; |
306 |
return false; |
67 |
gconf_client_set_bool (gconf_client, key, val, NULL); |
307 |
|
|
|
308 |
gchar *real_key=g_strdup_printf("%s/%s", section, key); |
309 |
*value = gconf_client_get_string(gconf_client, real_key, NULL); |
310 |
g_free(real_key); |
311 |
|
312 |
#endif |
313 |
return true; |
68 |
} |
314 |
} |
|
|
315 |
//--------------------------------------------------------------------------------- |
316 |
bool TBaseConf::ReadStrList(const gchar *section, const gchar *key, GSList **list) |
317 |
{ |
318 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
319 |
gchar *str; |
69 |
|
320 |
|
70 |
void AppConf::read_int(const gchar *key, gint *val ,gint def) |
321 |
if (!ReadString(section, key, &str)) { |
|
|
322 |
*list = NULL; |
323 |
return false; |
324 |
} |
325 |
|
326 |
*list = Str2List(str); |
327 |
g_free (str); |
328 |
#else |
329 |
if (!gconf_client) { |
330 |
*list = NULL; |
331 |
return false; |
332 |
} |
333 |
gchar *real_key=g_strdup_printf("%s/%s", section, key); |
334 |
*list = gconf_client_get_list(gconf_client, real_key, GCONF_VALUE_STRING, NULL); |
335 |
g_free(real_key); |
336 |
|
337 |
#endif |
338 |
return true; |
339 |
} |
340 |
//--------------------------------------------------------------------------------- |
341 |
void TBaseConf::WriteBool(const gchar *section, const gchar *key, gboolean value) |
71 |
{ |
342 |
{ |
72 |
if (!gconf_client) |
343 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
73 |
*val = def; |
344 |
if (value) |
|
|
345 |
WriteString(section, key, "1"); |
74 |
else |
346 |
else |
75 |
*val = gconf_client_get_int(gconf_client, key, NULL); |
347 |
WriteString(section, key, "0"); |
|
|
348 |
#else |
349 |
if (!gconf_client) |
350 |
return; |
351 |
gchar *real_key=g_strdup_printf("%s/%s", section, key); |
352 |
gconf_client_set_bool(gconf_client, real_key, value, NULL); |
353 |
g_free(real_key); |
354 |
#endif |
76 |
} |
355 |
} |
77 |
|
356 |
//--------------------------------------------------------------------------------- |
78 |
void AppConf::write_int(const gchar *key, gint val) |
357 |
void TBaseConf::WriteInt(const gchar *section, const gchar *key, gint value) |
79 |
{ |
358 |
{ |
|
|
359 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
360 |
gchar *strvalue = g_strdup_printf("%d", value); |
361 |
WriteString(section, key, strvalue); |
362 |
g_free(strvalue); |
363 |
#else |
80 |
if (!gconf_client) |
364 |
if (!gconf_client) |
81 |
return; |
365 |
return; |
82 |
gconf_client_set_int (gconf_client, key, val, NULL); |
366 |
gchar *real_key=g_strdup_printf("%s/%s", section, key); |
|
|
367 |
gconf_client_set_int(gconf_client, real_key, value, NULL); |
368 |
g_free(real_key); |
369 |
#endif |
83 |
} |
370 |
} |
84 |
|
371 |
//--------------------------------------------------------------------------------- |
85 |
void AppConf::read_string(const gchar *key, gchar **str) |
372 |
void TBaseConf::WriteString(const gchar *section, const gchar *key, const gchar *value) |
86 |
{ |
373 |
{ |
87 |
if (!gconf_client) |
374 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
88 |
*str = NULL; |
375 |
ConfigSection *sect; |
|
|
376 |
ConfigLine *line; |
377 |
|
378 |
sect = FindSection(section); |
379 |
if(!sect) |
380 |
sect = CreateSection(section); |
381 |
if((line = sect->FindString(key))){ |
382 |
g_free(line->value); |
383 |
line->value = g_strchug(g_strchomp(g_strdup (value))); |
384 |
} |
89 |
else |
385 |
else |
90 |
*str = gconf_client_get_string(gconf_client, key, NULL); |
386 |
sect->CreateString(key, value); |
|
|
387 |
Save(); |
388 |
#else |
389 |
if(!gconf_client) |
390 |
return; |
391 |
gchar *real_key=g_strdup_printf("%s/%s", section, key); |
392 |
gconf_client_set_string(gconf_client, real_key, value, NULL); |
393 |
g_free(real_key); |
394 |
#endif |
91 |
} |
395 |
} |
92 |
|
396 |
//--------------------------------------------------------------------------------- |
93 |
void AppConf::write_string(const gchar *key, const gchar *str) |
397 |
void TBaseConf::WriteStrList(const gchar *section, const gchar *key, GSList *list) |
94 |
{ |
398 |
{ |
|
|
399 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
400 |
std::string string; |
401 |
if (list) { |
402 |
string+=(gchar *)(list->data); |
403 |
list=list->next; |
404 |
} |
405 |
while (list) { |
406 |
string += STRING_SEP; |
407 |
string += (gchar *)(list->data); |
408 |
list = list->next; |
409 |
} |
410 |
WriteString(section, key, string.c_str()); |
411 |
#else |
95 |
if (!gconf_client) |
412 |
if (!gconf_client) |
96 |
return; |
413 |
return; |
97 |
gconf_client_set_string (gconf_client, key, str, NULL); |
414 |
gchar *real_key=g_strdup_printf("%s/%s", section, key); |
|
|
415 |
gconf_client_set_list(gconf_client, real_key, GCONF_VALUE_STRING, list, NULL); |
416 |
g_free(real_key); |
417 |
#endif |
98 |
} |
418 |
} |
|
|
419 |
//--------------------------------------------------------------------------------- |
99 |
|
420 |
|
100 |
void AppConf::read_list(const gchar *key, GConfValueType list_type, GSList **list) |
421 |
|
|
|
422 |
AppConf::AppConf(const gchar *conf_path) : TBaseConf(conf_path) |
101 |
{ |
423 |
{ |
102 |
if (!gconf_client) |
424 |
#if !defined(_WIN32) && !defined(WITHOUT_GNOME) |
103 |
*list = NULL; |
425 |
if (gconf_client!=NULL) { |
104 |
else |
426 |
gconf_client_notify_add(gconf_client, "/apps/stardict/preferences/dictionary/scan_selection", |
105 |
*list = gconf_client_get_list(gconf_client, key, list_type, NULL); |
427 |
dictionary_scan_selection_changed_cb, NULL, NULL, NULL); |
|
|
428 |
gconf_client_notify_add(gconf_client, "/apps/stardict/preferences/main_window/hide_list", |
429 |
main_window_hide_list_changed_cb, NULL, NULL, NULL); |
430 |
gconf_client_notify_add(gconf_client, "/apps/stardict/preferences/floating_window/lock", |
431 |
floatwin_lock_changed_cb, NULL, NULL, NULL); |
432 |
gconf_client_notify_add(gconf_client, "/apps/stardict/preferences/floating_window/lock_x", |
433 |
floatwin_lock_x_changed_cb, NULL, NULL, NULL); |
434 |
gconf_client_notify_add(gconf_client, "/apps/stardict/preferences/floating_window/lock_y", |
435 |
floatwin_lock_y_changed_cb, NULL, NULL, NULL); |
436 |
} |
437 |
#endif |
438 |
Load(); |
106 |
} |
439 |
} |
107 |
|
440 |
|
108 |
void AppConf::write_list(const gchar *key, GConfValueType list_type, GSList *list) |
441 |
AppConf::~AppConf() |
109 |
{ |
442 |
{ |
110 |
if (!gconf_client) |
443 |
free_list(search_website_list); |
111 |
return; |
444 |
free_list(dict_order_list); |
112 |
gconf_client_set_list(gconf_client, key, list_type, list, NULL); |
445 |
free_list(dict_disable_list); |
|
|
446 |
free_list(treedict_order_list); |
447 |
free_list(treedict_disable_list); |
113 |
} |
448 |
} |
114 |
|
449 |
|
115 |
void AppConf::dictionary_scan_selection_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
450 |
#if !defined(_WIN32) && !defined(WITHOUT_GNOME) |
|
|
451 |
void AppConf::dictionary_scan_selection_changed_cb(GConfClient *client, guint id, |
452 |
GConfEntry *entry, gpointer data) |
116 |
{ |
453 |
{ |
117 |
GConfValue *value = gconf_entry_get_value (entry); |
454 |
GConfValue *value = gconf_entry_get_value (entry); |
118 |
|
455 |
|
119 |
gboolean scan = gconf_value_get_bool (value); |
456 |
gboolean scan = gconf_value_get_bool (value); |
120 |
gpAppFrame->oAppCore.oSelection.bEnable = scan; |
457 |
// gpAppFrame->oAppCore.oSelection.bEnable = scan; |
121 |
gtk_widget_set_sensitive(gpAppFrame->oAppCore.oFloatWin.StopButton, scan); |
458 |
gtk_widget_set_sensitive(gpAppFrame->oAppCore.oFloatWin.StopButton, scan); |
122 |
if (scan != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gpAppFrame->oAppCore.oBottomWin.ScanSelectionCheckButton))) { |
459 |
if(scan != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gpAppFrame->oAppCore.oBottomWin.ScanSelectionCheckButton))) { |
123 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gpAppFrame->oAppCore.oBottomWin.ScanSelectionCheckButton),scan); |
460 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gpAppFrame->oAppCore.oBottomWin.ScanSelectionCheckButton),scan); |
124 |
//although this make check button's callback func write to Gconf again,this callback will not be called again. |
461 |
//although this make check button's callback func write to Gconf again,this callback will not be called again. |
125 |
} |
462 |
} |
126 |
if (scan) { |
463 |
if (scan) { |
127 |
if (!GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) |
464 |
if (!GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) |
128 |
gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_SCAN_ICON); |
465 |
gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_SCAN_ICON); |
129 |
if (gpAppFrame->oAppCore.oFloatWin.bIsLocked && (gpAppFrame->oAppCore.oFloatWin.QueryingWord.c_str())[0]!='\0') |
466 |
if (conf->get_lock() && (gpAppFrame->oAppCore.oFloatWin.QueryingWord.c_str())[0]!='\0') |
130 |
gpAppFrame->oAppCore.oFloatWin.Show(); |
467 |
gpAppFrame->oAppCore.oFloatWin.Show(); |
131 |
} |
468 |
} |
132 |
else { |
469 |
else { |
Lines 137-188
Link Here
|
137 |
} |
474 |
} |
138 |
} |
475 |
} |
139 |
|
476 |
|
140 |
void AppConf::dictionary_only_scan_while_modifier_key_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
477 |
|
|
|
478 |
void AppConf::main_window_hide_list_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
141 |
{ |
479 |
{ |
142 |
GConfValue *value = gconf_entry_get_value (entry); |
480 |
GConfValue *value = gconf_entry_get_value (entry); |
143 |
|
481 |
|
144 |
gpAppFrame->oAppCore.oSelection.only_scan_while_modifier_key = gconf_value_get_bool (value); |
482 |
gboolean hide = gconf_value_get_bool (value); |
|
|
483 |
if (hide) { |
484 |
gtk_widget_hide(gpAppFrame->oAppCore.oMidWin.oToolWin.HideListButton); |
485 |
gtk_widget_show(gpAppFrame->oAppCore.oMidWin.oToolWin.ShowListButton); |
486 |
gtk_widget_hide(gpAppFrame->oAppCore.oMidWin.oIndexWin.vbox); |
487 |
} |
488 |
else { |
489 |
gtk_widget_hide(gpAppFrame->oAppCore.oMidWin.oToolWin.ShowListButton); |
490 |
gtk_widget_show(gpAppFrame->oAppCore.oMidWin.oToolWin.HideListButton); |
491 |
gtk_widget_show(gpAppFrame->oAppCore.oMidWin.oIndexWin.vbox); |
492 |
} |
145 |
} |
493 |
} |
146 |
|
494 |
|
147 |
void AppConf::dictionary_hide_floatwin_when_modifier_key_released_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
495 |
|
|
|
496 |
void AppConf::floatwin_lock_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
148 |
{ |
497 |
{ |
149 |
GConfValue *value = gconf_entry_get_value (entry); |
498 |
GConfValue *value = gconf_entry_get_value (entry); |
150 |
|
499 |
|
151 |
gpAppFrame->oAppCore.oFloatWin.hide_floatwin_when_modifier_key_released = gconf_value_get_bool (value); |
500 |
gboolean lock = gconf_value_get_bool (value); |
|
|
501 |
// gpAppFrame->oAppCore.oFloatWin.bIsLocked = lock; |
502 |
if (lock) |
503 |
gtk_image_set_from_stock(GTK_IMAGE(gpAppFrame->oAppCore.oFloatWin.lock_image),GTK_STOCK_GOTO_LAST,GTK_ICON_SIZE_MENU); |
504 |
else |
505 |
gtk_image_set_from_stock(GTK_IMAGE(gpAppFrame->oAppCore.oFloatWin.lock_image),GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_MENU); |
152 |
} |
506 |
} |
153 |
|
507 |
|
154 |
void AppConf::dictionary_scan_modifier_key_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
508 |
void AppConf::floatwin_lock_x_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
155 |
{ |
509 |
{ |
|
|
510 |
if (conf->get_lock()){ |
156 |
GConfValue *value = gconf_entry_get_value (entry); |
511 |
GConfValue *value = gconf_entry_get_value (entry); |
|
|
512 |
gint lock_x = gconf_value_get_int (value); |
157 |
|
513 |
|
158 |
gpAppFrame->oAppCore.oSelection.scan_modifier_key = gconf_value_get_int (value); |
514 |
gint old_x,old_y; |
|
|
515 |
gtk_window_get_position(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),&old_x,&old_y); |
516 |
if (lock_x!=old_x) |
517 |
gtk_window_move(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),lock_x,old_y); |
518 |
} |
159 |
} |
519 |
} |
160 |
|
520 |
|
161 |
void AppConf::dictionary_enable_sound_event_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
521 |
void AppConf::floatwin_lock_y_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
162 |
{ |
522 |
{ |
|
|
523 |
if (conf->get_lock()){ |
163 |
GConfValue *value = gconf_entry_get_value (entry); |
524 |
GConfValue *value = gconf_entry_get_value (entry); |
|
|
525 |
gint lock_y = gconf_value_get_int (value); |
164 |
|
526 |
|
165 |
gpAppFrame->enable_sound_event = gconf_value_get_bool (value); |
527 |
gint old_x,old_y; |
|
|
528 |
gtk_window_get_position(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),&old_x,&old_y); |
529 |
if (lock_y!=old_y) |
530 |
gtk_window_move(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),old_x,lock_y); |
531 |
} |
166 |
} |
532 |
} |
167 |
|
533 |
#else |
168 |
void AppConf::main_window_searchwebsite_list_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
534 |
void on_conf_dictionary_scan_selection_changed(gboolean scan) |
169 |
{ |
535 |
{ |
170 |
g_slist_foreach (gpAppFrame->oAppCore.oBottomWin.searchwebsite_list, (GFunc)g_free, NULL); |
536 |
if (conf->get_scan_selection() == scan) |
171 |
g_slist_free (gpAppFrame->oAppCore.oBottomWin.searchwebsite_list); |
537 |
return; |
172 |
gpAppFrame->oAppCore.oBottomWin.searchwebsite_list = NULL; |
538 |
|
173 |
GConfValue *value = gconf_entry_get_value (entry); |
539 |
gtk_widget_set_sensitive(gpAppFrame->oAppCore.oFloatWin.StopButton, scan); |
174 |
GSList *list = gconf_value_get_list(value); |
540 |
if (scan != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gpAppFrame->oAppCore.oBottomWin.ScanSelectionCheckButton))) |
175 |
while (list) { |
541 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gpAppFrame->oAppCore.oBottomWin.ScanSelectionCheckButton),scan); |
176 |
gpAppFrame->oAppCore.oBottomWin.searchwebsite_list = g_slist_append(gpAppFrame->oAppCore.oBottomWin.searchwebsite_list, g_strdup(gconf_value_get_string((GConfValue *)(list->data)))); |
542 |
|
177 |
list = g_slist_next(list); |
543 |
if (scan) { |
|
|
544 |
if (!GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) |
545 |
gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_SCAN_ICON); |
546 |
if (conf->get_lock() && (gpAppFrame->oAppCore.oFloatWin.QueryingWord.c_str())[0]!='\0') |
547 |
gpAppFrame->oAppCore.oFloatWin.Show(); |
548 |
} else { |
549 |
if (!GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) |
550 |
gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_STOP_ICON); |
551 |
gpAppFrame->oAppCore.oFloatWin.Hide(); |
552 |
gpAppFrame->oAppCore.oSelection.LastClipWord.clear(); |
178 |
} |
553 |
} |
179 |
} |
554 |
} |
180 |
|
555 |
|
181 |
void AppConf::main_window_hide_list_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
|
|
182 |
{ |
183 |
GConfValue *value = gconf_entry_get_value (entry); |
184 |
|
556 |
|
185 |
gboolean hide = gconf_value_get_bool (value); |
557 |
void on_conf_main_window_hide_list_changed(gboolean hide) |
|
|
558 |
{ |
186 |
if (hide) { |
559 |
if (hide) { |
187 |
gtk_widget_hide(gpAppFrame->oAppCore.oMidWin.oToolWin.HideListButton); |
560 |
gtk_widget_hide(gpAppFrame->oAppCore.oMidWin.oToolWin.HideListButton); |
188 |
gtk_widget_show(gpAppFrame->oAppCore.oMidWin.oToolWin.ShowListButton); |
561 |
gtk_widget_show(gpAppFrame->oAppCore.oMidWin.oToolWin.ShowListButton); |
Lines 195-267
Link Here
|
195 |
} |
568 |
} |
196 |
} |
569 |
} |
197 |
|
570 |
|
198 |
void AppConf::notification_area_icon_show_in_floatwin_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
571 |
|
|
|
572 |
|
573 |
void on_conf_floatwin_lock_changed(gboolean lock) |
199 |
{ |
574 |
{ |
200 |
GConfValue *value = gconf_entry_get_value (entry); |
575 |
if (lock) |
|
|
576 |
gtk_image_set_from_stock(GTK_IMAGE(gpAppFrame->oAppCore.oFloatWin.lock_image),GTK_STOCK_GOTO_LAST,GTK_ICON_SIZE_MENU); |
577 |
else |
578 |
gtk_image_set_from_stock(GTK_IMAGE(gpAppFrame->oAppCore.oFloatWin.lock_image),GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_MENU); |
579 |
} |
201 |
|
580 |
|
202 |
gpAppFrame->oAppCore.oDockLet.query_in_floatwin = gconf_value_get_bool (value); |
581 |
#endif |
|
|
582 |
|
583 |
//--------------------------------------------------------------------------------- |
584 |
//load preference |
585 |
void AppConf::Load(void) |
586 |
{ |
587 |
ReadInt("/apps/stardict/preferences/main_window", "hpaned_pos", &hpaned_pos, DEFAULT_HPANED_POS); |
588 |
ReadInt("/apps/stardict/preferences/main_window", "window_width", &window_width, DEFAULT_WINDOW_WIDTH); |
589 |
ReadInt("/apps/stardict/preferences/main_window", "window_height", &window_height, DEFAULT_WINDOW_HEIGHT); |
590 |
ReadInt("/apps/stardict/preferences/floating_window", "lock_x", &lock_x, 0); |
591 |
ReadInt("/apps/stardict/preferences/floating_window", "lock_y", &lock_y, 0); |
592 |
ReadBool("/apps/stardict/preferences/main_window", "maximized", &maximized, FALSE); |
593 |
ReadBool("/apps/stardict/preferences/dictionary", "use_custom_font", &use_custom_font, FALSE); |
594 |
ReadString("/apps/stardict/preferences/dictionary", "custom_font", &custom_font); |
595 |
ReadBool("/apps/stardict/preferences/main_window", "hide_on_startup", &hide_on_startup, FALSE); |
596 |
ReadBool("/apps/stardict/preferences/dictionary", "enable_sound_event", &enable_sound_event, TRUE); |
597 |
ReadBool("/apps/stardict/preferences/main_window", "hide_list", &hide_list, FALSE); |
598 |
ReadStrList("/apps/stardict/preferences/main_window", "search_website_list", &search_website_list); |
599 |
ReadBool("/apps/stardict/preferences/dictionary", "scan_selection", &scan_selection, TRUE); |
600 |
ReadBool("/apps/stardict/preferences/notification_area_icon", "query_in_floatwin", &query_in_floatwin, TRUE); |
601 |
ReadBool("/apps/stardict/preferences/dictionary", "only_scan_while_modifier_key", &only_scan_while_modifier_key, FALSE); |
602 |
ReadBool("/apps/stardict/preferences/dictionary", "hide_floatwin_when_modifier_key_released", &hide_floatwin_when_modifier_key_released, TRUE); |
603 |
ReadInt("/apps/stardict/preferences/dictionary", "scan_modifier_key", &scan_modifier_key, 0); |
604 |
ReadBool("/apps/stardict/preferences/main_window", "hide_on_startup", &hide_on_startup, FALSE); |
605 |
ReadBool("/apps/stardict/preferences/floating_window", "pronounce_when_popup", &pronounce_when_popup, FALSE); |
606 |
ReadInt("/apps/stardict/preferences/floating_window", "max_window_width", &max_window_width, DEFAULT_MAX_FLOATWIN_WIDTH); |
607 |
ReadInt("/apps/stardict/preferences/floating_window", "max_window_height", &max_window_height, DEFAULT_MAX_FLOATWIN_HEIGHT); |
608 |
ReadStrList("/apps/stardict/manage_dictionaries", "treedict_order_list", &treedict_order_list); |
609 |
ReadStrList("/apps/stardict/manage_dictionaries", "treedict_disable_list", &treedict_disable_list); |
610 |
ReadStrList("/apps/stardict/manage_dictionaries", "dict_order_list", &dict_order_list); |
611 |
ReadStrList("/apps/stardict/manage_dictionaries", "dict_disable_list", &dict_disable_list); |
612 |
ReadBool("/apps/stardict/preferences/floating_window", "lock", &lock, FALSE); |
203 |
} |
613 |
} |
|
|
614 |
//--------------------------------------------------------------------------------- |
615 |
void AppConf::set_hpaned_pos(gint value) |
616 |
{ |
617 |
if (hpaned_pos==value) |
618 |
return; |
204 |
|
619 |
|
205 |
void AppConf::floatwin_max_window_width_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
620 |
WriteInt("/apps/stardict/preferences/main_window", "hpaned_pos", value); |
|
|
621 |
|
622 |
hpaned_pos=value; |
623 |
} |
624 |
|
625 |
void AppConf::set_window_width(gint value) |
206 |
{ |
626 |
{ |
207 |
GConfValue *value = gconf_entry_get_value (entry); |
627 |
if (window_width==value) |
|
|
628 |
return; |
208 |
|
629 |
|
209 |
gint width = gconf_value_get_int (value); |
630 |
WriteInt("/apps/stardict/preferences/main_window", "window_width", value); |
210 |
gpAppFrame->oAppCore.oFloatWin.Window_max_width = width; |
631 |
|
211 |
// need to resize floating window when it is locked? |
632 |
window_width=value; |
212 |
} |
633 |
} |
213 |
|
634 |
|
214 |
void AppConf::floatwin_pronounce_when_popup_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
635 |
void AppConf::set_window_height(gint value) |
215 |
{ |
636 |
{ |
216 |
GConfValue *value = gconf_entry_get_value (entry); |
637 |
if (window_height==value) |
|
|
638 |
return; |
217 |
|
639 |
|
218 |
gpAppFrame->oAppCore.oFloatWin.pronounce_when_popup = gconf_value_get_bool (value); |
640 |
WriteInt("/apps/stardict/preferences/main_window", "window_height", value); |
|
|
641 |
|
642 |
window_height=value; |
219 |
} |
643 |
} |
220 |
|
644 |
|
221 |
void AppConf::floatwin_max_window_height_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
645 |
void AppConf::set_lock_x(gint value) |
222 |
{ |
646 |
{ |
223 |
GConfValue *value = gconf_entry_get_value (entry); |
647 |
if (lock_x==value) |
|
|
648 |
return; |
224 |
|
649 |
|
225 |
gint height = gconf_value_get_int (value); |
650 |
WriteInt("/apps/stardict/preferences/floating_window", "lock_x", value); |
226 |
gpAppFrame->oAppCore.oFloatWin.Window_max_height = height; |
651 |
|
|
|
652 |
lock_x=value; |
227 |
} |
653 |
} |
228 |
|
654 |
|
229 |
void AppConf::floatwin_lock_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
655 |
void AppConf::set_lock_y(gint value) |
230 |
{ |
656 |
{ |
231 |
GConfValue *value = gconf_entry_get_value (entry); |
657 |
if (lock_y==value) |
|
|
658 |
return; |
232 |
|
659 |
|
233 |
gboolean lock = gconf_value_get_bool (value); |
660 |
WriteInt("/apps/stardict/preferences/floating_window", "lock_y", value); |
234 |
gpAppFrame->oAppCore.oFloatWin.bIsLocked = lock; |
661 |
|
235 |
if (lock) |
662 |
lock_y=value; |
236 |
gtk_image_set_from_stock(GTK_IMAGE(gpAppFrame->oAppCore.oFloatWin.lock_image),GTK_STOCK_GOTO_LAST,GTK_ICON_SIZE_MENU); |
|
|
237 |
else |
238 |
gtk_image_set_from_stock(GTK_IMAGE(gpAppFrame->oAppCore.oFloatWin.lock_image),GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_MENU); |
239 |
} |
663 |
} |
240 |
|
664 |
|
241 |
void AppConf::floatwin_lock_x_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
665 |
void AppConf::set_maximized(gboolean value) |
242 |
{ |
666 |
{ |
243 |
if (gpAppFrame->oAppCore.oFloatWin.bIsLocked) |
667 |
if (maximized==value) |
244 |
{ |
668 |
return; |
245 |
GConfValue *value = gconf_entry_get_value (entry); |
|
|
246 |
gint lock_x = gconf_value_get_int (value); |
247 |
|
669 |
|
248 |
gint old_x,old_y; |
670 |
WriteBool("/apps/stardict/preferences/main_window", "maximized", value); |
249 |
gtk_window_get_position(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),&old_x,&old_y); |
671 |
|
250 |
if (lock_x!=old_x) |
672 |
maximized=value; |
251 |
gtk_window_move(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),lock_x,old_y); |
|
|
252 |
} |
253 |
} |
673 |
} |
254 |
|
674 |
|
255 |
void AppConf::floatwin_lock_y_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) |
675 |
void AppConf::set_hide_list(gboolean value) |
256 |
{ |
676 |
{ |
257 |
if (gpAppFrame->oAppCore.oFloatWin.bIsLocked) |
677 |
if (hide_list==value) |
258 |
{ |
678 |
return; |
259 |
GConfValue *value = gconf_entry_get_value (entry); |
|
|
260 |
gint lock_y = gconf_value_get_int (value); |
261 |
|
679 |
|
262 |
gint old_x,old_y; |
680 |
WriteBool("/apps/stardict/preferences/main_window", "hide_list", value); |
263 |
gtk_window_get_position(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),&old_x,&old_y); |
681 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
264 |
if (lock_y!=old_y) |
682 |
on_conf_main_window_hide_list_changed(value); |
265 |
gtk_window_move(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),old_x,lock_y); |
683 |
#endif |
266 |
} |
684 |
|
|
|
685 |
hide_list=value; |
686 |
} |
687 |
|
688 |
void AppConf::set_search_website_list(GSList *value) |
689 |
{ |
690 |
if (search_website_list==value) |
691 |
return; |
692 |
g_slist_foreach(search_website_list, (GFunc)g_free, NULL); |
693 |
g_slist_free(search_website_list); |
694 |
search_website_list = NULL; |
695 |
|
696 |
WriteStrList("/apps/stardict/preferences/main_window", "search_website_list", value); |
697 |
|
698 |
search_website_list=value; |
699 |
} |
700 |
|
701 |
void AppConf::set_scan_selection(gboolean value) |
702 |
{ |
703 |
if (scan_selection==value) |
704 |
return; |
705 |
|
706 |
WriteBool("/apps/stardict/preferences/dictionary", "scan_selection", value); |
707 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
708 |
on_conf_dictionary_scan_selection_changed(value); |
709 |
#endif |
710 |
|
711 |
scan_selection=value; |
712 |
} |
713 |
|
714 |
void AppConf::set_only_scan_while_modifier_key(gboolean value) |
715 |
{ |
716 |
if (only_scan_while_modifier_key==value) |
717 |
return; |
718 |
|
719 |
WriteBool("/apps/stardict/preferences/dictionary", "only_scan_while_modifier_key", value); |
720 |
|
721 |
only_scan_while_modifier_key=value; |
722 |
} |
723 |
|
724 |
void AppConf::set_hide_floatwin_when_modifier_key_released(gboolean value) |
725 |
{ |
726 |
if (hide_floatwin_when_modifier_key_released==value) |
727 |
return; |
728 |
|
729 |
WriteBool("/apps/stardict/preferences/dictionary", "hide_floatwin_when_modifier_key_released", value); |
730 |
|
731 |
hide_floatwin_when_modifier_key_released=value; |
732 |
} |
733 |
|
734 |
void AppConf::set_scan_modifier_key(gint value) |
735 |
{ |
736 |
if (scan_modifier_key==value) |
737 |
return; |
738 |
|
739 |
WriteInt("/apps/stardict/preferences/dictionary", "scan_modifier_key", value); |
740 |
|
741 |
scan_modifier_key=value; |
742 |
} |
743 |
|
744 |
void AppConf::set_custom_font(const gchar *value) |
745 |
{ |
746 |
if (custom_font==value || |
747 |
(custom_font && value && strcmp(custom_font, value)==0)) |
748 |
return; |
749 |
|
750 |
WriteString("/apps/stardict/preferences/dictionary", "custom_font", value); |
751 |
|
752 |
custom_font=g_strdup(value); |
753 |
} |
754 |
|
755 |
void AppConf::set_enable_sound_event(gboolean value) |
756 |
{ |
757 |
if (enable_sound_event==value) |
758 |
return; |
759 |
|
760 |
WriteBool("/apps/stardict/preferences/dictionary", "enable_sound_event", value); |
761 |
|
762 |
enable_sound_event=value; |
763 |
} |
764 |
|
765 |
void AppConf::set_use_custom_font(gboolean value) |
766 |
{ |
767 |
if (use_custom_font==value) |
768 |
return; |
769 |
|
770 |
WriteBool("/apps/stardict/preferences/dictionary", "use_custom_font", value); |
771 |
|
772 |
use_custom_font=value; |
773 |
} |
774 |
|
775 |
void AppConf::set_hide_on_startup(gboolean value) |
776 |
{ |
777 |
if (hide_on_startup==value) |
778 |
return; |
779 |
|
780 |
WriteBool("/apps/stardict/preferences/main_window", "hide_on_startup", value); |
781 |
|
782 |
hide_on_startup=value; |
783 |
} |
784 |
|
785 |
void AppConf::set_query_in_floatwin(gboolean value) |
786 |
{ |
787 |
if (query_in_floatwin==value) |
788 |
return; |
789 |
|
790 |
WriteBool("/apps/stardict/preferences/notification_area_icon", "query_in_floatwin", value); |
791 |
|
792 |
query_in_floatwin=value; |
793 |
} |
794 |
|
795 |
void AppConf::set_pronounce_when_popup(gboolean value) |
796 |
{ |
797 |
if (pronounce_when_popup==value) |
798 |
return; |
799 |
|
800 |
WriteBool("/apps/stardict/preferences/floating_window", "pronounce_when_popup", value); |
801 |
|
802 |
pronounce_when_popup=value; |
803 |
} |
804 |
|
805 |
void AppConf::set_max_window_width(gint value) |
806 |
{ |
807 |
if (max_window_width==value) |
808 |
return; |
809 |
|
810 |
WriteInt("/apps/stardict/preferences/floating_window", "max_window_width", value); |
811 |
|
812 |
max_window_width=value; |
813 |
} |
814 |
|
815 |
void AppConf::set_max_window_height(gint value) |
816 |
{ |
817 |
if (max_window_height==value) |
818 |
return; |
819 |
|
820 |
WriteInt("/apps/stardict/preferences/floating_window", "max_window_height", value); |
821 |
|
822 |
max_window_height=value; |
823 |
} |
824 |
|
825 |
void AppConf::set_treedict_order_list(GSList *value) |
826 |
{ |
827 |
if (treedict_order_list==value) |
828 |
return; |
829 |
|
830 |
WriteStrList("/apps/stardict/manage_dictionaries", "treedict_order_list", value); |
831 |
|
832 |
g_slist_foreach(treedict_order_list, (GFunc)g_free, NULL); |
833 |
g_slist_free(treedict_order_list); |
834 |
treedict_order_list=value; |
835 |
} |
836 |
|
837 |
void AppConf::set_treedict_disable_list(GSList *value) |
838 |
{ |
839 |
if (treedict_disable_list==value) |
840 |
return; |
841 |
|
842 |
WriteStrList("/apps/stardict/manage_dictionaries", "treedict_disable_list", value); |
843 |
|
844 |
g_slist_foreach(treedict_disable_list, (GFunc)g_free, NULL); |
845 |
g_slist_free(treedict_disable_list); |
846 |
treedict_disable_list=value; |
847 |
} |
848 |
|
849 |
void AppConf::set_dict_order_list(GSList *value) |
850 |
{ |
851 |
if (dict_order_list==value) |
852 |
return; |
853 |
|
854 |
WriteStrList("/apps/stardict/manage_dictionaries", "dict_order_list", value); |
855 |
|
856 |
g_slist_foreach(dict_order_list, (GFunc)g_free, NULL); |
857 |
g_slist_free(dict_order_list); |
858 |
dict_order_list=value; |
859 |
} |
860 |
|
861 |
void AppConf::set_dict_disable_list(GSList *value) |
862 |
{ |
863 |
if (dict_disable_list==value) |
864 |
return; |
865 |
|
866 |
WriteStrList("/apps/stardict/manage_dictionaries", "dict_disable_list", value); |
867 |
|
868 |
g_slist_foreach(dict_disable_list, (GFunc)g_free, NULL); |
869 |
g_slist_free(dict_disable_list); |
870 |
|
871 |
dict_disable_list=value; |
872 |
} |
873 |
|
874 |
void AppConf::set_lock(gboolean value) |
875 |
{ |
876 |
if (lock==value) |
877 |
return; |
878 |
|
879 |
WriteBool("/apps/stardict/preferences/floating_window", "lock", value); |
880 |
#if defined(_WIN32) || defined(WITHOUT_GNOME) |
881 |
on_conf_floatwin_lock_changed(value); |
882 |
#endif |
883 |
|
884 |
lock=value; |
267 |
} |
885 |
} |