Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 86379 | Differences between
and this patch

Collapse All | Expand All

(-)stardict-2.4.4.orig/src/conf.cpp (-132 / +750 lines)
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
}
(-)stardict-2.4.4.orig/src/conf.h (-26 / +138 lines)
Lines 1-43 Link Here
1
#ifndef __SD_CONF_H__
1
#ifndef __SD_CONF_H__
2
#define __SD_CONF_H__
2
#define __SD_CONF_H__
3
3
4
#include <libgnome/libgnome.h>
4
#include <glib.h>
5
#include <gconf/gconf-client.h>
5
#include <memory>
6
6
7
class AppConf
7
#if defined(_WIN32) || defined(WITHOUT_GNOME)
8
{
8
struct ConfigLine {
9
private:
9
  gchar *key;
10
  gchar *value;
11
};
12
13
struct ConfigSection {
14
  gchar *name;
15
  GList *lines;
16
  ConfigLine *CreateString(const gchar * key, const gchar * value);
17
  ConfigLine *FindString(const gchar * key);
18
};
19
#else
20
#  include <gconf/gconf.h>
21
#  include <gconf/gconf-client.h>
22
#endif
23
24
/*
25
 * TBaseConf class encapsule methods
26
 * for geting access to variables in some config repository,
27
 * it can be gconf server or file.
28
*/
29
30
class TBaseConf {
31
public:  
32
  explicit TBaseConf(const gchar *conf_path);
33
  ~TBaseConf();
34
  
35
  bool ReadBool(const gchar *section, const gchar *key, gboolean *value, gboolean def);
36
  bool ReadInt(const gchar *section, const gchar *key, gint *value, gint def);
37
  bool ReadString(const gchar * section, const gchar *key, gchar **value);
38
  bool ReadStrList(const gchar * section, const gchar * key, GSList **slist);
39
40
  void WriteBool(const gchar *section, const gchar *key, gboolean value);
41
  void WriteInt(const gchar *section, const gchar *key, gint value);
42
  void WriteString(const gchar *section, const gchar *key, const gchar *value);
43
  void WriteStrList(const gchar *section, const gchar *key, GSList *slist);
44
45
protected:
46
  gchar *cfgfilename;
47
#if defined(_WIN32) || defined(WITHOUT_GNOME)
48
  GList *sections;
49
50
  ConfigSection *CreateSection(const gchar * name);
51
  ConfigSection *FindSection(const gchar * name);
52
  bool Open(const gchar * filename);
53
  bool Write(const gchar * filename);
54
  inline void Save(void){ Write(cfgfilename); }
55
#else
10
	GConfClient *gconf_client;
56
	GConfClient *gconf_client;
57
#endif
58
};
59
60
/*
61
 * AppConf class encapsulate 
62
 * all preference of stardict.
63
*/
64
65
class AppConf : public TBaseConf {
66
private:
67
  gint hpaned_pos;
68
  gint window_width, window_height;
69
  gint lock_x, lock_y;
70
  gboolean maximized;
71
  gboolean use_custom_font;
72
  gchar *custom_font;
73
  gboolean hide_on_startup;
74
  gboolean enable_sound_event;
75
  gboolean hide_list;
76
  GSList *search_website_list;
77
  gboolean scan_selection;
78
  gboolean query_in_floatwin;
79
  gboolean only_scan_while_modifier_key;
80
  gboolean hide_floatwin_when_modifier_key_released;
81
  gint scan_modifier_key;
82
  gboolean pronounce_when_popup;
83
  gint max_window_width, max_window_height;
84
  GSList *treedict_order_list, *treedict_disable_list;
85
  GSList *dict_order_list, *dict_disable_list;
86
  gboolean lock;
11
87
88
#if !defined(_WIN32) && !defined(WITHOUT_GNOME)
12
	static void dictionary_scan_selection_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
89
	static void dictionary_scan_selection_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
13
	static void dictionary_only_scan_while_modifier_key_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
14
	static void dictionary_hide_floatwin_when_modifier_key_released_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
15
	static void dictionary_scan_modifier_key_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
16
	static void dictionary_enable_sound_event_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
17
	static void main_window_searchwebsite_list_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
18
	static void main_window_hide_list_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);	
90
	static void main_window_hide_list_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);	
19
	static void notification_area_icon_show_in_floatwin_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
20
	static void floatwin_pronounce_when_popup_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
21
	static void floatwin_max_window_width_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
22
	static void floatwin_max_window_height_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
23
	static void floatwin_lock_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
91
	static void floatwin_lock_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
24
	static void floatwin_lock_x_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
92
	static void floatwin_lock_x_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
25
	static void floatwin_lock_y_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
93
	static void floatwin_lock_y_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data);
94
#endif
95
26
public:
96
public:
27
	AppConf();
97
  explicit AppConf(const gchar *conf_path);
28
	~AppConf();
98
	~AppConf();
99
  void Load(void);
29
100
30
	void EnableNotify();
101
  gint get_hpaned_pos(void){return hpaned_pos;}
31
	void DisableNotify();
102
  void set_hpaned_pos(gint value);
32
103
  gint get_window_width(void){return window_width;}
33
	void read_bool(const gchar *key, gboolean *val, gboolean def);
104
  void set_window_width(gint value);
34
	void write_bool(const gchar *key, gboolean val);
105
  gint get_window_height(void){return window_height;}
35
	void read_int(const gchar *key, gint *val ,gint def);	
106
  void set_window_height(gint value);
36
	void write_int(const gchar *key, gint val);
107
  gint get_lock_x(void){return lock_x;}
37
	void read_string(const gchar *key, gchar **str);
108
  void set_lock_x(gint value);
38
	void write_string(const gchar *key, const gchar *str);
109
  gint get_lock_y(void){return lock_y;}
39
	void read_list(const gchar *key, GConfValueType list_type, GSList **list);
110
  void set_lock_y(gint value);
40
	void write_list(const gchar *key, GConfValueType list_type, GSList *list);
111
  gboolean get_maximized(void){return maximized;}
112
  void set_maximized(gboolean value);
113
  gboolean get_use_custom_font(void){return use_custom_font;}
114
  void set_use_custom_font(gboolean value);
115
  const gchar *get_custom_font(void){return custom_font;}
116
  void set_custom_font(const gchar *value);
117
  gboolean get_hide_on_startup(void){return hide_on_startup;}
118
  void set_hide_on_startup(gboolean value);
119
  gboolean get_enable_sound_event(void){return enable_sound_event;}
120
  void set_enable_sound_event(gboolean value);
121
  gboolean get_hide_list(void){return hide_list;}
122
  void set_hide_list(gboolean value);
123
  const GSList *get_search_website_list(void){return search_website_list;}
124
  void set_search_website_list(GSList *value);
125
  gboolean get_scan_selection(void){return scan_selection;}
126
  void set_scan_selection(gboolean value);
127
  gboolean get_query_in_floatwin(void){return query_in_floatwin;}
128
  void set_query_in_floatwin(gboolean value);
129
  gboolean get_only_scan_while_modifier_key(void){return only_scan_while_modifier_key;}
130
  void set_only_scan_while_modifier_key(gboolean value);
131
  gboolean get_hide_floatwin_when_modifier_key_released(void){return hide_floatwin_when_modifier_key_released;}
132
  void set_hide_floatwin_when_modifier_key_released(gboolean value);
133
  gint get_scan_modifier_key(void){return scan_modifier_key;}
134
  void set_scan_modifier_key(gint value);
135
  gboolean get_pronounce_when_popup(void){return pronounce_when_popup;}
136
  void set_pronounce_when_popup(gboolean value);
137
  gint get_max_window_width(void){return max_window_width;}
138
  void set_max_window_width(gint value);
139
  gint get_max_window_height(void){return max_window_height;}
140
  void set_max_window_height(gint value);
141
  const GSList *get_treedict_order_list(void){return treedict_order_list;}
142
  void set_treedict_order_list(GSList *value);
143
  const GSList *get_treedict_disable_list(void){return treedict_disable_list;}
144
  void set_treedict_disable_list(GSList *value);
145
  const GSList *get_dict_order_list(void){return dict_order_list;}
146
  void set_dict_order_list(GSList *value);
147
  const GSList *get_dict_disable_list(void){return dict_disable_list;}
148
  void set_dict_disable_list(GSList *value);
149
  gboolean get_lock(void){return lock;}
150
  void set_lock(gboolean value);
41
};
151
};
42
152
153
extern std::auto_ptr<AppConf> conf;//global exemplar of AppConf class
154
43
#endif
155
#endif
(-)stardict-2.4.4.orig/src/dictmanagedlg.cpp (-62 / +21 lines)
Lines 1-9 Link Here
1
#ifdef HAVE_CONFIG_H
1
#ifdef HAVE_CONFIG_H
2
#  include "config.h"
2
#  include "config.h"
3
#endif
3
#endif
4
#include "dictmanagedlg.h"
4
5
#include "stardict.h"
5
#include <cstring>
6
#include "string.h"
7
#include <sys/stat.h>
6
#include <sys/stat.h>
8
7
9
#ifdef _WIN32
8
#ifdef _WIN32
Lines 11-16 Link Here
11
#  include "win32/intl.h"
10
#  include "win32/intl.h"
12
#endif
11
#endif
13
12
13
#include "stardict.h"
14
#include "conf.h"
15
16
#include "dictmanagedlg.h"
14
17
15
DictManageDlg::DictManageDlg()
18
DictManageDlg::DictManageDlg()
16
{
19
{
Lines 153-159 Link Here
153
	return true;				
156
	return true;				
154
}
157
}
155
158
156
void DictManageDlg::load_dir(gboolean istreedict, gchar *dirname, GSList *order_list, GSList *disable_list, GtkListStore *model)
159
void DictManageDlg::load_dir(gboolean istreedict, gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkListStore *model)
157
{
160
{
158
	GDir *dir = g_dir_open(dirname, 0, NULL);	
161
	GDir *dir = g_dir_open(dirname, 0, NULL);	
159
	if (dir)
162
	if (dir)
Lines 162-168 Link Here
162
		const gchar *filename;	
165
		const gchar *filename;	
163
		gchar fullfilename[256];
166
		gchar fullfilename[256];
164
		gboolean loaded;
167
		gboolean loaded;
165
		GSList *tmplist1,*tmplist2;
168
		const GSList *tmplist1,*tmplist2;
166
		gboolean disabled;
169
		gboolean disabled;
167
		glong wordcount;
170
		glong wordcount;
168
		gchar *bookname, *author, *email, *website, *description, *date;
171
		gchar *bookname, *author, *email, *website, *description, *date;
Lines 214-237 Link Here
214
217
215
	model = gtk_list_store_new (10, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_LONG, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
218
	model = gtk_list_store_new (10, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_LONG, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
216
219
217
	GSList *order_list, *disable_list;
220
  const GSList *order_list, *disable_list;
218
	if (istreedict) {
221
	if (istreedict) {
219
#ifdef _WIN32
222
    order_list=conf->get_treedict_order_list();
220
		rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "treedict_order_list", &order_list);
223
    disable_list=conf->get_treedict_disable_list();
221
		rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "treedict_disable_list", &disable_list);
224
  } else {
222
#else
225
    order_list=conf->get_dict_order_list();
223
		gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/treedict_order_list", GCONF_VALUE_STRING, &order_list);
226
    disable_list=conf->get_dict_disable_list();    
224
		gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/treedict_disable_list", GCONF_VALUE_STRING, &disable_list);
225
#endif
226
	}
227
	else {
228
#ifdef _WIN32
229
		rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "dict_order_list", &order_list);
230
		rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "dict_disable_list", &disable_list);
231
#else
232
		gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/dict_order_list", GCONF_VALUE_STRING, &order_list);
233
		gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/dict_disable_list", GCONF_VALUE_STRING, &disable_list);
234
#endif
235
	}
227
	}
236
	
228
	
237
	glong wordcount;
229
	glong wordcount;
Lines 240-246 Link Here
240
	GtkTreeIter iter;
232
	GtkTreeIter iter;
241
	
233
	
242
	gchar *ifofilename;
234
	gchar *ifofilename;
243
	GSList *tmplist1,*tmplist2;
235
  const GSList *tmplist1,*tmplist2;
244
	gboolean disabled;
236
	gboolean disabled;
245
	tmplist1 = order_list;	
237
	tmplist1 = order_list;	
246
	while (tmplist1) {
238
	while (tmplist1) {
Lines 291-302 Link Here
291
		load_dir(istreedict, STARDICT_DATA_DIR "/dic", order_list, disable_list, model);
283
		load_dir(istreedict, STARDICT_DATA_DIR "/dic", order_list, disable_list, model);
292
#endif
284
#endif
293
285
294
	g_slist_foreach (order_list, (GFunc)g_free, NULL);
295
	g_slist_free(order_list);
296
	
297
	g_slist_foreach (disable_list, (GFunc)g_free, NULL);
298
	g_slist_free(disable_list);
299
		
300
	return GTK_TREE_MODEL (model);	
286
	return GTK_TREE_MODEL (model);	
301
}
287
}
302
288
Lines 329-342 Link Here
329
		}
315
		}
330
		have_iter = gtk_tree_model_iter_next(model, &iter);
316
		have_iter = gtk_tree_model_iter_next(model, &iter);
331
	}
317
	}
332
#ifdef _WIN32
318
	conf->set_dict_disable_list(disable_list);
333
	rw_cfg_write_strlist (usercfgfile, "manage_dictionaries", "dict_disable_list", disable_list);
334
#else
335
	gpAppFrame->oAppConf.write_list("/apps/stardict/manage_dictionaries/dict_disable_list", GCONF_VALUE_STRING, disable_list);
336
#endif
337
338
	g_slist_foreach (disable_list, (GFunc)g_free, NULL);
339
	g_slist_free(disable_list);
340
}
319
}
341
320
342
void DictManageDlg::on_treedict_enable_toggled (GtkCellRendererToggle *cell, gchar *path_str, DictManageDlg *oDictManageDlg)
321
void DictManageDlg::on_treedict_enable_toggled (GtkCellRendererToggle *cell, gchar *path_str, DictManageDlg *oDictManageDlg)
Lines 368-381 Link Here
368
		}
347
		}
369
		have_iter = gtk_tree_model_iter_next(model, &iter);
348
		have_iter = gtk_tree_model_iter_next(model, &iter);
370
	}
349
	}
371
#ifdef _WIN32
350
	conf->set_treedict_disable_list(disable_list);
372
	rw_cfg_write_strlist (usercfgfile, "manage_dictionaries", "treedict_disable_list", disable_list);
373
#else
374
	gpAppFrame->oAppConf.write_list("/apps/stardict/manage_dictionaries/treedict_disable_list", GCONF_VALUE_STRING, disable_list);
375
#endif
376
377
	g_slist_foreach (disable_list, (GFunc)g_free, NULL);
378
	g_slist_free(disable_list);
379
}
351
}
380
352
381
void DictManageDlg::drag_data_get_cb(GtkWidget *widget, GdkDragContext *ctx, GtkSelectionData *data, guint info, guint time, DictManageDlg *oDictManageDlg)
353
void DictManageDlg::drag_data_get_cb(GtkWidget *widget, GdkDragContext *ctx, GtkSelectionData *data, guint info, guint time, DictManageDlg *oDictManageDlg)
Lines 563-585 Link Here
563
		have_iter = gtk_tree_model_iter_next(now_tree_model, &iter);
535
		have_iter = gtk_tree_model_iter_next(now_tree_model, &iter);
564
	}
536
	}
565
	
537
	
566
	if (istreedict) {
538
	if (istreedict)
567
#ifdef _WIN32
539
	  conf->set_treedict_order_list(order_list);
568
		rw_cfg_write_strlist (usercfgfile, "manage_dictionaries", "treedict_order_list", order_list);
540
	else
569
#else
541
	  conf->set_dict_order_list(order_list);
570
		gpAppFrame->oAppConf.write_list("/apps/stardict/manage_dictionaries/treedict_order_list", GCONF_VALUE_STRING, order_list);
571
#endif
572
	}
573
	else {
574
#ifdef _WIN32
575
		rw_cfg_write_strlist (usercfgfile, "manage_dictionaries", "dict_order_list", order_list);
576
#else
577
		gpAppFrame->oAppConf.write_list("/apps/stardict/manage_dictionaries/dict_order_list", GCONF_VALUE_STRING, order_list);
578
#endif
579
	}
580
581
	g_slist_foreach (order_list, (GFunc)g_free, NULL);
582
	g_slist_free(order_list);
583
}
542
}
584
543
585
void DictManageDlg::on_move_top_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg)
544
void DictManageDlg::on_move_top_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg)
(-)stardict-2.4.4.orig/src/dictmanagedlg.h (-1 / +1 lines)
Lines 13-19 Link Here
13
	GtkWidget *treedict_treeview;
13
	GtkWidget *treedict_treeview;
14
	GtkTreeModel *treedict_tree_model;
14
	GtkTreeModel *treedict_tree_model;
15
15
16
	static void load_dir(gboolean istreedict, gchar *dirname, GSList *order_list, GSList *disable_list, GtkListStore *model);
16
	static void load_dir(gboolean istreedict, gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkListStore *model);
17
	static GtkTreeModel* create_dict_tree_model (gboolean istreedict);
17
	static GtkTreeModel* create_dict_tree_model (gboolean istreedict);
18
	GtkWidget *create_dict_tree(gboolean istreedict);
18
	GtkWidget *create_dict_tree(gboolean istreedict);
19
		
19
		
(-)stardict-2.4.4.orig/src/docklet.cpp (-20 / +17 lines)
Lines 1-6 Link Here
1
#include "config.h"
1
#ifdef HAVE_CONFIG_H
2
#include "docklet.h"
2
#  include "config.h"
3
#endif
4
3
#include "stardict.h"
5
#include "stardict.h"
6
#include "conf.h"
7
8
#include "docklet.h"
4
9
5
/*
10
/*
6
// for my_gtk_window_get_active()
11
// for my_gtk_window_get_active()
Lines 18-25 Link Here
18
23
19
void DockLet::Create(DockLetIconType iconType)
24
void DockLet::Create(DockLetIconType iconType)
20
{	
25
{	
21
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/notification_area_icon/query_in_floatwin", &query_in_floatwin, true);
22
	
23
	docklet = egg_tray_icon_new("StarDict");
26
	docklet = egg_tray_icon_new("StarDict");
24
	GtkWidget *box = gtk_event_box_new();
27
	GtkWidget *box = gtk_event_box_new();
25
	if (iconType == DOCKLET_NORMAL_ICON)
28
	if (iconType == DOCKLET_NORMAL_ICON)
Lines 95-101 Link Here
95
98
96
void DockLet::MenuScanCallback(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
99
void DockLet::MenuScanCallback(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
97
{
100
{
98
	gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/scan_selection",gtk_check_menu_item_get_active(checkmenuitem));
101
  conf->set_scan_selection(gtk_check_menu_item_get_active(checkmenuitem));
99
}
102
}
100
103
101
void DockLet::MenuQuitCallback(GtkMenuItem *menuitem, gpointer user_data)
104
void DockLet::MenuQuitCallback(GtkMenuItem *menuitem, gpointer user_data)
Lines 126-132 Link Here
126
129
127
		gtk_widget_show_all(menu);
130
		gtk_widget_show_all(menu);
128
	}
131
	}
129
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(scan_menuitem), gpAppFrame->oAppCore.oSelection.bEnable);
132
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(scan_menuitem), conf->get_scan_selection());
130
	
133
	
131
	gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time);
134
	gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time);
132
}
135
}
Lines 197-234 Link Here
197
	if (event->button ==1) {
200
	if (event->button ==1) {
198
		
201
		
199
		if ((event->state & GDK_CONTROL_MASK)&&(!(event->state & GDK_MOD1_MASK))&&(!(event->state & GDK_SHIFT_MASK))) {
202
		if ((event->state & GDK_CONTROL_MASK)&&(!(event->state & GDK_MOD1_MASK))&&(!(event->state & GDK_SHIFT_MASK))) {
200
			gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/scan_selection", !(gpAppFrame->oAppCore.oSelection.bEnable));
203
      conf->set_scan_selection(!conf->get_scan_selection());
201
			return true;
204
			return true;
202
		}
205
    } else {			
203
		else {			
204
			if (GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) {
206
			if (GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) {
205
			//if (GTK_WINDOW(gpAppFrame->oAppCore.window)->is_active) {
207
			//if (GTK_WINDOW(gpAppFrame->oAppCore.window)->is_active) {
206
			//if (my_gtk_window_get_active(gpAppFrame->oAppCore.window)) {
208
			//if (my_gtk_window_get_active(gpAppFrame->oAppCore.window)) {
207
				gtk_widget_hide(gpAppFrame->oAppCore.window);
209
				gtk_widget_hide(gpAppFrame->oAppCore.window);
208
			}
210
      }	else {
209
			else {
210
				gtk_window_present(GTK_WINDOW(gpAppFrame->oAppCore.window));
211
				gtk_window_present(GTK_WINDOW(gpAppFrame->oAppCore.window));
211
				if (gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry))[0]) {
212
				if (gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry))[0]) {
212
					gtk_widget_grab_focus(gpAppFrame->oAppCore.oMidWin.oTextWin.textview); //so user can input word directly.
213
					gtk_widget_grab_focus(gpAppFrame->oAppCore.oMidWin.oTextWin.textview); //so user can input word directly.
213
				}
214
	} else {
214
				else {
215
					gtk_widget_grab_focus(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry); //this won't change selection text.
215
					gtk_widget_grab_focus(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry); //this won't change selection text.
216
				}
216
				}
217
			}
217
			}
218
		}		
218
		}		
219
	}
219
  } else if (event->button ==2) {
220
	else if (event->button ==2) {
220
    if (conf->get_query_in_floatwin()) {
221
		if (oDockLet->query_in_floatwin) {
222
			gpAppFrame->oAppCore.oSelection.LastClipWord.clear();
221
			gpAppFrame->oAppCore.oSelection.LastClipWord.clear();
223
			gtk_selection_convert (gpAppFrame->oAppCore.oSelection.selection_widget, GDK_SELECTION_PRIMARY, gpAppFrame->oAppCore.oSelection.UTF8_STRING_Atom, GDK_CURRENT_TIME);			
222
			gtk_selection_convert (gpAppFrame->oAppCore.oSelection.selection_widget, GDK_SELECTION_PRIMARY, gpAppFrame->oAppCore.oSelection.UTF8_STRING_Atom, GDK_CURRENT_TIME);			
224
		}
223
    } else {
225
		else {
226
			gtk_window_present(GTK_WINDOW(gpAppFrame->oAppCore.window));
224
			gtk_window_present(GTK_WINDOW(gpAppFrame->oAppCore.window));
227
			gtk_selection_convert (gpAppFrame->oAppCore.oMidWin.oTextWin.textview, GDK_SELECTION_PRIMARY, gpAppFrame->oAppCore.oSelection.UTF8_STRING_Atom, GDK_CURRENT_TIME);
225
			gtk_selection_convert (gpAppFrame->oAppCore.oMidWin.oTextWin.textview, GDK_SELECTION_PRIMARY, gpAppFrame->oAppCore.oSelection.UTF8_STRING_Atom, GDK_CURRENT_TIME);
228
		}
226
		}
229
		return true;
227
		return true;
230
	}
228
  } else if (event->button ==3) {
231
	else if (event->button ==3) {
232
		oDockLet->PopupMenu(event);
229
		oDockLet->PopupMenu(event);
233
		return true;
230
		return true;
234
	}
231
	}
(-)stardict-2.4.4.orig/src/docklet.h (-1 / +1 lines)
Lines 29-35 Link Here
29
	void PopupMenu(GdkEventButton *event);
29
	void PopupMenu(GdkEventButton *event);
30
public:	
30
public:	
31
	gboolean embedded;
31
	gboolean embedded;
32
	gboolean query_in_floatwin;
32
33
	DockLet();
33
	DockLet();
34
	void Create(DockLetIconType iconType = DOCKLET_NORMAL_ICON);
34
	void Create(DockLetIconType iconType = DOCKLET_NORMAL_ICON);
35
	void End();
35
	void End();
(-)stardict-2.4.4.orig/src/floatwin.cpp (-78 / +49 lines)
Lines 2-17 Link Here
2
#  include "config.h"
2
#  include "config.h"
3
#endif
3
#endif
4
4
5
#include <string.h>
5
#include <cstring>
6
#include <string>
6
#include <string>
7
#include "floatwin.h"
8
#include "stardict.h"
9
7
10
#ifdef _WIN32
8
#ifdef _WIN32
11
#  include <gdk/gdkwin32.h>
9
#  include <gdk/gdkwin32.h>
12
#  include "win32/intl.h"
10
#  include "win32/intl.h"
13
#endif
11
#endif
14
12
13
#include "stardict.h"
14
#include "conf.h"
15
16
#include "floatwin.h"
17
15
FloatWin::FloatWin()
18
FloatWin::FloatWin()
16
{
19
{
17
	timeout = 0;
20
	timeout = 0;
Lines 42-87 Link Here
42
	g_signal_connect (G_OBJECT (FloatWindow), "enter_notify_event", G_CALLBACK (vEnterNotifyCallback), this);
45
	g_signal_connect (G_OBJECT (FloatWindow), "enter_notify_event", G_CALLBACK (vEnterNotifyCallback), this);
43
	g_signal_connect (G_OBJECT (FloatWindow), "leave_notify_event", G_CALLBACK (vLeaveNotifyCallback), this);
46
	g_signal_connect (G_OBJECT (FloatWindow), "leave_notify_event", G_CALLBACK (vLeaveNotifyCallback), this);
44
47
45
#ifdef _WIN32
46
	rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "hide_floatwin_when_modifier_key_released", &hide_floatwin_when_modifier_key_released);
47
	rw_cfg_read_boolean (usercfgfile, "preferences/floating_window", "lock", &bIsLocked);
48
	rw_cfg_read_boolean (usercfgfile, "preferences/floating_window", "pronounce_when_popup", &pronounce_when_popup);
49
	rw_cfg_read_int (usercfgfile, "preferences/floating_window", "max_window_width", &Window_max_width);
50
	rw_cfg_read_int (usercfgfile, "preferences/floating_window", "max_window_height", &Window_max_height);
51
#else
52
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/hide_floatwin_when_modifier_key_released", &hide_floatwin_when_modifier_key_released, true);
53
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/floating_window/lock", &bIsLocked, false);
54
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/floating_window/pronounce_when_popup", &pronounce_when_popup, false);
55
	gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/floating_window/max_window_width", &Window_max_width, DEFAULT_MAX_FLOATWIN_WIDTH);
56
	gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/floating_window/max_window_height", &Window_max_height, DEFAULT_MAX_FLOATWIN_HEIGHT);
57
#endif
58
59
	GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(FloatWindow));
48
	GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(FloatWindow));
60
	gint screen_width = gdk_screen_get_width(screen);
49
	gint screen_width = gdk_screen_get_width(screen);
61
	gint screen_height = gdk_screen_get_height(screen);
50
	gint screen_height = gdk_screen_get_height(screen);
62
51
63
	if ((Window_max_width < MIN_MAX_FLOATWIN_WIDTH)||(Window_max_width>screen_width))
52
	if (conf->get_max_window_width() < MIN_MAX_FLOATWIN_WIDTH ||
64
		Window_max_width = DEFAULT_MAX_FLOATWIN_WIDTH;
53
	    conf->get_max_window_width()>screen_width)
65
	if ((Window_max_height < MIN_MAX_FLOATWIN_HEIGHT)||(Window_max_height>screen_height))
54
		conf->set_max_window_width(DEFAULT_MAX_FLOATWIN_WIDTH);
66
		Window_max_height = DEFAULT_MAX_FLOATWIN_HEIGHT;
55
	if (conf->get_max_window_height() < MIN_MAX_FLOATWIN_HEIGHT ||
56
	    conf->get_max_window_height()>screen_height)
57
		conf->set_max_window_height(DEFAULT_MAX_FLOATWIN_HEIGHT);
67
	
58
	
68
	gint lock_x,lock_y;
59
	gint 
69
#ifdef _WIN32
60
	  lock_x=conf->get_lock_x(),
70
	rw_cfg_read_int (usercfgfile, "preferences/floating_window", "lock_x", &lock_x);
61
	  lock_y=conf->get_lock_y();     
71
	rw_cfg_read_int (usercfgfile, "preferences/floating_window", "lock_y", &lock_y);
72
#else
73
	gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/floating_window/lock_x", &lock_x, 0);
74
	gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/floating_window/lock_y", &lock_y, 0);
75
#endif
76
62
77
	if (lock_x<0)
63
	if (lock_x<0)
78
		lock_x=0;
64
		lock_x=0;
79
	else if (lock_x > (screen_width - Window_max_width))
65
	else if (lock_x > (screen_width - conf->get_max_window_width()))
80
		lock_x = screen_width - Window_max_width;
66
		lock_x = screen_width - conf->get_max_window_width();
81
	if (lock_y<0)
67
	if (lock_y<0)
82
		lock_y=0;
68
		lock_y=0;
83
	else if (lock_y > (screen_height - Window_max_height))
69
	else if (lock_y > (screen_height - conf->get_max_window_height()))
84
		lock_y = screen_height - Window_max_height;
70
		lock_y = screen_height - conf->get_max_window_height();
85
	gtk_window_move(GTK_WINDOW(FloatWindow),lock_x,lock_y);
71
	gtk_window_move(GTK_WINDOW(FloatWindow),lock_x,lock_y);
86
	
72
	
87
	GtkWidget *frame;
73
	GtkWidget *frame;
Lines 130-141 Link Here
130
	g_signal_connect(G_OBJECT(StopButton),"enter_notify_event", G_CALLBACK(stardict_on_enter_notify), NULL);
116
	g_signal_connect(G_OBJECT(StopButton),"enter_notify_event", G_CALLBACK(stardict_on_enter_notify), NULL);
131
	gtk_box_pack_start(GTK_BOX(button_hbox),StopButton,false,false,0);
117
	gtk_box_pack_start(GTK_BOX(button_hbox),StopButton,false,false,0);
132
	gtk_tooltips_set_tip(gpAppFrame->oAppCore.tooltips, StopButton, _("Stop selection scanning"),NULL);
118
	gtk_tooltips_set_tip(gpAppFrame->oAppCore.tooltips, StopButton, _("Stop selection scanning"),NULL);
133
	gboolean scan;
119
	gboolean scan=conf->get_scan_selection();
134
#ifdef _WIN32
120
135
	rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "scan_selection", &scan);
136
#else
137
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/scan_selection", &scan, true);
138
#endif
139
	gtk_widget_set_sensitive(gpAppFrame->oAppCore.oFloatWin.StopButton, scan);
121
	gtk_widget_set_sensitive(gpAppFrame->oAppCore.oFloatWin.StopButton, scan);
140
122
141
	button= gtk_button_new();
123
	button= gtk_button_new();
Lines 155-161 Link Here
155
	gtk_tooltips_set_tip(gpAppFrame->oAppCore.tooltips,button,_("Quit"),NULL);
137
	gtk_tooltips_set_tip(gpAppFrame->oAppCore.tooltips,button,_("Quit"),NULL);
156
138
157
	button = gtk_button_new();
139
	button = gtk_button_new();
158
	if (bIsLocked)
140
	if (conf->get_lock())
159
		lock_image= gtk_image_new_from_stock(GTK_STOCK_GOTO_LAST,GTK_ICON_SIZE_MENU);
141
		lock_image= gtk_image_new_from_stock(GTK_STOCK_GOTO_LAST,GTK_ICON_SIZE_MENU);
160
	else
142
	else
161
		lock_image= gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_MENU);
143
		lock_image= gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_MENU);
Lines 294-300 Link Here
294
	gtk_widget_set_sensitive(PronounceWordButton, canRead);	
276
	gtk_widget_set_sensitive(PronounceWordButton, canRead);	
295
	Popup(true);
277
	Popup(true);
296
278
297
	if (canRead && pronounce_when_popup)
279
	if (canRead && conf->get_pronounce_when_popup())
298
		gpAppFrame->oReadWord.read(PronounceWord.c_str());
280
		gpAppFrame->oReadWord.read(PronounceWord.c_str());
299
}
281
}
300
282
Lines 427-433 Link Here
427
409
428
	Popup(false);
410
	Popup(false);
429
	
411
	
430
	if (canRead && pronounce_when_popup)
412
	if (canRead && conf->get_pronounce_when_popup())
431
		gpAppFrame->oReadWord.read(PronounceWord.c_str());
413
		gpAppFrame->oReadWord.read(PronounceWord.c_str());
432
}
414
}
433
415
Lines 458-464 Link Here
458
	g_free(m_word);
440
	g_free(m_word);
459
	g_free(m_reason);
441
	g_free(m_reason);
460
442
461
	if (canRead && pronounce_when_popup)
443
	if (canRead && conf->get_pronounce_when_popup())
462
		gpAppFrame->oReadWord.read(PronounceWord.c_str());
444
		gpAppFrame->oReadWord.read(PronounceWord.c_str());
463
}
445
}
464
446
Lines 478-491 Link Here
478
460
479
	GtkRequisition requisition;
461
	GtkRequisition requisition;
480
	gtk_widget_size_request(label,&requisition);
462
	gtk_widget_size_request(label,&requisition);
481
	if (requisition.width > Window_max_width) {
463
	if (requisition.width > conf->get_max_window_width()) {
482
		gtk_widget_set_size_request(label, Window_max_width, -1); // it is not really max window width setting.
464
		gtk_widget_set_size_request(label, conf->get_max_window_width(), -1); // it is not really max window width setting.
483
		gtk_label_set_line_wrap (GTK_LABEL (label), true);		
465
		gtk_label_set_line_wrap (GTK_LABEL (label), true);		
484
		gtk_widget_size_request(label,&requisition); //update requisition.
466
		gtk_widget_size_request(label,&requisition); //update requisition.
485
	}
467
	}
486
	gint window_width,window_height;
468
	gint window_width,window_height;
487
	window_width = 2*(FLOATWIN_BORDER_WIDTH+2) + requisition.width; // 2 is the frame 's width.or get it by gtk function? i am lazy,hoho
469
	window_width = 2*(FLOATWIN_BORDER_WIDTH+2) + requisition.width; // 2 is the frame 's width.or get it by gtk function? i am lazy,hoho
488
	if (requisition.height > Window_max_height) {
470
	if (requisition.height > conf->get_max_window_height()) {
489
		static gint vscrollbar_width = 0;
471
		static gint vscrollbar_width = 0;
490
		if (!vscrollbar_width) {
472
		if (!vscrollbar_width) {
491
			if (GTK_SCROLLED_WINDOW(scrolled_window)->vscrollbar) {
473
			if (GTK_SCROLLED_WINDOW(scrolled_window)->vscrollbar) {
Lines 497-504 Link Here
497
				vscrollbar_width += scrollbar_spacing;
479
				vscrollbar_width += scrollbar_spacing;
498
			}
480
			}
499
		}
481
		}
500
		gtk_widget_set_size_request(scrolled_window, requisition.width + vscrollbar_width, Window_max_height);
482
		gtk_widget_set_size_request(scrolled_window, requisition.width + vscrollbar_width, conf->get_max_window_height());
501
		window_height = 2*(FLOATWIN_BORDER_WIDTH+2) + Window_max_height;
483
		window_height = 2*(FLOATWIN_BORDER_WIDTH+2) + conf->get_max_window_height();
502
		window_width += vscrollbar_width;
484
		window_width += vscrollbar_width;
503
	}
485
	}
504
	else {
486
	else {
Lines 513-519 Link Here
513
			window_width = (button_hbox->allocation).width + 2*(FLOATWIN_BORDER_WIDTH+2);
495
			window_width = (button_hbox->allocation).width + 2*(FLOATWIN_BORDER_WIDTH+2);
514
	}	
496
	}	
515
497
516
	if (bIsLocked) {
498
	if (conf->get_lock()) {
517
		gtk_window_resize(GTK_WINDOW(FloatWindow),window_width,window_height);
499
		gtk_window_resize(GTK_WINDOW(FloatWindow),window_width,window_height);
518
		now_window_width = window_width;
500
		now_window_width = window_width;
519
		now_window_height = window_height;
501
		now_window_height = window_height;
Lines 533-539 Link Here
533
			gdk_display_get_pointer(display,NULL,&iCurrentX,&iCurrentY, &mask);
515
			gdk_display_get_pointer(display,NULL,&iCurrentX,&iCurrentY, &mask);
534
			
516
			
535
			gboolean pressed = false;
517
			gboolean pressed = false;
536
			switch (gpAppFrame->oAppCore.oSelection.scan_modifier_key) {
518
			switch (conf->get_scan_modifier_key()) {
537
#ifdef _WIN32
519
#ifdef _WIN32
538
				case 0:
520
				case 0:
539
					if (mask & GDK_SHIFT_MASK)
521
					if (mask & GDK_SHIFT_MASK)
Lines 630-637 Link Here
630
{
612
{
631
	FloatWin *oFloatWin = (FloatWin *)data;
613
	FloatWin *oFloatWin = (FloatWin *)data;
632
	
614
	
633
    if((!oFloatWin->bIsLocked) && (!oFloatWin->ismoving) && (GTK_WIDGET_VISIBLE(oFloatWin->FloatWindow)))
615
    if(!conf->get_lock() && (!oFloatWin->ismoving) && 
634
    {
616
       (GTK_WIDGET_VISIBLE(oFloatWin->FloatWindow))) {
635
		GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(oFloatWin->FloatWindow));
617
		GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(oFloatWin->FloatWindow));
636
		GdkDisplay *display = gdk_screen_get_display(screen);
618
		GdkDisplay *display = gdk_screen_get_display(screen);
637
619
Lines 639-648 Link Here
639
		GdkModifierType mask;
621
		GdkModifierType mask;
640
		gdk_display_get_pointer(display,NULL,&iCurrentX,&iCurrentY, &mask);
622
		gdk_display_get_pointer(display,NULL,&iCurrentX,&iCurrentY, &mask);
641
623
642
		if (gpAppFrame->oAppCore.oSelection.only_scan_while_modifier_key && oFloatWin->hide_floatwin_when_modifier_key_released) {
624
		if (conf->get_only_scan_while_modifier_key() && 
625
		    conf->get_hide_floatwin_when_modifier_key_released()) {
643
			if (iCurrentX == oFloatWin->popup_pointer_x && iCurrentY==oFloatWin->popup_pointer_y) {
626
			if (iCurrentX == oFloatWin->popup_pointer_x && iCurrentY==oFloatWin->popup_pointer_y) {
644
				gboolean released = false;
627
				gboolean released = false;
645
				switch (gpAppFrame->oAppCore.oSelection.scan_modifier_key) {
628
				switch (conf->get_scan_modifier_key()) {
646
#ifdef _WIN32
629
#ifdef _WIN32
647
					case 0:
630
					case 0:
648
						if (!(mask & GDK_SHIFT_MASK))
631
						if (!(mask & GDK_SHIFT_MASK))
Lines 655-661 Link Here
655
					default:
638
					default:
656
						if (!(mask & GDK_CONTROL_MASK))
639
						if (!(mask & GDK_CONTROL_MASK))
657
							released = true;
640
							released = true;
658
						break;
659
#else
641
#else
660
					case 0:
642
					case 0:
661
						if (!(mask & GDK_MOD4_MASK))
643
						if (!(mask & GDK_MOD4_MASK))
Lines 672-678 Link Here
672
					default:
654
					default:
673
						if (!(mask & GDK_CONTROL_MASK))
655
						if (!(mask & GDK_CONTROL_MASK))
674
							released = true;
656
							released = true;
675
						break;
676
#endif
657
#endif
677
				}
658
				}
678
				if (released) {
659
				if (released) {
Lines 723-729 Link Here
723
    } // to be hidden
704
    } // to be hidden
724
705
725
    /*if ( (bIsSavedWordItemValid||bIsSavedMessageValid)
706
    /*if ( (bIsSavedWordItemValid||bIsSavedMessageValid)
726
          && !bIsLocked && !bInMoving )
707
          && !conf->get_lock() && !bInMoving )
727
    {
708
    {
728
        int iCurrentShowStates = iGetShowLevel();
709
        int iCurrentShowStates = iGetShowLevel();
729
        if ( bIsSavedMessageValid && iCurrentShowStates!=FLOAT_SHOW_LEVEL_NONE)
710
        if ( bIsSavedMessageValid && iCurrentShowStates!=FLOAT_SHOW_LEVEL_NONE)
Lines 927-933 Link Here
927
			
908
			
928
			gtk_widget_show_all(oFloatWin->menu);
909
			gtk_widget_show_all(oFloatWin->menu);
929
			gtk_menu_popup(GTK_MENU(oFloatWin->menu), NULL, NULL, NULL, NULL, event->button, event->time);
910
			gtk_menu_popup(GTK_MENU(oFloatWin->menu), NULL, NULL, NULL, NULL, event->button, event->time);
930
			if (gpAppFrame->enable_sound_event) {
911
			if (conf->get_enable_sound_event()) {
931
#ifdef _WIN32
912
#ifdef _WIN32
932
				gchar *filename = g_build_filename(stardict_data_dir, "sounds", "menushow.wav", NULL);
913
				gchar *filename = g_build_filename(stardict_data_dir, "sounds", "menushow.wav", NULL);
933
				PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
914
				PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 994-1000 Link Here
994
975
995
void FloatWin::on_query_click(GtkWidget *widget, gpointer data)
976
void FloatWin::on_query_click(GtkWidget *widget, gpointer data)
996
{
977
{
997
	if (gpAppFrame->enable_sound_event) {
978
	if (conf->get_enable_sound_event()) {
998
#ifdef _WIN32
979
#ifdef _WIN32
999
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
980
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1000
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
981
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 1003-1009 Link Here
1003
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
984
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1004
#endif
985
#endif
1005
	}
986
	}
1006
	if (!gpAppFrame->oAppCore.oFloatWin.bIsLocked)
987
	if (!conf->get_lock())
1007
		gpAppFrame->oAppCore.oFloatWin.Hide();
988
		gpAppFrame->oAppCore.oFloatWin.Hide();
1008
	gpAppFrame->oAppCore.Query(gpAppFrame->oAppCore.oFloatWin.QueryingWord.c_str());	
989
	gpAppFrame->oAppCore.Query(gpAppFrame->oAppCore.oFloatWin.QueryingWord.c_str());	
1009
#ifdef _WIN32
990
#ifdef _WIN32
Lines 1015-1021 Link Here
1015
996
1016
void FloatWin::on_copy_click(GtkWidget *widget, gpointer data)
997
void FloatWin::on_copy_click(GtkWidget *widget, gpointer data)
1017
{
998
{
1018
	if (gpAppFrame->enable_sound_event) {
999
	if (conf->get_enable_sound_event()) {
1019
#ifdef _WIN32
1000
#ifdef _WIN32
1020
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1001
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1021
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1002
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 1036-1042 Link Here
1036
1017
1037
void FloatWin::on_stop_click(GtkWidget *widget, gpointer data)
1018
void FloatWin::on_stop_click(GtkWidget *widget, gpointer data)
1038
{
1019
{
1039
	if (gpAppFrame->enable_sound_event) {
1020
	if (conf->get_enable_sound_event()) {
1040
#ifdef _WIN32
1021
#ifdef _WIN32
1041
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1022
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1042
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1023
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 1045-1061 Link Here
1045
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1026
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1046
#endif
1027
#endif
1047
	}
1028
	}
1048
#ifdef _WIN32
1029
	conf->set_scan_selection(FALSE);
1049
	rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "scan_selection", false);
1050
	on_conf_dictionary_scan_selection_changed(false);
1051
#else
1052
	gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/scan_selection", false);
1053
#endif
1054
}
1030
}
1055
1031
1056
void FloatWin::on_help_click(GtkWidget *widget, gpointer data)
1032
void FloatWin::on_help_click(GtkWidget *widget, gpointer data)
1057
{
1033
{
1058
	if (gpAppFrame->enable_sound_event) {
1034
	if (conf->get_enable_sound_event()) {
1059
#ifdef _WIN32
1035
#ifdef _WIN32
1060
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1036
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1061
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1037
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 1064-1070 Link Here
1064
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1040
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1065
#endif
1041
#endif
1066
	}
1042
	}
1067
	if (!gpAppFrame->oAppCore.oFloatWin.bIsLocked)
1043
	if (!conf->get_lock())
1068
		gpAppFrame->oAppCore.oFloatWin.Hide();
1044
		gpAppFrame->oAppCore.oFloatWin.Hide();
1069
#ifdef _WIN32
1045
#ifdef _WIN32
1070
	//gchar *filename = g_strdup_printf(_("file:///%s/help/C/stardict.html#stardict-scan-selection"), stardict_data_dir);
1046
	//gchar *filename = g_strdup_printf(_("file:///%s/help/C/stardict.html#stardict-scan-selection"), stardict_data_dir);
Lines 1078-1084 Link Here
1078
1054
1079
void FloatWin::on_quit_click(GtkWidget *widget, gpointer data)
1055
void FloatWin::on_quit_click(GtkWidget *widget, gpointer data)
1080
{
1056
{
1081
	if (gpAppFrame->enable_sound_event) {
1057
	if (conf->get_enable_sound_event()) {
1082
#ifdef _WIN32
1058
#ifdef _WIN32
1083
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1059
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1084
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1060
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 1092-1098 Link Here
1092
1068
1093
void FloatWin::vLockCallback(GtkWidget *widget, FloatWin *oFloatWin)
1069
void FloatWin::vLockCallback(GtkWidget *widget, FloatWin *oFloatWin)
1094
{
1070
{
1095
	if (gpAppFrame->enable_sound_event) {
1071
	if (conf->get_enable_sound_event()) {
1096
#ifdef _WIN32
1072
#ifdef _WIN32
1097
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1073
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1098
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1074
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 1101-1110 Link Here
1101
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1077
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1102
#endif
1078
#endif
1103
	}
1079
	}
1104
#ifdef _WIN32
1080
	conf->set_lock(!conf->get_lock());
1105
	rw_cfg_write_boolean (usercfgfile, "preferences/floating_window", "lock", !(oFloatWin->bIsLocked));
1106
	on_conf_floatwin_lock_changed(!(oFloatWin->bIsLocked));
1107
#else
1108
	gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/floating_window/lock", !(oFloatWin->bIsLocked));
1109
#endif
1110
}
1081
}
(-)stardict-2.4.4.orig/src/floatwin.h (-4 lines)
Lines 56-65 Link Here
56
	std::string QueryingWord;
56
	std::string QueryingWord;
57
	std::string PronounceWord;
57
	std::string PronounceWord;
58
	FloatWinQueryResult found_result;
58
	FloatWinQueryResult found_result;
59
	gboolean bIsLocked;
60
	gboolean hide_floatwin_when_modifier_key_released;
61
	gboolean pronounce_when_popup;
62
	gint Window_max_width,Window_max_height;
63
	GtkWidget *FloatWindow,*label,*lock_image,*button_hbox,*scrolled_window;
59
	GtkWidget *FloatWindow,*label,*lock_image,*button_hbox,*scrolled_window;
64
	GtkWidget *PronounceWordButton, *StopButton;
60
	GtkWidget *PronounceWordButton, *StopButton;
65
	GtkWidget *menu;
61
	GtkWidget *menu;
(-)stardict-2.4.4.orig/src/lib.cpp (-36 / +9 lines)
Lines 597-603 Link Here
597
	return (oLib[iLib]->LookupWithRule(pspec,aiIndexes,iLen));
597
	return (oLib[iLib]->LookupWithRule(pspec,aiIndexes,iLen));
598
}
598
}
599
599
600
void Libs::LoadDir(gchar *dirname, GSList *order_list, GSList *disable_list)
600
void Libs::LoadDir(gchar *dirname, const GSList *order_list, const GSList *disable_list)
601
{	
601
{	
602
	GDir *dir = g_dir_open(dirname, 0, NULL);	
602
	GDir *dir = g_dir_open(dirname, 0, NULL);	
603
	if (dir)
603
	if (dir)
Lines 606-612 Link Here
606
		gchar fullfilename[256];
606
		gchar fullfilename[256];
607
		Lib *lib;
607
		Lib *lib;
608
		gboolean loaded;
608
		gboolean loaded;
609
		GSList *tmplist1,*tmplist2;
609
		const GSList *tmplist1,*tmplist2;
610
		gboolean disabled;
610
		gboolean disabled;
611
		while ((filename = g_dir_read_name(dir))!=NULL)
611
		while ((filename = g_dir_read_name(dir))!=NULL)
612
		{	
612
		{	
Lines 656-673 Link Here
656
	}	
656
	}	
657
}
657
}
658
658
659
void Libs::Load()
659
void Libs::Load(const GSList *order_list, const GSList *disable_list)
660
{
660
{
661
	GSList *order_list, *disable_list;
661
662
#ifdef _WIN32
663
	rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "dict_order_list", &order_list);
664
	rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "dict_disable_list", &disable_list);
665
#else
666
	gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/dict_order_list", GCONF_VALUE_STRING, &order_list);
667
	gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/dict_disable_list", GCONF_VALUE_STRING, &disable_list);
668
#endif
669
	gchar *idxfilename;
662
	gchar *idxfilename;
670
	GSList *tmplist1,*tmplist2;
663
  const GSList *tmplist1,*tmplist2;
671
	gboolean disabled;
664
	gboolean disabled;
672
	Lib *lib;
665
	Lib *lib;
673
	tmplist1 = order_list;	
666
	tmplist1 = order_list;	
Lines 707-718 Link Here
707
	LoadDir(home_dir, order_list, disable_list);
700
	LoadDir(home_dir, order_list, disable_list);
708
	LoadDir(STARDICT_DATA_DIR "/dic", order_list, disable_list);
701
	LoadDir(STARDICT_DATA_DIR "/dic", order_list, disable_list);
709
#endif
702
#endif
710
711
	g_slist_foreach (order_list, (GFunc)g_free, NULL);
712
	g_slist_free(order_list);
713
	
714
	g_slist_foreach (disable_list, (GFunc)g_free, NULL);
715
	g_slist_free(disable_list);	
716
}
703
}
717
704
718
gchar *
705
gchar *
Lines 1362-1381 Link Here
1362
	}
1349
	}
1363
}
1350
}
1364
1351
1365
GtkTreeStore* TreeDicts::Load()
1352
GtkTreeStore* TreeDicts::Load(const GSList *order_list, const GSList *disable_list)
1366
{
1353
{
1367
	GtkTreeStore *model = gtk_tree_store_new (3, G_TYPE_STRING, G_TYPE_LONG, G_TYPE_LONG); //word, offset, size
1354
	GtkTreeStore *model = gtk_tree_store_new (3, G_TYPE_STRING, G_TYPE_LONG, G_TYPE_LONG); //word, offset, size
1368
	
1355
	
1369
	GSList *order_list, *disable_list;
1370
#ifdef _WIN32
1371
	rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "treedict_order_list", &order_list);
1372
	rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "treedict_disable_list", &disable_list);
1373
#else
1374
	gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/treedict_order_list", GCONF_VALUE_STRING, &order_list);
1375
	gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/treedict_disable_list", GCONF_VALUE_STRING, &disable_list);
1376
#endif
1377
	gchar *ifofilename;
1356
	gchar *ifofilename;
1378
	GSList *tmplist1,*tmplist2;
1357
	const GSList *tmplist1,*tmplist2;
1379
	gboolean disabled;
1358
	gboolean disabled;
1380
	TreeDict *lib;
1359
	TreeDict *lib;
1381
	tmplist1 = order_list;	
1360
	tmplist1 = order_list;	
Lines 1416-1431 Link Here
1416
	LoadDir(STARDICT_DATA_DIR "/treedict", order_list, disable_list, model);
1395
	LoadDir(STARDICT_DATA_DIR "/treedict", order_list, disable_list, model);
1417
#endif
1396
#endif
1418
	
1397
	
1419
	g_slist_foreach (order_list, (GFunc)g_free, NULL);
1420
	g_slist_free(order_list);
1421
	
1422
	g_slist_foreach (disable_list, (GFunc)g_free, NULL);
1423
	g_slist_free(disable_list);	
1424
1425
	return model;
1398
	return model;
1426
}
1399
}
1427
1400
1428
void TreeDicts::LoadDir(gchar *dirname, GSList *order_list, GSList *disable_list, GtkTreeStore *model)
1401
void TreeDicts::LoadDir(gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkTreeStore *model)
1429
{
1402
{
1430
	GDir *dir = g_dir_open(dirname, 0, NULL);	
1403
	GDir *dir = g_dir_open(dirname, 0, NULL);	
1431
	if (dir)
1404
	if (dir)
Lines 1434-1440 Link Here
1434
		gchar fullfilename[256];
1407
		gchar fullfilename[256];
1435
		TreeDict *lib;
1408
		TreeDict *lib;
1436
		gboolean loaded;
1409
		gboolean loaded;
1437
		GSList *tmplist1,*tmplist2;
1410
		const GSList *tmplist1,*tmplist2;
1438
		gboolean disabled;
1411
		gboolean disabled;
1439
		while ((filename = g_dir_read_name(dir))!=NULL)
1412
		while ((filename = g_dir_read_name(dir))!=NULL)
1440
		{	
1413
		{	
(-)stardict-2.4.4.orig/src/lib.h (-4 / +4 lines)
Lines 87-97 Link Here
87
	Lib **oLib; // word library.
87
	Lib **oLib; // word library.
88
	gint libcount;
88
	gint libcount;
89
	
89
	
90
	void LoadDir(gchar *dirname, GSList *order_list, GSList *disable_list);
90
	void LoadDir(gchar *dirname, const GSList *order_list, const GSList *disable_list);
91
public:
91
public:
92
	Libs();
92
	Libs();
93
	~Libs();
93
	~Libs();
94
	void Load();
94
	void Load(const GSList *order_list, const GSList *disable_list);
95
	glong iLength(int iLib);
95
	glong iLength(int iLib);
96
	gchar* GetBookname(int iLib);
96
	gchar* GetBookname(int iLib);
97
	inline gint total_libs() { return(libcount); }
97
	inline gint total_libs() { return(libcount); }
Lines 122-134 Link Here
122
public:
122
public:
123
	TreeDicts();
123
	TreeDicts();
124
	~TreeDicts();
124
	~TreeDicts();
125
	GtkTreeStore* Load();
125
	GtkTreeStore* Load(const GSList *order_list, const GSList *disable_list);
126
	gchar * poGetWordData(glong offset, glong size, int iTreeDict);
126
	gchar * poGetWordData(glong offset, glong size, int iTreeDict);
127
private:
127
private:
128
	TreeDict **oTreeDict;
128
	TreeDict **oTreeDict;
129
	gint treedictcount;
129
	gint treedictcount;
130
	
130
	
131
	void LoadDir(gchar *dirname, GSList *order_list, GSList *disable_list, GtkTreeStore *model);	
131
	void LoadDir(gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkTreeStore *model);	
132
};
132
};
133
133
134
#endif
134
#endif
(-)stardict-2.4.4.orig/src/mainwin.cpp (-81 / +32 lines)
Lines 2-11 Link Here
2
#  include "config.h"
2
#  include "config.h"
3
#endif
3
#endif
4
4
5
#include "mainwin.h"
6
#include "stardict.h"
7
8
9
#ifndef _WIN32
5
#ifndef _WIN32
10
#  include <libgnome/libgnome.h>
6
#  include <libgnome/libgnome.h>
11
#  include <libgnomeui/libgnomeui.h>
7
#  include <libgnomeui/libgnomeui.h>
Lines 18-23 Link Here
18
#  include <gdk/gdkwin32.h>
14
#  include <gdk/gdkwin32.h>
19
#endif
15
#endif
20
16
17
#include "stardict.h"
18
#include "conf.h"
19
20
#include "mainwin.h"
21
21
22
#define STARDICT_RESPONSE_FIND 100
22
#define STARDICT_RESPONSE_FIND 100
23
23
Lines 207-213 Link Here
207
207
208
void TopWin::ClearCallback(GtkWidget *widget, TopWin *oTopWin)
208
void TopWin::ClearCallback(GtkWidget *widget, TopWin *oTopWin)
209
{
209
{
210
	if (gpAppFrame->enable_sound_event) {
210
	if (conf->get_enable_sound_event()) {
211
#ifdef _WIN32
211
#ifdef _WIN32
212
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
212
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
213
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
213
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 224-230 Link Here
224
224
225
void TopWin::GoCallback(GtkWidget *widget, TopWin *oTopWin)
225
void TopWin::GoCallback(GtkWidget *widget, TopWin *oTopWin)
226
{
226
{
227
	if (gpAppFrame->enable_sound_event) {
227
	if (conf->get_enable_sound_event()) {
228
#ifdef _WIN32
228
#ifdef _WIN32
229
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
229
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
230
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
230
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 276-282 Link Here
276
276
277
void TopWin::BackCallback(GtkWidget *widget, TopWin *oTopWin)
277
void TopWin::BackCallback(GtkWidget *widget, TopWin *oTopWin)
278
{
278
{
279
	if (gpAppFrame->enable_sound_event) {
279
	if (conf->get_enable_sound_event()) {
280
#ifdef _WIN32
280
#ifdef _WIN32
281
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
281
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
282
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
282
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 348-354 Link Here
348
348
349
void TopWin::PreviousCallback(GtkWidget *widget, TopWin *oTopWin)
349
void TopWin::PreviousCallback(GtkWidget *widget, TopWin *oTopWin)
350
{	
350
{	
351
	if (gpAppFrame->enable_sound_event) {
351
	if (conf->get_enable_sound_event()) {
352
#ifdef _WIN32
352
#ifdef _WIN32
353
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
353
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
354
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
354
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 428-434 Link Here
428
428
429
void TopWin::NextCallback(GtkWidget *widget, TopWin *oTopWin)
429
void TopWin::NextCallback(GtkWidget *widget, TopWin *oTopWin)
430
{
430
{
431
	if (gpAppFrame->enable_sound_event) {
431
	if (conf->get_enable_sound_event()) {
432
#ifdef _WIN32
432
#ifdef _WIN32
433
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
433
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
434
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
434
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 510-516 Link Here
510
510
511
void TopWin::do_menu()
511
void TopWin::do_menu()
512
{
512
{
513
	if (gpAppFrame->enable_sound_event) {
513
	if (conf->get_enable_sound_event()) {
514
#ifdef _WIN32
514
#ifdef _WIN32
515
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "menushow.wav", NULL);
515
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "menushow.wav", NULL);
516
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
516
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 855-861 Link Here
855
855
856
void TreeWin::Create(GtkWidget *notebook)
856
void TreeWin::Create(GtkWidget *notebook)
857
{
857
{
858
	GtkTreeStore *model = gpAppFrame->oAppCore.oTreeDicts.Load();
858
	GtkTreeStore *model = gpAppFrame->oAppCore.oTreeDicts.Load(conf->get_treedict_order_list(),
859
								   conf->get_treedict_disable_list());
859
	treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL(model));
860
	treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL(model));
860
	gtk_widget_show(treeview);
861
	gtk_widget_show(treeview);
861
	g_object_unref (model);
862
	g_object_unref (model);
Lines 953-964 Link Here
953
void IndexWin::Create(GtkWidget *hpaned)
954
void IndexWin::Create(GtkWidget *hpaned)
954
{
955
{
955
	vbox = gtk_vbox_new(false, 3);
956
	vbox = gtk_vbox_new(false, 3);
956
	gboolean hide;
957
	gboolean hide=conf->get_hide_list();
957
#ifdef _WIN32
958
958
	rw_cfg_read_boolean (usercfgfile, "preferences/main_window", "hide_list", &hide);
959
#else
960
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/main_window/hide_list",&hide,false);
961
#endif	
962
	if (!hide)
959
	if (!hide)
963
		gtk_widget_show(vbox);
960
		gtk_widget_show(vbox);
964
	
961
	
Lines 1060-1071 Link Here
1060
	gtk_box_pack_start(GTK_BOX(hbox),HideListButton,false,false,5);
1057
	gtk_box_pack_start(GTK_BOX(hbox),HideListButton,false,false,5);
1061
	gtk_tooltips_set_tip(gpAppFrame->oAppCore.tooltips, HideListButton,_("Hide the word list"),NULL);
1058
	gtk_tooltips_set_tip(gpAppFrame->oAppCore.tooltips, HideListButton,_("Hide the word list"),NULL);
1062
1059
1063
	gboolean hide;
1060
	gboolean hide=conf->get_hide_list();
1064
#ifdef _WIN32
1061
1065
	rw_cfg_read_boolean (usercfgfile, "preferences/main_window", "hide_list", &hide);
1066
#else
1067
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/main_window/hide_list", &hide, false);
1068
#endif	
1069
	if (hide) {
1062
	if (hide) {
1070
		gtk_widget_show(ShowListButton);
1063
		gtk_widget_show(ShowListButton);
1071
	}
1064
	}
Lines 1128-1149 Link Here
1128
1121
1129
void ToolWin::ShowListCallback(GtkWidget *widget, gpointer data)
1122
void ToolWin::ShowListCallback(GtkWidget *widget, gpointer data)
1130
{
1123
{
1131
#ifdef _WIN32
1124
  conf->set_hide_list(FALSE);
1132
	rw_cfg_write_boolean (usercfgfile, "preferences/main_window", "hide_list", false);
1133
	on_conf_main_window_hide_list_changed(false);
1134
#else
1135
	gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/main_window/hide_list",false);
1136
#endif
1137
}
1125
}
1138
1126
1139
void ToolWin::HideListCallback(GtkWidget *widget, gpointer data)
1127
void ToolWin::HideListCallback(GtkWidget *widget, gpointer data)
1140
{
1128
{
1141
#ifdef _WIN32
1129
  conf->set_hide_list(TRUE);
1142
	rw_cfg_write_boolean (usercfgfile, "preferences/main_window", "hide_list", true);
1143
	on_conf_main_window_hide_list_changed(true);
1144
#else
1145
	gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/main_window/hide_list",true);
1146
#endif
1147
}
1130
}
1148
1131
1149
void ToolWin::CopyCallback(GtkWidget *widget, ToolWin *oToolWin)
1132
void ToolWin::CopyCallback(GtkWidget *widget, ToolWin *oToolWin)
Lines 1627-1638 Link Here
1627
	oToolWin.Create(vbox1);
1610
	oToolWin.Create(vbox1);
1628
	oTextWin.Create(vbox1);	
1611
	oTextWin.Create(vbox1);	
1629
	
1612
	
1630
	gint pos;
1613
	gint pos=conf->get_hpaned_pos();
1631
#ifdef _WIN32
1614
1632
	rw_cfg_read_int (usercfgfile, "preferences/main_window", "hpaned_pos", &pos);
1633
#else
1634
	gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/main_window/hpaned_pos", &pos, DEFAULT_HPANED_POS);
1635
#endif
1636
	gtk_paned_set_position(GTK_PANED(hpaned),pos);
1615
	gtk_paned_set_position(GTK_PANED(hpaned),pos);
1637
}
1616
}
1638
1617
Lines 1640-1662 Link Here
1640
/*********************************************/
1619
/*********************************************/
1641
BottomWin::BottomWin()
1620
BottomWin::BottomWin()
1642
{
1621
{
1643
	searchwebsite_list = NULL;
1644
	SearchWebsiteMenu = NULL;
1622
	SearchWebsiteMenu = NULL;
1645
}
1623
}
1646
1624
1647
BottomWin::~BottomWin()
1648
{
1649
	g_slist_foreach (searchwebsite_list, (GFunc)g_free, NULL);
1650
	g_slist_free (searchwebsite_list);
1651
}
1652
1653
void BottomWin::Create(GtkWidget *vbox)
1625
void BottomWin::Create(GtkWidget *vbox)
1654
{
1626
{
1655
#ifdef _WIN32
1627
  const GSList *searchwebsite_list=conf->get_search_website_list();
1656
	rw_cfg_read_strlist (usercfgfile, "preferences/main_window", "search_website_list", &searchwebsite_list);
1628
1657
#else
1658
	gpAppFrame->oAppConf.read_list("/apps/stardict/preferences/main_window/search_website_list", GCONF_VALUE_STRING, &searchwebsite_list);
1659
#endif	
1660
	if (!searchwebsite_list) {
1629
	if (!searchwebsite_list) {
1661
		gchar *default_website = _(""
1630
		gchar *default_website = _(""
1662
		"dict.leo.org	http://dict.leo.org	http://dict.leo.org/?search=%s&lang=en\n"
1631
		"dict.leo.org	http://dict.leo.org	http://dict.leo.org/?search=%s&lang=en\n"
Lines 1677-1691 Link Here
1677
			list = g_slist_append(list, g_strndup(p, p1-p));
1646
			list = g_slist_append(list, g_strndup(p, p1-p));
1678
			p= p1+1;
1647
			p= p1+1;
1679
		}
1648
		}
1680
#ifdef _WIN32
1649
    conf->set_search_website_list(list);
1681
		rw_cfg_write_strlist (usercfgfile, "preferences/main_window", "search_website_list", list);
1682
#else
1683
		gpAppFrame->oAppConf.write_list("/apps/stardict/preferences/main_window/search_website_list", GCONF_VALUE_STRING, list);
1684
#endif		
1685
		//as oAppConf.EnableNotify() didn't call now, we change searchwebsite_list manually;
1686
		searchwebsite_list = list;
1687
		//g_slist_foreach (list, (GFunc)g_free, NULL);
1688
		//g_slist_free(list);
1689
	}
1650
	}
1690
	
1651
	
1691
	GtkWidget *hbox = gtk_hbox_new(false,0);
1652
	GtkWidget *hbox = gtk_hbox_new(false,0);
Lines 1695-1706 Link Here
1695
	ScanSelectionCheckButton = gtk_check_button_new_with_mnemonic(_("_Scan"));
1656
	ScanSelectionCheckButton = gtk_check_button_new_with_mnemonic(_("_Scan"));
1696
	gtk_widget_show(ScanSelectionCheckButton);
1657
	gtk_widget_show(ScanSelectionCheckButton);
1697
	GTK_WIDGET_UNSET_FLAGS (ScanSelectionCheckButton, GTK_CAN_FOCUS);
1658
	GTK_WIDGET_UNSET_FLAGS (ScanSelectionCheckButton, GTK_CAN_FOCUS);
1698
	gboolean scan;
1659
  gboolean scan=conf->get_scan_selection();
1699
#ifdef _WIN32
1660
1700
	rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "scan_selection", &scan);
1701
#else
1702
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/scan_selection", &scan, true);
1703
#endif
1704
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ScanSelectionCheckButton),scan);
1661
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ScanSelectionCheckButton),scan);
1705
	g_signal_connect(G_OBJECT(ScanSelectionCheckButton),"toggled", G_CALLBACK(ScanCallback),NULL);
1662
	g_signal_connect(G_OBJECT(ScanSelectionCheckButton),"toggled", G_CALLBACK(ScanCallback),NULL);
1706
	gtk_box_pack_start(GTK_BOX(hbox),ScanSelectionCheckButton,false,false,0);
1663
	gtk_box_pack_start(GTK_BOX(hbox),ScanSelectionCheckButton,false,false,0);
Lines 1774-1791 Link Here
1774
1731
1775
void BottomWin::ScanCallback(GtkToggleButton *button, gpointer data)
1732
void BottomWin::ScanCallback(GtkToggleButton *button, gpointer data)
1776
{
1733
{
1777
#ifdef _WIN32
1734
  conf->set_scan_selection(gtk_toggle_button_get_active(button));
1778
	gboolean scan = gtk_toggle_button_get_active(button);
1779
	rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "scan_selection", scan);
1780
	on_conf_dictionary_scan_selection_changed(scan);	
1781
#else
1782
	gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/scan_selection",gtk_toggle_button_get_active(button));
1783
#endif
1784
}
1735
}
1785
1736
1786
void BottomWin::AboutCallback(GtkButton *button, gpointer data)
1737
void BottomWin::AboutCallback(GtkButton *button, gpointer data)
1787
{
1738
{
1788
	if (gpAppFrame->enable_sound_event) {
1739
	if (conf->get_enable_sound_event()) {
1789
#ifdef _WIN32
1740
#ifdef _WIN32
1790
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1741
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1791
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1742
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 1799-1805 Link Here
1799
1750
1800
void BottomWin::QuitCallback(GtkButton *button, gpointer data)
1751
void BottomWin::QuitCallback(GtkButton *button, gpointer data)
1801
{
1752
{
1802
	if (gpAppFrame->enable_sound_event) {
1753
	if (conf->get_enable_sound_event()) {
1803
#ifdef _WIN32
1754
#ifdef _WIN32
1804
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1755
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1805
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1756
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 1815-1821 Link Here
1815
{
1766
{
1816
	if (event->button == 3) {
1767
	if (event->button == 3) {
1817
	
1768
	
1818
		if (!(oBottomWin->searchwebsite_list))
1769
		if (!conf->get_search_website_list())
1819
			return true;
1770
			return true;
1820
	
1771
	
1821
		if (oBottomWin->SearchWebsiteMenu)
1772
		if (oBottomWin->SearchWebsiteMenu)
Lines 1825-1831 Link Here
1825
		
1776
		
1826
		GtkWidget *menuitem;
1777
		GtkWidget *menuitem;
1827
		gchar *p;
1778
		gchar *p;
1828
		GSList *list = oBottomWin->searchwebsite_list;
1779
		const GSList *list = conf->get_search_website_list();
1829
		while (list) {			
1780
		while (list) {			
1830
			p = strchr((gchar *)(list->data), '\t');
1781
			p = strchr((gchar *)(list->data), '\t');
1831
			if (p) {
1782
			if (p) {
Lines 1879-1887 Link Here
1879
1830
1880
void BottomWin::InternetSearchCallback(GtkButton *button, BottomWin *oBottomWin)
1831
void BottomWin::InternetSearchCallback(GtkButton *button, BottomWin *oBottomWin)
1881
{	
1832
{	
1882
	if (!oBottomWin->searchwebsite_list)
1833
	if (!conf->get_search_website_list())
1883
		return;
1834
		return;
1884
	gchar *website = (gchar *)(oBottomWin->searchwebsite_list->data);
1835
	gchar *website = (gchar *)(conf->get_search_website_list()->data);
1885
	gchar *website_link = strchr(website, '\t');
1836
	gchar *website_link = strchr(website, '\t');
1886
	if (website_link)
1837
	if (website_link)
1887
		*website_link = '\0';
1838
		*website_link = '\0';
(-)stardict-2.4.4.orig/src/mainwin.h (-2 lines)
Lines 221-231 Link Here
221
221
222
public:
222
public:
223
	GtkWidget* ScanSelectionCheckButton;
223
	GtkWidget* ScanSelectionCheckButton;
224
	GSList *searchwebsite_list;
225
	GtkWidget* SearchWebsiteMenu;
224
	GtkWidget* SearchWebsiteMenu;
226
225
227
	BottomWin();
226
	BottomWin();
228
	~BottomWin();
229
	void Create(GtkWidget *vbox);
227
	void Create(GtkWidget *vbox);
230
};
228
};
231
229
(-)stardict-2.4.4.orig/src/prefsdlg.cpp (-150 / +45 lines)
Lines 1-14 Link Here
1
#ifdef HAVE_CONFIG_H
1
#ifdef HAVE_CONFIG_H
2
#  include "config.h"
2
#  include "config.h"
3
#endif
3
#endif
4
#include "prefsdlg.h"
5
#include "stardict.h"
6
4
7
#ifdef _WIN32
5
#ifdef _WIN32
8
#  include <gdk/gdkwin32.h>
6
#  include <gdk/gdkwin32.h>
9
#  include "win32/intl.h"
7
#  include "win32/intl.h"
10
#endif
8
#endif
11
9
10
#include "stardict.h"
11
#include "conf.h"
12
13
#include "prefsdlg.h"
12
14
13
#define LOGO										0
15
#define LOGO										0
14
#define	DICTIONARY_SCAN_SETTINGS 					1
16
#define	DICTIONARY_SCAN_SETTINGS 					1
Lines 261-294 Link Here
261
{
263
{
262
	gboolean b = gtk_toggle_button_get_active (button);
264
	gboolean b = gtk_toggle_button_get_active (button);
263
	gtk_widget_set_sensitive(oPrefsDlg->scan_modifier_key_vbox,b);
265
	gtk_widget_set_sensitive(oPrefsDlg->scan_modifier_key_vbox,b);
264
#ifdef _WIN32
266
	conf->set_only_scan_while_modifier_key(b);
265
	rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "only_scan_while_modifier_key", b);
266
	on_conf_dictionary_only_scan_while_modifier_key_changed(b);
267
#else
268
	gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/only_scan_while_modifier_key", b);
269
#endif
270
}
267
}
271
268
272
void PrefsDlg::on_setup_dictionary_scan_optionmenu_changed(GtkOptionMenu *option_menu, PrefsDlg *oPrefsDlg)
269
void PrefsDlg::on_setup_dictionary_scan_optionmenu_changed(GtkOptionMenu *option_menu, PrefsDlg *oPrefsDlg)
273
{	
270
{	
274
#ifdef _WIN32	
275
	gint key = gtk_option_menu_get_history(option_menu);
271
	gint key = gtk_option_menu_get_history(option_menu);
276
	rw_cfg_write_int (usercfgfile, "preferences/dictionary", "scan_modifier_key", key);
272
  conf->set_scan_modifier_key(key);
277
	on_conf_dictionary_scan_modifier_key_changed(key);
278
#else
279
	gpAppFrame->oAppConf.write_int("/apps/stardict/preferences/dictionary/scan_modifier_key", gtk_option_menu_get_history(option_menu));	
280
#endif
281
}
273
}
282
274
283
void PrefsDlg::on_setup_dictionary_scan_hide_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg)
275
void PrefsDlg::on_setup_dictionary_scan_hide_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg)
284
{
276
{
285
#ifdef _WIN32
286
	gboolean hide = gtk_toggle_button_get_active(button);
277
	gboolean hide = gtk_toggle_button_get_active(button);
287
	rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "hide_floatwin_when_modifier_key_released", hide);
278
  conf->set_hide_floatwin_when_modifier_key_released(hide);
288
	on_conf_dictionary_hide_floatwin_when_modifier_key_released_changed(hide);
289
#else
290
	gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/hide_floatwin_when_modifier_key_released", gtk_toggle_button_get_active(button));
291
#endif
292
}
279
}
293
280
294
void PrefsDlg::setup_dictionary_scan_page()
281
void PrefsDlg::setup_dictionary_scan_page()
Lines 317-328 Link Here
317
	gtk_box_pack_start(GTK_BOX(vbox),vbox1,false,false, 0);
304
	gtk_box_pack_start(GTK_BOX(vbox),vbox1,false,false, 0);
318
	GtkWidget *check_button = gtk_check_button_new_with_mnemonic(_("_Only do scanning while modifier key being pressed."));
305
	GtkWidget *check_button = gtk_check_button_new_with_mnemonic(_("_Only do scanning while modifier key being pressed."));
319
	gtk_box_pack_start(GTK_BOX(vbox1),check_button,false,false,0);
306
	gtk_box_pack_start(GTK_BOX(vbox1),check_button,false,false,0);
320
	gboolean only_scan_while_modifier_key;
307
	gboolean only_scan_while_modifier_key=conf->get_only_scan_while_modifier_key();
321
#ifdef _WIN32
308
322
	rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "only_scan_while_modifier_key", &only_scan_while_modifier_key);
323
#else
324
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/only_scan_while_modifier_key", &only_scan_while_modifier_key, false);	
325
#endif
326
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),only_scan_while_modifier_key);
309
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),only_scan_while_modifier_key);
327
	g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_dictionary_scan_ckbutton_toggled), this);		
310
	g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_dictionary_scan_ckbutton_toggled), this);		
328
	
311
	
Lines 332-343 Link Here
332
315
333
	check_button = gtk_check_button_new_with_mnemonic(_("H_ide floating window when modifier key released."));
316
	check_button = gtk_check_button_new_with_mnemonic(_("H_ide floating window when modifier key released."));
334
	gtk_box_pack_start(GTK_BOX(scan_modifier_key_vbox),check_button,false,false,0);	
317
	gtk_box_pack_start(GTK_BOX(scan_modifier_key_vbox),check_button,false,false,0);	
335
	gboolean hide_floatwin_when_modifier_key_released;
318
	gboolean hide_floatwin_when_modifier_key_released=conf->get_hide_floatwin_when_modifier_key_released();
336
#ifdef _WIN32
319
337
	rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "hide_floatwin_when_modifier_key_released", &hide_floatwin_when_modifier_key_released);
338
#else
339
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/hide_floatwin_when_modifier_key_released", &hide_floatwin_when_modifier_key_released, true);	
340
#endif
341
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),hide_floatwin_when_modifier_key_released);
320
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),hide_floatwin_when_modifier_key_released);
342
	g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_dictionary_scan_hide_ckbutton_toggled), this);		
321
	g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_dictionary_scan_hide_ckbutton_toggled), this);		
343
322
Lines 361-372 Link Here
361
	menuitem = gtk_menu_item_new_with_mnemonic(_("_Ctrl"));
340
	menuitem = gtk_menu_item_new_with_mnemonic(_("_Ctrl"));
362
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
341
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
363
	gtk_option_menu_set_menu(GTK_OPTION_MENU(option_menu), menu);
342
	gtk_option_menu_set_menu(GTK_OPTION_MENU(option_menu), menu);
364
	gint scan_modifier_key;
343
	gint scan_modifier_key=conf->get_scan_modifier_key();
365
#ifdef _WIN32
344
366
	rw_cfg_read_int (usercfgfile, "preferences/dictionary", "scan_modifier_key", &scan_modifier_key);
367
#else
368
	gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/dictionary/scan_modifier_key", &scan_modifier_key, 0);
369
#endif
370
	gtk_option_menu_set_history(GTK_OPTION_MENU(option_menu), scan_modifier_key);
345
	gtk_option_menu_set_history(GTK_OPTION_MENU(option_menu), scan_modifier_key);
371
	
346
	
372
	gtk_label_set_mnemonic_widget(GTK_LABEL(label), option_menu);
347
	gtk_label_set_mnemonic_widget(GTK_LABEL(label), option_menu);
Lines 376-388 Link Here
376
351
377
void PrefsDlg::on_setup_dictionary_font_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg)
352
void PrefsDlg::on_setup_dictionary_font_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg)
378
{
353
{
379
	gboolean b = gtk_toggle_button_get_active (button);
354
  gboolean b = gtk_toggle_button_get_active(button);
380
	gtk_widget_set_sensitive(oPrefsDlg->custom_font_hbox,b);
355
  gtk_widget_set_sensitive(oPrefsDlg->custom_font_hbox, b);
381
#ifdef _WIN32
356
  conf->set_use_custom_font(b);
382
	rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "use_custom_font", b);
383
#else
384
	gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/use_custom_font", b);
385
#endif
386
}
357
}
387
358
388
void PrefsDlg::on_setup_dictionary_font_button_clicked(GtkWidget *widget, PrefsDlg *oPrefsDlg)
359
void PrefsDlg::on_setup_dictionary_font_button_clicked(GtkWidget *widget, PrefsDlg *oPrefsDlg)
Lines 400-414 Link Here
400
		font_name = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dlg));
371
		font_name = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dlg));
401
		if (font_name) {
372
		if (font_name) {
402
			gtk_button_set_label(GTK_BUTTON(widget),font_name);
373
			gtk_button_set_label(GTK_BUTTON(widget),font_name);
403
#ifdef _WIN32
374
			conf->set_custom_font(font_name);
404
			rw_cfg_write_string (usercfgfile, "preferences/dictionary", "custom_font", font_name);
405
#else
406
			gpAppFrame->oAppConf.write_string("/apps/stardict/preferences/dictionary/custom_font", font_name);
407
#endif
408
		}
375
		}
409
		break;
376
		break;
410
		default:
377
		default:
411
			break;
378
	  /*nothing*/;
412
	}
379
	}
413
	gtk_widget_destroy (dlg);
380
	gtk_widget_destroy (dlg);
414
}
381
}
Lines 439-450 Link Here
439
	gtk_box_pack_start(GTK_BOX(vbox),vbox1,false,false, 0);
406
	gtk_box_pack_start(GTK_BOX(vbox),vbox1,false,false, 0);
440
	GtkWidget *check_button = gtk_check_button_new_with_mnemonic(_("_Use custom font."));
407
	GtkWidget *check_button = gtk_check_button_new_with_mnemonic(_("_Use custom font."));
441
	gtk_box_pack_start(GTK_BOX(vbox1),check_button,false,false,0);
408
	gtk_box_pack_start(GTK_BOX(vbox1),check_button,false,false,0);
442
	gboolean use_custom_font;
409
	gboolean use_custom_font=conf->get_use_custom_font();
443
#ifdef _WIN32
410
444
	rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "use_custom_font", &use_custom_font);
445
#else
446
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/use_custom_font", &use_custom_font, false);	
447
#endif
448
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),use_custom_font);
411
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),use_custom_font);
449
	g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_dictionary_font_ckbutton_toggled), this);		
412
	g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_dictionary_font_ckbutton_toggled), this);		
450
	custom_font_hbox = gtk_hbox_new(false, 12);	
413
	custom_font_hbox = gtk_hbox_new(false, 12);	
Lines 455-471 Link Here
455
	gtk_box_pack_start(GTK_BOX(custom_font_hbox),label,false,false,0);
418
	gtk_box_pack_start(GTK_BOX(custom_font_hbox),label,false,false,0);
456
	gtk_misc_set_alignment (GTK_MISC (label), 0, .5);	
419
	gtk_misc_set_alignment (GTK_MISC (label), 0, .5);	
457
	GtkWidget *button;
420
	GtkWidget *button;
458
	gchar *custom_font;
421
	const gchar *custom_font=conf->get_custom_font();
459
#ifdef _WIN32
422
460
	rw_cfg_read_string (usercfgfile, "preferences/dictionary", "custom_font", &custom_font);
461
#else
462
	gpAppFrame->oAppConf.read_string("/apps/stardict/preferences/dictionary/custom_font", &custom_font);	
463
#endif
464
	if (custom_font && custom_font[0])
423
	if (custom_font && custom_font[0])
465
		button = gtk_button_new_with_label(custom_font);
424
		button = gtk_button_new_with_label(custom_font);
466
	else
425
	else
467
		button=gtk_button_new_with_label(_("Choose"));	
426
		button=gtk_button_new_with_label(_("Choose"));	
468
	g_free(custom_font);
427
469
	gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
428
	gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
470
	gtk_box_pack_start(GTK_BOX(custom_font_hbox),button,false,false,0);
429
	gtk_box_pack_start(GTK_BOX(custom_font_hbox),button,false,false,0);
471
	g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_setup_dictionary_font_button_clicked), this);
430
	g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_setup_dictionary_font_button_clicked), this);
Lines 473-485 Link Here
473
432
474
void PrefsDlg::on_setup_dictionary_sound_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg)
433
void PrefsDlg::on_setup_dictionary_sound_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg)
475
{
434
{
476
#ifdef _WIN32
477
	gboolean enable = gtk_toggle_button_get_active(button);
435
	gboolean enable = gtk_toggle_button_get_active(button);
478
	rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "enable_sound_event", enable);
436
  conf->set_enable_sound_event(enable);
479
	on_conf_dictionary_enable_sound_event_changed(enable);
480
#else
481
	gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/enable_sound_event",gtk_toggle_button_get_active(button));
482
#endif
483
}
437
}
484
438
485
void PrefsDlg::setup_dictionary_sound_page()
439
void PrefsDlg::setup_dictionary_sound_page()
Lines 510-521 Link Here
510
	
464
	
511
	GtkWidget *check_button;
465
	GtkWidget *check_button;
512
	check_button = gtk_check_button_new_with_mnemonic(_("_Enable sound event."));
466
	check_button = gtk_check_button_new_with_mnemonic(_("_Enable sound event."));
513
	gboolean enable;
467
	gboolean enable=conf->get_enable_sound_event();
514
#ifdef _WIN32
468
515
	rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "enable_sound_event", &enable);
516
#else
517
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/enable_sound_event", &enable, true);
518
#endif
519
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),enable);
469
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),enable);
520
	g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_dictionary_sound_ckbutton_toggled), (gpointer)this);
470
	g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_dictionary_sound_ckbutton_toggled), (gpointer)this);
521
	gtk_box_pack_start(GTK_BOX(hbox1),check_button,false,false,0);
471
	gtk_box_pack_start(GTK_BOX(hbox1),check_button,false,false,0);
Lines 523-533 Link Here
523
473
524
void PrefsDlg::on_setup_mainwin_startup_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg)
474
void PrefsDlg::on_setup_mainwin_startup_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg)
525
{
475
{
526
#ifdef _WIN32
476
  conf->set_hide_on_startup(gtk_toggle_button_get_active(button));
527
	rw_cfg_write_boolean (usercfgfile, "preferences/main_window", "hide_on_startup", gtk_toggle_button_get_active(button));
528
#else
529
	gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/main_window/hide_on_startup",gtk_toggle_button_get_active(button));
530
#endif
531
}
477
}
532
478
533
void PrefsDlg::setup_mainwin_options_page()
479
void PrefsDlg::setup_mainwin_options_page()
Lines 558-569 Link Here
558
	
504
	
559
	GtkWidget *check_button;
505
	GtkWidget *check_button;
560
	check_button = gtk_check_button_new_with_mnemonic(_("Hide main window when _starting StarDict."));
506
	check_button = gtk_check_button_new_with_mnemonic(_("Hide main window when _starting StarDict."));
561
	gboolean hide;
507
	gboolean hide=conf->get_hide_on_startup();
562
#ifdef _WIN32
508
563
	rw_cfg_read_boolean (usercfgfile, "preferences/main_window", "hide_on_startup", &hide);
564
#else
565
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/main_window/hide_on_startup", &hide, false);
566
#endif
567
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),hide);
509
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),hide);
568
	g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_mainwin_startup_ckbutton_toggled), (gpointer)this);
510
	g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_mainwin_startup_ckbutton_toggled), (gpointer)this);
569
	gtk_box_pack_start(GTK_BOX(hbox1),check_button,false,false,0);
511
	gtk_box_pack_start(GTK_BOX(hbox1),check_button,false,false,0);
Lines 587-600 Link Here
587
		searchwebsite_list = g_slist_append(searchwebsite_list, website);
529
		searchwebsite_list = g_slist_append(searchwebsite_list, website);
588
		have_iter = gtk_tree_model_iter_next(model, &iter);
530
		have_iter = gtk_tree_model_iter_next(model, &iter);
589
	}
531
	}
590
#ifdef _WIN32
532
	conf->set_search_website_list(searchwebsite_list);
591
	rw_cfg_write_strlist (usercfgfile, "preferences/main_window", "search_website_list", searchwebsite_list);
592
	on_conf_main_window_searchwebsite_list_changed(searchwebsite_list);
593
#else
594
	gpAppFrame->oAppConf.write_list("/apps/stardict/preferences/main_window/search_website_list", GCONF_VALUE_STRING, searchwebsite_list);
595
	g_slist_foreach (searchwebsite_list, (GFunc)g_free, NULL);
596
	g_slist_free(searchwebsite_list);
597
#endif
598
}
533
}
599
534
600
void PrefsDlg::on_setup_mainwin_searchwebsite_moveup_button_clicked(GtkWidget *widget, PrefsDlg *oPrefsDlg)
535
void PrefsDlg::on_setup_mainwin_searchwebsite_moveup_button_clicked(GtkWidget *widget, PrefsDlg *oPrefsDlg)
Lines 834-851 Link Here
834
	GtkListStore *model;
769
	GtkListStore *model;
835
	model = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
770
	model = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
836
771
837
	GSList *searchwebsite_list;
772
	const GSList *searchwebsite_list=conf->get_search_website_list();
838
#ifdef _WIN32
773
839
	rw_cfg_read_strlist (usercfgfile, "preferences/main_window", "search_website_list", &searchwebsite_list);
840
#else
841
	gpAppFrame->oAppConf.read_list("/apps/stardict/preferences/main_window/search_website_list", GCONF_VALUE_STRING, &searchwebsite_list);
842
#endif
843
	gchar *website;
774
	gchar *website;
844
	gchar *website_link;
775
	gchar *website_link;
845
	gchar *website_searchlink;
776
	gchar *website_searchlink;
846
	GtkTreeIter iter;
777
	GtkTreeIter iter;
847
	GSList *list;
778
	const GSList *list = searchwebsite_list;
848
	list = searchwebsite_list;
849
	while (list) {
779
	while (list) {
850
		website = (gchar *)(list->data);
780
		website = (gchar *)(list->data);
851
		website_link = strchr(website, '\t');
781
		website_link = strchr(website, '\t');
Lines 857-864 Link Here
857
		}
787
		}
858
		list = g_slist_next(list);
788
		list = g_slist_next(list);
859
	}
789
	}
860
	g_slist_foreach (searchwebsite_list, (GFunc)g_free, NULL);
861
	g_slist_free (searchwebsite_list);
862
	
790
	
863
	GtkWidget *sw;	
791
	GtkWidget *sw;	
864
	sw = gtk_scrolled_window_new (NULL, NULL);
792
	sw = gtk_scrolled_window_new (NULL, NULL);
Lines 953-965 Link Here
953
881
954
void PrefsDlg::on_setup_NotificationAreaIcon_QueryInFloatWin_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg)
882
void PrefsDlg::on_setup_NotificationAreaIcon_QueryInFloatWin_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg)
955
{
883
{
956
#ifdef _WIN32
957
	gboolean queryin = gtk_toggle_button_get_active(button);
884
	gboolean queryin = gtk_toggle_button_get_active(button);
958
	rw_cfg_write_boolean (usercfgfile, "preferences/notification_area_icon", "query_in_floatwin", queryin);
885
  conf->set_query_in_floatwin(queryin);
959
	on_conf_notification_area_icon_show_in_floatwin_changed(queryin);
960
#else
961
	gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/notification_area_icon/query_in_floatwin",gtk_toggle_button_get_active(button));
962
#endif
963
}
886
}
964
887
965
void PrefsDlg::setup_NotificationAreaIcon_options_page()
888
void PrefsDlg::setup_NotificationAreaIcon_options_page()
Lines 990-1001 Link Here
990
	
913
	
991
	GtkWidget *check_button;
914
	GtkWidget *check_button;
992
	check_button = gtk_check_button_new_with_mnemonic(_("_Query in the floating window when middle mouse\nbutton clicked."));
915
	check_button = gtk_check_button_new_with_mnemonic(_("_Query in the floating window when middle mouse\nbutton clicked."));
993
	gboolean query_in_floatwin;
916
	gboolean query_in_floatwin=conf->get_query_in_floatwin();
994
#ifdef _WIN32
917
995
	rw_cfg_read_boolean (usercfgfile, "preferences/notification_area_icon", "query_in_floatwin", &query_in_floatwin);
996
#else
997
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/notification_area_icon/query_in_floatwin", &query_in_floatwin, true);
998
#endif
999
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),query_in_floatwin);
918
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),query_in_floatwin);
1000
	g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_NotificationAreaIcon_QueryInFloatWin_ckbutton_toggled), (gpointer)this);
919
	g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_NotificationAreaIcon_QueryInFloatWin_ckbutton_toggled), (gpointer)this);
1001
	gtk_box_pack_start(GTK_BOX(hbox1),check_button,false,false,0);
920
	gtk_box_pack_start(GTK_BOX(hbox1),check_button,false,false,0);
Lines 1003-1015 Link Here
1003
922
1004
void PrefsDlg::on_setup_floatwin_pronounce_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg)
923
void PrefsDlg::on_setup_floatwin_pronounce_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg)
1005
{
924
{
1006
#ifdef _WIN32
925
  conf->set_pronounce_when_popup(gtk_toggle_button_get_active(button));
1007
	gboolean pronounce = gtk_toggle_button_get_active(button);
1008
	rw_cfg_write_boolean (usercfgfile, "preferences/floating_window", "pronounce_when_popup", pronounce);
1009
	on_conf_floatwin_pronounce_when_popup_changed(pronounce);
1010
#else
1011
	gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/floating_window/pronounce_when_popup",gtk_toggle_button_get_active(button));
1012
#endif
1013
}
926
}
1014
927
1015
void PrefsDlg::setup_floatwin_options_page()
928
void PrefsDlg::setup_floatwin_options_page()
Lines 1040-1051 Link Here
1040
	
953
	
1041
	GtkWidget *check_button;
954
	GtkWidget *check_button;
1042
	check_button = gtk_check_button_new_with_mnemonic(_("_Pronouce the word when pop up."));
955
	check_button = gtk_check_button_new_with_mnemonic(_("_Pronouce the word when pop up."));
1043
	gboolean pronounce_when_popup;
956
	gboolean pronounce_when_popup=conf->get_pronounce_when_popup();
1044
#ifdef _WIN32
957
1045
	rw_cfg_read_boolean (usercfgfile, "preferences/floating_window", "pronounce_when_popup", &pronounce_when_popup);
1046
#else
1047
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/floating_window/pronounce_when_popup", &pronounce_when_popup, false);
1048
#endif
1049
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),pronounce_when_popup);
958
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),pronounce_when_popup);
1050
	g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_floatwin_pronounce_ckbutton_toggled), (gpointer)this);
959
	g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_floatwin_pronounce_ckbutton_toggled), (gpointer)this);
1051
	gtk_box_pack_start(GTK_BOX(hbox1),check_button,false,false,0);
960
	gtk_box_pack_start(GTK_BOX(hbox1),check_button,false,false,0);
Lines 1053-1076 Link Here
1053
962
1054
void PrefsDlg::on_setup_floatwin_size_max_width_spinbutton_changed(GtkSpinButton *button, PrefsDlg *oPrefsDlg)
963
void PrefsDlg::on_setup_floatwin_size_max_width_spinbutton_changed(GtkSpinButton *button, PrefsDlg *oPrefsDlg)
1055
{
964
{
1056
#ifdef _WIN32
1057
	gint width = gtk_spin_button_get_value_as_int(button);
965
	gint width = gtk_spin_button_get_value_as_int(button);
1058
	rw_cfg_write_int (usercfgfile, "preferences/floating_window", "max_window_width", width);
966
  conf->set_max_window_width(width);
1059
	on_conf_floatwin_max_window_width_changed(width);
1060
#else
1061
	gpAppFrame->oAppConf.write_int("/apps/stardict/preferences/floating_window/max_window_width",gtk_spin_button_get_value_as_int(button));
1062
#endif
1063
}
967
}
1064
968
1065
void PrefsDlg::on_setup_floatwin_size_max_height_spinbutton_changed(GtkSpinButton *button, PrefsDlg *oPrefsDlg)
969
void PrefsDlg::on_setup_floatwin_size_max_height_spinbutton_changed(GtkSpinButton *button, PrefsDlg *oPrefsDlg)
1066
{
970
{
1067
#ifdef _WIN32
1068
	gint height = gtk_spin_button_get_value_as_int(button);
971
	gint height = gtk_spin_button_get_value_as_int(button);
1069
	rw_cfg_write_int (usercfgfile, "preferences/floating_window", "max_window_height", height);
972
  conf->set_max_window_height(height);
1070
	on_conf_floatwin_max_window_height_changed(height);
1071
#else
1072
	gpAppFrame->oAppConf.write_int("/apps/stardict/preferences/floating_window/max_window_height",gtk_spin_button_get_value_as_int(button));
1073
#endif
1074
}
973
}
1075
974
1076
void PrefsDlg::setup_floatwin_size_page()
975
void PrefsDlg::setup_floatwin_size_page()
Lines 1099-1112 Link Here
1099
	vbox2 = gtk_vbox_new(false,6);
998
	vbox2 = gtk_vbox_new(false,6);
1100
	gtk_box_pack_start(GTK_BOX(vbox),vbox2,false,false,0);
999
	gtk_box_pack_start(GTK_BOX(vbox),vbox2,false,false,0);
1101
	
1000
	
1102
	gint max_width,max_height;
1001
	gint 
1103
#ifdef _WIN32
1002
	  max_width=conf->get_max_window_width(),
1104
	rw_cfg_read_int (usercfgfile, "preferences/floating_window", "max_window_width", &max_width);
1003
	  max_height=conf->get_max_window_height();
1105
	rw_cfg_read_int (usercfgfile, "preferences/floating_window", "max_window_height", &max_height);
1004
1106
#else
1107
	gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/floating_window/max_window_width", &max_width, DEFAULT_MAX_FLOATWIN_WIDTH);
1108
	gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/floating_window/max_window_height", &max_height, DEFAULT_MAX_FLOATWIN_HEIGHT);
1109
#endif
1110
	GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(gpAppFrame->oAppCore.window));
1005
	GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(gpAppFrame->oAppCore.window));
1111
	gint screen_width = gdk_screen_get_width(screen);
1006
	gint screen_width = gdk_screen_get_width(screen);
1112
	gint screen_height = gdk_screen_get_height(screen);
1007
	gint screen_height = gdk_screen_get_height(screen);
(-)stardict-2.4.4.orig/src/selection.cpp (-21 / +12 lines)
Lines 2-15 Link Here
2
#  include "config.h"
2
#  include "config.h"
3
#endif
3
#endif
4
4
5
#include <string.h>
5
#include <cstring>
6
#include "selection.h"
7
#include "stardict.h"
8
6
9
#ifdef _WIN32
7
#ifdef _WIN32
10
#  include "win32/intl.h"
8
#  include "win32/intl.h"
11
#endif
9
#endif
12
10
11
#include "stardict.h"
12
#include "conf.h"
13
14
#include "selection.h"
15
16
13
// Notice: once you changed this file, try to change src/win32/clipboard.cpp too.
17
// Notice: once you changed this file, try to change src/win32/clipboard.cpp too.
14
18
15
19
Lines 37-46 Link Here
37
/********************************************************************/
41
/********************************************************************/
38
gboolean Selection::Enable()
42
gboolean Selection::Enable()
39
{
43
{
40
    return(bEnable
44
  return conf->get_scan_selection() && 
41
		&&(!gpAppFrame->oAppCore.oTopWin.TextSelected())
45
    !gpAppFrame->oAppCore.oTopWin.TextSelected();
42
		//&&(!gtk_label_get_selection_bounds(GTK_LABEL(gpAppFrame->oAppCore.oFloatWin.label),NULL,NULL))
43
		);
44
}
46
}
45
47
46
void Selection::create_selection_widget()
48
void Selection::create_selection_widget()
Lines 54-69 Link Here
54
56
55
void Selection::Start()
57
void Selection::Start()
56
{
58
{
57
#ifdef _WIN32
58
	rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "scan_selection", &bEnable);
59
	rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "only_scan_while_modifier_key", &only_scan_while_modifier_key);
60
	rw_cfg_read_int (usercfgfile, "preferences/dictionary", "scan_modifier_key", &scan_modifier_key);
61
#else
62
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/scan_selection", &bEnable, true);
63
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/only_scan_while_modifier_key", &only_scan_while_modifier_key, false);
64
	gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/dictionary/scan_modifier_key", &scan_modifier_key, 0);
65
#endif
66
67
	UTF8_STRING_Atom = gdk_atom_intern("UTF8_STRING",false);
59
	UTF8_STRING_Atom = gdk_atom_intern("UTF8_STRING",false);
68
	COMPOUND_TEXT_Atom = gdk_atom_intern("COMPOUND_TEXT",false);
60
	COMPOUND_TEXT_Atom = gdk_atom_intern("COMPOUND_TEXT",false);
69
61
Lines 87-99 Link Here
87
	Selection *oSelection = (Selection *)data;
79
	Selection *oSelection = (Selection *)data;
88
    if(oSelection->Enable() )
80
    if(oSelection->Enable() )
89
    {
81
    {
90
		if (oSelection->only_scan_while_modifier_key) {
82
		if (conf->get_only_scan_while_modifier_key()) {
91
			GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(gpAppFrame->oAppCore.window));
83
			GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(gpAppFrame->oAppCore.window));
92
			GdkDisplay *display = gdk_screen_get_display(screen);
84
			GdkDisplay *display = gdk_screen_get_display(screen);
93
			GdkModifierType mask;
85
			GdkModifierType mask;
94
			gdk_display_get_pointer(display,NULL, NULL, NULL, &mask);
86
			gdk_display_get_pointer(display,NULL, NULL, NULL, &mask);
95
			gboolean do_scan = false;
87
			gboolean do_scan = false;
96
			switch (oSelection->scan_modifier_key) {
88
			switch (conf->get_scan_modifier_key()) {
97
#ifdef _WIN32
89
#ifdef _WIN32
98
				case 0:
90
				case 0:
99
					if ((mask & GDK_SHIFT_MASK)&&(!(mask & GDK_CONTROL_MASK))&&(!(mask & GDK_MOD1_MASK)))						
91
					if ((mask & GDK_SHIFT_MASK)&&(!(mask & GDK_CONTROL_MASK))&&(!(mask & GDK_MOD1_MASK)))						
Lines 106-112 Link Here
106
				default:
98
				default:
107
					if ((mask & GDK_CONTROL_MASK)&&(!(mask & GDK_MOD1_MASK))&&(!(mask & GDK_SHIFT_MASK)))
99
					if ((mask & GDK_CONTROL_MASK)&&(!(mask & GDK_MOD1_MASK))&&(!(mask & GDK_SHIFT_MASK)))
108
						do_scan = true;
100
						do_scan = true;
109
					break;
110
#else
101
#else
111
				case 0:
102
				case 0:
112
					if ((mask & GDK_MOD4_MASK)&&(!(mask & GDK_CONTROL_MASK))&&(!(mask & GDK_SHIFT_MASK))&&(!(mask & GDK_MOD1_MASK)))
103
					if ((mask & GDK_MOD4_MASK)&&(!(mask & GDK_CONTROL_MASK))&&(!(mask & GDK_SHIFT_MASK))&&(!(mask & GDK_MOD1_MASK)))
Lines 123-129 Link Here
123
				default:
114
				default:
124
					if ((mask & GDK_CONTROL_MASK)&&(!(mask & GDK_MOD1_MASK))&&(!(mask & GDK_SHIFT_MASK))&&(!(mask & GDK_MOD4_MASK)))
115
					if ((mask & GDK_CONTROL_MASK)&&(!(mask & GDK_MOD1_MASK))&&(!(mask & GDK_SHIFT_MASK))&&(!(mask & GDK_MOD4_MASK)))
125
						do_scan = true;
116
						do_scan = true;
126
					break;
117
	
127
#endif
118
#endif
128
				}
119
				}
129
			if (!do_scan)
120
			if (!do_scan)
(-)stardict-2.4.4.orig/src/selection.h (-5 / +1 lines)
Lines 6-13 Link Here
6
6
7
const int SELECTION_INTERVAL=300; 		    // check selection interval.
7
const int SELECTION_INTERVAL=300; 		    // check selection interval.
8
8
9
class Selection
9
class Selection {
10
{
11
private:
10
private:
12
    gint IsBusy;
11
    gint IsBusy;
13
	gint timeout;
12
	gint timeout;
Lines 21-29 Link Here
21
public:
20
public:
22
	GdkAtom UTF8_STRING_Atom, COMPOUND_TEXT_Atom; //need to set it to static? this make oTextWin can't use it conveniently.
21
	GdkAtom UTF8_STRING_Atom, COMPOUND_TEXT_Atom; //need to set it to static? this make oTextWin can't use it conveniently.
23
	std::string LastClipWord;
22
	std::string LastClipWord;
24
	gboolean bEnable;
25
	gboolean only_scan_while_modifier_key;
26
	gint scan_modifier_key;
27
	GtkWidget* selection_widget;
23
	GtkWidget* selection_widget;
28
24
29
	Selection();
25
	Selection();
(-)stardict-2.4.4.orig/src/stardict.cpp (-101 / +59 lines)
Lines 32-38 Link Here
32
#include <string.h>
32
#include <string.h>
33
#include <stdlib.h>
33
#include <stdlib.h>
34
34
35
#include "stardict.h"
36
#ifndef _WIN32
35
#ifndef _WIN32
37
#  include "stardict-application-server.h"
36
#  include "stardict-application-server.h"
38
#  include "GNOME_Stardict.h"
37
#  include "GNOME_Stardict.h"
Lines 54-59 Link Here
54
	gchar stardict_data_dir[256];
53
	gchar stardict_data_dir[256];
55
#endif
54
#endif
56
55
56
#include "conf.h"
57
58
#include "stardict.h"
57
59
58
AppFrame * gpAppFrame;
60
AppFrame * gpAppFrame;
59
61
Lines 100-122 Link Here
100
102
101
void AppCore::Create(gchar *queryword)
103
void AppCore::Create(gchar *queryword)
102
{		
104
{		
103
	oLibs.Load();
105
	oLibs.Load(conf->get_dict_order_list(), conf->get_dict_disable_list());
104
	iCurrentIndex = (glong*)g_malloc0(sizeof(glong) * oLibs.total_libs());
106
	iCurrentIndex = (glong*)g_malloc0(sizeof(glong) * oLibs.total_libs());
105
107
106
	gboolean use_custom_font;
108
	gboolean use_custom_font=conf->get_use_custom_font();
107
#ifdef _WIN32
109
108
	rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "use_custom_font", &use_custom_font);	
109
#else
110
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/use_custom_font", &use_custom_font, false);
111
#endif
112
	if (use_custom_font)
110
	if (use_custom_font)
113
	{
111
	{
114
		gchar *custom_font;
112
		const gchar *custom_font=conf->get_custom_font();
115
#ifdef _WIN32
113
116
		rw_cfg_read_string (usercfgfile, "preferences/dictionary", "custom_font", &custom_font);
117
#else
118
		gpAppFrame->oAppConf.read_string("/apps/stardict/preferences/dictionary/custom_font", &custom_font);
119
#endif
120
		if (custom_font && custom_font[0])
114
		if (custom_font && custom_font[0])
121
		{
115
		{
122
			gchar *aa;
116
			gchar *aa;
Lines 124-148 Link Here
124
			gtk_rc_parse_string(aa);
118
			gtk_rc_parse_string(aa);
125
			g_free(aa);
119
			g_free(aa);
126
		}
120
		}
127
		g_free(custom_font);
128
	}
121
	}
129
122
130
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
123
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
131
	gtk_container_set_border_width(GTK_CONTAINER(window),2);
124
	gtk_container_set_border_width(GTK_CONTAINER(window),2);
132
	gboolean maximized;
125
	gboolean maximized=conf->get_maximized();
133
#ifdef _WIN32
126
134
	rw_cfg_read_boolean (usercfgfile, "preferences/main_window", "maximized", &maximized);
127
	gint 
135
#else
128
	  width=conf->get_window_width(),
136
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/main_window/maximized", &maximized, false);
129
	  height=conf->get_window_height();
137
#endif
130
138
	gint width,height;
139
#ifdef _WIN32
140
	rw_cfg_read_int (usercfgfile, "preferences/main_window", "window_width", &width);
141
	rw_cfg_read_int (usercfgfile, "preferences/main_window", "window_height", &height);
142
#else
143
	gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/main_window/window_width", &width, DEFAULT_WINDOW_WIDTH);
144
	gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/main_window/window_height", &height, DEFAULT_WINDOW_HEIGHT);
145
#endif
146
	if (width < MIN_WINDOW_WIDTH)
131
	if (width < MIN_WINDOW_WIDTH)
147
		width = MIN_WINDOW_WIDTH;
132
		width = MIN_WINDOW_WIDTH;
148
	if (height < MIN_WINDOW_HEIGHT)
133
	if (height < MIN_WINDOW_HEIGHT)
Lines 179-194 Link Here
179
	oClipboard.Start();
164
	oClipboard.Start();
180
#endif
165
#endif
181
166
182
#ifndef _WIN32
183
	poAppFrame->oAppConf.EnableNotify();    
184
#endif
185
167
186
	gboolean hide;
168
	gboolean hide=conf->get_hide_on_startup();
187
#ifdef _WIN32
188
	rw_cfg_read_boolean (usercfgfile, "preferences/main_window", "hide_on_startup", &hide);
189
#else
190
	gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/main_window/hide_on_startup", &hide, false);
191
#endif
192
	
169
	
193
	//NOTICE: when docklet embedded failed,it should always show the window,but,how to detect the failure?
170
	//NOTICE: when docklet embedded failed,it should always show the window,but,how to detect the failure?
194
	// As stardict is FOR GNOME,so i don't want to consider the case that haven't the Notification area applet.
171
	// As stardict is FOR GNOME,so i don't want to consider the case that haven't the Notification area applet.
Lines 197-203 Link Here
197
	}
174
	}
198
	else {
175
	else {
199
		gdk_notify_startup_complete ();
176
		gdk_notify_startup_complete ();
200
		if (gpAppFrame->oAppCore.oSelection.bEnable)
177
		if (conf->get_scan_selection())
201
			gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_SCAN_ICON);
178
			gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_SCAN_ICON);
202
		else
179
		else
203
			gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_STOP_ICON);
180
			gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_STOP_ICON);
Lines 236-242 Link Here
236
{
213
{
237
	if (event->changed_mask == GDK_WINDOW_STATE_WITHDRAWN) {
214
	if (event->changed_mask == GDK_WINDOW_STATE_WITHDRAWN) {
238
		if (event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN) {
215
		if (event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN) {
239
			if (gpAppFrame->oAppCore.oSelection.bEnable) {
216
			if (conf->get_scan_selection()) {
240
				gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_SCAN_ICON);
217
				gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_SCAN_ICON);
241
			}
218
			}
242
			else {
219
			else {
Lines 262-274 Link Here
262
			}
239
			}
263
		}
240
		}
264
	}
241
	}
265
	else if (event->changed_mask == GDK_WINDOW_STATE_MAXIMIZED) {
242
	else if (event->changed_mask == GDK_WINDOW_STATE_MAXIMIZED) 
266
#ifdef _WIN32
243
	  conf->set_maximized((event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED));
267
		rw_cfg_write_boolean (usercfgfile, "preferences/main_window", "maximized", (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED));
244
	
268
#else
269
		gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/main_window/maximized", (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED));
270
#endif
271
	}
272
	return false;
245
	return false;
273
}
246
}
274
247
Lines 1216-1233 Link Here
1216
	if (!hide_option)
1189
	if (!hide_option)
1217
		show_splash_screen();
1190
		show_splash_screen();
1218
1191
1219
#ifdef _WIN32
1220
	init_conf();
1221
#endif
1222
1223
#ifdef _WIN32
1224
	rw_cfg_read_int (usercfgfile, "preferences/dictionary", "enable_sound_event", &enable_sound_event);
1225
#else
1226
	oAppConf.read_bool("/apps/stardict/preferences/dictionary/enable_sound_event", &enable_sound_event, true);
1227
#endif
1228
	//if (enable_sound_event)
1229
	//	gnome_sound_play(STARDICT_DATA_DIR "/sounds/startup.wav");
1230
	
1231
	oAppSkin.load();
1192
	oAppSkin.load();
1232
		
1193
		
1233
	oAppCore.Create(queryword);
1194
	oAppCore.Create(queryword);
Lines 1249-1291 Link Here
1249
1210
1250
void AppFrame::Quit()
1211
void AppFrame::Quit()
1251
{   
1212
{   
1252
#ifndef _WIN32
1213
  gboolean maximized=conf->get_maximized();
1253
	oAppConf.DisableNotify();
1254
#endif
1255
	
1214
	
1256
	gboolean maximized;
1257
#ifdef _WIN32
1258
	rw_cfg_read_boolean (usercfgfile, "preferences/main_window", "maximized", &maximized);
1259
#else
1260
	oAppConf.read_bool("/apps/stardict/preferences/main_window/maximized", &maximized, false);
1261
#endif
1262
	if (!maximized) {
1215
	if (!maximized) {
1263
    	gint width,height;
1216
    	gint width,height;
1264
		gtk_window_get_size(GTK_WINDOW (oAppCore.window), &width, &height);
1217
		gtk_window_get_size(GTK_WINDOW (oAppCore.window), &width, &height);
1265
#ifdef _WIN32
1218
    conf->set_window_width(width);
1266
		rw_cfg_write_int (usercfgfile, "preferences/main_window", "window_width", width);
1219
    conf->set_window_height(height);
1267
		rw_cfg_write_int (usercfgfile, "preferences/main_window", "window_height", height);
1220
1268
#else
1269
		oAppConf.write_int("/apps/stardict/preferences/main_window/window_width",width);
1270
		oAppConf.write_int("/apps/stardict/preferences/main_window/window_height",height);
1271
#endif
1272
	}
1221
	}
1273
	gint pos = gtk_paned_get_position(GTK_PANED(oAppCore.oMidWin.hpaned));
1222
	gint pos = gtk_paned_get_position(GTK_PANED(oAppCore.oMidWin.hpaned));
1274
#ifdef _WIN32
1223
  conf->set_hpaned_pos(pos);
1275
	rw_cfg_write_int (usercfgfile, "preferences/main_window", "hpaned_pos", pos);
1224
1276
#else
1225
  if (conf->get_lock()) {
1277
	oAppConf.write_int("/apps/stardict/preferences/main_window/hpaned_pos",pos);
1278
#endif
1279
	if (oAppCore.oFloatWin.bIsLocked) {
1280
		gint x,y;
1226
		gint x,y;
1281
		gtk_window_get_position(GTK_WINDOW(oAppCore.oFloatWin.FloatWindow),&x,&y);
1227
		gtk_window_get_position(GTK_WINDOW(oAppCore.oFloatWin.FloatWindow),&x,&y);
1282
#ifdef _WIN32
1228
    conf->set_lock_x(x);
1283
		rw_cfg_write_int (usercfgfile, "preferences/floating_window", "lock_x", x);
1229
    conf->set_lock_y(y);
1284
		rw_cfg_write_int (usercfgfile, "preferences/floating_window", "lock_y", y);
1285
#else
1286
		oAppConf.write_int("/apps/stardict/preferences/floating_window/lock_x",x);
1287
		oAppConf.write_int("/apps/stardict/preferences/floating_window/lock_y",y);
1288
#endif
1289
	}
1230
	}
1290
    
1231
    
1291
	oAppCore.End();
1232
	oAppCore.End();
Lines 1294-1302 Link Here
1294
	bonobo_object_unref (stardict_app_server);
1235
	bonobo_object_unref (stardict_app_server);
1295
#endif
1236
#endif
1296
	
1237
	
1297
#ifdef _WIN32
1298
	save_conf();
1299
#endif
1300
    gtk_main_quit ();
1238
    gtk_main_quit ();
1301
}
1239
}
1302
1240
Lines 1371-1377 Link Here
1371
1309
1372
gboolean stardict_on_enter_notify (GtkWidget * widget, GdkEventCrossing * event, gpointer data)
1310
gboolean stardict_on_enter_notify (GtkWidget * widget, GdkEventCrossing * event, gpointer data)
1373
{
1311
{
1374
	if (gpAppFrame->enable_sound_event && event->mode == GDK_CROSSING_NORMAL) {
1312
  if (conf->get_enable_sound_event() && event->mode == GDK_CROSSING_NORMAL) {
1375
#ifdef _WIN32
1313
#ifdef _WIN32
1376
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1314
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1377
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1315
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
Lines 1508-1514 Link Here
1508
{			
1446
{			
1509
#ifdef _WIN32
1447
#ifdef _WIN32
1510
	if (set_stardict_data_dir())
1448
	if (set_stardict_data_dir())
1511
		return 0;
1449
    return EXIT_SUCCESS;
1512
	gchar *locale_dir;
1450
	gchar *locale_dir;
1513
	locale_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "locale", stardict_data_dir);
1451
	locale_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "locale", stardict_data_dir);
1514
	bindtextdomain (GETTEXT_PACKAGE, locale_dir);
1452
	bindtextdomain (GETTEXT_PACKAGE, locale_dir);
Lines 1593-1604 Link Here
1593
	args = (char**) poptGetArgs(pctx);
1530
	args = (char**) poptGetArgs(pctx);
1594
1531
1595
	gchar *queryword = NULL;
1532
	gchar *queryword = NULL;
1596
	if (args && args[0]) 
1533
  if (args && args[0]) {	
1597
	{	
1598
		//only look up the first word should OK.
1534
		//only look up the first word should OK.
1599
		if (g_utf8_validate (args[0], -1, NULL)) {
1535
    if (g_utf8_validate (args[0], -1, NULL))
1600
			queryword= g_strdup(args[0]);			
1536
			queryword= g_strdup(args[0]);			
1601
		}
1602
		else
1537
		else
1603
			queryword = g_locale_to_utf8(args[0],-1,NULL,NULL,NULL);
1538
			queryword = g_locale_to_utf8(args[0],-1,NULL,NULL,NULL);
1604
	}	
1539
	}	
Lines 1610-1623 Link Here
1610
		Bonobo_ACTIVATION_FLAG_EXISTING_ONLY,
1545
		Bonobo_ACTIVATION_FLAG_EXISTING_ONLY,
1611
		NULL, NULL);
1546
		NULL, NULL);
1612
1547
1613
	if (factory != NULL) 
1548
  if (factory != NULL) {
1614
	{
1615
		/* there is an instance already running, so send
1549
		/* there is an instance already running, so send
1616
		 * commands to it if needed
1550
		 * commands to it if needed
1617
		 */
1551
		 */
1618
                stardict_handle_automation_cmdline (queryword);				
1552
                stardict_handle_automation_cmdline (queryword);				
1619
                /* and we're done */
1553
                /* and we're done */
1620
                exit (0);
1554
    exit(EXIT_SUCCESS);
1621
	}
1555
	}
1622
	
1556
	
1623
	GnomeClient *client;
1557
	GnomeClient *client;
Lines 1627-1636 Link Here
1627
	}		
1561
	}		
1628
#endif		
1562
#endif		
1629
	
1563
	
1564
#if defined(_WIN32) || defined(WITHOUT_GNOME)
1565
  gchar *conf_path;
1566
  gchar *conf_dir;
1567
# ifdef WITHOUT_GNOME
1568
  conf_dir = g_build_filename(g_get_home_dir(), ".stardict", NULL);
1569
  if (mkdir(conf_dir, S_IRWXU)==-1 && errno!=EEXIST) {
1570
    g_warning(N_("Can not create %s."), conf_dir);
1571
    g_free(conf_dir);
1572
    conf_dir=NULL;
1573
  }
1574
# else
1575
  conf_dir=stardict_data_dir;
1576
# endif
1577
  conf_path = g_build_filename(conf_dir, "stardict.cfg", NULL);
1578
#endif
1579
  conf.reset(new AppConf(
1580
#if defined(_WIN32) || defined(WITHOUT_GNOME)
1581
		       conf_path
1582
#else
1583
		       "/apps/stardict"
1584
#endif
1585
		       ));
1630
    AppFrame oAppFrame;
1586
    AppFrame oAppFrame;
1631
	gpAppFrame = &oAppFrame;
1587
	gpAppFrame = &oAppFrame;
1632
    oAppFrame.Init(queryword);
1588
    oAppFrame.Init(queryword);
1633
	return 0;
1589
1590
  return EXIT_SUCCESS;
1634
}
1591
}
1635
1592
1636
#ifdef _WIN32
1593
#ifdef _WIN32
(-)stardict-2.4.4.orig/src/stardict.h (-11 / +6 lines)
Lines 3-10 Link Here
3
3
4
#include <gtk/gtk.h>
4
#include <gtk/gtk.h>
5
5
6
#ifndef _WIN32
6
#if !defined(_WIN32)
7
    #include <bonobo/bonobo-object.h>
7
# include <bonobo/bonobo-object.h>
8
# include <libgnome/libgnome.h>
8
#endif
9
#endif
9
10
10
11
Lines 15-26 Link Here
15
#include "lib.h"
16
#include "lib.h"
16
#include "mainwin.h"
17
#include "mainwin.h"
17
#ifdef _WIN32
18
#ifdef _WIN32
18
	#include "win32/clipboard.h"
19
#  include "win32/clipboard.h"	
19
	#include "win32/winconf.h"
20
#  include "win32/systray.h"
20
	#include "win32/systray.h"
21
#else
21
#else
22
    #include "conf.h"
22
#  include "docklet.h"
23
    #include "docklet.h"
24
#endif
23
#endif
25
#include "floatwin.h"
24
#include "floatwin.h"
26
#include "selection.h"
25
#include "selection.h"
Lines 111-124 Link Here
111
private:
110
private:
112
111
113
public:
112
public:
114
#ifndef _WIN32
115
	AppConf oAppConf;
116
#endif
117
	AppCore oAppCore;
113
	AppCore oAppCore;
118
	AppSkin oAppSkin;
114
	AppSkin oAppSkin;
119
	ReadWord oReadWord;
115
	ReadWord oReadWord;
120
116
121
	gboolean enable_sound_event;
122
117
123
#ifndef _WIN32	
118
#ifndef _WIN32	
124
	BonoboObject *stardict_app_server;
119
	BonoboObject *stardict_app_server;
(-)stardict-2.4.4.orig/src/win32/clipboard.cpp (-2 / +5 lines)
Lines 2-10 Link Here
2
#  include "config.h"
2
#  include "config.h"
3
#endif
3
#endif
4
4
5
#include "clipboard.h"
6
#include "../stardict.h"
5
#include "../stardict.h"
7
#include "intl.h"
6
#include "intl.h"
7
#include "../conf.h"
8
9
#include "clipboard.h"
8
10
9
11
10
// Notice: once you changed this file, try to change src/selection.cpp too.
12
// Notice: once you changed this file, try to change src/selection.cpp too.
Lines 16-22 Link Here
16
18
17
gboolean Clipboard::Enable()
19
gboolean Clipboard::Enable()
18
{
20
{
19
    return(gpAppFrame->oAppCore.oSelection.bEnable &&(!gpAppFrame->oAppCore.oTopWin.TextSelected()));
21
    return conf->get_scan_selection() && 
22
      !gpAppFrame->oAppCore.oTopWin.TextSelected();
20
}
23
}
21
24
22
void Clipboard::Start()
25
void Clipboard::Start()
(-)stardict-2.4.4.orig/src/win32/systray.cpp (-26 / +17 lines)
Lines 1-11 Link Here
1
#include "systray.h"
1
#include <gdk/gdkwin32.h>
2
2
3
#include "intl.h"
3
#include "intl.h"
4
#include "resource.h"
4
#include "resource.h"
5
#include "MinimizeToTray.h"
5
#include "MinimizeToTray.h"
6
#include "../stardict.h"
6
#include "../stardict.h"
7
#include "../conf.h"
7
8
8
#include <gdk/gdkwin32.h>
9
10
#include "systray.h"
9
11
10
#define WM_TRAYMESSAGE WM_USER /* User defined WM Message */
12
#define WM_TRAYMESSAGE WM_USER /* User defined WM Message */
11
13
Lines 85-91 Link Here
85
           of the menu scope */
87
           of the menu scope */
86
	SetForegroundWindow(systray_hwnd);
88
	SetForegroundWindow(systray_hwnd);
87
89
88
	if (gpAppFrame->oAppCore.oSelection.bEnable)
90
  if (conf->get_scan_selection())
89
		CheckMenuItem(systray_menu, SYSTRAY_CMND_MENU_SCAN, MF_BYCOMMAND | MF_CHECKED);
91
		CheckMenuItem(systray_menu, SYSTRAY_CMND_MENU_SCAN, MF_BYCOMMAND | MF_CHECKED);
90
	else
92
	else
91
		CheckMenuItem(systray_menu, SYSTRAY_CMND_MENU_SCAN, MF_BYCOMMAND | MF_UNCHECKED);
93
		CheckMenuItem(systray_menu, SYSTRAY_CMND_MENU_SCAN, MF_BYCOMMAND | MF_UNCHECKED);
Lines 104-110 Link Here
104
{
106
{
105
	static UINT taskbarRestartMsg; /* static here means value is kept across multiple calls to this func */
107
	static UINT taskbarRestartMsg; /* static here means value is kept across multiple calls to this func */
106
108
107
	switch(msg) {
109
  switch (msg) {
108
	case WM_CREATE:
110
	case WM_CREATE:
109
		taskbarRestartMsg = RegisterWindowMessage("TaskbarCreated");
111
		taskbarRestartMsg = RegisterWindowMessage("TaskbarCreated");
110
		break;
112
		break;
Lines 113-124 Link Here
113
		switch(LOWORD(wparam)) {
115
		switch(LOWORD(wparam)) {
114
		case SYSTRAY_CMND_MENU_SCAN:
116
		case SYSTRAY_CMND_MENU_SCAN:
115
			if (GetMenuState(gpAppFrame->oAppCore.oDockLet.systray_menu, SYSTRAY_CMND_MENU_SCAN, MF_BYCOMMAND) & MF_CHECKED) {
117
			if (GetMenuState(gpAppFrame->oAppCore.oDockLet.systray_menu, SYSTRAY_CMND_MENU_SCAN, MF_BYCOMMAND) & MF_CHECKED) {
116
				rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "scan_selection", false);
118
	conf->set_scan_selection(FALSE);
117
				on_conf_dictionary_scan_selection_changed(false);
119
      }	else {
118
			}
120
	conf->set_scan_selection(TRUE);
119
			else {
120
				rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "scan_selection", true);
121
				on_conf_dictionary_scan_selection_changed(true);
122
			}				
121
			}				
123
			break;
122
			break;
124
		case SYSTRAY_CMND_MENU_QUIT:
123
		case SYSTRAY_CMND_MENU_QUIT:
Lines 130-168 Link Here
130
	{
129
	{
131
		if ( lparam == WM_LBUTTONDOWN ) {
130
		if ( lparam == WM_LBUTTONDOWN ) {
132
			if (GetKeyState(VK_CONTROL)<0) {
131
			if (GetKeyState(VK_CONTROL)<0) {
133
				rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "scan_selection", !(gpAppFrame->oAppCore.oSelection.bEnable));
132
	conf->set_scan_selection(!conf->get_scan_selection());
134
				on_conf_dictionary_scan_selection_changed(!(gpAppFrame->oAppCore.oSelection.bEnable));
135
			}
136
		}
133
		}
137
		else if( lparam == WM_LBUTTONDBLCLK ) {
134
    } else if ( lparam == WM_LBUTTONDBLCLK ) {
138
			// Only use left button will conflict with the menu.
135
			// Only use left button will conflict with the menu.
139
			if (GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) {
136
			if (GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) {
140
				stardict_systray_minimize(gpAppFrame->oAppCore.window);
137
				stardict_systray_minimize(gpAppFrame->oAppCore.window);
141
				gtk_widget_hide(gpAppFrame->oAppCore.window);
138
				gtk_widget_hide(gpAppFrame->oAppCore.window);
142
			}
139
      }	else {
143
			else {
144
				stardict_systray_maximize(gpAppFrame->oAppCore.window);
140
				stardict_systray_maximize(gpAppFrame->oAppCore.window);
145
				gtk_window_present(GTK_WINDOW(gpAppFrame->oAppCore.window));
141
				gtk_window_present(GTK_WINDOW(gpAppFrame->oAppCore.window));
146
				if (gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry))[0]) {
142
				if (gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry))[0]) {
147
					gtk_widget_grab_focus(gpAppFrame->oAppCore.oMidWin.oTextWin.textview); //so user can input word directly.
143
					gtk_widget_grab_focus(gpAppFrame->oAppCore.oMidWin.oTextWin.textview); //so user can input word directly.
148
				}
144
	} else {
149
				else {
150
					gtk_widget_grab_focus(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry); //this won't change selection text.
145
					gtk_widget_grab_focus(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry); //this won't change selection text.
151
				}
146
				}
152
			}
147
			}
153
		}
148
    } else if (lparam == WM_MBUTTONDOWN) {
154
		else if( lparam == WM_MBUTTONDOWN ) {
149
      if (conf->get_query_in_floatwin()) {
155
			if (gpAppFrame->oAppCore.oDockLet.query_in_floatwin) {
156
				gpAppFrame->oAppCore.oSelection.LastClipWord.clear();
150
				gpAppFrame->oAppCore.oSelection.LastClipWord.clear();
157
				gtk_selection_convert (gpAppFrame->oAppCore.oSelection.selection_widget, GDK_SELECTION_PRIMARY, gpAppFrame->oAppCore.oSelection.UTF8_STRING_Atom, GDK_CURRENT_TIME);			
151
				gtk_selection_convert (gpAppFrame->oAppCore.oSelection.selection_widget, GDK_SELECTION_PRIMARY, gpAppFrame->oAppCore.oSelection.UTF8_STRING_Atom, GDK_CURRENT_TIME);			
158
			}
152
      } else {
159
			else {
160
				stardict_systray_maximize(gpAppFrame->oAppCore.window);
153
				stardict_systray_maximize(gpAppFrame->oAppCore.window);
161
				gtk_window_present(GTK_WINDOW(gpAppFrame->oAppCore.window));
154
				gtk_window_present(GTK_WINDOW(gpAppFrame->oAppCore.window));
162
				gtk_selection_convert (gpAppFrame->oAppCore.oMidWin.oTextWin.textview, GDK_SELECTION_PRIMARY, gpAppFrame->oAppCore.oSelection.UTF8_STRING_Atom, GDK_CURRENT_TIME);
155
				gtk_selection_convert (gpAppFrame->oAppCore.oMidWin.oTextWin.textview, GDK_SELECTION_PRIMARY, gpAppFrame->oAppCore.oSelection.UTF8_STRING_Atom, GDK_CURRENT_TIME);
163
			}	
156
			}	
164
		}
157
    } else if (lparam == WM_RBUTTONUP) {
165
		else if( lparam == WM_RBUTTONUP ) {
166
			/* Right Click */
158
			/* Right Click */
167
			POINT mpoint;
159
			POINT mpoint;
168
			GetCursorPos(&mpoint);
160
			GetCursorPos(&mpoint);
Lines 177-183 Link Here
177
			   This will put the systray icon back in it's place, when it restarts */
169
			   This will put the systray icon back in it's place, when it restarts */
178
			Shell_NotifyIcon(NIM_ADD,&(gpAppFrame->oAppCore.oDockLet.stardict_nid));
170
			Shell_NotifyIcon(NIM_ADD,&(gpAppFrame->oAppCore.oDockLet.stardict_nid));
179
		}
171
		}
180
		break;
181
	}
172
	}
182
173
183
	return DefWindowProc(hwnd, msg, wparam, lparam);
174
	return DefWindowProc(hwnd, msg, wparam, lparam);

Return to bug 86379