Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 54225 Details for
Bug 86379
stardict-2.4.4-r1.ebuild
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
config.patch
config.patch (text/plain), 115.52 KB, created by
Evgeniy Dushistov
on 2005-03-23 05:40:47 UTC
(
hide
)
Description:
config.patch
Filename:
MIME Type:
Creator:
Evgeniy Dushistov
Created:
2005-03-23 05:40:47 UTC
Size:
115.52 KB
patch
obsolete
>diff -bBurNd stardict-2.4.4.orig/src/conf.cpp stardict-2.4.4/src/conf.cpp >--- stardict-2.4.4.orig/src/conf.cpp 2003-11-30 06:13:09.000000000 +0300 >+++ stardict-2.4.4/src/conf.cpp 2005-01-19 14:14:22.014449888 +0300 >@@ -2,131 +2,468 @@ > # include "config.h" > #endif > >-#include "conf.h" >+#include <sys/stat.h> >+#include <cstdio> >+#include <cstring> >+#include <cstdlib> >+#include <cerrno> >+#include <string> >+ >+#include <glib.h> >+#include <glib/gi18n.h> >+ > #include "stardict.h" > >-// Notice: once you changed this file, try to change src/win32/winconf.cpp too. >+#include "conf.h" > >-AppConf::AppConf() >-{ >- gconf_client = gconf_client_get_default (); >- if (gconf_client == NULL) { >- g_warning (_("Cannot connect to gconf.")); >+std::auto_ptr<AppConf> conf; >+ >+inline void free_list(GSList *l){ >+ if(l!=NULL){ >+ g_slist_foreach(l, (GFunc)g_free, NULL); >+ g_slist_free(l); > } >- else { >- gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/dictionary/scan_selection", dictionary_scan_selection_changed_cb, NULL, NULL, NULL); >- 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); >- 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); >- gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/dictionary/scan_modifier_key", dictionary_scan_modifier_key_changed_cb, NULL, NULL, NULL); >- gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/dictionary/enable_sound_event", dictionary_enable_sound_event_changed_cb, NULL, NULL, NULL); >- gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/main_window/search_website_list", main_window_searchwebsite_list_changed_cb, NULL, NULL, NULL); >- gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/main_window/hide_list", main_window_hide_list_changed_cb, NULL, NULL, NULL); >- 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); >- gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/floating_window/pronounce_when_popup", floatwin_pronounce_when_popup_changed_cb, NULL, NULL, NULL); >- gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/floating_window/max_window_width", floatwin_max_window_width_changed_cb, NULL, NULL, NULL); >- gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/floating_window/max_window_height", floatwin_max_window_height_changed_cb, NULL, NULL, NULL); >- gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/floating_window/lock", floatwin_lock_changed_cb, NULL, NULL, NULL); >- gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/floating_window/lock_x", floatwin_lock_x_changed_cb, NULL, NULL, NULL); >- gconf_client_notify_add (gconf_client, "/apps/stardict/preferences/floating_window/lock_y", floatwin_lock_y_changed_cb, NULL, NULL, NULL); >+} >+ >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ >+const char STRING_SEP = (const char) 0xff; >+ >+//--------------------------------------------------------------------------------- >+static GSList * Str2List(gchar *str) >+{ >+ GSList *list = NULL; >+ gchar *p; >+ while ((p = strchr(str, STRING_SEP))!=NULL) { >+ list = g_slist_append(list, g_strndup(str, p - str)); >+ str = p+1; > } >+ if (str[0]) >+ list = g_slist_append(list, g_strdup(str)); >+ return list; > } > >-AppConf::~AppConf() >+//--------------------------------------------------------------------------------- >+ConfigLine *ConfigSection::CreateString(const gchar * key, const gchar * value) > { >- if (!gconf_client) >- return; >- g_object_unref (gconf_client); >+ ConfigLine *line; >+ line = (ConfigLine *)g_malloc0(sizeof(ConfigLine)); >+ line->key = g_strchug(g_strchomp(g_strdup (key))); >+ line->value = g_strchug(g_strchomp(g_strdup (value))); >+ this->lines = g_list_append(this->lines, line); >+ >+ return line; > } >+//--------------------------------------------------------------------------------- >+ConfigLine *ConfigSection::FindString(const gchar * key) >+{ >+ ConfigLine *line; >+ GList *list; > >-void AppConf::EnableNotify() >+ list = this->lines; >+ while (list){ >+ line = (ConfigLine *) list->data; >+ if (!strcasecmp (line->key, key)) >+ return line; >+ list = g_list_next (list); >+ } >+ return NULL; >+} >+//--------------------------------------------------------------------------------- >+#endif >+ >+// >+//TBaseConf methods >+// >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ >+ConfigSection *TBaseConf::CreateSection(const gchar * name) > { >- if (!gconf_client) >- return; >- gconf_client_add_dir(gconf_client, "/apps/stardict", GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); >+ ConfigSection *section; >+ section = (ConfigSection *)g_malloc0(sizeof(ConfigSection)); >+ section->name = g_strdup(name); >+ this->sections = g_list_append(this->sections, section); >+ >+ return section; > } >+//--------------------------------------------------------------------------------- >+ConfigSection *TBaseConf::FindSection(const gchar * name) >+{ >+ ConfigSection *section; >+ GList *list; > >-void AppConf::DisableNotify() >+ list = this->sections; >+ while (list){ >+ section = (ConfigSection *) list->data; >+ if (!strcasecmp (section->name, name)) >+ return section; >+ list = g_list_next (list); >+ } >+ return NULL; >+} >+#endif >+ >+TBaseConf::TBaseConf(const gchar *conf_path) >+{ >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ sections=NULL; >+ cfgfilename=NULL; >+ Open(conf_path); >+#else >+ cfgfilename=g_strdup(conf_path); >+ if ((gconf_client = gconf_client_get_default())==NULL) >+ g_warning(_("Cannot connect to gconf.")); >+ else >+ gconf_client_add_dir(gconf_client, conf_path, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); >+#endif >+} >+//--------------------------------------------------------------------------------- >+TBaseConf::~TBaseConf() > { >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ ConfigSection *section; >+ ConfigLine *line; >+ GList *section_list, *line_list; >+ >+ g_free(this->cfgfilename); >+ section_list=this->sections; >+ while (section_list) { >+ section = (ConfigSection *) section_list->data; >+ g_free (section->name); >+ >+ line_list = section->lines; >+ while (line_list) { >+ line = (ConfigLine *) line_list->data; >+ g_free (line->key); >+ g_free (line->value); >+ g_free (line); >+ line_list = g_list_next(line_list); >+ } >+ g_list_free (section->lines); >+ g_free (section); >+ >+ section_list = g_list_next(section_list); >+ } >+ g_list_free(this->sections); >+ this->sections = NULL; >+ this->cfgfilename = NULL; >+#else > if (!gconf_client) > return; >- gconf_client_remove_dir(gconf_client, "/apps/stardict", NULL); >+ gconf_client_remove_dir(gconf_client, cfgfilename, NULL); >+ g_object_unref(gconf_client); >+ g_free(cfgfilename); >+#endif > } >+//--------------------------------------------------------------------------------- >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+bool TBaseConf::Open(const gchar * filename) >+{ >+ FILE *file; >+ gchar *buffer, **lines, *tmp; >+ gint i; >+ struct stat stats; >+ ConfigSection *section = NULL; >+ if (NULL==filename) >+ return false; >+ g_free(this->cfgfilename); >+ this->cfgfilename = g_strdup(filename); > >-void AppConf::read_bool(const gchar *key, gboolean *val, gboolean def) >+ if (stat(filename, &stats) == -1) >+ return false; >+ >+ if (!(file = fopen (filename, "rb"))) >+ return false; >+ >+ >+ buffer = (gchar *)g_malloc (stats.st_size + 1); >+ fread(buffer, 1, stats.st_size, file); >+ fclose(file); >+ buffer[stats.st_size] = '\0'; >+ >+ lines = g_strsplit(buffer, "\n", 0); >+ g_free(buffer); >+ i = 0; >+ while (lines[i]) { >+ if (lines[i][0] == '[') { >+ if ((tmp = strchr(lines[i], ']'))) { >+ *tmp = '\0'; >+ section = CreateSection(&lines[i][1]); >+ } >+ } else if(lines[i][0] != '#' && section) { >+ if ((tmp = strchr (lines[i], '='))) { >+ *tmp = '\0'; >+ tmp++; >+ section->CreateString(lines[i], tmp); >+ } >+ } >+ i++; >+ } >+ g_strfreev(lines); >+ >+ return true; >+} >+//--------------------------------------------------------------------------------- >+bool TBaseConf::Write(const gchar * filename) > { >- if (!gconf_client) >- *val = def; >+ FILE *file; >+ GList *section_list, *line_list; >+ ConfigSection *section; >+ ConfigLine *line; >+ if (NULL==filename) >+ return false; >+ if (!(file = fopen (filename, "wb"))) { >+ g_warning(N_("Can not open: %s - %s\n"), filename, strerror(errno)); >+ return false; >+ } >+ section_list = this->sections; >+ while (section_list) { >+ section = (ConfigSection *) section_list->data; >+ if (section->lines) { >+ fprintf(file, "[%s]\n", section->name); >+ line_list = section->lines; >+ while (line_list) { >+ line = (ConfigLine *)line_list->data; >+ fprintf(file, "%s=%s\n", line->key, line->value); >+ line_list = g_list_next(line_list); >+ } >+ fprintf(file, "\n"); >+ } >+ section_list = g_list_next(section_list); >+ } >+ fclose(file); >+ return true; >+} >+//--------------------------------------------------------------------------------- >+#endif >+bool TBaseConf::ReadBool(const gchar *section, const gchar *key, gboolean *value, gboolean def) >+{ >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ gchar *str; >+ >+ if (!ReadString(section, key, &str)) { >+ *value = def; >+ return false; >+ } >+ >+ if (!strcmp (str, "0")) >+ *value=FALSE; > else >- *val = gconf_client_get_bool(gconf_client, key, NULL); >+ *value=TRUE; >+ >+ g_free(str); >+#else >+ if (!gconf_client) { >+ *value=def; >+ return false; >+ } >+ >+ gchar *real_key=g_strdup_printf("%s/%s", section, key); >+ *value=gconf_client_get_bool(gconf_client, real_key, NULL); >+ g_free(real_key); >+#endif >+ return true; > } >+//--------------------------------------------------------------------------------- >+bool TBaseConf::ReadInt(const gchar *section, const gchar *key, gint *value, gint def) >+{ >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ gchar *str; > >-void AppConf::write_bool(const gchar *key, gboolean val) >+ if (!ReadString(section, key, &str)) { >+ *value = def; >+ return false; >+ } >+ *value = atoi(str); >+ g_free(str); >+#else >+ if (!gconf_client) { >+ *value=def; >+ return false; >+ } >+ >+ gchar *real_key=g_strdup_printf("%s/%s", section, key); >+ *value=gconf_client_get_int(gconf_client, real_key, NULL); >+ g_free(real_key); >+#endif >+ return true; >+} >+//--------------------------------------------------------------------------------- >+bool TBaseConf::ReadString(const gchar *section, const gchar *key, gchar **value) > { >+ *value=NULL; >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ ConfigSection *sect; >+ ConfigLine *line; >+ >+ if (!(sect = FindSection(section))) >+ return false; >+ if (!(line = sect->FindString(key))) >+ return false; >+ *value = g_strdup(line->value); >+#else > if (!gconf_client) >- return; >- gconf_client_set_bool (gconf_client, key, val, NULL); >+ return false; >+ >+ gchar *real_key=g_strdup_printf("%s/%s", section, key); >+ *value = gconf_client_get_string(gconf_client, real_key, NULL); >+ g_free(real_key); >+ >+#endif >+ return true; > } >+//--------------------------------------------------------------------------------- >+bool TBaseConf::ReadStrList(const gchar *section, const gchar *key, GSList **list) >+{ >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ gchar *str; > >-void AppConf::read_int(const gchar *key, gint *val ,gint def) >+ if (!ReadString(section, key, &str)) { >+ *list = NULL; >+ return false; >+ } >+ >+ *list = Str2List(str); >+ g_free (str); >+#else >+ if (!gconf_client) { >+ *list = NULL; >+ return false; >+ } >+ gchar *real_key=g_strdup_printf("%s/%s", section, key); >+ *list = gconf_client_get_list(gconf_client, real_key, GCONF_VALUE_STRING, NULL); >+ g_free(real_key); >+ >+#endif >+ return true; >+} >+//--------------------------------------------------------------------------------- >+void TBaseConf::WriteBool(const gchar *section, const gchar *key, gboolean value) > { >- if (!gconf_client) >- *val = def; >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ if (value) >+ WriteString(section, key, "1"); > else >- *val = gconf_client_get_int(gconf_client, key, NULL); >+ WriteString(section, key, "0"); >+#else >+ if (!gconf_client) >+ return; >+ gchar *real_key=g_strdup_printf("%s/%s", section, key); >+ gconf_client_set_bool(gconf_client, real_key, value, NULL); >+ g_free(real_key); >+#endif > } >- >-void AppConf::write_int(const gchar *key, gint val) >+//--------------------------------------------------------------------------------- >+void TBaseConf::WriteInt(const gchar *section, const gchar *key, gint value) > { >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ gchar *strvalue = g_strdup_printf("%d", value); >+ WriteString(section, key, strvalue); >+ g_free(strvalue); >+#else > if (!gconf_client) > return; >- gconf_client_set_int (gconf_client, key, val, NULL); >+ gchar *real_key=g_strdup_printf("%s/%s", section, key); >+ gconf_client_set_int(gconf_client, real_key, value, NULL); >+ g_free(real_key); >+#endif > } >- >-void AppConf::read_string(const gchar *key, gchar **str) >+//--------------------------------------------------------------------------------- >+void TBaseConf::WriteString(const gchar *section, const gchar *key, const gchar *value) > { >- if (!gconf_client) >- *str = NULL; >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ ConfigSection *sect; >+ ConfigLine *line; >+ >+ sect = FindSection(section); >+ if(!sect) >+ sect = CreateSection(section); >+ if((line = sect->FindString(key))){ >+ g_free(line->value); >+ line->value = g_strchug(g_strchomp(g_strdup (value))); >+ } > else >- *str = gconf_client_get_string(gconf_client, key, NULL); >+ sect->CreateString(key, value); >+ Save(); >+#else >+ if(!gconf_client) >+ return; >+ gchar *real_key=g_strdup_printf("%s/%s", section, key); >+ gconf_client_set_string(gconf_client, real_key, value, NULL); >+ g_free(real_key); >+#endif > } >- >-void AppConf::write_string(const gchar *key, const gchar *str) >+//--------------------------------------------------------------------------------- >+void TBaseConf::WriteStrList(const gchar *section, const gchar *key, GSList *list) > { >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ std::string string; >+ if (list) { >+ string+=(gchar *)(list->data); >+ list=list->next; >+ } >+ while (list) { >+ string += STRING_SEP; >+ string += (gchar *)(list->data); >+ list = list->next; >+ } >+ WriteString(section, key, string.c_str()); >+#else > if (!gconf_client) > return; >- gconf_client_set_string (gconf_client, key, str, NULL); >+ gchar *real_key=g_strdup_printf("%s/%s", section, key); >+ gconf_client_set_list(gconf_client, real_key, GCONF_VALUE_STRING, list, NULL); >+ g_free(real_key); >+#endif > } >+//--------------------------------------------------------------------------------- > >-void AppConf::read_list(const gchar *key, GConfValueType list_type, GSList **list) >+ >+AppConf::AppConf(const gchar *conf_path) : TBaseConf(conf_path) > { >- if (!gconf_client) >- *list = NULL; >- else >- *list = gconf_client_get_list(gconf_client, key, list_type, NULL); >+#if !defined(_WIN32) && !defined(WITHOUT_GNOME) >+ if (gconf_client!=NULL) { >+ gconf_client_notify_add(gconf_client, "/apps/stardict/preferences/dictionary/scan_selection", >+ dictionary_scan_selection_changed_cb, NULL, NULL, NULL); >+ gconf_client_notify_add(gconf_client, "/apps/stardict/preferences/main_window/hide_list", >+ main_window_hide_list_changed_cb, NULL, NULL, NULL); >+ gconf_client_notify_add(gconf_client, "/apps/stardict/preferences/floating_window/lock", >+ floatwin_lock_changed_cb, NULL, NULL, NULL); >+ gconf_client_notify_add(gconf_client, "/apps/stardict/preferences/floating_window/lock_x", >+ floatwin_lock_x_changed_cb, NULL, NULL, NULL); >+ gconf_client_notify_add(gconf_client, "/apps/stardict/preferences/floating_window/lock_y", >+ floatwin_lock_y_changed_cb, NULL, NULL, NULL); >+ } >+#endif >+ Load(); > } > >-void AppConf::write_list(const gchar *key, GConfValueType list_type, GSList *list) >+AppConf::~AppConf() > { >- if (!gconf_client) >- return; >- gconf_client_set_list(gconf_client, key, list_type, list, NULL); >+ free_list(search_website_list); >+ free_list(dict_order_list); >+ free_list(dict_disable_list); >+ free_list(treedict_order_list); >+ free_list(treedict_disable_list); > } > >-void AppConf::dictionary_scan_selection_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) >+#if !defined(_WIN32) && !defined(WITHOUT_GNOME) >+void AppConf::dictionary_scan_selection_changed_cb(GConfClient *client, guint id, >+ GConfEntry *entry, gpointer data) > { > GConfValue *value = gconf_entry_get_value (entry); > > gboolean scan = gconf_value_get_bool (value); >- gpAppFrame->oAppCore.oSelection.bEnable = scan; >+ // gpAppFrame->oAppCore.oSelection.bEnable = scan; > gtk_widget_set_sensitive(gpAppFrame->oAppCore.oFloatWin.StopButton, scan); >- if (scan != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gpAppFrame->oAppCore.oBottomWin.ScanSelectionCheckButton))) { >+ if(scan != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gpAppFrame->oAppCore.oBottomWin.ScanSelectionCheckButton))) { > gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gpAppFrame->oAppCore.oBottomWin.ScanSelectionCheckButton),scan); > //although this make check button's callback func write to Gconf again,this callback will not be called again. > } > if (scan) { > if (!GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) > gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_SCAN_ICON); >- if (gpAppFrame->oAppCore.oFloatWin.bIsLocked && (gpAppFrame->oAppCore.oFloatWin.QueryingWord.c_str())[0]!='\0') >+ if (conf->get_lock() && (gpAppFrame->oAppCore.oFloatWin.QueryingWord.c_str())[0]!='\0') > gpAppFrame->oAppCore.oFloatWin.Show(); > } > else { >@@ -137,52 +474,88 @@ > } > } > >-void AppConf::dictionary_only_scan_while_modifier_key_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) >+ >+void AppConf::main_window_hide_list_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) > { > GConfValue *value = gconf_entry_get_value (entry); > >- gpAppFrame->oAppCore.oSelection.only_scan_while_modifier_key = gconf_value_get_bool (value); >+ gboolean hide = gconf_value_get_bool (value); >+ if (hide) { >+ gtk_widget_hide(gpAppFrame->oAppCore.oMidWin.oToolWin.HideListButton); >+ gtk_widget_show(gpAppFrame->oAppCore.oMidWin.oToolWin.ShowListButton); >+ gtk_widget_hide(gpAppFrame->oAppCore.oMidWin.oIndexWin.vbox); >+ } >+ else { >+ gtk_widget_hide(gpAppFrame->oAppCore.oMidWin.oToolWin.ShowListButton); >+ gtk_widget_show(gpAppFrame->oAppCore.oMidWin.oToolWin.HideListButton); >+ gtk_widget_show(gpAppFrame->oAppCore.oMidWin.oIndexWin.vbox); >+ } > } > >-void AppConf::dictionary_hide_floatwin_when_modifier_key_released_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) >+ >+void AppConf::floatwin_lock_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) > { > GConfValue *value = gconf_entry_get_value (entry); > >- gpAppFrame->oAppCore.oFloatWin.hide_floatwin_when_modifier_key_released = gconf_value_get_bool (value); >+ gboolean lock = gconf_value_get_bool (value); >+ // gpAppFrame->oAppCore.oFloatWin.bIsLocked = lock; >+ if (lock) >+ gtk_image_set_from_stock(GTK_IMAGE(gpAppFrame->oAppCore.oFloatWin.lock_image),GTK_STOCK_GOTO_LAST,GTK_ICON_SIZE_MENU); >+ else >+ gtk_image_set_from_stock(GTK_IMAGE(gpAppFrame->oAppCore.oFloatWin.lock_image),GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_MENU); > } > >-void AppConf::dictionary_scan_modifier_key_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) >+void AppConf::floatwin_lock_x_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) > { >+ if (conf->get_lock()){ > GConfValue *value = gconf_entry_get_value (entry); >+ gint lock_x = gconf_value_get_int (value); > >- gpAppFrame->oAppCore.oSelection.scan_modifier_key = gconf_value_get_int (value); >+ gint old_x,old_y; >+ gtk_window_get_position(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),&old_x,&old_y); >+ if (lock_x!=old_x) >+ gtk_window_move(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),lock_x,old_y); >+ } > } > >-void AppConf::dictionary_enable_sound_event_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) >+void AppConf::floatwin_lock_y_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) > { >+ if (conf->get_lock()){ > GConfValue *value = gconf_entry_get_value (entry); >+ gint lock_y = gconf_value_get_int (value); > >- gpAppFrame->enable_sound_event = gconf_value_get_bool (value); >+ gint old_x,old_y; >+ gtk_window_get_position(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),&old_x,&old_y); >+ if (lock_y!=old_y) >+ gtk_window_move(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),old_x,lock_y); >+ } > } >- >-void AppConf::main_window_searchwebsite_list_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) >+#else >+void on_conf_dictionary_scan_selection_changed(gboolean scan) > { >- g_slist_foreach (gpAppFrame->oAppCore.oBottomWin.searchwebsite_list, (GFunc)g_free, NULL); >- g_slist_free (gpAppFrame->oAppCore.oBottomWin.searchwebsite_list); >- gpAppFrame->oAppCore.oBottomWin.searchwebsite_list = NULL; >- GConfValue *value = gconf_entry_get_value (entry); >- GSList *list = gconf_value_get_list(value); >- while (list) { >- gpAppFrame->oAppCore.oBottomWin.searchwebsite_list = g_slist_append(gpAppFrame->oAppCore.oBottomWin.searchwebsite_list, g_strdup(gconf_value_get_string((GConfValue *)(list->data)))); >- list = g_slist_next(list); >+ if (conf->get_scan_selection() == scan) >+ return; >+ >+ gtk_widget_set_sensitive(gpAppFrame->oAppCore.oFloatWin.StopButton, scan); >+ if (scan != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gpAppFrame->oAppCore.oBottomWin.ScanSelectionCheckButton))) >+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gpAppFrame->oAppCore.oBottomWin.ScanSelectionCheckButton),scan); >+ >+ if (scan) { >+ if (!GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) >+ gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_SCAN_ICON); >+ if (conf->get_lock() && (gpAppFrame->oAppCore.oFloatWin.QueryingWord.c_str())[0]!='\0') >+ gpAppFrame->oAppCore.oFloatWin.Show(); >+ } else { >+ if (!GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) >+ gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_STOP_ICON); >+ gpAppFrame->oAppCore.oFloatWin.Hide(); >+ gpAppFrame->oAppCore.oSelection.LastClipWord.clear(); > } > } > >-void AppConf::main_window_hide_list_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) >-{ >- GConfValue *value = gconf_entry_get_value (entry); > >- gboolean hide = gconf_value_get_bool (value); >+void on_conf_main_window_hide_list_changed(gboolean hide) >+{ > if (hide) { > gtk_widget_hide(gpAppFrame->oAppCore.oMidWin.oToolWin.HideListButton); > gtk_widget_show(gpAppFrame->oAppCore.oMidWin.oToolWin.ShowListButton); >@@ -195,73 +568,318 @@ > } > } > >-void AppConf::notification_area_icon_show_in_floatwin_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) >+ >+ >+void on_conf_floatwin_lock_changed(gboolean lock) > { >- GConfValue *value = gconf_entry_get_value (entry); >+ if (lock) >+ gtk_image_set_from_stock(GTK_IMAGE(gpAppFrame->oAppCore.oFloatWin.lock_image),GTK_STOCK_GOTO_LAST,GTK_ICON_SIZE_MENU); >+ else >+ gtk_image_set_from_stock(GTK_IMAGE(gpAppFrame->oAppCore.oFloatWin.lock_image),GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_MENU); >+} > >- gpAppFrame->oAppCore.oDockLet.query_in_floatwin = gconf_value_get_bool (value); >+#endif >+ >+//--------------------------------------------------------------------------------- >+//load preference >+void AppConf::Load(void) >+{ >+ ReadInt("/apps/stardict/preferences/main_window", "hpaned_pos", &hpaned_pos, DEFAULT_HPANED_POS); >+ ReadInt("/apps/stardict/preferences/main_window", "window_width", &window_width, DEFAULT_WINDOW_WIDTH); >+ ReadInt("/apps/stardict/preferences/main_window", "window_height", &window_height, DEFAULT_WINDOW_HEIGHT); >+ ReadInt("/apps/stardict/preferences/floating_window", "lock_x", &lock_x, 0); >+ ReadInt("/apps/stardict/preferences/floating_window", "lock_y", &lock_y, 0); >+ ReadBool("/apps/stardict/preferences/main_window", "maximized", &maximized, FALSE); >+ ReadBool("/apps/stardict/preferences/dictionary", "use_custom_font", &use_custom_font, FALSE); >+ ReadString("/apps/stardict/preferences/dictionary", "custom_font", &custom_font); >+ ReadBool("/apps/stardict/preferences/main_window", "hide_on_startup", &hide_on_startup, FALSE); >+ ReadBool("/apps/stardict/preferences/dictionary", "enable_sound_event", &enable_sound_event, TRUE); >+ ReadBool("/apps/stardict/preferences/main_window", "hide_list", &hide_list, FALSE); >+ ReadStrList("/apps/stardict/preferences/main_window", "search_website_list", &search_website_list); >+ ReadBool("/apps/stardict/preferences/dictionary", "scan_selection", &scan_selection, TRUE); >+ ReadBool("/apps/stardict/preferences/notification_area_icon", "query_in_floatwin", &query_in_floatwin, TRUE); >+ ReadBool("/apps/stardict/preferences/dictionary", "only_scan_while_modifier_key", &only_scan_while_modifier_key, FALSE); >+ ReadBool("/apps/stardict/preferences/dictionary", "hide_floatwin_when_modifier_key_released", &hide_floatwin_when_modifier_key_released, TRUE); >+ ReadInt("/apps/stardict/preferences/dictionary", "scan_modifier_key", &scan_modifier_key, 0); >+ ReadBool("/apps/stardict/preferences/main_window", "hide_on_startup", &hide_on_startup, FALSE); >+ ReadBool("/apps/stardict/preferences/floating_window", "pronounce_when_popup", &pronounce_when_popup, FALSE); >+ ReadInt("/apps/stardict/preferences/floating_window", "max_window_width", &max_window_width, DEFAULT_MAX_FLOATWIN_WIDTH); >+ ReadInt("/apps/stardict/preferences/floating_window", "max_window_height", &max_window_height, DEFAULT_MAX_FLOATWIN_HEIGHT); >+ ReadStrList("/apps/stardict/manage_dictionaries", "treedict_order_list", &treedict_order_list); >+ ReadStrList("/apps/stardict/manage_dictionaries", "treedict_disable_list", &treedict_disable_list); >+ ReadStrList("/apps/stardict/manage_dictionaries", "dict_order_list", &dict_order_list); >+ ReadStrList("/apps/stardict/manage_dictionaries", "dict_disable_list", &dict_disable_list); >+ ReadBool("/apps/stardict/preferences/floating_window", "lock", &lock, FALSE); > } >+//--------------------------------------------------------------------------------- >+void AppConf::set_hpaned_pos(gint value) >+{ >+ if (hpaned_pos==value) >+ return; > >-void AppConf::floatwin_max_window_width_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) >+ WriteInt("/apps/stardict/preferences/main_window", "hpaned_pos", value); >+ >+ hpaned_pos=value; >+} >+ >+void AppConf::set_window_width(gint value) > { >- GConfValue *value = gconf_entry_get_value (entry); >+ if (window_width==value) >+ return; > >- gint width = gconf_value_get_int (value); >- gpAppFrame->oAppCore.oFloatWin.Window_max_width = width; >- // need to resize floating window when it is locked? >+ WriteInt("/apps/stardict/preferences/main_window", "window_width", value); >+ >+ window_width=value; > } > >-void AppConf::floatwin_pronounce_when_popup_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) >+void AppConf::set_window_height(gint value) > { >- GConfValue *value = gconf_entry_get_value (entry); >+ if (window_height==value) >+ return; > >- gpAppFrame->oAppCore.oFloatWin.pronounce_when_popup = gconf_value_get_bool (value); >+ WriteInt("/apps/stardict/preferences/main_window", "window_height", value); >+ >+ window_height=value; > } > >-void AppConf::floatwin_max_window_height_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) >+void AppConf::set_lock_x(gint value) > { >- GConfValue *value = gconf_entry_get_value (entry); >+ if (lock_x==value) >+ return; > >- gint height = gconf_value_get_int (value); >- gpAppFrame->oAppCore.oFloatWin.Window_max_height = height; >+ WriteInt("/apps/stardict/preferences/floating_window", "lock_x", value); >+ >+ lock_x=value; > } > >-void AppConf::floatwin_lock_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) >+void AppConf::set_lock_y(gint value) > { >- GConfValue *value = gconf_entry_get_value (entry); >+ if (lock_y==value) >+ return; > >- gboolean lock = gconf_value_get_bool (value); >- gpAppFrame->oAppCore.oFloatWin.bIsLocked = lock; >- if (lock) >- gtk_image_set_from_stock(GTK_IMAGE(gpAppFrame->oAppCore.oFloatWin.lock_image),GTK_STOCK_GOTO_LAST,GTK_ICON_SIZE_MENU); >- else >- gtk_image_set_from_stock(GTK_IMAGE(gpAppFrame->oAppCore.oFloatWin.lock_image),GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_MENU); >+ WriteInt("/apps/stardict/preferences/floating_window", "lock_y", value); >+ >+ lock_y=value; > } > >-void AppConf::floatwin_lock_x_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) >+void AppConf::set_maximized(gboolean value) > { >- if (gpAppFrame->oAppCore.oFloatWin.bIsLocked) >- { >- GConfValue *value = gconf_entry_get_value (entry); >- gint lock_x = gconf_value_get_int (value); >+ if (maximized==value) >+ return; > >- gint old_x,old_y; >- gtk_window_get_position(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),&old_x,&old_y); >- if (lock_x!=old_x) >- gtk_window_move(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),lock_x,old_y); >- } >+ WriteBool("/apps/stardict/preferences/main_window", "maximized", value); >+ >+ maximized=value; > } > >-void AppConf::floatwin_lock_y_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data) >+void AppConf::set_hide_list(gboolean value) > { >- if (gpAppFrame->oAppCore.oFloatWin.bIsLocked) >- { >- GConfValue *value = gconf_entry_get_value (entry); >- gint lock_y = gconf_value_get_int (value); >+ if (hide_list==value) >+ return; > >- gint old_x,old_y; >- gtk_window_get_position(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),&old_x,&old_y); >- if (lock_y!=old_y) >- gtk_window_move(GTK_WINDOW(gpAppFrame->oAppCore.oFloatWin.FloatWindow),old_x,lock_y); >- } >+ WriteBool("/apps/stardict/preferences/main_window", "hide_list", value); >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ on_conf_main_window_hide_list_changed(value); >+#endif >+ >+ hide_list=value; >+} >+ >+void AppConf::set_search_website_list(GSList *value) >+{ >+ if (search_website_list==value) >+ return; >+ g_slist_foreach(search_website_list, (GFunc)g_free, NULL); >+ g_slist_free(search_website_list); >+ search_website_list = NULL; >+ >+ WriteStrList("/apps/stardict/preferences/main_window", "search_website_list", value); >+ >+ search_website_list=value; >+} >+ >+void AppConf::set_scan_selection(gboolean value) >+{ >+ if (scan_selection==value) >+ return; >+ >+ WriteBool("/apps/stardict/preferences/dictionary", "scan_selection", value); >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ on_conf_dictionary_scan_selection_changed(value); >+#endif >+ >+ scan_selection=value; >+} >+ >+void AppConf::set_only_scan_while_modifier_key(gboolean value) >+{ >+ if (only_scan_while_modifier_key==value) >+ return; >+ >+ WriteBool("/apps/stardict/preferences/dictionary", "only_scan_while_modifier_key", value); >+ >+ only_scan_while_modifier_key=value; >+} >+ >+void AppConf::set_hide_floatwin_when_modifier_key_released(gboolean value) >+{ >+ if (hide_floatwin_when_modifier_key_released==value) >+ return; >+ >+ WriteBool("/apps/stardict/preferences/dictionary", "hide_floatwin_when_modifier_key_released", value); >+ >+ hide_floatwin_when_modifier_key_released=value; >+} >+ >+void AppConf::set_scan_modifier_key(gint value) >+{ >+ if (scan_modifier_key==value) >+ return; >+ >+ WriteInt("/apps/stardict/preferences/dictionary", "scan_modifier_key", value); >+ >+ scan_modifier_key=value; >+} >+ >+void AppConf::set_custom_font(const gchar *value) >+{ >+ if (custom_font==value || >+ (custom_font && value && strcmp(custom_font, value)==0)) >+ return; >+ >+ WriteString("/apps/stardict/preferences/dictionary", "custom_font", value); >+ >+ custom_font=g_strdup(value); >+} >+ >+void AppConf::set_enable_sound_event(gboolean value) >+{ >+ if (enable_sound_event==value) >+ return; >+ >+ WriteBool("/apps/stardict/preferences/dictionary", "enable_sound_event", value); >+ >+ enable_sound_event=value; >+} >+ >+void AppConf::set_use_custom_font(gboolean value) >+{ >+ if (use_custom_font==value) >+ return; >+ >+ WriteBool("/apps/stardict/preferences/dictionary", "use_custom_font", value); >+ >+ use_custom_font=value; >+} >+ >+void AppConf::set_hide_on_startup(gboolean value) >+{ >+ if (hide_on_startup==value) >+ return; >+ >+ WriteBool("/apps/stardict/preferences/main_window", "hide_on_startup", value); >+ >+ hide_on_startup=value; >+} >+ >+void AppConf::set_query_in_floatwin(gboolean value) >+{ >+ if (query_in_floatwin==value) >+ return; >+ >+ WriteBool("/apps/stardict/preferences/notification_area_icon", "query_in_floatwin", value); >+ >+ query_in_floatwin=value; >+} >+ >+void AppConf::set_pronounce_when_popup(gboolean value) >+{ >+ if (pronounce_when_popup==value) >+ return; >+ >+ WriteBool("/apps/stardict/preferences/floating_window", "pronounce_when_popup", value); >+ >+ pronounce_when_popup=value; >+} >+ >+void AppConf::set_max_window_width(gint value) >+{ >+ if (max_window_width==value) >+ return; >+ >+ WriteInt("/apps/stardict/preferences/floating_window", "max_window_width", value); >+ >+ max_window_width=value; >+} >+ >+void AppConf::set_max_window_height(gint value) >+{ >+ if (max_window_height==value) >+ return; >+ >+ WriteInt("/apps/stardict/preferences/floating_window", "max_window_height", value); >+ >+ max_window_height=value; >+} >+ >+void AppConf::set_treedict_order_list(GSList *value) >+{ >+ if (treedict_order_list==value) >+ return; >+ >+ WriteStrList("/apps/stardict/manage_dictionaries", "treedict_order_list", value); >+ >+ g_slist_foreach(treedict_order_list, (GFunc)g_free, NULL); >+ g_slist_free(treedict_order_list); >+ treedict_order_list=value; >+} >+ >+void AppConf::set_treedict_disable_list(GSList *value) >+{ >+ if (treedict_disable_list==value) >+ return; >+ >+ WriteStrList("/apps/stardict/manage_dictionaries", "treedict_disable_list", value); >+ >+ g_slist_foreach(treedict_disable_list, (GFunc)g_free, NULL); >+ g_slist_free(treedict_disable_list); >+ treedict_disable_list=value; >+} >+ >+void AppConf::set_dict_order_list(GSList *value) >+{ >+ if (dict_order_list==value) >+ return; >+ >+ WriteStrList("/apps/stardict/manage_dictionaries", "dict_order_list", value); >+ >+ g_slist_foreach(dict_order_list, (GFunc)g_free, NULL); >+ g_slist_free(dict_order_list); >+ dict_order_list=value; >+} >+ >+void AppConf::set_dict_disable_list(GSList *value) >+{ >+ if (dict_disable_list==value) >+ return; >+ >+ WriteStrList("/apps/stardict/manage_dictionaries", "dict_disable_list", value); >+ >+ g_slist_foreach(dict_disable_list, (GFunc)g_free, NULL); >+ g_slist_free(dict_disable_list); >+ >+ dict_disable_list=value; >+} >+ >+void AppConf::set_lock(gboolean value) >+{ >+ if (lock==value) >+ return; >+ >+ WriteBool("/apps/stardict/preferences/floating_window", "lock", value); >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ on_conf_floatwin_lock_changed(value); >+#endif >+ >+ lock=value; > } >diff -bBurNd stardict-2.4.4.orig/src/conf.h stardict-2.4.4/src/conf.h >--- stardict-2.4.4.orig/src/conf.h 2003-09-23 14:19:44.000000000 +0400 >+++ stardict-2.4.4/src/conf.h 2005-01-18 23:48:52.000000000 +0300 >@@ -1,43 +1,155 @@ > #ifndef __SD_CONF_H__ > #define __SD_CONF_H__ > >-#include <libgnome/libgnome.h> >-#include <gconf/gconf-client.h> >+#include <glib.h> >+#include <memory> > >-class AppConf >-{ >-private: >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+struct ConfigLine { >+ gchar *key; >+ gchar *value; >+}; >+ >+struct ConfigSection { >+ gchar *name; >+ GList *lines; >+ ConfigLine *CreateString(const gchar * key, const gchar * value); >+ ConfigLine *FindString(const gchar * key); >+}; >+#else >+# include <gconf/gconf.h> >+# include <gconf/gconf-client.h> >+#endif >+ >+/* >+ * TBaseConf class encapsule methods >+ * for geting access to variables in some config repository, >+ * it can be gconf server or file. >+*/ >+ >+class TBaseConf { >+public: >+ explicit TBaseConf(const gchar *conf_path); >+ ~TBaseConf(); >+ >+ bool ReadBool(const gchar *section, const gchar *key, gboolean *value, gboolean def); >+ bool ReadInt(const gchar *section, const gchar *key, gint *value, gint def); >+ bool ReadString(const gchar * section, const gchar *key, gchar **value); >+ bool ReadStrList(const gchar * section, const gchar * key, GSList **slist); >+ >+ void WriteBool(const gchar *section, const gchar *key, gboolean value); >+ void WriteInt(const gchar *section, const gchar *key, gint value); >+ void WriteString(const gchar *section, const gchar *key, const gchar *value); >+ void WriteStrList(const gchar *section, const gchar *key, GSList *slist); >+ >+protected: >+ gchar *cfgfilename; >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ GList *sections; >+ >+ ConfigSection *CreateSection(const gchar * name); >+ ConfigSection *FindSection(const gchar * name); >+ bool Open(const gchar * filename); >+ bool Write(const gchar * filename); >+ inline void Save(void){ Write(cfgfilename); } >+#else > GConfClient *gconf_client; >+#endif >+}; >+ >+/* >+ * AppConf class encapsulate >+ * all preference of stardict. >+*/ >+ >+class AppConf : public TBaseConf { >+private: >+ gint hpaned_pos; >+ gint window_width, window_height; >+ gint lock_x, lock_y; >+ gboolean maximized; >+ gboolean use_custom_font; >+ gchar *custom_font; >+ gboolean hide_on_startup; >+ gboolean enable_sound_event; >+ gboolean hide_list; >+ GSList *search_website_list; >+ gboolean scan_selection; >+ gboolean query_in_floatwin; >+ gboolean only_scan_while_modifier_key; >+ gboolean hide_floatwin_when_modifier_key_released; >+ gint scan_modifier_key; >+ gboolean pronounce_when_popup; >+ gint max_window_width, max_window_height; >+ GSList *treedict_order_list, *treedict_disable_list; >+ GSList *dict_order_list, *dict_disable_list; >+ gboolean lock; > >+#if !defined(_WIN32) && !defined(WITHOUT_GNOME) > static void dictionary_scan_selection_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data); >- static void dictionary_only_scan_while_modifier_key_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data); >- static void dictionary_hide_floatwin_when_modifier_key_released_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data); >- static void dictionary_scan_modifier_key_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data); >- static void dictionary_enable_sound_event_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data); >- static void main_window_searchwebsite_list_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data); > static void main_window_hide_list_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data); >- static void notification_area_icon_show_in_floatwin_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data); >- static void floatwin_pronounce_when_popup_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data); >- static void floatwin_max_window_width_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data); >- static void floatwin_max_window_height_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data); > static void floatwin_lock_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data); > static void floatwin_lock_x_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data); > static void floatwin_lock_y_changed_cb(GConfClient *client, guint id, GConfEntry *entry, gpointer data); >+#endif >+ > public: >- AppConf(); >+ explicit AppConf(const gchar *conf_path); > ~AppConf(); >+ void Load(void); > >- void EnableNotify(); >- void DisableNotify(); >- >- void read_bool(const gchar *key, gboolean *val, gboolean def); >- void write_bool(const gchar *key, gboolean val); >- void read_int(const gchar *key, gint *val ,gint def); >- void write_int(const gchar *key, gint val); >- void read_string(const gchar *key, gchar **str); >- void write_string(const gchar *key, const gchar *str); >- void read_list(const gchar *key, GConfValueType list_type, GSList **list); >- void write_list(const gchar *key, GConfValueType list_type, GSList *list); >+ gint get_hpaned_pos(void){return hpaned_pos;} >+ void set_hpaned_pos(gint value); >+ gint get_window_width(void){return window_width;} >+ void set_window_width(gint value); >+ gint get_window_height(void){return window_height;} >+ void set_window_height(gint value); >+ gint get_lock_x(void){return lock_x;} >+ void set_lock_x(gint value); >+ gint get_lock_y(void){return lock_y;} >+ void set_lock_y(gint value); >+ gboolean get_maximized(void){return maximized;} >+ void set_maximized(gboolean value); >+ gboolean get_use_custom_font(void){return use_custom_font;} >+ void set_use_custom_font(gboolean value); >+ const gchar *get_custom_font(void){return custom_font;} >+ void set_custom_font(const gchar *value); >+ gboolean get_hide_on_startup(void){return hide_on_startup;} >+ void set_hide_on_startup(gboolean value); >+ gboolean get_enable_sound_event(void){return enable_sound_event;} >+ void set_enable_sound_event(gboolean value); >+ gboolean get_hide_list(void){return hide_list;} >+ void set_hide_list(gboolean value); >+ const GSList *get_search_website_list(void){return search_website_list;} >+ void set_search_website_list(GSList *value); >+ gboolean get_scan_selection(void){return scan_selection;} >+ void set_scan_selection(gboolean value); >+ gboolean get_query_in_floatwin(void){return query_in_floatwin;} >+ void set_query_in_floatwin(gboolean value); >+ gboolean get_only_scan_while_modifier_key(void){return only_scan_while_modifier_key;} >+ void set_only_scan_while_modifier_key(gboolean value); >+ gboolean get_hide_floatwin_when_modifier_key_released(void){return hide_floatwin_when_modifier_key_released;} >+ void set_hide_floatwin_when_modifier_key_released(gboolean value); >+ gint get_scan_modifier_key(void){return scan_modifier_key;} >+ void set_scan_modifier_key(gint value); >+ gboolean get_pronounce_when_popup(void){return pronounce_when_popup;} >+ void set_pronounce_when_popup(gboolean value); >+ gint get_max_window_width(void){return max_window_width;} >+ void set_max_window_width(gint value); >+ gint get_max_window_height(void){return max_window_height;} >+ void set_max_window_height(gint value); >+ const GSList *get_treedict_order_list(void){return treedict_order_list;} >+ void set_treedict_order_list(GSList *value); >+ const GSList *get_treedict_disable_list(void){return treedict_disable_list;} >+ void set_treedict_disable_list(GSList *value); >+ const GSList *get_dict_order_list(void){return dict_order_list;} >+ void set_dict_order_list(GSList *value); >+ const GSList *get_dict_disable_list(void){return dict_disable_list;} >+ void set_dict_disable_list(GSList *value); >+ gboolean get_lock(void){return lock;} >+ void set_lock(gboolean value); > }; > >+extern std::auto_ptr<AppConf> conf;//global exemplar of AppConf class >+ > #endif >diff -bBurNd stardict-2.4.4.orig/src/dictmanagedlg.cpp stardict-2.4.4/src/dictmanagedlg.cpp >--- stardict-2.4.4.orig/src/dictmanagedlg.cpp 2003-11-14 07:10:36.000000000 +0300 >+++ stardict-2.4.4/src/dictmanagedlg.cpp 2005-01-18 19:30:10.000000000 +0300 >@@ -1,9 +1,8 @@ > #ifdef HAVE_CONFIG_H > # include "config.h" > #endif >-#include "dictmanagedlg.h" >-#include "stardict.h" >-#include "string.h" >+ >+#include <cstring> > #include <sys/stat.h> > > #ifdef _WIN32 >@@ -11,6 +10,10 @@ > # include "win32/intl.h" > #endif > >+#include "stardict.h" >+#include "conf.h" >+ >+#include "dictmanagedlg.h" > > DictManageDlg::DictManageDlg() > { >@@ -153,7 +156,7 @@ > return true; > } > >-void DictManageDlg::load_dir(gboolean istreedict, gchar *dirname, GSList *order_list, GSList *disable_list, GtkListStore *model) >+void DictManageDlg::load_dir(gboolean istreedict, gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkListStore *model) > { > GDir *dir = g_dir_open(dirname, 0, NULL); > if (dir) >@@ -162,7 +165,7 @@ > const gchar *filename; > gchar fullfilename[256]; > gboolean loaded; >- GSList *tmplist1,*tmplist2; >+ const GSList *tmplist1,*tmplist2; > gboolean disabled; > glong wordcount; > gchar *bookname, *author, *email, *website, *description, *date; >@@ -214,24 +217,13 @@ > > 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); > >- GSList *order_list, *disable_list; >+ const GSList *order_list, *disable_list; > if (istreedict) { >-#ifdef _WIN32 >- rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "treedict_order_list", &order_list); >- rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "treedict_disable_list", &disable_list); >-#else >- gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/treedict_order_list", GCONF_VALUE_STRING, &order_list); >- gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/treedict_disable_list", GCONF_VALUE_STRING, &disable_list); >-#endif >- } >- else { >-#ifdef _WIN32 >- rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "dict_order_list", &order_list); >- rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "dict_disable_list", &disable_list); >-#else >- gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/dict_order_list", GCONF_VALUE_STRING, &order_list); >- gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/dict_disable_list", GCONF_VALUE_STRING, &disable_list); >-#endif >+ order_list=conf->get_treedict_order_list(); >+ disable_list=conf->get_treedict_disable_list(); >+ } else { >+ order_list=conf->get_dict_order_list(); >+ disable_list=conf->get_dict_disable_list(); > } > > glong wordcount; >@@ -240,7 +232,7 @@ > GtkTreeIter iter; > > gchar *ifofilename; >- GSList *tmplist1,*tmplist2; >+ const GSList *tmplist1,*tmplist2; > gboolean disabled; > tmplist1 = order_list; > while (tmplist1) { >@@ -291,12 +283,6 @@ > load_dir(istreedict, STARDICT_DATA_DIR "/dic", order_list, disable_list, model); > #endif > >- g_slist_foreach (order_list, (GFunc)g_free, NULL); >- g_slist_free(order_list); >- >- g_slist_foreach (disable_list, (GFunc)g_free, NULL); >- g_slist_free(disable_list); >- > return GTK_TREE_MODEL (model); > } > >@@ -329,14 +315,7 @@ > } > have_iter = gtk_tree_model_iter_next(model, &iter); > } >-#ifdef _WIN32 >- rw_cfg_write_strlist (usercfgfile, "manage_dictionaries", "dict_disable_list", disable_list); >-#else >- gpAppFrame->oAppConf.write_list("/apps/stardict/manage_dictionaries/dict_disable_list", GCONF_VALUE_STRING, disable_list); >-#endif >- >- g_slist_foreach (disable_list, (GFunc)g_free, NULL); >- g_slist_free(disable_list); >+ conf->set_dict_disable_list(disable_list); > } > > void DictManageDlg::on_treedict_enable_toggled (GtkCellRendererToggle *cell, gchar *path_str, DictManageDlg *oDictManageDlg) >@@ -368,14 +347,7 @@ > } > have_iter = gtk_tree_model_iter_next(model, &iter); > } >-#ifdef _WIN32 >- rw_cfg_write_strlist (usercfgfile, "manage_dictionaries", "treedict_disable_list", disable_list); >-#else >- gpAppFrame->oAppConf.write_list("/apps/stardict/manage_dictionaries/treedict_disable_list", GCONF_VALUE_STRING, disable_list); >-#endif >- >- g_slist_foreach (disable_list, (GFunc)g_free, NULL); >- g_slist_free(disable_list); >+ conf->set_treedict_disable_list(disable_list); > } > > void DictManageDlg::drag_data_get_cb(GtkWidget *widget, GdkDragContext *ctx, GtkSelectionData *data, guint info, guint time, DictManageDlg *oDictManageDlg) >@@ -563,23 +535,10 @@ > have_iter = gtk_tree_model_iter_next(now_tree_model, &iter); > } > >- if (istreedict) { >-#ifdef _WIN32 >- rw_cfg_write_strlist (usercfgfile, "manage_dictionaries", "treedict_order_list", order_list); >-#else >- gpAppFrame->oAppConf.write_list("/apps/stardict/manage_dictionaries/treedict_order_list", GCONF_VALUE_STRING, order_list); >-#endif >- } >- else { >-#ifdef _WIN32 >- rw_cfg_write_strlist (usercfgfile, "manage_dictionaries", "dict_order_list", order_list); >-#else >- gpAppFrame->oAppConf.write_list("/apps/stardict/manage_dictionaries/dict_order_list", GCONF_VALUE_STRING, order_list); >-#endif >- } >- >- g_slist_foreach (order_list, (GFunc)g_free, NULL); >- g_slist_free(order_list); >+ if (istreedict) >+ conf->set_treedict_order_list(order_list); >+ else >+ conf->set_dict_order_list(order_list); > } > > void DictManageDlg::on_move_top_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg) >diff -bBurNd stardict-2.4.4.orig/src/dictmanagedlg.h stardict-2.4.4/src/dictmanagedlg.h >--- stardict-2.4.4.orig/src/dictmanagedlg.h 2003-11-14 05:11:59.000000000 +0300 >+++ stardict-2.4.4/src/dictmanagedlg.h 2005-01-18 19:25:59.000000000 +0300 >@@ -13,7 +13,7 @@ > GtkWidget *treedict_treeview; > GtkTreeModel *treedict_tree_model; > >- static void load_dir(gboolean istreedict, gchar *dirname, GSList *order_list, GSList *disable_list, GtkListStore *model); >+ static void load_dir(gboolean istreedict, gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkListStore *model); > static GtkTreeModel* create_dict_tree_model (gboolean istreedict); > GtkWidget *create_dict_tree(gboolean istreedict); > >diff -bBurNd stardict-2.4.4.orig/src/docklet.cpp stardict-2.4.4/src/docklet.cpp >--- stardict-2.4.4.orig/src/docklet.cpp 2003-11-13 11:42:15.000000000 +0300 >+++ stardict-2.4.4/src/docklet.cpp 2005-01-18 19:48:26.000000000 +0300 >@@ -1,6 +1,11 @@ >-#include "config.h" >-#include "docklet.h" >+#ifdef HAVE_CONFIG_H >+# include "config.h" >+#endif >+ > #include "stardict.h" >+#include "conf.h" >+ >+#include "docklet.h" > > /* > // for my_gtk_window_get_active() >@@ -18,8 +23,6 @@ > > void DockLet::Create(DockLetIconType iconType) > { >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/notification_area_icon/query_in_floatwin", &query_in_floatwin, true); >- > docklet = egg_tray_icon_new("StarDict"); > GtkWidget *box = gtk_event_box_new(); > if (iconType == DOCKLET_NORMAL_ICON) >@@ -95,7 +98,7 @@ > > void DockLet::MenuScanCallback(GtkCheckMenuItem *checkmenuitem, gpointer user_data) > { >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/scan_selection",gtk_check_menu_item_get_active(checkmenuitem)); >+ conf->set_scan_selection(gtk_check_menu_item_get_active(checkmenuitem)); > } > > void DockLet::MenuQuitCallback(GtkMenuItem *menuitem, gpointer user_data) >@@ -126,7 +129,7 @@ > > gtk_widget_show_all(menu); > } >- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(scan_menuitem), gpAppFrame->oAppCore.oSelection.bEnable); >+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(scan_menuitem), conf->get_scan_selection()); > > gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time); > } >@@ -197,38 +200,32 @@ > if (event->button ==1) { > > if ((event->state & GDK_CONTROL_MASK)&&(!(event->state & GDK_MOD1_MASK))&&(!(event->state & GDK_SHIFT_MASK))) { >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/scan_selection", !(gpAppFrame->oAppCore.oSelection.bEnable)); >+ conf->set_scan_selection(!conf->get_scan_selection()); > return true; >- } >- else { >+ } else { > if (GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) { > //if (GTK_WINDOW(gpAppFrame->oAppCore.window)->is_active) { > //if (my_gtk_window_get_active(gpAppFrame->oAppCore.window)) { > gtk_widget_hide(gpAppFrame->oAppCore.window); >- } >- else { >+ } else { > gtk_window_present(GTK_WINDOW(gpAppFrame->oAppCore.window)); > if (gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry))[0]) { > gtk_widget_grab_focus(gpAppFrame->oAppCore.oMidWin.oTextWin.textview); //so user can input word directly. >- } >- else { >+ } else { > gtk_widget_grab_focus(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry); //this won't change selection text. > } > } > } >- } >- else if (event->button ==2) { >- if (oDockLet->query_in_floatwin) { >+ } else if (event->button ==2) { >+ if (conf->get_query_in_floatwin()) { > gpAppFrame->oAppCore.oSelection.LastClipWord.clear(); > gtk_selection_convert (gpAppFrame->oAppCore.oSelection.selection_widget, GDK_SELECTION_PRIMARY, gpAppFrame->oAppCore.oSelection.UTF8_STRING_Atom, GDK_CURRENT_TIME); >- } >- else { >+ } else { > gtk_window_present(GTK_WINDOW(gpAppFrame->oAppCore.window)); > gtk_selection_convert (gpAppFrame->oAppCore.oMidWin.oTextWin.textview, GDK_SELECTION_PRIMARY, gpAppFrame->oAppCore.oSelection.UTF8_STRING_Atom, GDK_CURRENT_TIME); > } > return true; >- } >- else if (event->button ==3) { >+ } else if (event->button ==3) { > oDockLet->PopupMenu(event); > return true; > } >diff -bBurNd stardict-2.4.4.orig/src/docklet.h stardict-2.4.4/src/docklet.h >--- stardict-2.4.4.orig/src/docklet.h 2003-09-23 14:19:44.000000000 +0400 >+++ stardict-2.4.4/src/docklet.h 2005-01-18 18:51:57.000000000 +0300 >@@ -29,7 +29,7 @@ > void PopupMenu(GdkEventButton *event); > public: > gboolean embedded; >- gboolean query_in_floatwin; >+ > DockLet(); > void Create(DockLetIconType iconType = DOCKLET_NORMAL_ICON); > void End(); >diff -bBurNd stardict-2.4.4.orig/src/floatwin.cpp stardict-2.4.4/src/floatwin.cpp >--- stardict-2.4.4.orig/src/floatwin.cpp 2004-10-29 12:12:29.000000000 +0400 >+++ stardict-2.4.4/src/floatwin.cpp 2005-01-18 19:49:46.000000000 +0300 >@@ -2,16 +2,19 @@ > # include "config.h" > #endif > >-#include <string.h> >+#include <cstring> > #include <string> >-#include "floatwin.h" >-#include "stardict.h" > > #ifdef _WIN32 > # include <gdk/gdkwin32.h> > # include "win32/intl.h" > #endif > >+#include "stardict.h" >+#include "conf.h" >+ >+#include "floatwin.h" >+ > FloatWin::FloatWin() > { > timeout = 0; >@@ -42,46 +45,29 @@ > g_signal_connect (G_OBJECT (FloatWindow), "enter_notify_event", G_CALLBACK (vEnterNotifyCallback), this); > g_signal_connect (G_OBJECT (FloatWindow), "leave_notify_event", G_CALLBACK (vLeaveNotifyCallback), this); > >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "hide_floatwin_when_modifier_key_released", &hide_floatwin_when_modifier_key_released); >- rw_cfg_read_boolean (usercfgfile, "preferences/floating_window", "lock", &bIsLocked); >- rw_cfg_read_boolean (usercfgfile, "preferences/floating_window", "pronounce_when_popup", &pronounce_when_popup); >- rw_cfg_read_int (usercfgfile, "preferences/floating_window", "max_window_width", &Window_max_width); >- rw_cfg_read_int (usercfgfile, "preferences/floating_window", "max_window_height", &Window_max_height); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/hide_floatwin_when_modifier_key_released", &hide_floatwin_when_modifier_key_released, true); >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/floating_window/lock", &bIsLocked, false); >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/floating_window/pronounce_when_popup", &pronounce_when_popup, false); >- gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/floating_window/max_window_width", &Window_max_width, DEFAULT_MAX_FLOATWIN_WIDTH); >- gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/floating_window/max_window_height", &Window_max_height, DEFAULT_MAX_FLOATWIN_HEIGHT); >-#endif >- > GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(FloatWindow)); > gint screen_width = gdk_screen_get_width(screen); > gint screen_height = gdk_screen_get_height(screen); > >- if ((Window_max_width < MIN_MAX_FLOATWIN_WIDTH)||(Window_max_width>screen_width)) >- Window_max_width = DEFAULT_MAX_FLOATWIN_WIDTH; >- if ((Window_max_height < MIN_MAX_FLOATWIN_HEIGHT)||(Window_max_height>screen_height)) >- Window_max_height = DEFAULT_MAX_FLOATWIN_HEIGHT; >+ if (conf->get_max_window_width() < MIN_MAX_FLOATWIN_WIDTH || >+ conf->get_max_window_width()>screen_width) >+ conf->set_max_window_width(DEFAULT_MAX_FLOATWIN_WIDTH); >+ if (conf->get_max_window_height() < MIN_MAX_FLOATWIN_HEIGHT || >+ conf->get_max_window_height()>screen_height) >+ conf->set_max_window_height(DEFAULT_MAX_FLOATWIN_HEIGHT); > >- gint lock_x,lock_y; >-#ifdef _WIN32 >- rw_cfg_read_int (usercfgfile, "preferences/floating_window", "lock_x", &lock_x); >- rw_cfg_read_int (usercfgfile, "preferences/floating_window", "lock_y", &lock_y); >-#else >- gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/floating_window/lock_x", &lock_x, 0); >- gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/floating_window/lock_y", &lock_y, 0); >-#endif >+ gint >+ lock_x=conf->get_lock_x(), >+ lock_y=conf->get_lock_y(); > > if (lock_x<0) > lock_x=0; >- else if (lock_x > (screen_width - Window_max_width)) >- lock_x = screen_width - Window_max_width; >+ else if (lock_x > (screen_width - conf->get_max_window_width())) >+ lock_x = screen_width - conf->get_max_window_width(); > if (lock_y<0) > lock_y=0; >- else if (lock_y > (screen_height - Window_max_height)) >- lock_y = screen_height - Window_max_height; >+ else if (lock_y > (screen_height - conf->get_max_window_height())) >+ lock_y = screen_height - conf->get_max_window_height(); > gtk_window_move(GTK_WINDOW(FloatWindow),lock_x,lock_y); > > GtkWidget *frame; >@@ -130,12 +116,8 @@ > g_signal_connect(G_OBJECT(StopButton),"enter_notify_event", G_CALLBACK(stardict_on_enter_notify), NULL); > gtk_box_pack_start(GTK_BOX(button_hbox),StopButton,false,false,0); > gtk_tooltips_set_tip(gpAppFrame->oAppCore.tooltips, StopButton, _("Stop selection scanning"),NULL); >- gboolean scan; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "scan_selection", &scan); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/scan_selection", &scan, true); >-#endif >+ gboolean scan=conf->get_scan_selection(); >+ > gtk_widget_set_sensitive(gpAppFrame->oAppCore.oFloatWin.StopButton, scan); > > button= gtk_button_new(); >@@ -155,7 +137,7 @@ > gtk_tooltips_set_tip(gpAppFrame->oAppCore.tooltips,button,_("Quit"),NULL); > > button = gtk_button_new(); >- if (bIsLocked) >+ if (conf->get_lock()) > lock_image= gtk_image_new_from_stock(GTK_STOCK_GOTO_LAST,GTK_ICON_SIZE_MENU); > else > lock_image= gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_MENU); >@@ -294,7 +276,7 @@ > gtk_widget_set_sensitive(PronounceWordButton, canRead); > Popup(true); > >- if (canRead && pronounce_when_popup) >+ if (canRead && conf->get_pronounce_when_popup()) > gpAppFrame->oReadWord.read(PronounceWord.c_str()); > } > >@@ -427,7 +409,7 @@ > > Popup(false); > >- if (canRead && pronounce_when_popup) >+ if (canRead && conf->get_pronounce_when_popup()) > gpAppFrame->oReadWord.read(PronounceWord.c_str()); > } > >@@ -458,7 +440,7 @@ > g_free(m_word); > g_free(m_reason); > >- if (canRead && pronounce_when_popup) >+ if (canRead && conf->get_pronounce_when_popup()) > gpAppFrame->oReadWord.read(PronounceWord.c_str()); > } > >@@ -478,14 +460,14 @@ > > GtkRequisition requisition; > gtk_widget_size_request(label,&requisition); >- if (requisition.width > Window_max_width) { >- gtk_widget_set_size_request(label, Window_max_width, -1); // it is not really max window width setting. >+ if (requisition.width > conf->get_max_window_width()) { >+ gtk_widget_set_size_request(label, conf->get_max_window_width(), -1); // it is not really max window width setting. > gtk_label_set_line_wrap (GTK_LABEL (label), true); > gtk_widget_size_request(label,&requisition); //update requisition. > } > gint window_width,window_height; > 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 >- if (requisition.height > Window_max_height) { >+ if (requisition.height > conf->get_max_window_height()) { > static gint vscrollbar_width = 0; > if (!vscrollbar_width) { > if (GTK_SCROLLED_WINDOW(scrolled_window)->vscrollbar) { >@@ -497,8 +479,8 @@ > vscrollbar_width += scrollbar_spacing; > } > } >- gtk_widget_set_size_request(scrolled_window, requisition.width + vscrollbar_width, Window_max_height); >- window_height = 2*(FLOATWIN_BORDER_WIDTH+2) + Window_max_height; >+ gtk_widget_set_size_request(scrolled_window, requisition.width + vscrollbar_width, conf->get_max_window_height()); >+ window_height = 2*(FLOATWIN_BORDER_WIDTH+2) + conf->get_max_window_height(); > window_width += vscrollbar_width; > } > else { >@@ -513,7 +495,7 @@ > window_width = (button_hbox->allocation).width + 2*(FLOATWIN_BORDER_WIDTH+2); > } > >- if (bIsLocked) { >+ if (conf->get_lock()) { > gtk_window_resize(GTK_WINDOW(FloatWindow),window_width,window_height); > now_window_width = window_width; > now_window_height = window_height; >@@ -533,7 +515,7 @@ > gdk_display_get_pointer(display,NULL,&iCurrentX,&iCurrentY, &mask); > > gboolean pressed = false; >- switch (gpAppFrame->oAppCore.oSelection.scan_modifier_key) { >+ switch (conf->get_scan_modifier_key()) { > #ifdef _WIN32 > case 0: > if (mask & GDK_SHIFT_MASK) >@@ -630,8 +612,8 @@ > { > FloatWin *oFloatWin = (FloatWin *)data; > >- if((!oFloatWin->bIsLocked) && (!oFloatWin->ismoving) && (GTK_WIDGET_VISIBLE(oFloatWin->FloatWindow))) >- { >+ if(!conf->get_lock() && (!oFloatWin->ismoving) && >+ (GTK_WIDGET_VISIBLE(oFloatWin->FloatWindow))) { > GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(oFloatWin->FloatWindow)); > GdkDisplay *display = gdk_screen_get_display(screen); > >@@ -639,10 +621,11 @@ > GdkModifierType mask; > gdk_display_get_pointer(display,NULL,&iCurrentX,&iCurrentY, &mask); > >- if (gpAppFrame->oAppCore.oSelection.only_scan_while_modifier_key && oFloatWin->hide_floatwin_when_modifier_key_released) { >+ if (conf->get_only_scan_while_modifier_key() && >+ conf->get_hide_floatwin_when_modifier_key_released()) { > if (iCurrentX == oFloatWin->popup_pointer_x && iCurrentY==oFloatWin->popup_pointer_y) { > gboolean released = false; >- switch (gpAppFrame->oAppCore.oSelection.scan_modifier_key) { >+ switch (conf->get_scan_modifier_key()) { > #ifdef _WIN32 > case 0: > if (!(mask & GDK_SHIFT_MASK)) >@@ -655,7 +638,6 @@ > default: > if (!(mask & GDK_CONTROL_MASK)) > released = true; >- break; > #else > case 0: > if (!(mask & GDK_MOD4_MASK)) >@@ -672,7 +654,6 @@ > default: > if (!(mask & GDK_CONTROL_MASK)) > released = true; >- break; > #endif > } > if (released) { >@@ -723,7 +704,7 @@ > } // to be hidden > > /*if ( (bIsSavedWordItemValid||bIsSavedMessageValid) >- && !bIsLocked && !bInMoving ) >+ && !conf->get_lock() && !bInMoving ) > { > int iCurrentShowStates = iGetShowLevel(); > if ( bIsSavedMessageValid && iCurrentShowStates!=FLOAT_SHOW_LEVEL_NONE) >@@ -927,7 +908,7 @@ > > gtk_widget_show_all(oFloatWin->menu); > gtk_menu_popup(GTK_MENU(oFloatWin->menu), NULL, NULL, NULL, NULL, event->button, event->time); >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "menushow.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -994,7 +975,7 @@ > > void FloatWin::on_query_click(GtkWidget *widget, gpointer data) > { >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -1003,7 +984,7 @@ > gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav"); > #endif > } >- if (!gpAppFrame->oAppCore.oFloatWin.bIsLocked) >+ if (!conf->get_lock()) > gpAppFrame->oAppCore.oFloatWin.Hide(); > gpAppFrame->oAppCore.Query(gpAppFrame->oAppCore.oFloatWin.QueryingWord.c_str()); > #ifdef _WIN32 >@@ -1015,7 +996,7 @@ > > void FloatWin::on_copy_click(GtkWidget *widget, gpointer data) > { >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -1036,7 +1017,7 @@ > > void FloatWin::on_stop_click(GtkWidget *widget, gpointer data) > { >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -1045,17 +1026,12 @@ > gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav"); > #endif > } >-#ifdef _WIN32 >- rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "scan_selection", false); >- on_conf_dictionary_scan_selection_changed(false); >-#else >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/scan_selection", false); >-#endif >+ conf->set_scan_selection(FALSE); > } > > void FloatWin::on_help_click(GtkWidget *widget, gpointer data) > { >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -1064,7 +1040,7 @@ > gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav"); > #endif > } >- if (!gpAppFrame->oAppCore.oFloatWin.bIsLocked) >+ if (!conf->get_lock()) > gpAppFrame->oAppCore.oFloatWin.Hide(); > #ifdef _WIN32 > //gchar *filename = g_strdup_printf(_("file:///%s/help/C/stardict.html#stardict-scan-selection"), stardict_data_dir); >@@ -1078,7 +1054,7 @@ > > void FloatWin::on_quit_click(GtkWidget *widget, gpointer data) > { >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -1092,7 +1068,7 @@ > > void FloatWin::vLockCallback(GtkWidget *widget, FloatWin *oFloatWin) > { >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -1101,10 +1077,5 @@ > gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav"); > #endif > } >-#ifdef _WIN32 >- rw_cfg_write_boolean (usercfgfile, "preferences/floating_window", "lock", !(oFloatWin->bIsLocked)); >- on_conf_floatwin_lock_changed(!(oFloatWin->bIsLocked)); >-#else >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/floating_window/lock", !(oFloatWin->bIsLocked)); >-#endif >+ conf->set_lock(!conf->get_lock()); > } >diff -bBurNd stardict-2.4.4.orig/src/floatwin.h stardict-2.4.4/src/floatwin.h >--- stardict-2.4.4.orig/src/floatwin.h 2003-09-23 14:19:44.000000000 +0400 >+++ stardict-2.4.4/src/floatwin.h 2005-01-18 19:45:04.000000000 +0300 >@@ -56,10 +56,6 @@ > std::string QueryingWord; > std::string PronounceWord; > FloatWinQueryResult found_result; >- gboolean bIsLocked; >- gboolean hide_floatwin_when_modifier_key_released; >- gboolean pronounce_when_popup; >- gint Window_max_width,Window_max_height; > GtkWidget *FloatWindow,*label,*lock_image,*button_hbox,*scrolled_window; > GtkWidget *PronounceWordButton, *StopButton; > GtkWidget *menu; >diff -bBurNd stardict-2.4.4.orig/src/lib.cpp stardict-2.4.4/src/lib.cpp >--- stardict-2.4.4.orig/src/lib.cpp 2004-10-29 12:12:59.000000000 +0400 >+++ stardict-2.4.4/src/lib.cpp 2005-01-18 19:58:39.000000000 +0300 >@@ -597,7 +597,7 @@ > return (oLib[iLib]->LookupWithRule(pspec,aiIndexes,iLen)); > } > >-void Libs::LoadDir(gchar *dirname, GSList *order_list, GSList *disable_list) >+void Libs::LoadDir(gchar *dirname, const GSList *order_list, const GSList *disable_list) > { > GDir *dir = g_dir_open(dirname, 0, NULL); > if (dir) >@@ -606,7 +606,7 @@ > gchar fullfilename[256]; > Lib *lib; > gboolean loaded; >- GSList *tmplist1,*tmplist2; >+ const GSList *tmplist1,*tmplist2; > gboolean disabled; > while ((filename = g_dir_read_name(dir))!=NULL) > { >@@ -656,18 +656,11 @@ > } > } > >-void Libs::Load() >+void Libs::Load(const GSList *order_list, const GSList *disable_list) > { >- GSList *order_list, *disable_list; >-#ifdef _WIN32 >- rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "dict_order_list", &order_list); >- rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "dict_disable_list", &disable_list); >-#else >- gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/dict_order_list", GCONF_VALUE_STRING, &order_list); >- gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/dict_disable_list", GCONF_VALUE_STRING, &disable_list); >-#endif >+ > gchar *idxfilename; >- GSList *tmplist1,*tmplist2; >+ const GSList *tmplist1,*tmplist2; > gboolean disabled; > Lib *lib; > tmplist1 = order_list; >@@ -707,12 +700,6 @@ > LoadDir(home_dir, order_list, disable_list); > LoadDir(STARDICT_DATA_DIR "/dic", order_list, disable_list); > #endif >- >- g_slist_foreach (order_list, (GFunc)g_free, NULL); >- g_slist_free(order_list); >- >- g_slist_foreach (disable_list, (GFunc)g_free, NULL); >- g_slist_free(disable_list); > } > > gchar * >@@ -1362,20 +1349,12 @@ > } > } > >-GtkTreeStore* TreeDicts::Load() >+GtkTreeStore* TreeDicts::Load(const GSList *order_list, const GSList *disable_list) > { > GtkTreeStore *model = gtk_tree_store_new (3, G_TYPE_STRING, G_TYPE_LONG, G_TYPE_LONG); //word, offset, size > >- GSList *order_list, *disable_list; >-#ifdef _WIN32 >- rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "treedict_order_list", &order_list); >- rw_cfg_read_strlist (usercfgfile, "manage_dictionaries", "treedict_disable_list", &disable_list); >-#else >- gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/treedict_order_list", GCONF_VALUE_STRING, &order_list); >- gpAppFrame->oAppConf.read_list("/apps/stardict/manage_dictionaries/treedict_disable_list", GCONF_VALUE_STRING, &disable_list); >-#endif > gchar *ifofilename; >- GSList *tmplist1,*tmplist2; >+ const GSList *tmplist1,*tmplist2; > gboolean disabled; > TreeDict *lib; > tmplist1 = order_list; >@@ -1416,16 +1395,10 @@ > LoadDir(STARDICT_DATA_DIR "/treedict", order_list, disable_list, model); > #endif > >- g_slist_foreach (order_list, (GFunc)g_free, NULL); >- g_slist_free(order_list); >- >- g_slist_foreach (disable_list, (GFunc)g_free, NULL); >- g_slist_free(disable_list); >- > return model; > } > >-void TreeDicts::LoadDir(gchar *dirname, GSList *order_list, GSList *disable_list, GtkTreeStore *model) >+void TreeDicts::LoadDir(gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkTreeStore *model) > { > GDir *dir = g_dir_open(dirname, 0, NULL); > if (dir) >@@ -1434,7 +1407,7 @@ > gchar fullfilename[256]; > TreeDict *lib; > gboolean loaded; >- GSList *tmplist1,*tmplist2; >+ const GSList *tmplist1,*tmplist2; > gboolean disabled; > while ((filename = g_dir_read_name(dir))!=NULL) > { >diff -bBurNd stardict-2.4.4.orig/src/lib.h stardict-2.4.4/src/lib.h >--- stardict-2.4.4.orig/src/lib.h 2003-11-13 12:48:54.000000000 +0300 >+++ stardict-2.4.4/src/lib.h 2005-01-18 19:57:52.000000000 +0300 >@@ -87,11 +87,11 @@ > Lib **oLib; // word library. > gint libcount; > >- void LoadDir(gchar *dirname, GSList *order_list, GSList *disable_list); >+ void LoadDir(gchar *dirname, const GSList *order_list, const GSList *disable_list); > public: > Libs(); > ~Libs(); >- void Load(); >+ void Load(const GSList *order_list, const GSList *disable_list); > glong iLength(int iLib); > gchar* GetBookname(int iLib); > inline gint total_libs() { return(libcount); } >@@ -122,13 +122,13 @@ > public: > TreeDicts(); > ~TreeDicts(); >- GtkTreeStore* Load(); >+ GtkTreeStore* Load(const GSList *order_list, const GSList *disable_list); > gchar * poGetWordData(glong offset, glong size, int iTreeDict); > private: > TreeDict **oTreeDict; > gint treedictcount; > >- void LoadDir(gchar *dirname, GSList *order_list, GSList *disable_list, GtkTreeStore *model); >+ void LoadDir(gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkTreeStore *model); > }; > > #endif >diff -bBurNd stardict-2.4.4.orig/src/mainwin.cpp stardict-2.4.4/src/mainwin.cpp >--- stardict-2.4.4.orig/src/mainwin.cpp 2004-11-28 09:13:29.000000000 +0300 >+++ stardict-2.4.4/src/mainwin.cpp 2005-01-18 19:57:22.000000000 +0300 >@@ -2,10 +2,6 @@ > # include "config.h" > #endif > >-#include "mainwin.h" >-#include "stardict.h" >- >- > #ifndef _WIN32 > # include <libgnome/libgnome.h> > # include <libgnomeui/libgnomeui.h> >@@ -18,6 +14,10 @@ > # include <gdk/gdkwin32.h> > #endif > >+#include "stardict.h" >+#include "conf.h" >+ >+#include "mainwin.h" > > #define STARDICT_RESPONSE_FIND 100 > >@@ -207,7 +207,7 @@ > > void TopWin::ClearCallback(GtkWidget *widget, TopWin *oTopWin) > { >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -224,7 +224,7 @@ > > void TopWin::GoCallback(GtkWidget *widget, TopWin *oTopWin) > { >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -276,7 +276,7 @@ > > void TopWin::BackCallback(GtkWidget *widget, TopWin *oTopWin) > { >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -348,7 +348,7 @@ > > void TopWin::PreviousCallback(GtkWidget *widget, TopWin *oTopWin) > { >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -428,7 +428,7 @@ > > void TopWin::NextCallback(GtkWidget *widget, TopWin *oTopWin) > { >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -510,7 +510,7 @@ > > void TopWin::do_menu() > { >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "menushow.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -855,7 +855,8 @@ > > void TreeWin::Create(GtkWidget *notebook) > { >- GtkTreeStore *model = gpAppFrame->oAppCore.oTreeDicts.Load(); >+ GtkTreeStore *model = gpAppFrame->oAppCore.oTreeDicts.Load(conf->get_treedict_order_list(), >+ conf->get_treedict_disable_list()); > treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL(model)); > gtk_widget_show(treeview); > g_object_unref (model); >@@ -953,12 +954,8 @@ > void IndexWin::Create(GtkWidget *hpaned) > { > vbox = gtk_vbox_new(false, 3); >- gboolean hide; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/main_window", "hide_list", &hide); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/main_window/hide_list",&hide,false); >-#endif >+ gboolean hide=conf->get_hide_list(); >+ > if (!hide) > gtk_widget_show(vbox); > >@@ -1060,12 +1057,8 @@ > gtk_box_pack_start(GTK_BOX(hbox),HideListButton,false,false,5); > gtk_tooltips_set_tip(gpAppFrame->oAppCore.tooltips, HideListButton,_("Hide the word list"),NULL); > >- gboolean hide; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/main_window", "hide_list", &hide); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/main_window/hide_list", &hide, false); >-#endif >+ gboolean hide=conf->get_hide_list(); >+ > if (hide) { > gtk_widget_show(ShowListButton); > } >@@ -1128,22 +1121,12 @@ > > void ToolWin::ShowListCallback(GtkWidget *widget, gpointer data) > { >-#ifdef _WIN32 >- rw_cfg_write_boolean (usercfgfile, "preferences/main_window", "hide_list", false); >- on_conf_main_window_hide_list_changed(false); >-#else >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/main_window/hide_list",false); >-#endif >+ conf->set_hide_list(FALSE); > } > > void ToolWin::HideListCallback(GtkWidget *widget, gpointer data) > { >-#ifdef _WIN32 >- rw_cfg_write_boolean (usercfgfile, "preferences/main_window", "hide_list", true); >- on_conf_main_window_hide_list_changed(true); >-#else >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/main_window/hide_list",true); >-#endif >+ conf->set_hide_list(TRUE); > } > > void ToolWin::CopyCallback(GtkWidget *widget, ToolWin *oToolWin) >@@ -1627,12 +1610,8 @@ > oToolWin.Create(vbox1); > oTextWin.Create(vbox1); > >- gint pos; >-#ifdef _WIN32 >- rw_cfg_read_int (usercfgfile, "preferences/main_window", "hpaned_pos", &pos); >-#else >- gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/main_window/hpaned_pos", &pos, DEFAULT_HPANED_POS); >-#endif >+ gint pos=conf->get_hpaned_pos(); >+ > gtk_paned_set_position(GTK_PANED(hpaned),pos); > } > >@@ -1640,23 +1619,13 @@ > /*********************************************/ > BottomWin::BottomWin() > { >- searchwebsite_list = NULL; > SearchWebsiteMenu = NULL; > } > >-BottomWin::~BottomWin() >-{ >- g_slist_foreach (searchwebsite_list, (GFunc)g_free, NULL); >- g_slist_free (searchwebsite_list); >-} >- > void BottomWin::Create(GtkWidget *vbox) > { >-#ifdef _WIN32 >- rw_cfg_read_strlist (usercfgfile, "preferences/main_window", "search_website_list", &searchwebsite_list); >-#else >- gpAppFrame->oAppConf.read_list("/apps/stardict/preferences/main_window/search_website_list", GCONF_VALUE_STRING, &searchwebsite_list); >-#endif >+ const GSList *searchwebsite_list=conf->get_search_website_list(); >+ > if (!searchwebsite_list) { > gchar *default_website = _("" > "dict.leo.org http://dict.leo.org http://dict.leo.org/?search=%s&lang=en\n" >@@ -1677,15 +1646,7 @@ > list = g_slist_append(list, g_strndup(p, p1-p)); > p= p1+1; > } >-#ifdef _WIN32 >- rw_cfg_write_strlist (usercfgfile, "preferences/main_window", "search_website_list", list); >-#else >- gpAppFrame->oAppConf.write_list("/apps/stardict/preferences/main_window/search_website_list", GCONF_VALUE_STRING, list); >-#endif >- //as oAppConf.EnableNotify() didn't call now, we change searchwebsite_list manually; >- searchwebsite_list = list; >- //g_slist_foreach (list, (GFunc)g_free, NULL); >- //g_slist_free(list); >+ conf->set_search_website_list(list); > } > > GtkWidget *hbox = gtk_hbox_new(false,0); >@@ -1695,12 +1656,8 @@ > ScanSelectionCheckButton = gtk_check_button_new_with_mnemonic(_("_Scan")); > gtk_widget_show(ScanSelectionCheckButton); > GTK_WIDGET_UNSET_FLAGS (ScanSelectionCheckButton, GTK_CAN_FOCUS); >- gboolean scan; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "scan_selection", &scan); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/scan_selection", &scan, true); >-#endif >+ gboolean scan=conf->get_scan_selection(); >+ > gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ScanSelectionCheckButton),scan); > g_signal_connect(G_OBJECT(ScanSelectionCheckButton),"toggled", G_CALLBACK(ScanCallback),NULL); > gtk_box_pack_start(GTK_BOX(hbox),ScanSelectionCheckButton,false,false,0); >@@ -1774,18 +1731,12 @@ > > void BottomWin::ScanCallback(GtkToggleButton *button, gpointer data) > { >-#ifdef _WIN32 >- gboolean scan = gtk_toggle_button_get_active(button); >- rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "scan_selection", scan); >- on_conf_dictionary_scan_selection_changed(scan); >-#else >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/scan_selection",gtk_toggle_button_get_active(button)); >-#endif >+ conf->set_scan_selection(gtk_toggle_button_get_active(button)); > } > > void BottomWin::AboutCallback(GtkButton *button, gpointer data) > { >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -1799,7 +1750,7 @@ > > void BottomWin::QuitCallback(GtkButton *button, gpointer data) > { >- if (gpAppFrame->enable_sound_event) { >+ if (conf->get_enable_sound_event()) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -1815,7 +1766,7 @@ > { > if (event->button == 3) { > >- if (!(oBottomWin->searchwebsite_list)) >+ if (!conf->get_search_website_list()) > return true; > > if (oBottomWin->SearchWebsiteMenu) >@@ -1825,7 +1776,7 @@ > > GtkWidget *menuitem; > gchar *p; >- GSList *list = oBottomWin->searchwebsite_list; >+ const GSList *list = conf->get_search_website_list(); > while (list) { > p = strchr((gchar *)(list->data), '\t'); > if (p) { >@@ -1879,9 +1830,9 @@ > > void BottomWin::InternetSearchCallback(GtkButton *button, BottomWin *oBottomWin) > { >- if (!oBottomWin->searchwebsite_list) >+ if (!conf->get_search_website_list()) > return; >- gchar *website = (gchar *)(oBottomWin->searchwebsite_list->data); >+ gchar *website = (gchar *)(conf->get_search_website_list()->data); > gchar *website_link = strchr(website, '\t'); > if (website_link) > *website_link = '\0'; >diff -bBurNd stardict-2.4.4.orig/src/mainwin.h stardict-2.4.4/src/mainwin.h >--- stardict-2.4.4.orig/src/mainwin.h 2003-09-23 14:19:44.000000000 +0400 >+++ stardict-2.4.4/src/mainwin.h 2005-01-18 18:48:18.000000000 +0300 >@@ -221,11 +221,9 @@ > > public: > GtkWidget* ScanSelectionCheckButton; >- GSList *searchwebsite_list; > GtkWidget* SearchWebsiteMenu; > > BottomWin(); >- ~BottomWin(); > void Create(GtkWidget *vbox); > }; > >diff -bBurNd stardict-2.4.4.orig/src/prefsdlg.cpp stardict-2.4.4/src/prefsdlg.cpp >--- stardict-2.4.4.orig/src/prefsdlg.cpp 2003-11-09 16:15:27.000000000 +0300 >+++ stardict-2.4.4/src/prefsdlg.cpp 2005-01-18 19:21:09.000000000 +0300 >@@ -1,14 +1,16 @@ > #ifdef HAVE_CONFIG_H > # include "config.h" > #endif >-#include "prefsdlg.h" >-#include "stardict.h" > > #ifdef _WIN32 > # include <gdk/gdkwin32.h> > # include "win32/intl.h" > #endif > >+#include "stardict.h" >+#include "conf.h" >+ >+#include "prefsdlg.h" > > #define LOGO 0 > #define DICTIONARY_SCAN_SETTINGS 1 >@@ -261,34 +263,19 @@ > { > gboolean b = gtk_toggle_button_get_active (button); > gtk_widget_set_sensitive(oPrefsDlg->scan_modifier_key_vbox,b); >-#ifdef _WIN32 >- rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "only_scan_while_modifier_key", b); >- on_conf_dictionary_only_scan_while_modifier_key_changed(b); >-#else >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/only_scan_while_modifier_key", b); >-#endif >+ conf->set_only_scan_while_modifier_key(b); > } > > void PrefsDlg::on_setup_dictionary_scan_optionmenu_changed(GtkOptionMenu *option_menu, PrefsDlg *oPrefsDlg) > { >-#ifdef _WIN32 > gint key = gtk_option_menu_get_history(option_menu); >- rw_cfg_write_int (usercfgfile, "preferences/dictionary", "scan_modifier_key", key); >- on_conf_dictionary_scan_modifier_key_changed(key); >-#else >- gpAppFrame->oAppConf.write_int("/apps/stardict/preferences/dictionary/scan_modifier_key", gtk_option_menu_get_history(option_menu)); >-#endif >+ conf->set_scan_modifier_key(key); > } > > void PrefsDlg::on_setup_dictionary_scan_hide_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg) > { >-#ifdef _WIN32 > gboolean hide = gtk_toggle_button_get_active(button); >- rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "hide_floatwin_when_modifier_key_released", hide); >- on_conf_dictionary_hide_floatwin_when_modifier_key_released_changed(hide); >-#else >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/hide_floatwin_when_modifier_key_released", gtk_toggle_button_get_active(button)); >-#endif >+ conf->set_hide_floatwin_when_modifier_key_released(hide); > } > > void PrefsDlg::setup_dictionary_scan_page() >@@ -317,12 +304,8 @@ > gtk_box_pack_start(GTK_BOX(vbox),vbox1,false,false, 0); > GtkWidget *check_button = gtk_check_button_new_with_mnemonic(_("_Only do scanning while modifier key being pressed.")); > gtk_box_pack_start(GTK_BOX(vbox1),check_button,false,false,0); >- gboolean only_scan_while_modifier_key; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "only_scan_while_modifier_key", &only_scan_while_modifier_key); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/only_scan_while_modifier_key", &only_scan_while_modifier_key, false); >-#endif >+ gboolean only_scan_while_modifier_key=conf->get_only_scan_while_modifier_key(); >+ > gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),only_scan_while_modifier_key); > g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_dictionary_scan_ckbutton_toggled), this); > >@@ -332,12 +315,8 @@ > > check_button = gtk_check_button_new_with_mnemonic(_("H_ide floating window when modifier key released.")); > gtk_box_pack_start(GTK_BOX(scan_modifier_key_vbox),check_button,false,false,0); >- gboolean hide_floatwin_when_modifier_key_released; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "hide_floatwin_when_modifier_key_released", &hide_floatwin_when_modifier_key_released); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/hide_floatwin_when_modifier_key_released", &hide_floatwin_when_modifier_key_released, true); >-#endif >+ gboolean hide_floatwin_when_modifier_key_released=conf->get_hide_floatwin_when_modifier_key_released(); >+ > gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),hide_floatwin_when_modifier_key_released); > g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_dictionary_scan_hide_ckbutton_toggled), this); > >@@ -361,12 +340,8 @@ > menuitem = gtk_menu_item_new_with_mnemonic(_("_Ctrl")); > gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); > gtk_option_menu_set_menu(GTK_OPTION_MENU(option_menu), menu); >- gint scan_modifier_key; >-#ifdef _WIN32 >- rw_cfg_read_int (usercfgfile, "preferences/dictionary", "scan_modifier_key", &scan_modifier_key); >-#else >- gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/dictionary/scan_modifier_key", &scan_modifier_key, 0); >-#endif >+ gint scan_modifier_key=conf->get_scan_modifier_key(); >+ > gtk_option_menu_set_history(GTK_OPTION_MENU(option_menu), scan_modifier_key); > > gtk_label_set_mnemonic_widget(GTK_LABEL(label), option_menu); >@@ -376,13 +351,9 @@ > > void PrefsDlg::on_setup_dictionary_font_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg) > { >- gboolean b = gtk_toggle_button_get_active (button); >- gtk_widget_set_sensitive(oPrefsDlg->custom_font_hbox,b); >-#ifdef _WIN32 >- rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "use_custom_font", b); >-#else >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/use_custom_font", b); >-#endif >+ gboolean b = gtk_toggle_button_get_active(button); >+ gtk_widget_set_sensitive(oPrefsDlg->custom_font_hbox, b); >+ conf->set_use_custom_font(b); > } > > void PrefsDlg::on_setup_dictionary_font_button_clicked(GtkWidget *widget, PrefsDlg *oPrefsDlg) >@@ -400,15 +371,11 @@ > font_name = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dlg)); > if (font_name) { > gtk_button_set_label(GTK_BUTTON(widget),font_name); >-#ifdef _WIN32 >- rw_cfg_write_string (usercfgfile, "preferences/dictionary", "custom_font", font_name); >-#else >- gpAppFrame->oAppConf.write_string("/apps/stardict/preferences/dictionary/custom_font", font_name); >-#endif >+ conf->set_custom_font(font_name); > } > break; > default: >- break; >+ /*nothing*/; > } > gtk_widget_destroy (dlg); > } >@@ -439,12 +406,8 @@ > gtk_box_pack_start(GTK_BOX(vbox),vbox1,false,false, 0); > GtkWidget *check_button = gtk_check_button_new_with_mnemonic(_("_Use custom font.")); > gtk_box_pack_start(GTK_BOX(vbox1),check_button,false,false,0); >- gboolean use_custom_font; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "use_custom_font", &use_custom_font); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/use_custom_font", &use_custom_font, false); >-#endif >+ gboolean use_custom_font=conf->get_use_custom_font(); >+ > gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),use_custom_font); > g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_dictionary_font_ckbutton_toggled), this); > custom_font_hbox = gtk_hbox_new(false, 12); >@@ -455,17 +418,13 @@ > gtk_box_pack_start(GTK_BOX(custom_font_hbox),label,false,false,0); > gtk_misc_set_alignment (GTK_MISC (label), 0, .5); > GtkWidget *button; >- gchar *custom_font; >-#ifdef _WIN32 >- rw_cfg_read_string (usercfgfile, "preferences/dictionary", "custom_font", &custom_font); >-#else >- gpAppFrame->oAppConf.read_string("/apps/stardict/preferences/dictionary/custom_font", &custom_font); >-#endif >+ const gchar *custom_font=conf->get_custom_font(); >+ > if (custom_font && custom_font[0]) > button = gtk_button_new_with_label(custom_font); > else > button=gtk_button_new_with_label(_("Choose")); >- g_free(custom_font); >+ > gtk_label_set_mnemonic_widget(GTK_LABEL(label), button); > gtk_box_pack_start(GTK_BOX(custom_font_hbox),button,false,false,0); > g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_setup_dictionary_font_button_clicked), this); >@@ -473,13 +432,8 @@ > > void PrefsDlg::on_setup_dictionary_sound_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg) > { >-#ifdef _WIN32 > gboolean enable = gtk_toggle_button_get_active(button); >- rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "enable_sound_event", enable); >- on_conf_dictionary_enable_sound_event_changed(enable); >-#else >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/dictionary/enable_sound_event",gtk_toggle_button_get_active(button)); >-#endif >+ conf->set_enable_sound_event(enable); > } > > void PrefsDlg::setup_dictionary_sound_page() >@@ -510,12 +464,8 @@ > > GtkWidget *check_button; > check_button = gtk_check_button_new_with_mnemonic(_("_Enable sound event.")); >- gboolean enable; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "enable_sound_event", &enable); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/enable_sound_event", &enable, true); >-#endif >+ gboolean enable=conf->get_enable_sound_event(); >+ > gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),enable); > g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_dictionary_sound_ckbutton_toggled), (gpointer)this); > gtk_box_pack_start(GTK_BOX(hbox1),check_button,false,false,0); >@@ -523,11 +473,7 @@ > > void PrefsDlg::on_setup_mainwin_startup_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg) > { >-#ifdef _WIN32 >- rw_cfg_write_boolean (usercfgfile, "preferences/main_window", "hide_on_startup", gtk_toggle_button_get_active(button)); >-#else >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/main_window/hide_on_startup",gtk_toggle_button_get_active(button)); >-#endif >+ conf->set_hide_on_startup(gtk_toggle_button_get_active(button)); > } > > void PrefsDlg::setup_mainwin_options_page() >@@ -558,12 +504,8 @@ > > GtkWidget *check_button; > check_button = gtk_check_button_new_with_mnemonic(_("Hide main window when _starting StarDict.")); >- gboolean hide; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/main_window", "hide_on_startup", &hide); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/main_window/hide_on_startup", &hide, false); >-#endif >+ gboolean hide=conf->get_hide_on_startup(); >+ > gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),hide); > g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_mainwin_startup_ckbutton_toggled), (gpointer)this); > gtk_box_pack_start(GTK_BOX(hbox1),check_button,false,false,0); >@@ -587,14 +529,7 @@ > searchwebsite_list = g_slist_append(searchwebsite_list, website); > have_iter = gtk_tree_model_iter_next(model, &iter); > } >-#ifdef _WIN32 >- rw_cfg_write_strlist (usercfgfile, "preferences/main_window", "search_website_list", searchwebsite_list); >- on_conf_main_window_searchwebsite_list_changed(searchwebsite_list); >-#else >- gpAppFrame->oAppConf.write_list("/apps/stardict/preferences/main_window/search_website_list", GCONF_VALUE_STRING, searchwebsite_list); >- g_slist_foreach (searchwebsite_list, (GFunc)g_free, NULL); >- g_slist_free(searchwebsite_list); >-#endif >+ conf->set_search_website_list(searchwebsite_list); > } > > void PrefsDlg::on_setup_mainwin_searchwebsite_moveup_button_clicked(GtkWidget *widget, PrefsDlg *oPrefsDlg) >@@ -834,18 +769,13 @@ > GtkListStore *model; > model = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); > >- GSList *searchwebsite_list; >-#ifdef _WIN32 >- rw_cfg_read_strlist (usercfgfile, "preferences/main_window", "search_website_list", &searchwebsite_list); >-#else >- gpAppFrame->oAppConf.read_list("/apps/stardict/preferences/main_window/search_website_list", GCONF_VALUE_STRING, &searchwebsite_list); >-#endif >+ const GSList *searchwebsite_list=conf->get_search_website_list(); >+ > gchar *website; > gchar *website_link; > gchar *website_searchlink; > GtkTreeIter iter; >- GSList *list; >- list = searchwebsite_list; >+ const GSList *list = searchwebsite_list; > while (list) { > website = (gchar *)(list->data); > website_link = strchr(website, '\t'); >@@ -857,8 +787,6 @@ > } > list = g_slist_next(list); > } >- g_slist_foreach (searchwebsite_list, (GFunc)g_free, NULL); >- g_slist_free (searchwebsite_list); > > GtkWidget *sw; > sw = gtk_scrolled_window_new (NULL, NULL); >@@ -953,13 +881,8 @@ > > void PrefsDlg::on_setup_NotificationAreaIcon_QueryInFloatWin_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg) > { >-#ifdef _WIN32 > gboolean queryin = gtk_toggle_button_get_active(button); >- rw_cfg_write_boolean (usercfgfile, "preferences/notification_area_icon", "query_in_floatwin", queryin); >- on_conf_notification_area_icon_show_in_floatwin_changed(queryin); >-#else >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/notification_area_icon/query_in_floatwin",gtk_toggle_button_get_active(button)); >-#endif >+ conf->set_query_in_floatwin(queryin); > } > > void PrefsDlg::setup_NotificationAreaIcon_options_page() >@@ -990,12 +913,8 @@ > > GtkWidget *check_button; > check_button = gtk_check_button_new_with_mnemonic(_("_Query in the floating window when middle mouse\nbutton clicked.")); >- gboolean query_in_floatwin; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/notification_area_icon", "query_in_floatwin", &query_in_floatwin); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/notification_area_icon/query_in_floatwin", &query_in_floatwin, true); >-#endif >+ gboolean query_in_floatwin=conf->get_query_in_floatwin(); >+ > gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),query_in_floatwin); > g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_NotificationAreaIcon_QueryInFloatWin_ckbutton_toggled), (gpointer)this); > gtk_box_pack_start(GTK_BOX(hbox1),check_button,false,false,0); >@@ -1003,13 +922,7 @@ > > void PrefsDlg::on_setup_floatwin_pronounce_ckbutton_toggled(GtkToggleButton *button, PrefsDlg *oPrefsDlg) > { >-#ifdef _WIN32 >- gboolean pronounce = gtk_toggle_button_get_active(button); >- rw_cfg_write_boolean (usercfgfile, "preferences/floating_window", "pronounce_when_popup", pronounce); >- on_conf_floatwin_pronounce_when_popup_changed(pronounce); >-#else >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/floating_window/pronounce_when_popup",gtk_toggle_button_get_active(button)); >-#endif >+ conf->set_pronounce_when_popup(gtk_toggle_button_get_active(button)); > } > > void PrefsDlg::setup_floatwin_options_page() >@@ -1040,12 +953,8 @@ > > GtkWidget *check_button; > check_button = gtk_check_button_new_with_mnemonic(_("_Pronouce the word when pop up.")); >- gboolean pronounce_when_popup; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/floating_window", "pronounce_when_popup", &pronounce_when_popup); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/floating_window/pronounce_when_popup", &pronounce_when_popup, false); >-#endif >+ gboolean pronounce_when_popup=conf->get_pronounce_when_popup(); >+ > gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),pronounce_when_popup); > g_signal_connect (G_OBJECT (check_button), "toggled", G_CALLBACK (on_setup_floatwin_pronounce_ckbutton_toggled), (gpointer)this); > gtk_box_pack_start(GTK_BOX(hbox1),check_button,false,false,0); >@@ -1053,24 +962,14 @@ > > void PrefsDlg::on_setup_floatwin_size_max_width_spinbutton_changed(GtkSpinButton *button, PrefsDlg *oPrefsDlg) > { >-#ifdef _WIN32 > gint width = gtk_spin_button_get_value_as_int(button); >- rw_cfg_write_int (usercfgfile, "preferences/floating_window", "max_window_width", width); >- on_conf_floatwin_max_window_width_changed(width); >-#else >- gpAppFrame->oAppConf.write_int("/apps/stardict/preferences/floating_window/max_window_width",gtk_spin_button_get_value_as_int(button)); >-#endif >+ conf->set_max_window_width(width); > } > > void PrefsDlg::on_setup_floatwin_size_max_height_spinbutton_changed(GtkSpinButton *button, PrefsDlg *oPrefsDlg) > { >-#ifdef _WIN32 > gint height = gtk_spin_button_get_value_as_int(button); >- rw_cfg_write_int (usercfgfile, "preferences/floating_window", "max_window_height", height); >- on_conf_floatwin_max_window_height_changed(height); >-#else >- gpAppFrame->oAppConf.write_int("/apps/stardict/preferences/floating_window/max_window_height",gtk_spin_button_get_value_as_int(button)); >-#endif >+ conf->set_max_window_height(height); > } > > void PrefsDlg::setup_floatwin_size_page() >@@ -1099,14 +998,10 @@ > vbox2 = gtk_vbox_new(false,6); > gtk_box_pack_start(GTK_BOX(vbox),vbox2,false,false,0); > >- gint max_width,max_height; >-#ifdef _WIN32 >- rw_cfg_read_int (usercfgfile, "preferences/floating_window", "max_window_width", &max_width); >- rw_cfg_read_int (usercfgfile, "preferences/floating_window", "max_window_height", &max_height); >-#else >- gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/floating_window/max_window_width", &max_width, DEFAULT_MAX_FLOATWIN_WIDTH); >- gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/floating_window/max_window_height", &max_height, DEFAULT_MAX_FLOATWIN_HEIGHT); >-#endif >+ gint >+ max_width=conf->get_max_window_width(), >+ max_height=conf->get_max_window_height(); >+ > GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(gpAppFrame->oAppCore.window)); > gint screen_width = gdk_screen_get_width(screen); > gint screen_height = gdk_screen_get_height(screen); >diff -bBurNd stardict-2.4.4.orig/src/selection.cpp stardict-2.4.4/src/selection.cpp >--- stardict-2.4.4.orig/src/selection.cpp 2003-11-13 13:39:39.000000000 +0300 >+++ stardict-2.4.4/src/selection.cpp 2005-01-19 14:13:45.111060056 +0300 >@@ -2,14 +2,18 @@ > # include "config.h" > #endif > >-#include <string.h> >-#include "selection.h" >-#include "stardict.h" >+#include <cstring> > > #ifdef _WIN32 > # include "win32/intl.h" > #endif > >+#include "stardict.h" >+#include "conf.h" >+ >+#include "selection.h" >+ >+ > // Notice: once you changed this file, try to change src/win32/clipboard.cpp too. > > >@@ -37,10 +41,8 @@ > /********************************************************************/ > gboolean Selection::Enable() > { >- return(bEnable >- &&(!gpAppFrame->oAppCore.oTopWin.TextSelected()) >- //&&(!gtk_label_get_selection_bounds(GTK_LABEL(gpAppFrame->oAppCore.oFloatWin.label),NULL,NULL)) >- ); >+ return conf->get_scan_selection() && >+ !gpAppFrame->oAppCore.oTopWin.TextSelected(); > } > > void Selection::create_selection_widget() >@@ -54,16 +56,6 @@ > > void Selection::Start() > { >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "scan_selection", &bEnable); >- rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "only_scan_while_modifier_key", &only_scan_while_modifier_key); >- rw_cfg_read_int (usercfgfile, "preferences/dictionary", "scan_modifier_key", &scan_modifier_key); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/scan_selection", &bEnable, true); >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/only_scan_while_modifier_key", &only_scan_while_modifier_key, false); >- gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/dictionary/scan_modifier_key", &scan_modifier_key, 0); >-#endif >- > UTF8_STRING_Atom = gdk_atom_intern("UTF8_STRING",false); > COMPOUND_TEXT_Atom = gdk_atom_intern("COMPOUND_TEXT",false); > >@@ -87,13 +79,13 @@ > Selection *oSelection = (Selection *)data; > if(oSelection->Enable() ) > { >- if (oSelection->only_scan_while_modifier_key) { >+ if (conf->get_only_scan_while_modifier_key()) { > GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(gpAppFrame->oAppCore.window)); > GdkDisplay *display = gdk_screen_get_display(screen); > GdkModifierType mask; > gdk_display_get_pointer(display,NULL, NULL, NULL, &mask); > gboolean do_scan = false; >- switch (oSelection->scan_modifier_key) { >+ switch (conf->get_scan_modifier_key()) { > #ifdef _WIN32 > case 0: > if ((mask & GDK_SHIFT_MASK)&&(!(mask & GDK_CONTROL_MASK))&&(!(mask & GDK_MOD1_MASK))) >@@ -106,7 +98,6 @@ > default: > if ((mask & GDK_CONTROL_MASK)&&(!(mask & GDK_MOD1_MASK))&&(!(mask & GDK_SHIFT_MASK))) > do_scan = true; >- break; > #else > case 0: > if ((mask & GDK_MOD4_MASK)&&(!(mask & GDK_CONTROL_MASK))&&(!(mask & GDK_SHIFT_MASK))&&(!(mask & GDK_MOD1_MASK))) >@@ -123,7 +114,7 @@ > default: > if ((mask & GDK_CONTROL_MASK)&&(!(mask & GDK_MOD1_MASK))&&(!(mask & GDK_SHIFT_MASK))&&(!(mask & GDK_MOD4_MASK))) > do_scan = true; >- break; >+ > #endif > } > if (!do_scan) >diff -bBurNd stardict-2.4.4.orig/src/selection.h stardict-2.4.4/src/selection.h >--- stardict-2.4.4.orig/src/selection.h 2003-09-23 14:19:44.000000000 +0400 >+++ stardict-2.4.4/src/selection.h 2005-01-18 19:46:38.000000000 +0300 >@@ -6,8 +6,7 @@ > > const int SELECTION_INTERVAL=300; // check selection interval. > >-class Selection >-{ >+class Selection { > private: > gint IsBusy; > gint timeout; >@@ -21,9 +20,6 @@ > public: > GdkAtom UTF8_STRING_Atom, COMPOUND_TEXT_Atom; //need to set it to static? this make oTextWin can't use it conveniently. > std::string LastClipWord; >- gboolean bEnable; >- gboolean only_scan_while_modifier_key; >- gint scan_modifier_key; > GtkWidget* selection_widget; > > Selection(); >diff -bBurNd stardict-2.4.4.orig/src/stardict.cpp stardict-2.4.4/src/stardict.cpp >--- stardict-2.4.4.orig/src/stardict.cpp 2004-10-19 07:09:47.000000000 +0400 >+++ stardict-2.4.4/src/stardict.cpp 2005-01-18 23:30:36.000000000 +0300 >@@ -32,7 +32,6 @@ > #include <string.h> > #include <stdlib.h> > >-#include "stardict.h" > #ifndef _WIN32 > # include "stardict-application-server.h" > # include "GNOME_Stardict.h" >@@ -54,6 +53,9 @@ > gchar stardict_data_dir[256]; > #endif > >+#include "conf.h" >+ >+#include "stardict.h" > > AppFrame * gpAppFrame; > >@@ -100,23 +102,15 @@ > > void AppCore::Create(gchar *queryword) > { >- oLibs.Load(); >+ oLibs.Load(conf->get_dict_order_list(), conf->get_dict_disable_list()); > iCurrentIndex = (glong*)g_malloc0(sizeof(glong) * oLibs.total_libs()); > >- gboolean use_custom_font; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/dictionary", "use_custom_font", &use_custom_font); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/dictionary/use_custom_font", &use_custom_font, false); >-#endif >+ gboolean use_custom_font=conf->get_use_custom_font(); >+ > if (use_custom_font) > { >- gchar *custom_font; >-#ifdef _WIN32 >- rw_cfg_read_string (usercfgfile, "preferences/dictionary", "custom_font", &custom_font); >-#else >- gpAppFrame->oAppConf.read_string("/apps/stardict/preferences/dictionary/custom_font", &custom_font); >-#endif >+ const gchar *custom_font=conf->get_custom_font(); >+ > if (custom_font && custom_font[0]) > { > gchar *aa; >@@ -124,25 +118,16 @@ > gtk_rc_parse_string(aa); > g_free(aa); > } >- g_free(custom_font); > } > > window = gtk_window_new (GTK_WINDOW_TOPLEVEL); > gtk_container_set_border_width(GTK_CONTAINER(window),2); >- gboolean maximized; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/main_window", "maximized", &maximized); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/main_window/maximized", &maximized, false); >-#endif >- gint width,height; >-#ifdef _WIN32 >- rw_cfg_read_int (usercfgfile, "preferences/main_window", "window_width", &width); >- rw_cfg_read_int (usercfgfile, "preferences/main_window", "window_height", &height); >-#else >- gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/main_window/window_width", &width, DEFAULT_WINDOW_WIDTH); >- gpAppFrame->oAppConf.read_int("/apps/stardict/preferences/main_window/window_height", &height, DEFAULT_WINDOW_HEIGHT); >-#endif >+ gboolean maximized=conf->get_maximized(); >+ >+ gint >+ width=conf->get_window_width(), >+ height=conf->get_window_height(); >+ > if (width < MIN_WINDOW_WIDTH) > width = MIN_WINDOW_WIDTH; > if (height < MIN_WINDOW_HEIGHT) >@@ -179,16 +164,8 @@ > oClipboard.Start(); > #endif > >-#ifndef _WIN32 >- poAppFrame->oAppConf.EnableNotify(); >-#endif > >- gboolean hide; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/main_window", "hide_on_startup", &hide); >-#else >- gpAppFrame->oAppConf.read_bool("/apps/stardict/preferences/main_window/hide_on_startup", &hide, false); >-#endif >+ gboolean hide=conf->get_hide_on_startup(); > > //NOTICE: when docklet embedded failed,it should always show the window,but,how to detect the failure? > // As stardict is FOR GNOME,so i don't want to consider the case that haven't the Notification area applet. >@@ -197,7 +174,7 @@ > } > else { > gdk_notify_startup_complete (); >- if (gpAppFrame->oAppCore.oSelection.bEnable) >+ if (conf->get_scan_selection()) > gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_SCAN_ICON); > else > gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_STOP_ICON); >@@ -236,7 +213,7 @@ > { > if (event->changed_mask == GDK_WINDOW_STATE_WITHDRAWN) { > if (event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN) { >- if (gpAppFrame->oAppCore.oSelection.bEnable) { >+ if (conf->get_scan_selection()) { > gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_SCAN_ICON); > } > else { >@@ -262,13 +239,9 @@ > } > } > } >- else if (event->changed_mask == GDK_WINDOW_STATE_MAXIMIZED) { >-#ifdef _WIN32 >- rw_cfg_write_boolean (usercfgfile, "preferences/main_window", "maximized", (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED)); >-#else >- gpAppFrame->oAppConf.write_bool("/apps/stardict/preferences/main_window/maximized", (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED)); >-#endif >- } >+ else if (event->changed_mask == GDK_WINDOW_STATE_MAXIMIZED) >+ conf->set_maximized((event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED)); >+ > return false; > } > >@@ -1216,18 +1189,6 @@ > if (!hide_option) > show_splash_screen(); > >-#ifdef _WIN32 >- init_conf(); >-#endif >- >-#ifdef _WIN32 >- rw_cfg_read_int (usercfgfile, "preferences/dictionary", "enable_sound_event", &enable_sound_event); >-#else >- oAppConf.read_bool("/apps/stardict/preferences/dictionary/enable_sound_event", &enable_sound_event, true); >-#endif >- //if (enable_sound_event) >- // gnome_sound_play(STARDICT_DATA_DIR "/sounds/startup.wav"); >- > oAppSkin.load(); > > oAppCore.Create(queryword); >@@ -1249,43 +1210,23 @@ > > void AppFrame::Quit() > { >-#ifndef _WIN32 >- oAppConf.DisableNotify(); >-#endif >+ gboolean maximized=conf->get_maximized(); > >- gboolean maximized; >-#ifdef _WIN32 >- rw_cfg_read_boolean (usercfgfile, "preferences/main_window", "maximized", &maximized); >-#else >- oAppConf.read_bool("/apps/stardict/preferences/main_window/maximized", &maximized, false); >-#endif > if (!maximized) { > gint width,height; > gtk_window_get_size(GTK_WINDOW (oAppCore.window), &width, &height); >-#ifdef _WIN32 >- rw_cfg_write_int (usercfgfile, "preferences/main_window", "window_width", width); >- rw_cfg_write_int (usercfgfile, "preferences/main_window", "window_height", height); >-#else >- oAppConf.write_int("/apps/stardict/preferences/main_window/window_width",width); >- oAppConf.write_int("/apps/stardict/preferences/main_window/window_height",height); >-#endif >+ conf->set_window_width(width); >+ conf->set_window_height(height); >+ > } > gint pos = gtk_paned_get_position(GTK_PANED(oAppCore.oMidWin.hpaned)); >-#ifdef _WIN32 >- rw_cfg_write_int (usercfgfile, "preferences/main_window", "hpaned_pos", pos); >-#else >- oAppConf.write_int("/apps/stardict/preferences/main_window/hpaned_pos",pos); >-#endif >- if (oAppCore.oFloatWin.bIsLocked) { >+ conf->set_hpaned_pos(pos); >+ >+ if (conf->get_lock()) { > gint x,y; > gtk_window_get_position(GTK_WINDOW(oAppCore.oFloatWin.FloatWindow),&x,&y); >-#ifdef _WIN32 >- rw_cfg_write_int (usercfgfile, "preferences/floating_window", "lock_x", x); >- rw_cfg_write_int (usercfgfile, "preferences/floating_window", "lock_y", y); >-#else >- oAppConf.write_int("/apps/stardict/preferences/floating_window/lock_x",x); >- oAppConf.write_int("/apps/stardict/preferences/floating_window/lock_y",y); >-#endif >+ conf->set_lock_x(x); >+ conf->set_lock_y(y); > } > > oAppCore.End(); >@@ -1294,9 +1235,6 @@ > bonobo_object_unref (stardict_app_server); > #endif > >-#ifdef _WIN32 >- save_conf(); >-#endif > gtk_main_quit (); > } > >@@ -1371,7 +1309,7 @@ > > gboolean stardict_on_enter_notify (GtkWidget * widget, GdkEventCrossing * event, gpointer data) > { >- if (gpAppFrame->enable_sound_event && event->mode == GDK_CROSSING_NORMAL) { >+ if (conf->get_enable_sound_event() && event->mode == GDK_CROSSING_NORMAL) { > #ifdef _WIN32 > gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL); > PlaySound(filename, 0, SND_ASYNC | SND_FILENAME); >@@ -1508,7 +1446,7 @@ > { > #ifdef _WIN32 > if (set_stardict_data_dir()) >- return 0; >+ return EXIT_SUCCESS; > gchar *locale_dir; > locale_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "locale", stardict_data_dir); > bindtextdomain (GETTEXT_PACKAGE, locale_dir); >@@ -1593,12 +1530,10 @@ > args = (char**) poptGetArgs(pctx); > > gchar *queryword = NULL; >- if (args && args[0]) >- { >+ if (args && args[0]) { > //only look up the first word should OK. >- if (g_utf8_validate (args[0], -1, NULL)) { >+ if (g_utf8_validate (args[0], -1, NULL)) > queryword= g_strdup(args[0]); >- } > else > queryword = g_locale_to_utf8(args[0],-1,NULL,NULL,NULL); > } >@@ -1610,14 +1545,13 @@ > Bonobo_ACTIVATION_FLAG_EXISTING_ONLY, > NULL, NULL); > >- if (factory != NULL) >- { >+ if (factory != NULL) { > /* there is an instance already running, so send > * commands to it if needed > */ > stardict_handle_automation_cmdline (queryword); > /* and we're done */ >- exit (0); >+ exit(EXIT_SUCCESS); > } > > GnomeClient *client; >@@ -1627,10 +1561,33 @@ > } > #endif > >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ gchar *conf_path; >+ gchar *conf_dir; >+# ifdef WITHOUT_GNOME >+ conf_dir = g_build_filename(g_get_home_dir(), ".stardict", NULL); >+ if (mkdir(conf_dir, S_IRWXU)==-1 && errno!=EEXIST) { >+ g_warning(N_("Can not create %s."), conf_dir); >+ g_free(conf_dir); >+ conf_dir=NULL; >+ } >+# else >+ conf_dir=stardict_data_dir; >+# endif >+ conf_path = g_build_filename(conf_dir, "stardict.cfg", NULL); >+#endif >+ conf.reset(new AppConf( >+#if defined(_WIN32) || defined(WITHOUT_GNOME) >+ conf_path >+#else >+ "/apps/stardict" >+#endif >+ )); > AppFrame oAppFrame; > gpAppFrame = &oAppFrame; > oAppFrame.Init(queryword); >- return 0; >+ >+ return EXIT_SUCCESS; > } > > #ifdef _WIN32 >diff -bBurNd stardict-2.4.4.orig/src/stardict.h stardict-2.4.4/src/stardict.h >--- stardict-2.4.4.orig/src/stardict.h 2003-11-13 14:12:54.000000000 +0300 >+++ stardict-2.4.4/src/stardict.h 2005-01-18 18:16:55.000000000 +0300 >@@ -3,8 +3,9 @@ > > #include <gtk/gtk.h> > >-#ifndef _WIN32 >- #include <bonobo/bonobo-object.h> >+#if !defined(_WIN32) >+# include <bonobo/bonobo-object.h> >+# include <libgnome/libgnome.h> > #endif > > >@@ -15,12 +16,10 @@ > #include "lib.h" > #include "mainwin.h" > #ifdef _WIN32 >- #include "win32/clipboard.h" >- #include "win32/winconf.h" >- #include "win32/systray.h" >+# include "win32/clipboard.h" >+# include "win32/systray.h" > #else >- #include "conf.h" >- #include "docklet.h" >+# include "docklet.h" > #endif > #include "floatwin.h" > #include "selection.h" >@@ -111,14 +110,10 @@ > private: > > public: >-#ifndef _WIN32 >- AppConf oAppConf; >-#endif > AppCore oAppCore; > AppSkin oAppSkin; > ReadWord oReadWord; > >- gboolean enable_sound_event; > > #ifndef _WIN32 > BonoboObject *stardict_app_server; >diff -bBurNd stardict-2.4.4.orig/src/win32/clipboard.cpp stardict-2.4.4/src/win32/clipboard.cpp >--- stardict-2.4.4.orig/src/win32/clipboard.cpp 2003-11-13 15:00:54.000000000 +0300 >+++ stardict-2.4.4/src/win32/clipboard.cpp 2005-01-19 13:37:03.012829872 +0300 >@@ -2,9 +2,11 @@ > # include "config.h" > #endif > >-#include "clipboard.h" > #include "../stardict.h" > #include "intl.h" >+#include "../conf.h" >+ >+#include "clipboard.h" > > > // Notice: once you changed this file, try to change src/selection.cpp too. >@@ -16,7 +18,8 @@ > > gboolean Clipboard::Enable() > { >- return(gpAppFrame->oAppCore.oSelection.bEnable &&(!gpAppFrame->oAppCore.oTopWin.TextSelected())); >+ return conf->get_scan_selection() && >+ !gpAppFrame->oAppCore.oTopWin.TextSelected(); > } > > void Clipboard::Start() >diff -bBurNd stardict-2.4.4.orig/src/win32/systray.cpp stardict-2.4.4/src/win32/systray.cpp >--- stardict-2.4.4.orig/src/win32/systray.cpp 2003-11-03 13:08:43.000000000 +0300 >+++ stardict-2.4.4/src/win32/systray.cpp 2005-01-19 13:49:34.546579376 +0300 >@@ -1,11 +1,13 @@ >-#include "systray.h" >+#include <gdk/gdkwin32.h> > > #include "intl.h" > #include "resource.h" > #include "MinimizeToTray.h" > #include "../stardict.h" >+#include "../conf.h" > >-#include <gdk/gdkwin32.h> >+ >+#include "systray.h" > > #define WM_TRAYMESSAGE WM_USER /* User defined WM Message */ > >@@ -85,7 +87,7 @@ > of the menu scope */ > SetForegroundWindow(systray_hwnd); > >- if (gpAppFrame->oAppCore.oSelection.bEnable) >+ if (conf->get_scan_selection()) > CheckMenuItem(systray_menu, SYSTRAY_CMND_MENU_SCAN, MF_BYCOMMAND | MF_CHECKED); > else > CheckMenuItem(systray_menu, SYSTRAY_CMND_MENU_SCAN, MF_BYCOMMAND | MF_UNCHECKED); >@@ -104,7 +106,7 @@ > { > static UINT taskbarRestartMsg; /* static here means value is kept across multiple calls to this func */ > >- switch(msg) { >+ switch (msg) { > case WM_CREATE: > taskbarRestartMsg = RegisterWindowMessage("TaskbarCreated"); > break; >@@ -113,12 +115,9 @@ > switch(LOWORD(wparam)) { > case SYSTRAY_CMND_MENU_SCAN: > if (GetMenuState(gpAppFrame->oAppCore.oDockLet.systray_menu, SYSTRAY_CMND_MENU_SCAN, MF_BYCOMMAND) & MF_CHECKED) { >- rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "scan_selection", false); >- on_conf_dictionary_scan_selection_changed(false); >- } >- else { >- rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "scan_selection", true); >- on_conf_dictionary_scan_selection_changed(true); >+ conf->set_scan_selection(FALSE); >+ } else { >+ conf->set_scan_selection(TRUE); > } > break; > case SYSTRAY_CMND_MENU_QUIT: >@@ -130,39 +129,32 @@ > { > if ( lparam == WM_LBUTTONDOWN ) { > if (GetKeyState(VK_CONTROL)<0) { >- rw_cfg_write_boolean (usercfgfile, "preferences/dictionary", "scan_selection", !(gpAppFrame->oAppCore.oSelection.bEnable)); >- on_conf_dictionary_scan_selection_changed(!(gpAppFrame->oAppCore.oSelection.bEnable)); >- } >+ conf->set_scan_selection(!conf->get_scan_selection()); > } >- else if( lparam == WM_LBUTTONDBLCLK ) { >+ } else if ( lparam == WM_LBUTTONDBLCLK ) { > // Only use left button will conflict with the menu. > if (GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) { > stardict_systray_minimize(gpAppFrame->oAppCore.window); > gtk_widget_hide(gpAppFrame->oAppCore.window); >- } >- else { >+ } else { > stardict_systray_maximize(gpAppFrame->oAppCore.window); > gtk_window_present(GTK_WINDOW(gpAppFrame->oAppCore.window)); > if (gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry))[0]) { > gtk_widget_grab_focus(gpAppFrame->oAppCore.oMidWin.oTextWin.textview); //so user can input word directly. >- } >- else { >+ } else { > gtk_widget_grab_focus(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry); //this won't change selection text. > } > } >- } >- else if( lparam == WM_MBUTTONDOWN ) { >- if (gpAppFrame->oAppCore.oDockLet.query_in_floatwin) { >+ } else if (lparam == WM_MBUTTONDOWN) { >+ if (conf->get_query_in_floatwin()) { > gpAppFrame->oAppCore.oSelection.LastClipWord.clear(); > gtk_selection_convert (gpAppFrame->oAppCore.oSelection.selection_widget, GDK_SELECTION_PRIMARY, gpAppFrame->oAppCore.oSelection.UTF8_STRING_Atom, GDK_CURRENT_TIME); >- } >- else { >+ } else { > stardict_systray_maximize(gpAppFrame->oAppCore.window); > gtk_window_present(GTK_WINDOW(gpAppFrame->oAppCore.window)); > gtk_selection_convert (gpAppFrame->oAppCore.oMidWin.oTextWin.textview, GDK_SELECTION_PRIMARY, gpAppFrame->oAppCore.oSelection.UTF8_STRING_Atom, GDK_CURRENT_TIME); > } >- } >- else if( lparam == WM_RBUTTONUP ) { >+ } else if (lparam == WM_RBUTTONUP) { > /* Right Click */ > POINT mpoint; > GetCursorPos(&mpoint); >@@ -177,7 +169,6 @@ > This will put the systray icon back in it's place, when it restarts */ > Shell_NotifyIcon(NIM_ADD,&(gpAppFrame->oAppCore.oDockLet.stardict_nid)); > } >- break; > } > > return DefWindowProc(hwnd, msg, wparam, lparam);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 86379
:
54223
|
54224
|
54225
|
54226
|
54227
|
54228
|
57739
|
77422