[gtranslator] Port gtranslator to gsettings.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator] Port gtranslator to gsettings.
- Date: Tue, 7 Sep 2010 22:51:36 +0000 (UTC)
commit 60e2d54861c5ab04937700b2efa095d71bf2cd63
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Mon Aug 16 21:44:03 2010 +0200
Port gtranslator to gsettings.
configure.ac | 24 +-
data/Makefile.am | 44 +-
data/gtranslator.schemas.in | 257 --------
data/org.gnome.gtranslator.gschema.xml.in.in | 210 ++++++
po/POTFILES.in | 3 +-
src/Makefile.am | 17 +-
src/dialogs/gtr-header-dialog.c | 80 ++-
src/dialogs/gtr-preferences-dialog.c | 569 ++++++-----------
src/gtr-application.c | 89 ++-
src/gtr-application.h | 2 +
src/gtr-header.c | 32 +-
src/gtr-history-entry.c | 120 ++--
src/gtr-history-entry.h | 7 +-
src/gtr-po.c | 1 -
src/gtr-prefs-manager-app.c | 670 --------------------
src/gtr-prefs-manager-app.h | 69 --
src/gtr-prefs-manager-private.h | 40 --
src/gtr-prefs-manager.c | 328 ----------
src/gtr-prefs-manager.h | 169 -----
src/gtr-settings.c | 461 ++++++++++++++
src/gtr-settings.h | 105 +++
src/gtr-tab.c | 103 ++-
src/gtr-view.c | 82 ++-
src/gtr-window.c | 34 +-
src/main.c | 21 +-
src/plugin-system/gtr-plugins-engine.c | 153 ++---
src/translation-memory/gtr-translation-memory-ui.c | 1 -
27 files changed, 1398 insertions(+), 2293 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index dcc0f3f..ec6a915 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,6 +64,12 @@ GNOME_COMPILE_WARNINGS([maximum])
AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums])
+dnl ================================================================
+dnl GSettings stuff
+dnl ================================================================
+
+GLIB_GSETTINGS
+
dnl ==========================================================================
dnl
dnl If you add a version number here, you *must* add an AC_SUBST line for
@@ -73,8 +79,7 @@ dnl ==========================================================================
GTHREAD_REQUIRED=2.13.0
GTK_REQUIRED=2.21.5
-GLIB_REQUIRED=2.15.5
-GCONF_REQUIRED=2.18.0
+GLIB_REQUIRED=2.25.10
LIBXML_REQUIRED=2.4.12
SOURCEVIEW_REQUIRED=2.4.0
GDL_REQUIRED=2.26.0
@@ -84,7 +89,6 @@ LIBSOUP_OPTIONAL=2.4.0
AC_SUBST(GTK_REQUIRED)
AC_SUBST(GLIB_REQUIRED)
-AC_SUBST(GCONF_REQUIRED)
AC_SUBST(LIBXML_REQUIRED)
AC_SUBST(SOURCEVIEW_REQUIRED)
AC_SUBST(GDL_REQUIDED)
@@ -99,7 +103,6 @@ PKG_CHECK_MODULES(GTRANSLATOR, [
gtk+-2.0 >= $GTK_REQUIRED
gtksourceview-2.0 >= $SOURCEVIEW_REQUIRED
gdl-1.0 >= $GDL_REQUIRED
- gconf-2.0 >= $GCONF_REQUIRED
unique-1.0
libgda-4.0
])
@@ -136,18 +139,6 @@ else
fi
AC_SUBST(PLUGIN_LIBTOOL_FLAGS)
-
-dnl ------
-dnl GCONF
-dnl ------
-AM_GCONF_SOURCE_2
-
-AC_PATH_PROG([GCONFTOOL], [gconftool-2], [no])
-
-if test "$GCONFTOOL" = "no"; then
- AC_MSG_ERROR([gconftool-2 not found])
-fi
-
dnl -------------------------------------------------------------------
dnl Check for gtkspell >= 2.0 and use it if found
dnl -------------------------------------------------------------------
@@ -270,6 +261,7 @@ data/gtranslator.pc
data/desktop/Makefile
data/desktop/gtranslator.desktop.in
data/desktop/icons/Makefile
+data/org.gnome.gtranslator.gschema.xml.in
data/pixmaps/Makefile
doc/Makefile
doc/reference/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index a7ddee0..e6806c5 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -4,35 +4,33 @@ SUBDIRS = \
desktop \
pixmaps
-schemasdir = $(GCONF_SCHEMA_FILE_DIR)
-schemas_in_files = gtranslator.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
- INTLTOOL_SCHEMAS_RULE@
-
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gtranslator.pc
uidir = $(pkgdatadir)
-ui_DATA = \
- gtranslator-ui.xml \
- gtr-toolbar.xml \
- po.lang \
- layout.xml
-
-install-data-local:
- if test -z "$(DESTDIR)" ; then \
- for p in $(schemas_DATA) ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/data/$$p; \
- done \
- fi
-
-EXTRA_DIST = \
- $(schemas_in_files) \
- $(ui_DATA) \
+ui_DATA = \
+ gtranslator-ui.xml \
+ gtr-toolbar.xml \
+ po.lang \
+ layout.xml
+
+gsettings_SCHEMAS = org.gnome.gtranslator.gschema.xml
+
+ INTLTOOL_XML_NOMERGE_RULE@
+
+ GSETTINGS_RULES@
+
+EXTRA_DIST = \
+ $(ui_DATA) \
+ org.gnome.gtranslator.gschema.xml.in \
gtranslator.pc.in
-CLEANFILES = \
- $(schemas_DATA) \
+CLEANFILES = \
+ $(gsettings_SCHEMAS) \
+ $(pkgconfig_DATA)
+
+DISTCLEANFILES = \
+ $(gsettings_SCHEMAS) \
$(pkgconfig_DATA)
-include $(top_srcdir)/git.mk
diff --git a/data/org.gnome.gtranslator.gschema.xml.in.in b/data/org.gnome.gtranslator.gschema.xml.in.in
new file mode 100644
index 0000000..49cc11b
--- /dev/null
+++ b/data/org.gnome.gtranslator.gschema.xml.in.in
@@ -0,0 +1,210 @@
+<schemalist>
+ <enum id="org.gnome.gtranslator.SwitcherStyle">
+ <value nick="text" value="0"/>
+ <value nick="icon" value="1"/>
+ <value nick="both" value="2"/>
+ <value nick="toolbar" value="3"/>
+ <value nick="tabs" value="4"/>
+ <value nick="none" value="5"/>
+ </enum>
+
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gtranslator" path="/apps/gtranslator/">
+ <child name="preferences" schema="org.gnome.gtranslator.preferences"/>
+ <child name="state" schema="org.gnome.gtranslator.state"/>
+ <child name="plugins" schema="org.gnome.gtranslator.plugins"/>
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gtranslator.preferences" path="/apps/gtranslator/preferences/">
+ <child name="files" schema="org.gnome.gtranslator.preferences.files"/>
+ <child name="editor" schema="org.gnome.gtranslator.preferences.editor"/>
+ <child name="tm" schema="org.gnome.gtranslator.preferences.tm"/>
+ <child name="ui" schema="org.gnome.gtranslator.preferences.ui"/>
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gtranslator.preferences.files" path="/apps/gtranslator/preferences/files/">
+ <key name="warn-if-contains-fuzzy" type="b">
+ <default>true</default>
+ <_summary>Warn if file contains fuzzy translations</_summary>
+ <_description>
+ If true, warn the user when saving a PO translation file containing
+ fuzzy strings.
+ </_description>
+ </key>
+ <key name="delete-compiled" type="b">
+ <default>false</default>
+ <_summary>Delete compiled GMO files</_summary>
+ <_description>
+ If true, remove compiled GMO binary files when saving.
+ </_description>
+ </key>
+ <key name="auto-save" type="b">
+ <default>false</default>
+ <_summary>Auto save files</_summary>
+ <_description>
+ If true, automatically save files at specified intervals.
+ </_description>
+ </key>
+ <key name="auto-save-interval" type="i">
+ <default>4</default>
+ <_summary>Auto save interval</_summary>
+ <_description>
+ Interval in minutes at which to automatically save files.
+ </_description>
+ </key>
+ <key name="create-backup" type="b">
+ <default>true</default>
+ <_summary>Create backup before saving</_summary>
+ <_description>
+ If true, create a backup copy of a file before saving it.
+ </_description>
+ </key>
+ <key name="use-profile-values" type="b">
+ <default>true</default>
+ <_summary>Use profile values for header</_summary>
+ <_description>
+ If true, overwrite the values in the PO header with those in the active
+ profile.
+ </_description>
+ </key>
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gtranslator.preferences.editor" path="/apps/gtranslator/preferences/editor/">
+ <key name="highlight-syntax" type="b">
+ <default>true</default>
+ <_summary>Highlight syntax in edit fields</_summary>
+ <_description>
+ If true, apply syntax highlighting to strings in edit fields.
+ </_description>
+ </key>
+ <key name="visible-whitespace" type="b">
+ <default>true</default>
+ <_summary>Make whitespace visible</_summary>
+ <_description>
+ If true, display whitespace in strings as representative symbols.
+ </_description>
+ </key>
+ <key name="use-custom-font" type="b">
+ <default>false</default>
+ <_summary>Use custom font</_summary>
+ <_description>
+ If true, use a custom font for edit fields.
+ </_description>
+ </key>
+ <key name="editor-font" type="s">
+ <default>'Sans 10'</default>
+ <_summary>Editor font</_summary>
+ <_description>
+ Custom font to use for edit fields.
+ </_description>
+ </key>
+ <key name="unmark-fuzzy-when-changed" type="b">
+ <default>true</default>
+ <_summary>Remove fuzzy status when message is changed</_summary>
+ <_description>
+ If true, remove fuzzy status from translations when they are changed.
+ </_description>
+ </key>
+ <key name="spellcheck" type="b">
+ <default>true</default>
+ <_summary>Check spelling</_summary>
+ <_description>
+ If true, check the spelling of translated messages.
+ </_description>
+ </key>
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gtranslator.preferences.tm" path="/apps/gtranslator/preferences/tm/">
+ <key name="po-directory" type="s">
+ <default>''</default>
+ <_summary>PO directory</_summary>
+ <_description>
+ Directory containing PO files to add to the translation memory.
+ </_description>
+ </key>
+ <key name="restrict-to-filename" type="b">
+ <default>false</default>
+ <_summary>Restrict search by filename</_summary>
+ <_description>
+ If true, only include files with a specified filename when searching
+ the translation memory.
+ </_description>
+ </key>
+ <key name="filename-restriction" type="s">
+ <default>''</default>
+ <_summary>Filename to restrict search to</_summary>
+ <_description>
+ Filename to which searching of the translation memory should be
+ restricted.
+ </_description>
+ </key>
+ <key name="max-missing-words" type="i">
+ <default>2</default>
+ <_summary>Maximum number of missing words</_summary>
+ <_description>
+ Maximum number of words that can be missing from a message displayed as
+ a match by the translation memory.
+ </_description>
+ </key>
+ <key name="max-length-diff" type="i">
+ <default>2</default>
+ <_summary>Maximum difference in message length</_summary>
+ <_description>
+ Maximum difference in length between messages displayed as matches by
+ the translation memory.
+ </_description>
+ </key>
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gtranslator.preferences.ui" path="/apps/gtranslator/preferences/ui/">
+ <key name="panel-switcher-style" enum="org.gnome.gtranslator.SwitcherStyle">
+ <default>'both'</default>
+ <_summary>Side panel switcher style</_summary>
+ <_description>
+ Style for switchers in the side panel.
+ </_description>
+ </key>
+ <key name="color-scheme" type="s">
+ <default>'classic'</default>
+ <_summary>Color scheme</_summary>
+ <_description>
+ Name of a gtksourceview color scheme to use for syntax highlighting.
+ </_description>
+ </key>
+ <key name="sort-order" type="s">
+ <default>'id'</default>
+ <_summary>Message list sort order</_summary>
+ <_description>
+ Sort order to use in the message list. Possible values are "status",
+ "id", "original-text" and "translated-text".
+ </_description>
+ </key>
+ </schema>
+ <schema id="org.gnome.gtranslator.state" path="/apps/gtranslator/state/">
+ <child name="window" schema="org.gnome.gtranslator.state.window"/>
+ <child name="history-entry" schema="org.gnome.gtranslator.state.history-entry"/>
+ </schema>
+ <schema id="org.gnome.gtranslator.state.window" path="/apps/gtranslator/state/window/">
+ <key name="state" type="i">
+ <default>0</default>
+ </key>
+ <key name="size" type="(ii)">
+ <default>(775, 500)</default>
+ </key>
+ <key name="content-panel-size" type="i">
+ <default>325</default>
+ </key>
+ <key name="context-panel-size" type="i">
+ <default>525</default>
+ </key>
+ </schema>
+ <schema id="org.gnome.gtranslator.state.history-entry" path="/apps/gtranslator/state/history-entry/">
+ <key name="search-for-entry" type="as">
+ <default>['']</default>
+ </key>
+ <key name="replace-with-entry" type="as">
+ <default>['']</default>
+ </key>
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gtranslator.plugins" path="/apps/gtranslator/plugins/">
+ <key name="active-plugins" type="as">
+ <default>['']</default>
+ <_summary>Active plugins</_summary>
+ <_description>List of active plugins. It contains the "Location" of the active plugins. See the .gtranslator-plugin file for obtaining the "Location" of a given plugin.</_description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3c9b6fb..fc526f9 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,7 +2,7 @@
# Please keep this file sorted alphabetically.
[encoding: UTF-8]
data/desktop/gtranslator.desktop.in.in
-data/gtranslator.schemas.in
+data/org.gnome.gtranslator.gschema.xml.in.in
data/po.lang
plugins/alternate-language/gtr-alternate-language-panel.c
plugins/alternate-language/gtr-alternate-language-plugin.c
@@ -49,7 +49,6 @@ src/gtr-message-table.c
src/gtr-notebook.c
src/gtr-po.c
src/plugin-system/gtr-plugin-manager.c
-src/gtr-prefs-manager.c
src/gtr-statusbar.c
src/gtr-tab.c
src/gtr-tab-label.c
diff --git a/src/Makefile.am b/src/Makefile.am
index a0e1aeb..178fccc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,8 +29,6 @@ INCLUDES = \
$(WARN_CFLAGS) \
$(DISABLE_DEPRECATED) \
-DG_LOG_DOMAIN=\""$(PACKAGE)"\" \
- -DSCRIPTSDIR=\""$(pkgdatadir)"/scripts\" \
- -DWINDOW_ICON=\""$(datadir)"/pixmaps/gtranslator.png\" \
-DPIXMAPSDIR=\""$(datadir)"/pixmaps/gtranslator\"
bin_PROGRAMS = \
@@ -52,9 +50,9 @@ endif
libgtranslator_la_LDFLAGS = -export-dynamic -no-undefined -export-symbols-regex "^[[^_]].*"
-BUILT_SOURCES = \
- gtr-marshal.h \
- gtr-marshal.c \
+BUILT_SOURCES = \
+ gtr-marshal.h \
+ gtr-marshal.c \
gtr-enum-types.h \
gtr-enum-types.c
@@ -65,7 +63,7 @@ gtranslator-res.o: gtranslator.rc
gtranslator_LDADD += gtranslator-res.o
endif
-INST_H_FILES = \
+INST_H_FILES = \
gtr-application.h \
gtr-context.h \
gtr-debug.h \
@@ -115,11 +113,6 @@ libgtranslator_la_SOURCES = \
gtr-actions-view.c \
gtr-actions-help.c \
gtr-io-error-info-bar.c \
- gtr-prefs-manager.c \
- gtr-prefs-manager.h \
- gtr-prefs-manager-private.h \
- gtr-prefs-manager-app.c \
- gtr-prefs-manager-app.h \
gtr-history-entry.c \
gtr-history-entry.h \
gtr-actions-search.c \
@@ -128,6 +121,8 @@ libgtranslator_la_SOURCES = \
gtr-context.c \
gtr-profile-manager.h \
gtr-profile-manager.c \
+ gtr-settings.h \
+ gtr-settings.c \
gtr-status-combo-box.h \
gtr-status-combo-box.c \
$(INST_H_FILES)
diff --git a/src/dialogs/gtr-header-dialog.c b/src/dialogs/gtr-header-dialog.c
index 72918dc..8cc4c7d 100644
--- a/src/dialogs/gtr-header-dialog.c
+++ b/src/dialogs/gtr-header-dialog.c
@@ -31,7 +31,7 @@
#include "gtr-dirs.h"
#include "gtr-header-dialog.h"
#include "gtr-utils.h"
-#include "gtr-prefs-manager.h"
+#include "gtr-settings.h"
#include "gtr-po.h"
#define GTR_HEADER_DIALOG_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
@@ -40,35 +40,47 @@
GtrHeaderDialogPrivate))
G_DEFINE_TYPE (GtrHeaderDialog, gtr_header_dialog, GTK_TYPE_DIALOG)
- struct _GtrHeaderDialogPrivate
- {
- GtkWidget *main_box;
- GtkWidget *notebook;
-
- GtkWidget *prj_page;
- GtkWidget *lang_page;
- GtkWidget *lang_vbox;
-
- GtkWidget *prj_id_version;
- GtkWidget *rmbt;
- GtkWidget *prj_comment;
- GtkWidget *take_my_options;
-
- GtkWidget *translator;
- GtkWidget *tr_email;
- GtkWidget *pot_date;
- GtkWidget *po_date;
- GtkWidget *language;
- GtkWidget *lg_email;
- GtkWidget *charset;
- GtkWidget *encoding;
-
- GtrHeader *header;
- };
-
- static void gtr_header_dialog_finalize (GObject * object)
+
+struct _GtrHeaderDialogPrivate
{
- G_OBJECT_CLASS (gtr_header_dialog_parent_class)->finalize (object);
+ GSettings *settings;
+
+ GtkWidget *main_box;
+ GtkWidget *notebook;
+
+ GtkWidget *prj_page;
+ GtkWidget *lang_page;
+ GtkWidget *lang_vbox;
+
+ GtkWidget *prj_id_version;
+ GtkWidget *rmbt;
+ GtkWidget *prj_comment;
+ GtkWidget *take_my_options;
+
+ GtkWidget *translator;
+ GtkWidget *tr_email;
+ GtkWidget *pot_date;
+ GtkWidget *po_date;
+ GtkWidget *language;
+ GtkWidget *lg_email;
+ GtkWidget *charset;
+ GtkWidget *encoding;
+
+ GtrHeader *header;
+};
+
+static void
+gtr_header_dialog_dispose (GObject * object)
+{
+ GtrHeaderDialog *dlg = GTR_HEADER_DIALOG (object);
+
+ if (dlg->priv->settings != NULL)
+ {
+ g_object_unref (dlg->priv->settings);
+ dlg->priv->settings = NULL;
+ }
+
+ G_OBJECT_CLASS (gtr_header_dialog_parent_class)->dispose (object);
}
static void
@@ -78,7 +90,7 @@ gtr_header_dialog_class_init (GtrHeaderDialogClass * klass)
g_type_class_add_private (klass, sizeof (GtrHeaderDialogPrivate));
- object_class->finalize = gtr_header_dialog_finalize;
+ object_class->dispose = gtr_header_dialog_dispose;
}
static void
@@ -91,7 +103,8 @@ take_my_options_checkbutton_toggled (GtkToggleButton * button,
active = gtk_toggle_button_get_active (button);
- gtr_prefs_manager_set_use_profile_values (active);
+ g_settings_set_boolean (dlg->priv->settings, GTR_SETTINGS_USE_PROFILE_VALUES,
+ active);
gtk_widget_set_sensitive (dlg->priv->translator, !active);
gtk_widget_set_sensitive (dlg->priv->tr_email, !active);
@@ -231,6 +244,8 @@ gtr_header_dialog_init (GtrHeaderDialog * dlg)
dlg->priv = GTR_HEADER_DIALOG_GET_PRIVATE (dlg);
+ dlg->priv->settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
+
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
@@ -289,7 +304,8 @@ gtr_header_dialog_init (GtrHeaderDialog * dlg)
gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->notebook), 5);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->take_my_options),
- gtr_prefs_manager_get_use_profile_values ());
+ g_settings_get_boolean (dlg->priv->settings,
+ GTR_SETTINGS_USE_PROFILE_VALUES));
gtk_text_view_set_editable (GTK_TEXT_VIEW (dlg->priv->prj_comment), TRUE);
diff --git a/src/dialogs/gtr-preferences-dialog.c b/src/dialogs/gtr-preferences-dialog.c
index 8345a88..095d2a0 100644
--- a/src/dialogs/gtr-preferences-dialog.c
+++ b/src/dialogs/gtr-preferences-dialog.c
@@ -28,7 +28,7 @@
#include "gtr-application.h"
#include "gtr-dirs.h"
#include "gtr-preferences-dialog.h"
-#include "gtr-prefs-manager.h"
+#include "gtr-settings.h"
#include "gtr-profile.h"
#include "gtr-profile-manager.h"
#include "gtr-utils.h"
@@ -56,6 +56,11 @@ G_DEFINE_TYPE (GtrPreferencesDialog, gtr_preferences_dialog, GTK_TYPE_DIALOG)
struct _GtrPreferencesDialogPrivate
{
+ GSettings *ui_settings;
+ GSettings *tm_settings;
+ GSettings *editor_settings;
+ GSettings *files_settings;
+
GtkWidget *notebook;
/* Files->General */
@@ -128,125 +133,63 @@ enum
/***************Files pages****************/
static void
-warn_if_contains_fuzzy_checkbutton_toggled (GtkToggleButton * button,
- GtrPreferencesDialog * dlg)
-{
- g_return_if_fail (button ==
- GTK_TOGGLE_BUTTON (dlg->
- priv->warn_if_contains_fuzzy_checkbutton));
-
- gtr_prefs_manager_set_warn_if_contains_fuzzy
- (gtk_toggle_button_get_active (button));
-}
-
-static void
-delete_compiled_checkbutton_toggled (GtkToggleButton * button,
- GtrPreferencesDialog * dlg)
-{
- g_return_if_fail (button ==
- GTK_TOGGLE_BUTTON (dlg->
- priv->delete_compiled_checkbutton));
-
- gtr_prefs_manager_set_delete_compiled (gtk_toggle_button_get_active
- (button));
-}
-
-static void
setup_files_general_page (GtrPreferencesDialog * dlg)
{
- /*Set initial value */
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dlg->
- priv->warn_if_contains_fuzzy_checkbutton),
- gtr_prefs_manager_get_warn_if_contains_fuzzy
- ());
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dlg->priv->delete_compiled_checkbutton),
- gtr_prefs_manager_get_delete_compiled ());
-
- /*Connect signals */
- g_signal_connect (dlg->priv->warn_if_contains_fuzzy_checkbutton, "toggled",
- G_CALLBACK (warn_if_contains_fuzzy_checkbutton_toggled),
- dlg);
- g_signal_connect (dlg->priv->delete_compiled_checkbutton, "toggled",
- G_CALLBACK (delete_compiled_checkbutton_toggled), dlg);
+ g_settings_bind (dlg->priv->files_settings,
+ GTR_SETTINGS_WARN_IF_CONTAINS_FUZZY,
+ dlg->priv->warn_if_contains_fuzzy_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_settings_bind (dlg->priv->files_settings,
+ GTR_SETTINGS_DELETE_COMPILED,
+ dlg->priv->delete_compiled_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
}
static void
-autosave_checkbutton_toggled (GtkToggleButton * button,
- GtrPreferencesDialog * dlg)
+on_auto_save_changed (GSettings *settings,
+ const gchar *key,
+ GtrPreferencesDialog *dlg)
{
- gboolean autosave;
-
- g_return_if_fail (button ==
- GTK_TOGGLE_BUTTON (dlg->priv->autosave_checkbutton));
-
- autosave = gtk_toggle_button_get_active (button);
-
gtk_widget_set_sensitive (dlg->priv->autosave_interval_spinbutton,
- autosave);
- gtr_prefs_manager_set_autosave (autosave);
-}
-
-static void
-create_backup_checkbutton_toggled (GtkToggleButton * button,
- GtrPreferencesDialog * dlg)
-{
- gboolean create_backup;
-
- g_return_if_fail (button ==
- GTK_TOGGLE_BUTTON (dlg->priv->create_backup_checkbutton));
-
- create_backup = gtk_toggle_button_get_active (button);
-
- gtr_prefs_manager_set_create_backup (create_backup);
-}
-
-static void
-autosave_interval_spinbutton_value_changed (GtkSpinButton * spin_button,
- GtrPreferencesDialog * dlg)
-{
- g_return_if_fail (spin_button ==
- GTK_SPIN_BUTTON (dlg->
- priv->autosave_interval_spinbutton));
-
- gtr_prefs_manager_set_autosave_interval
- (gtk_spin_button_get_value_as_int (spin_button));
+ g_settings_get_boolean (settings, key));
}
static void
setup_files_autosave_page (GtrPreferencesDialog * dlg)
{
- gboolean autosave, backup;
- gint autosave_interval;
+ gboolean autosave;
/*Set initial value */
- autosave = gtr_prefs_manager_get_autosave ();
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dlg->priv->autosave_checkbutton), autosave);
- backup = gtr_prefs_manager_get_create_backup ();
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dlg->priv->create_backup_checkbutton),
- backup);
-
- autosave_interval = gtr_prefs_manager_get_autosave_interval ();
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON
- (dlg->priv->autosave_interval_spinbutton),
- autosave_interval);
+ autosave = g_settings_get_boolean (dlg->priv->files_settings,
+ GTR_SETTINGS_AUTO_SAVE);
/*Set sensitive */
gtk_widget_set_sensitive (dlg->priv->autosave_interval_spinbutton,
autosave);
- /*Connect signals */
- g_signal_connect (dlg->priv->autosave_checkbutton, "toggled",
- G_CALLBACK (autosave_checkbutton_toggled), dlg);
- g_signal_connect (dlg->priv->create_backup_checkbutton, "toggled",
- G_CALLBACK (create_backup_checkbutton_toggled), dlg);
- g_signal_connect (dlg->priv->autosave_interval_spinbutton, "value-changed",
- G_CALLBACK (autosave_interval_spinbutton_value_changed),
+ g_settings_bind (dlg->priv->files_settings,
+ GTR_SETTINGS_AUTO_SAVE_INTERVAL,
+ dlg->priv->autosave_interval_spinbutton,
+ "value",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dlg->priv->files_settings,
+ GTR_SETTINGS_AUTO_SAVE,
+ dlg->priv->autosave_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_signal_connect (dlg->priv->files_settings,
+ "changed::auto-save",
+ G_CALLBACK (on_auto_save_changed),
dlg);
+
+ g_settings_bind (dlg->priv->files_settings,
+ GTR_SETTINGS_CREATE_BACKUP,
+ dlg->priv->create_backup_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
}
static void
@@ -259,149 +202,58 @@ setup_files_pages (GtrPreferencesDialog * dlg)
/***************Editor pages****************/
-static void
-highlight_syntax_checkbutton_toggled (GtkToggleButton * button,
- GtrPreferencesDialog * dlg)
-{
- g_return_if_fail (button ==
- GTK_TOGGLE_BUTTON (dlg->
- priv->highlight_syntax_checkbutton));
-
- gtr_prefs_manager_set_highlight_syntax (gtk_toggle_button_get_active
- (button));
-}
-
-static void
-visible_whitespace_checkbutton_toggled (GtkToggleButton * button,
- GtrPreferencesDialog * dlg)
-{
- g_return_if_fail (button ==
- GTK_TOGGLE_BUTTON (dlg->
- priv->visible_whitespace_checkbutton));
-
- gtr_prefs_manager_set_visible_whitespace
- (gtk_toggle_button_get_active (button));
-}
static void
use_custom_font_checkbutton_toggled (GtkToggleButton * button,
GtrPreferencesDialog * dlg)
{
- gboolean use_custom_font;
-
- g_return_if_fail (button ==
- GTK_TOGGLE_BUTTON (dlg->
- priv->use_custom_font_checkbutton));
-
- use_custom_font = gtk_toggle_button_get_active (button);
-
- gtr_prefs_manager_set_use_custom_font (use_custom_font);
-
- gtk_widget_set_sensitive (dlg->priv->editor_font_hbox, use_custom_font);
-}
-
-static void
-editor_font_set (GtkFontButton * button, GtrPreferencesDialog * dlg)
-{
- const gchar *editor_font;
-
- g_return_if_fail (button ==
- GTK_FONT_BUTTON (dlg->priv->editor_font_fontbutton));
-
- editor_font =
- gtk_font_button_get_font_name (GTK_FONT_BUTTON
- (dlg->priv->editor_font_fontbutton));
-
- if (editor_font)
- gtr_prefs_manager_set_editor_font (editor_font);
- //FIXME:else set default font
+ gtk_widget_set_sensitive (dlg->priv->editor_font_hbox,
+ gtk_toggle_button_get_active (button));
}
static void
setup_editor_text_display_page (GtrPreferencesDialog * dlg)
{
- gboolean use_custom_font;
- const gchar *editor_font;
-
- /*Set initial value */
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dlg->priv->highlight_syntax_checkbutton),
- gtr_prefs_manager_get_highlight_syntax ());
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dlg->priv->visible_whitespace_checkbutton),
- gtr_prefs_manager_get_visible_whitespace ());
-
- use_custom_font = gtr_prefs_manager_get_use_custom_font ();
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dlg->priv->use_custom_font_checkbutton),
- use_custom_font);
-
- if (use_custom_font)
- {
- editor_font = gtr_prefs_manager_get_editor_font ();
- if (editor_font)
- gtk_font_button_set_font_name (GTK_FONT_BUTTON
- (dlg->priv->editor_font_fontbutton),
- editor_font);
- //else FIXME: I think i need to set the system font (maybe Sans 12?)
- }
-
- /*Set sensitive */
- gtk_widget_set_sensitive (dlg->priv->editor_font_hbox, use_custom_font);
-
- /*Connect signals */
- g_signal_connect (dlg->priv->highlight_syntax_checkbutton, "toggled",
- G_CALLBACK (highlight_syntax_checkbutton_toggled), dlg);
- g_signal_connect (dlg->priv->visible_whitespace_checkbutton, "toggled",
- G_CALLBACK (visible_whitespace_checkbutton_toggled), dlg);
+ g_settings_bind (dlg->priv->editor_settings,
+ GTR_SETTINGS_HIGHLIGHT_SYNTAX,
+ dlg->priv->highlight_syntax_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_settings_bind (dlg->priv->editor_settings,
+ GTR_SETTINGS_VISIBLE_WHITESPACE,
+ dlg->priv->visible_whitespace_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ /* Connect before binding to set the sensitivity */
g_signal_connect (dlg->priv->use_custom_font_checkbutton, "toggled",
G_CALLBACK (use_custom_font_checkbutton_toggled), dlg);
- g_signal_connect (dlg->priv->editor_font_fontbutton, "font-set",
- G_CALLBACK (editor_font_set), dlg);
-}
-
-static void
-unmark_fuzzy_when_changed_checkbutton_toggled (GtkToggleButton * button,
- GtrPreferencesDialog * dlg)
-{
- g_return_if_fail (button ==
- GTK_TOGGLE_BUTTON (dlg->
- priv->unmark_fuzzy_when_changed_checkbutton));
-
- gtr_prefs_manager_set_unmark_fuzzy_when_changed
- (gtk_toggle_button_get_active (button));
-}
-
-static void
-spellcheck_checkbutton_toggled (GtkToggleButton * button,
- GtrPreferencesDialog * dlg)
-{
- g_return_if_fail (button ==
- GTK_TOGGLE_BUTTON (dlg->priv->spellcheck_checkbutton));
-
- gtr_prefs_manager_set_spellcheck (gtk_toggle_button_get_active (button));
+ g_settings_bind (dlg->priv->editor_settings,
+ GTR_SETTINGS_USE_CUSTOM_FONT,
+ dlg->priv->use_custom_font_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dlg->priv->editor_settings,
+ GTR_SETTINGS_EDITOR_FONT,
+ dlg->priv->editor_font_fontbutton,
+ "font-name",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
}
static void
setup_editor_contents (GtrPreferencesDialog * dlg)
{
- /*Set initial values */
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dlg->
- priv->unmark_fuzzy_when_changed_checkbutton),
- gtr_prefs_manager_get_unmark_fuzzy_when_changed
- ());
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dlg->priv->spellcheck_checkbutton),
- gtr_prefs_manager_get_spellcheck ());
-
- /*Connect signals */
- g_signal_connect (dlg->priv->unmark_fuzzy_when_changed_checkbutton,
- "toggled",
- G_CALLBACK
- (unmark_fuzzy_when_changed_checkbutton_toggled), dlg);
- g_signal_connect (dlg->priv->spellcheck_checkbutton, "toggled",
- G_CALLBACK (spellcheck_checkbutton_toggled), dlg);
+ g_settings_bind (dlg->priv->editor_settings,
+ GTR_SETTINGS_UNMARK_FUZZY_WHEN_CHANGED,
+ dlg->priv->unmark_fuzzy_when_changed_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_settings_bind (dlg->priv->editor_settings,
+ GTR_SETTINGS_SPELLCHECK,
+ dlg->priv->spellcheck_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
}
static void
@@ -763,43 +615,30 @@ setup_profile_pages (GtrPreferencesDialog *dlg)
/***************Interface pages****************/
static void
-style_changed_cb (GtkComboBox * combobox, GtrPreferencesDialog * dlg)
-{
- g_return_if_fail (combobox == GTK_COMBO_BOX (dlg->priv->gdl_combobox));
-
- gtr_prefs_manager_set_color_scheme (gtk_combo_box_get_active_text
- (combobox));
-}
-
-static void
scheme_color_changed_cb (GtkComboBox * combobox, GtrPreferencesDialog * dlg)
{
- g_return_if_fail (combobox ==
- GTK_COMBO_BOX (dlg->priv->scheme_color_combobox));
-
- gtr_prefs_manager_set_color_scheme (gtk_combo_box_get_active_text
- (combobox));
+ g_settings_set_string (dlg->priv->ui_settings,
+ GTR_SETTINGS_COLOR_SCHEME,
+ gtk_combo_box_get_active_text (combobox));
}
static void
setup_interface_pages (GtrPreferencesDialog * dlg)
{
- gint pane_switcher_style;
GtkSourceStyleSchemeManager *manager;
const gchar *const *scheme_ids;
- const gchar *scheme_active;
+ gchar *scheme_active;
gint i = 0;
GtkListStore *store;
GtkCellRenderer *cell;
- /*Set initial value */
- pane_switcher_style = gtr_prefs_manager_get_pane_switcher_style ();
- if (pane_switcher_style)
- gtk_combo_box_set_active (GTK_COMBO_BOX (dlg->priv->gdl_combobox),
- pane_switcher_style);
- /*
- * Scheme color
- */
+ g_settings_bind (dlg->priv->ui_settings,
+ GTR_SETTINGS_PANEL_SWITCHER_STYLE,
+ dlg->priv->gdl_combobox,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ /* Scheme color */
store = gtk_list_store_new (1, G_TYPE_STRING);
gtk_combo_box_set_model (GTK_COMBO_BOX (dlg->priv->scheme_color_combobox),
GTK_TREE_MODEL (store));
@@ -814,7 +653,8 @@ setup_interface_pages (GtrPreferencesDialog * dlg)
manager = gtk_source_style_scheme_manager_get_default ();
scheme_ids = gtk_source_style_scheme_manager_get_scheme_ids (manager);
- scheme_active = gtr_prefs_manager_get_color_scheme ();
+ scheme_active = g_settings_get_string (dlg->priv->ui_settings,
+ GTR_SETTINGS_COLOR_SCHEME);
while (scheme_ids[i] != NULL)
{
gtk_combo_box_append_text (GTK_COMBO_BOX
@@ -826,9 +666,9 @@ setup_interface_pages (GtrPreferencesDialog * dlg)
i++;
}
+ g_free (scheme_active);
+
/*Connect signals */
- g_signal_connect (dlg->priv->gdl_combobox, "changed",
- G_CALLBACK (style_changed_cb), dlg);
g_signal_connect (dlg->priv->scheme_color_combobox, "changed",
G_CALLBACK (scheme_color_changed_cb), dlg);
}
@@ -836,35 +676,28 @@ setup_interface_pages (GtrPreferencesDialog * dlg)
/***************Translation Memory pages****************/
static void
response_filechooser_cb (GtkDialog * dialog,
- gint response_id, gpointer user_data)
+ gint response_id, GtrPreferencesDialog *dlg)
{
- GtrPreferencesDialog *dlg;
-
- dlg = (GtrPreferencesDialog *) user_data;
-
-
if (response_id == GTK_RESPONSE_YES)
{
+ gchar *filename;
+
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
gtk_entry_set_text (GTK_ENTRY (dlg->priv->directory_entry),
- gtk_file_chooser_get_filename (GTK_FILE_CHOOSER
- (dialog)));
- gtr_prefs_manager_set_po_directory
- (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)));
- gtk_widget_destroy (GTK_WIDGET (dialog));
- }
- else
- {
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ filename);
+ g_settings_set_string (dlg->priv->tm_settings,
+ GTR_SETTINGS_PO_DIRECTORY,
+ filename);
+ g_free (filename);
}
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
-on_search_button_clicked (GtkButton * button, gpointer data)
+on_search_button_clicked (GtkButton * button, GtrPreferencesDialog *dlg)
{
GtkWidget *filechooser;
- GtrPreferencesDialog *dlg;
-
- dlg = (GtrPreferencesDialog *) data;
filechooser = gtk_file_chooser_dialog_new ("Select PO directory",
GTK_WINDOW (dlg),
@@ -975,19 +808,28 @@ static void
on_add_database_button_clicked (GtkButton * button, GtrPreferencesDialog * dlg)
{
GFile *dir;
- const gchar *dir_name;
+ gchar *dir_name;
IdleData *data;
data = g_new0 (IdleData, 1);
data->list = NULL;
- dir_name = gtr_prefs_manager_get_po_directory ();
+ dir_name = g_settings_get_string (dlg->priv->tm_settings,
+ GTR_SETTINGS_PO_DIRECTORY);
dir = g_file_new_for_path (dir_name);
+ g_free (dir_name);
+
+ if (g_settings_get_boolean (dlg->priv->tm_settings,
+ GTR_SETTINGS_RESTRICT_TO_FILENAME))
+ {
+ gchar *restriction;
- if (gtr_prefs_manager_get_restrict_to_filename ())
- gtr_utils_scan_dir (dir, &data->list,
- gtr_prefs_manager_get_filename_restriction ());
+ restriction = g_settings_get_string (dlg->priv->tm_settings,
+ GTR_SETTINGS_FILENAME_RESTRICTION);
+ gtr_utils_scan_dir (dir, &data->list, restriction);
+ g_free (restriction);
+ }
else
gtr_utils_scan_dir (dir, &data->list, NULL);
@@ -1005,79 +847,12 @@ on_add_database_button_clicked (GtkButton * button, GtrPreferencesDialog * dlg)
}
static void
-on_use_lang_profile_checkbutton_changed (GtkToggleButton * button,
- gpointer user_data)
-{
- gtr_prefs_manager_set_restrict_to_filename
- (gtk_toggle_button_get_active (button));
-}
-
-static void
-tm_lang_entry_changed (GObject * gobject,
- GParamSpec * arg1, GtrPreferencesDialog * dlg)
-{
- const gchar *text;
-
- g_return_if_fail (GTK_ENTRY (gobject) ==
- GTK_ENTRY (dlg->priv->tm_lang_entry));
-
- text = gtk_entry_get_text (GTK_ENTRY (gobject));
-
- if (text)
- gtr_prefs_manager_set_filename_restriction (text);
-}
-
-
-static void
-on_missing_words_spinbutton_changed (GtkSpinButton * spinbutton,
- gpointer data)
-{
- gint value;
-
- value = gtk_spin_button_get_value_as_int (spinbutton);
-
- gtr_prefs_manager_set_max_missing_words (value);
-}
-
-static void
-on_sentence_length_spinbutton_changed (GtkSpinButton * spinbutton,
- gpointer data)
-{
- gint value;
-
- value = gtk_spin_button_get_value_as_int (spinbutton);
-
- gtr_prefs_manager_set_max_length_diff (value);
-}
-
-static void
-directory_entry_changed (GObject * gobject,
- GParamSpec * arg1, GtrPreferencesDialog * dlg)
-{
- const gchar *text;
-
- g_return_if_fail (GTK_ENTRY (gobject) ==
- GTK_ENTRY (dlg->priv->directory_entry));
-
- text = gtk_entry_get_text (GTK_ENTRY (gobject));
-
- if (text)
- gtr_prefs_manager_set_po_directory (text);
-}
-
-
-static void
setup_tm_pages (GtrPreferencesDialog * dlg)
{
GtrProfileManager *prof_manager;
GtrProfile *profile;
const gchar *language_code;
- const gchar *filename = NULL;
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dlg->priv->use_lang_profile_in_tm),
- gtr_prefs_manager_get_restrict_to_filename
- ());
+ gchar *filename = NULL;
prof_manager = gtr_profile_manager_get_default ();
profile = gtr_profile_manager_get_active_profile (prof_manager);
@@ -1085,51 +860,50 @@ setup_tm_pages (GtrPreferencesDialog * dlg)
if (profile != NULL)
{
language_code = gtr_profile_get_language_code (profile);
- filename = (const gchar *) g_strconcat (language_code, ".po", NULL);
+ filename = g_strconcat (language_code, ".po", NULL);
gtk_entry_set_text (GTK_ENTRY (dlg->priv->tm_lang_entry), filename);
}
g_object_unref (prof_manager);
if (filename != NULL)
- gtr_prefs_manager_set_filename_restriction (filename);
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON
- (dlg->priv->missing_words_spinbutton),
- (gdouble)
- gtr_prefs_manager_get_max_missing_words ());
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON
- (dlg->priv->sentence_length_spinbutton),
- (gdouble)
- gtr_prefs_manager_get_max_length_diff ());
+ g_settings_set_string (dlg->priv->tm_settings,
+ GTR_SETTINGS_FILENAME_RESTRICTION,
+ filename);
+
+ g_free (filename);
+
+ g_settings_bind (dlg->priv->tm_settings,
+ GTR_SETTINGS_RESTRICT_TO_FILENAME,
+ dlg->priv->use_lang_profile_in_tm,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_settings_bind (dlg->priv->tm_settings,
+ GTR_SETTINGS_MAX_MISSING_WORDS,
+ dlg->priv->missing_words_spinbutton,
+ "value",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_settings_bind (dlg->priv->tm_settings,
+ GTR_SETTINGS_MAX_LENGTH_DIFF,
+ dlg->priv->sentence_length_spinbutton,
+ "value",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_settings_bind (dlg->priv->tm_settings,
+ GTR_SETTINGS_PO_DIRECTORY,
+ dlg->priv->directory_entry,
+ "text",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_settings_bind (dlg->priv->tm_settings,
+ GTR_SETTINGS_FILENAME_RESTRICTION,
+ dlg->priv->tm_lang_entry,
+ "text",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
g_signal_connect (GTK_BUTTON (dlg->priv->search_button), "clicked",
G_CALLBACK (on_search_button_clicked), dlg);
- g_signal_connect (dlg->priv->directory_entry, "notify::text",
- G_CALLBACK (directory_entry_changed), dlg);
-
- g_signal_connect (dlg->priv->tm_lang_entry, "notify::text",
- G_CALLBACK (tm_lang_entry_changed), dlg);
-
g_signal_connect (GTK_BUTTON (dlg->priv->add_database_button), "clicked",
G_CALLBACK (on_add_database_button_clicked), dlg);
-
- g_signal_connect (GTK_TOGGLE_BUTTON (dlg->priv->use_lang_profile_in_tm),
- "toggled",
- G_CALLBACK (on_use_lang_profile_checkbutton_changed),
- dlg);
-
- g_signal_connect (GTK_SPIN_BUTTON (dlg->priv->missing_words_spinbutton),
- "value-changed",
- G_CALLBACK (on_missing_words_spinbutton_changed), dlg);
-
- g_signal_connect (GTK_SPIN_BUTTON (dlg->priv->sentence_length_spinbutton),
- "value-changed",
- G_CALLBACK (on_sentence_length_spinbutton_changed), dlg);
-
- g_free ((gpointer) filename);
}
/***************Plugins pages****************/
@@ -1182,6 +956,11 @@ gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
dlg->priv = GTR_PREFERENCES_DIALOG_GET_PRIVATE (dlg);
+ dlg->priv->ui_settings = g_settings_new ("org.gnome.gtranslator.preferences.ui");
+ dlg->priv->editor_settings = g_settings_new ("org.gnome.gtranslator.preferences.editor");
+ dlg->priv->tm_settings = g_settings_new ("org.gnome.gtranslator.preferences.tm");
+ dlg->priv->files_settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
+
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
GTK_STOCK_CLOSE,
GTK_RESPONSE_CLOSE,
@@ -1272,8 +1051,6 @@ gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
return;
}
-
-
gtk_box_pack_start (content_area, dlg->priv->notebook, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->notebook), 5);
@@ -1287,9 +1064,35 @@ gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
}
static void
-gtr_preferences_dialog_finalize (GObject * object)
+gtr_preferences_dialog_dispose (GObject * object)
{
- G_OBJECT_CLASS (gtr_preferences_dialog_parent_class)->finalize (object);
+ GtrPreferencesDialog *dlg = GTR_PREFERENCES_DIALOG (object);
+
+ if (dlg->priv->ui_settings != NULL)
+ {
+ g_object_unref (dlg->priv->ui_settings);
+ dlg->priv->ui_settings = NULL;
+ }
+
+ if (dlg->priv->tm_settings != NULL)
+ {
+ g_object_unref (dlg->priv->tm_settings);
+ dlg->priv->tm_settings = NULL;
+ }
+
+ if (dlg->priv->editor_settings != NULL)
+ {
+ g_object_unref (dlg->priv->editor_settings);
+ dlg->priv->editor_settings = NULL;
+ }
+
+ if (dlg->priv->files_settings != NULL)
+ {
+ g_object_unref (dlg->priv->files_settings);
+ dlg->priv->files_settings = NULL;
+ }
+
+ G_OBJECT_CLASS (gtr_preferences_dialog_parent_class)->dispose (object);
}
static void
@@ -1299,7 +1102,7 @@ gtr_preferences_dialog_class_init (GtrPreferencesDialogClass * klass)
g_type_class_add_private (klass, sizeof (GtrPreferencesDialogPrivate));
- object_class->finalize = gtr_preferences_dialog_finalize;
+ object_class->dispose = gtr_preferences_dialog_dispose;
}
void
diff --git a/src/gtr-application.c b/src/gtr-application.c
index 23325b0..dd1c783 100644
--- a/src/gtr-application.c
+++ b/src/gtr-application.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <icq gnome org>
* 2008 Igalia
*
* This program is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
- * Ignacio Casal Quinteiro <nacho resa gmail com>
+ * Ignacio Casal Quinteiro <icq gnome org>
* Pablo Sanxiao <psanxiao gmail com>
*/
@@ -29,8 +29,7 @@
#include "gtr-application.h"
#include "gtr-debug.h"
#include "gtr-dirs.h"
-#include "gtr-prefs-manager.h"
-#include "gtr-prefs-manager-app.h"
+#include "gtr-settings.h"
#include "gtr-utils.h"
#include "gtr-window.h"
#include "egg-toolbars-model.h"
@@ -52,6 +51,10 @@ G_DEFINE_TYPE (GtrApplication, gtr_application, UNIQUE_TYPE_APP)
struct _GtrApplicationPrivate
{
+ GSettings *settings;
+ GSettings *tm_settings;
+ GSettings *window_settings;
+
GList *windows;
GtrWindow *active_window;
@@ -186,6 +189,11 @@ gtr_application_init (GtrApplication *application)
/* Creating config folder */
ensure_user_config_dir (); /* FIXME: is this really needed ? */
+ /* Load settings */
+ priv->settings = gtr_settings_new ();
+ priv->tm_settings = g_settings_new ("org.gnome.gtranslator.preferences.tm");
+ priv->window_settings = g_settings_new ("org.gnome.gtranslator.state.window");
+
/* If the config folder exists but there is no profile */
gtr_folder = gtr_dirs_get_user_config_dir ();
profiles_file = g_build_filename (gtr_folder, "profiles.xml", NULL);
@@ -228,15 +236,14 @@ gtr_application_init (GtrApplication *application)
/* Creating translation memory */
application->priv->tm = GTR_TRANSLATION_MEMORY (gtr_gda_new ());
gtr_translation_memory_set_max_omits (application->priv->tm,
- gtr_prefs_manager_get_max_missing_words
- ());
+ g_settings_get_int (priv->tm_settings,
+ GTR_SETTINGS_MAX_MISSING_WORDS));
gtr_translation_memory_set_max_delta (application->priv->tm,
- gtr_prefs_manager_get_max_length_diff
- ());
+ g_settings_get_int (priv->tm_settings,
+ GTR_SETTINGS_MAX_LENGTH_DIFF));
gtr_translation_memory_set_max_items (application->priv->tm, 10);
}
-
static void
gtr_application_dispose (GObject * object)
{
@@ -244,6 +251,24 @@ gtr_application_dispose (GObject * object)
DEBUG_PRINT ("Disposing app");
+ if (app->priv->settings != NULL)
+ {
+ g_object_unref (app->priv->settings);
+ app->priv->settings = NULL;
+ }
+
+ if (app->priv->tm_settings != NULL)
+ {
+ g_object_unref (app->priv->tm_settings);
+ app->priv->tm_settings = NULL;
+ }
+
+ if (app->priv->window_settings != NULL)
+ {
+ g_object_unref (app->priv->window_settings);
+ app->priv->window_settings = NULL;
+ }
+
if (app->priv->icon_factory != NULL)
{
g_object_unref (app->priv->icon_factory);
@@ -327,36 +352,30 @@ gtr_application_create_window (GtrApplication *app)
g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
- /*
- * We need to be careful here, there is a race condition:
- * when another gedit is launched it checks active_window,
- * so we must do our best to ensure that active_window
- * is never NULL when at least a window exists.
- */
- if (app->priv->windows == NULL)
- window = g_object_new (GTR_TYPE_WINDOW, NULL);
- else
- window = g_object_new (GTR_TYPE_WINDOW, NULL);
-
+ window = g_object_new (GTR_TYPE_WINDOW, NULL);
set_active_window (app, window);
app->priv->windows = g_list_prepend (app->priv->windows,
window);
- state = gtr_prefs_manager_get_window_state ();
+ state = g_settings_get_int (app->priv->window_settings,
+ GTR_SETTINGS_WINDOW_STATE);
+
+ g_settings_get (app->priv->window_settings,
+ GTR_SETTINGS_WINDOW_SIZE,
+ "(ii)", &w, &h);
+
+ gtk_window_set_default_size (GTK_WINDOW (window), w, h);
if ((state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
- {
- gtr_prefs_manager_get_default_window_size (&w, &h);
- gtk_window_set_default_size (GTK_WINDOW (window), w, h);
- gtk_window_maximize (GTK_WINDOW (window));
- }
+ gtk_window_maximize (GTK_WINDOW (window));
else
- {
- gtr_prefs_manager_get_window_size (&w, &h);
- gtk_window_set_default_size (GTK_WINDOW (window), w, h);
- gtk_window_unmaximize (GTK_WINDOW (window));
- }
+ gtk_window_unmaximize (GTK_WINDOW (window));
+
+ if ((state & GDK_WINDOW_STATE_STICKY ) != 0)
+ gtk_window_stick (GTK_WINDOW (window));
+ else
+ gtk_window_unstick (GTK_WINDOW (window));
g_signal_connect (window, "focus_in_event",
G_CALLBACK (window_focus_in_event), app);
@@ -537,3 +556,11 @@ gtr_application_get_translation_memory (GtrApplication * app)
return G_OBJECT (app->priv->tm);
}
+
+GSettings *
+_gtr_application_get_settings (GtrApplication *app)
+{
+ g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
+
+ return app->priv->settings;
+}
diff --git a/src/gtr-application.h b/src/gtr-application.h
index f4a846c..97372a5 100644
--- a/src/gtr-application.h
+++ b/src/gtr-application.h
@@ -102,5 +102,7 @@ const gchar *_gtr_application_get_last_dir (GtrApplication *app);
void _gtr_application_set_last_dir (GtrApplication *app,
const gchar *last_dir);
+GSettings *_gtr_application_get_settings (GtrApplication *app);
+
G_END_DECLS
#endif /* __APPLICATION_H__ */
diff --git a/src/gtr-header.c b/src/gtr-header.c
index d8f71a5..cd821a2 100644
--- a/src/gtr-header.c
+++ b/src/gtr-header.c
@@ -1,6 +1,6 @@
/*
* (C) 2007 Pablo Sanxiao <psanxiao gmail com>
- * Ignacio Casal Quinteiro <nacho resa gmail com>
+ * Ignacio Casal Quinteiro <icq gnome org>
* 2008 Igalia
*
* gtranslator is free software; you can redistribute it and/or modify
@@ -19,12 +19,12 @@
*
* Authors:
* Pablo Sanxiao <psanxiao gmail com>
- * Ignacio Casal Quinteiro <nacho resa gmail com>
+ * Ignacio Casal Quinteiro <icq gnome org>
*/
#include "gtr-application.h"
#include "gtr-header.h"
-#include "gtr-prefs-manager.h"
+#include "gtr-settings.h"
#include "gtr-profile.h"
#include "gtr-profile-manager.h"
#include "gtr-utils.h"
@@ -42,6 +42,8 @@ G_DEFINE_TYPE (GtrHeader, gtr_header, GTR_TYPE_MSG)
struct _GtrHeaderPrivate
{
+ GSettings *settings;
+
GtrProfileManager *prof_manager;
GtrProfile *profile;
gint nplurals;
@@ -68,11 +70,14 @@ static void
parse_nplurals (GtrHeader * header)
{
gchar *pointer, *plural_forms;
+ gboolean use_profile_values;
plural_forms = gtr_header_get_plural_forms (header);
header->priv->nplurals = -1;
+ use_profile_values = g_settings_get_boolean (header->priv->settings,
+ GTR_SETTINGS_USE_PROFILE_VALUES);
- if (gtr_prefs_manager_get_use_profile_values () || !plural_forms)
+ if (use_profile_values || !plural_forms)
{
const gchar *plural_form = NULL;
GtrProfile *profile;
@@ -146,6 +151,7 @@ gtr_header_init (GtrHeader * header)
header->priv->nplurals = -1;
header->priv->profile = NULL;
+ header->priv->settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
header->priv->prof_manager = gtr_profile_manager_get_default ();
g_signal_connect (header->priv->prof_manager, "profile-removed",
@@ -157,6 +163,12 @@ gtr_header_dispose (GObject * object)
{
GtrHeader *header = GTR_HEADER (object);
+ if (header->priv->settings != NULL)
+ {
+ g_object_unref (header->priv->settings);
+ header->priv->settings = NULL;
+ }
+
if (header->priv->prof_manager != NULL)
{
g_object_unref (header->priv->prof_manager);
@@ -538,13 +550,17 @@ static void
set_profile_values (GtrHeader *header)
{
GtrProfile *active_profile;
+ gboolean use_profile_values;
if (header->priv->profile != NULL)
active_profile = header->priv->profile;
else
active_profile = gtr_profile_manager_get_active_profile (header->priv->prof_manager);
- if (gtr_prefs_manager_get_use_profile_values () && active_profile != NULL)
+ use_profile_values = g_settings_get_boolean (header->priv->settings,
+ GTR_SETTINGS_USE_PROFILE_VALUES);
+
+ if (use_profile_values && active_profile != NULL)
{
gtr_header_set_translator (header,
gtr_profile_get_author_name (active_profile),
@@ -592,6 +608,7 @@ update_comments (GtrHeader *header, const gchar *comments)
gchar *translator;
gchar *email;
gchar *current_year;
+ gboolean use_profile_values;
gint i;
if (header->priv->profile != NULL)
@@ -601,8 +618,11 @@ update_comments (GtrHeader *header, const gchar *comments)
current_year = gtr_utils_get_current_year ();
+ use_profile_values = g_settings_get_boolean (header->priv->settings,
+ GTR_SETTINGS_USE_PROFILE_VALUES);
+
/* Save the previous translator to update the header's comment */
- if (gtr_prefs_manager_get_use_profile_values () && active_profile != NULL)
+ if (use_profile_values && active_profile != NULL)
{
translator = g_strdup (gtr_profile_get_author_name (active_profile));
email = g_strdup (gtr_profile_get_author_email (active_profile));
diff --git a/src/gtr-history-entry.c b/src/gtr-history-entry.c
index e86c11a..0550801 100644
--- a/src/gtr-history-entry.c
+++ b/src/gtr-history-entry.c
@@ -1,6 +1,6 @@
/*
- * history-entry.c
- * This file is part of gtranslator
+ * gtr-history-entry.c
+ * This file is part of gtr
*
* Copyright (C) 2006 - Paolo Borelli
*
@@ -21,7 +21,7 @@
*/
/*
- * Modified by the gedit Team, 2006. See the AUTHORS file for a
+ * Modified by the gtr Team, 2006. See the AUTHORS file for a
* list of people on the gtr Team.
* See the ChangeLog files for a list of changes.
*
@@ -35,7 +35,6 @@
#include <string.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
#include "gtr-history-entry.h"
@@ -61,7 +60,7 @@ struct _GtrHistoryEntryPrivate
GtkEntryCompletion *completion;
- GConfClient *gconf_client;
+ GSettings *settings;
};
G_DEFINE_TYPE (GtrHistoryEntry, gtr_history_entry, GTK_TYPE_COMBO_BOX_ENTRY)
@@ -86,7 +85,7 @@ G_DEFINE_TYPE (GtrHistoryEntry, gtr_history_entry, GTK_TYPE_COMBO_BOX_ENTRY)
gtr_history_entry_set_history_length (entry, g_value_get_uint (value));
break;
default:
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
}
}
@@ -131,10 +130,10 @@ gtr_history_entry_finalize (GObject * object)
g_free (priv->history_id);
- if (priv->gconf_client != NULL)
+ if (priv->settings != NULL)
{
- g_object_unref (G_OBJECT (priv->gconf_client));
- priv->gconf_client = NULL;
+ g_object_unref (G_OBJECT (priv->settings));
+ priv->settings = NULL;
}
G_OBJECT_CLASS (gtr_history_entry_parent_class)->finalize (object);
@@ -187,38 +186,21 @@ get_history_store (GtrHistoryEntry * entry)
return (GtkListStore *) store;
}
-static char *
-get_history_key (GtrHistoryEntry * entry)
-{
- gchar *tmp;
- gchar *key;
-
- /*
- * We store the data under /apps/gnome-settings/
- * like the old GnomeEntry did. Maybe we should
- * consider moving it to the /gtranslator GConf prefix...
- * Or maybe we should just switch away from GConf.
- */
-
- tmp = gconf_escape_key (entry->priv->history_id, -1);
- key = g_strconcat ("/apps/gnome-settings/",
- "gtranslator", "/history-", tmp, NULL);
- g_free (tmp);
-
- return key;
-}
-
-static GSList *
-get_history_list (GtrHistoryEntry * entry)
+static gchar **
+get_history_items (GtrHistoryEntry * entry)
{
GtkListStore *store;
GtkTreeIter iter;
+ GPtrArray *array;
gboolean valid;
- GSList *list = NULL;
+ gint n_children;
store = get_history_store (entry);
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
+ n_children = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL);
+
+ array = g_ptr_array_sized_new (n_children + 1);
while (valid)
{
@@ -226,31 +208,30 @@ get_history_list (GtrHistoryEntry * entry)
gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, 0, &str, -1);
- list = g_slist_prepend (list, str);
+ g_ptr_array_add (array, str);
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
}
- return g_slist_reverse (list);
+ g_ptr_array_add (array, NULL);
+
+ return (gchar **) g_ptr_array_free (array, FALSE);
}
static void
gtr_history_entry_save_history (GtrHistoryEntry * entry)
{
- GSList *gconf_items;
- gchar *key;
+ gchar **items;
g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
- gconf_items = get_history_list (entry);
- key = get_history_key (entry);
+ items = get_history_items (entry);
- gconf_client_set_list (entry->priv->gconf_client,
- key, GCONF_VALUE_STRING, gconf_items, NULL);
+ g_settings_set_strv (entry->priv->settings,
+ entry->priv->history_id,
+ (const gchar * const *) items);
- g_slist_foreach (gconf_items, (GFunc) g_free, NULL);
- g_slist_free (gconf_items);
- g_free (key);
+ g_strfreev (items);
}
static gboolean
@@ -295,7 +276,7 @@ clamp_list_store (GtkListStore * store, guint max)
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path))
{
- while (1)
+ while (TRUE)
{
if (!gtk_list_store_remove (store, &iter))
break;
@@ -356,32 +337,32 @@ gtr_history_entry_append_text (GtrHistoryEntry * entry, const gchar * text)
static void
gtr_history_entry_load_history (GtrHistoryEntry * entry)
{
- GSList *gconf_items, *l;
+ gchar **items;
GtkListStore *store;
GtkTreeIter iter;
- gchar *key;
- guint i;
+ gsize i;
g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
store = get_history_store (entry);
- key = get_history_key (entry);
- gconf_items = gconf_client_get_list (entry->priv->gconf_client,
- key, GCONF_VALUE_STRING, NULL);
+ items = g_settings_get_strv (entry->priv->settings,
+ entry->priv->history_id);
+ i = 0;
gtk_list_store_clear (store);
- for (l = gconf_items, i = 0;
- l != NULL && i < entry->priv->history_length; l = l->next, i++)
+ /* Now the default value is an empty string so we have to take care
+ of it to not add the empty string in the search list */
+ while (items[i] != NULL && *items[i] != '\0' &&
+ i < entry->priv->history_length)
{
gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, 0, l->data, -1);
+ gtk_list_store_set (store, &iter, 0, items[i], -1);
+ i++;
}
- g_slist_foreach (gconf_items, (GFunc) g_free, NULL);
- g_slist_free (gconf_items);
- g_free (key);
+ g_strfreev (items);
}
void
@@ -410,7 +391,8 @@ gtr_history_entry_init (GtrHistoryEntry * entry)
priv->completion = NULL;
- priv->gconf_client = gconf_client_get_default ();
+ priv->settings =
+ g_settings_new ("org.gnome.gtranslator.state.history-entry");
}
void
@@ -584,15 +566,21 @@ gtr_history_entry_set_escape_func (GtrHistoryEntry * entry,
g_return_if_fail (cells->data != NULL && cells->next == NULL);
if (escape_func != NULL)
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
- GTK_CELL_RENDERER (cells->data),
- (GtkCellLayoutDataFunc)
- escape_cell_data_func, escape_func,
- NULL);
+ {
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
+ GTK_CELL_RENDERER (cells->data),
+ (GtkCellLayoutDataFunc)
+ escape_cell_data_func, escape_func,
+ NULL);
+ }
else
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
- GTK_CELL_RENDERER (cells->data),
- NULL, NULL, NULL);
+ {
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
+ GTK_CELL_RENDERER (cells->data),
+ NULL, NULL, NULL);
+ }
g_list_free (cells);
}
+
+/* ex:ts=8:noet: */
diff --git a/src/gtr-history-entry.h b/src/gtr-history-entry.h
index fe2786f..55cf79d 100644
--- a/src/gtr-history-entry.h
+++ b/src/gtr-history-entry.h
@@ -1,6 +1,6 @@
/*
- * history-entry.h
- * This file is part of gtranslator
+ * gtr-history-entry.h
+ * This file is part of gtr
*
* Copyright (C) 2006 - Paolo Borelli
*
@@ -21,7 +21,7 @@
*/
/*
- * Modified by the gedit Team, 2006. See the AUTHORS file for a
+ * Modified by the gtr Team, 2006. See the AUTHORS file for a
* list of people on the gtr Team.
* See the ChangeLog files for a list of changes.
*
@@ -92,3 +92,4 @@ gtr_history_entry_get_type (void)
G_END_DECLS
#endif /* __GTR_HISTORY_ENTRY_H__ */
+/* ex:ts=8:noet: */
diff --git a/src/gtr-po.c b/src/gtr-po.c
index f387e69..1db941f 100644
--- a/src/gtr-po.c
+++ b/src/gtr-po.c
@@ -37,7 +37,6 @@
#include "gtr-po.h"
#include "gtr-msg.h"
#include "gtr-enum-types.h"
-#include "gtr-prefs-manager.h"
#include "gtr-profile.h"
#include "gtr-utils.h"
diff --git a/src/gtr-settings.c b/src/gtr-settings.c
new file mode 100644
index 0000000..c732a31
--- /dev/null
+++ b/src/gtr-settings.c
@@ -0,0 +1,461 @@
+/*
+ * gtr-settings.c
+ * This file is part of gtranslator
+ *
+ * Copyright (C) 2002-2005 - Paolo Maggi
+ * 2009 - Ignacio Casal Quinteiro
+ *
+ * gtranslator is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gtranslator is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gtr; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#include <string.h>
+#include <gdl/gdl.h>
+
+#include "gtr-settings.h"
+#include "gtr-application.h"
+#include "gtr-debug.h"
+#include "gtr-view.h"
+#include "gtr-window.h"
+#include "gtr-dirs.h"
+#include "gtr-utils.h"
+
+#define GTR_SETTINGS_SYSTEM_FONT "monospace-font-name"
+
+#define GTR_SETTINGS_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GTR_TYPE_SETTINGS, GtrSettingsPrivate))
+
+struct _GtrSettingsPrivate
+{
+ GSettings *interface;
+ GSettings *editor;
+ GSettings *ui;
+ GSettings *files;
+
+ gchar *old_scheme;
+};
+
+G_DEFINE_TYPE (GtrSettings, gtr_settings, G_TYPE_SETTINGS)
+
+static void
+gtr_settings_finalize (GObject * object)
+{
+ GtrSettings *gs = GTR_SETTINGS (object);
+
+ g_free (gs->priv->old_scheme);
+
+ G_OBJECT_CLASS (gtr_settings_parent_class)->finalize (object);
+}
+
+static void
+gtr_settings_dispose (GObject * object)
+{
+ GtrSettings *gs = GTR_SETTINGS (object);
+
+ if (gs->priv->interface != NULL)
+ {
+ g_object_unref (gs->priv->interface);
+ gs->priv->interface = NULL;
+ }
+
+ if (gs->priv->editor != NULL)
+ {
+ g_object_unref (gs->priv->editor);
+ gs->priv->editor = NULL;
+ }
+
+ if (gs->priv->ui != NULL)
+ {
+ g_object_unref (gs->priv->ui);
+ gs->priv->ui = NULL;
+ }
+
+ G_OBJECT_CLASS (gtr_settings_parent_class)->dispose (object);
+}
+
+static void
+set_font (GtrSettings * gs, const gchar * font)
+{
+ GList *views, *l;
+
+ views = gtr_application_get_views (GTR_APP, TRUE, TRUE);
+
+ for (l = views; l != NULL; l = g_list_next (l))
+ {
+ /* Note: we use def=FALSE to avoid GtrView to query gconf */
+ gtr_view_set_font (GTR_VIEW (l->data), FALSE, font);
+ }
+
+ g_list_free (views);
+}
+
+static void
+on_system_font_changed (GSettings * settings,
+ const gchar * key, GtrSettings * gs)
+{
+
+ gboolean use_custom_font;
+ gchar *font;
+
+ use_custom_font = g_settings_get_boolean (gs->priv->editor,
+ GTR_SETTINGS_USE_CUSTOM_FONT);
+ if (!use_custom_font)
+ return;
+
+ font = g_settings_get_string (settings, key);
+
+ set_font (gs, font);
+
+ g_free (font);
+}
+
+static void
+on_use_custom_font_changed (GSettings * settings,
+ const gchar * key, GtrSettings * gs)
+{
+ gboolean def;
+ gchar *font;
+
+ def = g_settings_get_boolean (settings, key);
+
+ if (!def)
+ {
+ font = g_settings_get_string (gs->priv->interface,
+ GTR_SETTINGS_SYSTEM_FONT);
+ }
+ else
+ {
+ font = g_settings_get_string (gs->priv->editor,
+ GTR_SETTINGS_EDITOR_FONT);
+ }
+
+ set_font (gs, font);
+
+ g_free (font);
+}
+
+static void
+on_editor_font_changed (GSettings * settings,
+ const gchar * key, GtrSettings * gs)
+{
+ gboolean use_custom_font;
+ gchar *font;
+
+ use_custom_font = g_settings_get_boolean (gs->priv->editor,
+ GTR_SETTINGS_USE_CUSTOM_FONT);
+ if (!use_custom_font)
+ return;
+
+ font = g_settings_get_string (settings, key);
+
+ set_font (gs, font);
+
+ g_free (font);
+}
+
+static void
+on_auto_save_changed (GSettings * settings,
+ const gchar * key, GtrSettings * gs)
+{
+ const GList *windows, *l;
+ gboolean auto_save;
+
+ auto_save = g_settings_get_boolean (settings, key);
+
+ windows = gtr_application_get_windows (GTR_APP);
+
+ for (l = windows; l != NULL; l = g_list_next (l))
+ {
+ GList *tabs, *t;
+
+ tabs = gtr_window_get_all_tabs (GTR_WINDOW (l->data));
+
+ for (t = tabs; t != NULL; t = g_list_next (t))
+ {
+ gtr_tab_set_autosave_enabled (GTR_TAB (t), auto_save);
+ }
+
+ g_list_free (tabs);
+ }
+}
+
+static void
+on_auto_save_interval_changed (GSettings * settings,
+ const gchar * key, GtrSettings * gs)
+{
+ const GList *windows, *l;
+ gint auto_save_interval;
+
+ g_settings_get (settings, key, "u", &auto_save_interval);
+
+ windows = gtr_application_get_windows (GTR_APP);
+
+ for (l = windows; l != NULL; l = g_list_next (l))
+ {
+ GList *tabs, *t;
+
+ tabs = gtr_window_get_all_tabs (GTR_WINDOW (l->data));
+
+ for (t = tabs; t != NULL; t = g_list_next (t))
+ {
+ gtr_tab_set_autosave_interval (GTR_TAB (t->data), auto_save_interval);
+ }
+
+ g_list_free (tabs);
+ }
+}
+
+static void
+on_syntax_highlighting_changed (GSettings * settings,
+ const gchar * key, GtrSettings * gs)
+{
+ GList *views, *l;
+ gboolean enable;
+
+ enable = g_settings_get_boolean (settings, key);
+
+ views = gtr_application_get_views (GTR_APP, TRUE, TRUE);
+
+ for (l = views; l != NULL; l = g_list_next (l))
+ {
+ GtkSourceBuffer *buf;
+
+ buf = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (l->data)));
+ gtk_source_buffer_set_highlight_syntax (buf, enable);
+ }
+
+ g_list_free (views);
+}
+
+static void
+on_visible_whitespace_changed (GSettings * settings,
+ const gchar * key, GtrSettings * gs)
+{
+ GList *views, *l;
+ gboolean enable;
+
+ enable = g_settings_get_boolean (settings, key);
+
+ views = gtr_application_get_views (GTR_APP, TRUE, TRUE);
+
+ for (l = views; l != NULL; l = g_list_next (l))
+ {
+ gtr_view_enable_visible_whitespace (GTR_VIEW (l->data), enable);
+ }
+
+ g_list_free (views);
+}
+
+static void
+on_spellcheck_changed (GSettings * settings,
+ const gchar * key, GtrSettings * gs)
+{
+ GList *views, *l;
+ gboolean enable;
+
+ enable = g_settings_get_boolean (settings, key);
+
+ views = gtr_application_get_views (GTR_APP, TRUE, TRUE);
+
+ for (l = views; l != NULL; l = g_list_next (l))
+ {
+ gtr_view_enable_spellcheck (GTR_VIEW (l->data), enable);
+ }
+
+ g_list_free (views);
+}
+
+static void
+on_pane_switcher_style_changed (GSettings * settings, const gchar * key,
+ GtrSettings * gs)
+{
+ const GList *windows, *l;
+ GdlSwitcherStyle style;
+
+ style = g_settings_get_enum (settings, key);
+
+ windows = gtr_application_get_windows (GTR_APP);
+
+ for (l = windows; l != NULL; l = g_list_next (l))
+ {
+ GdlDockLayout *layout_manager;
+
+ layout_manager = GDL_DOCK_LAYOUT (_gtr_window_get_layout_manager (GTR_WINDOW (l->data)));
+
+ g_object_set (G_OBJECT (layout_manager->master),
+ "switcher-style", style, NULL);
+ }
+}
+
+static void
+on_scheme_changed (GSettings * settings, const gchar * key, GtrSettings * gs)
+{
+ GList *views, *l;
+
+ views = gtr_application_get_views (GTR_APP, TRUE, TRUE);
+
+ for (l = views; l != NULL; l = g_list_next (l))
+ {
+ gtr_view_reload_scheme_color (GTR_VIEW (l->data));
+ }
+
+ g_list_free (views);
+}
+
+static void
+gtr_settings_init (GtrSettings * gs)
+{
+ gs->priv = GTR_SETTINGS_GET_PRIVATE (gs);
+
+ gs->priv->old_scheme = NULL;
+}
+
+static void
+initialize (GtrSettings * gs)
+{
+ GSettings *prefs;
+
+ prefs = g_settings_get_child (G_SETTINGS (gs), "preferences");
+ gs->priv->files = g_settings_get_child (prefs, "files");
+ gs->priv->editor = g_settings_get_child (prefs, "editor");
+ gs->priv->ui = g_settings_get_child (prefs, "ui");
+ g_object_unref (prefs);
+
+ /* Load settings */
+ gs->priv->interface = g_settings_new ("org.gnome.desktop.interface");
+
+ g_signal_connect (gs->priv->interface,
+ "changed::monospace-font-name",
+ G_CALLBACK (on_system_font_changed), gs);
+
+ /* editor changes */
+ g_signal_connect (gs->priv->files,
+ "changed::autosave",
+ G_CALLBACK (on_auto_save_changed), gs);
+ g_signal_connect (gs->priv->files,
+ "changed::autosave-interval",
+ G_CALLBACK (on_auto_save_interval_changed), gs);
+ g_signal_connect (gs->priv->editor,
+ "changed::use-custom-font",
+ G_CALLBACK (on_use_custom_font_changed), gs);
+ g_signal_connect (gs->priv->editor,
+ "changed::editor-font",
+ G_CALLBACK (on_editor_font_changed), gs);
+ g_signal_connect (gs->priv->editor,
+ "changed::highlight-syntax",
+ G_CALLBACK (on_syntax_highlighting_changed), gs);
+ g_signal_connect (gs->priv->editor,
+ "changed::visible-whitespace",
+ G_CALLBACK (on_visible_whitespace_changed), gs);
+ g_signal_connect (gs->priv->editor,
+ "changed::spellcheck",
+ G_CALLBACK (on_spellcheck_changed), gs);
+ g_signal_connect (gs->priv->ui,
+ "changed::pane-switcher-style",
+ G_CALLBACK (on_pane_switcher_style_changed), gs);
+ g_signal_connect (gs->priv->ui,
+ "changed::color-scheme",
+ G_CALLBACK (on_scheme_changed), gs);
+}
+
+static void
+gtr_settings_class_init (GtrSettingsClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gtr_settings_finalize;
+ object_class->dispose = gtr_settings_dispose;
+
+ g_type_class_add_private (object_class, sizeof (GtrSettingsPrivate));
+}
+
+GSettings *
+gtr_settings_new ()
+{
+ GtrSettings *settings;
+
+ settings = g_object_new (GTR_TYPE_SETTINGS,
+ "schema", "org.gnome.gtranslator", NULL);
+
+ initialize (settings);
+
+ return G_SETTINGS (settings);
+}
+
+gchar *
+gtr_settings_get_system_font (GtrSettings * gs)
+{
+ gchar *system_font;
+
+ g_return_val_if_fail (GTR_IS_SETTINGS (gs), NULL);
+
+ system_font = g_settings_get_string (gs->priv->interface,
+ "monospace-font-name");
+
+ return system_font;
+}
+
+GSList *
+gtr_settings_get_list (GSettings * settings, const gchar * key)
+{
+ GSList *list = NULL;
+ gchar **values;
+ gsize i;
+
+ g_return_val_if_fail (G_IS_SETTINGS (settings), NULL);
+ g_return_val_if_fail (key != NULL, NULL);
+
+ values = g_settings_get_strv (settings, key);
+ i = 0;
+
+ while (values[i] != NULL)
+ {
+ list = g_slist_prepend (list, values[i]);
+ i++;
+ }
+
+ g_free (values);
+
+ return g_slist_reverse (list);
+}
+
+void
+gtr_settings_set_list (GSettings * settings,
+ const gchar * key, const GSList * list)
+{
+ gchar **values = NULL;
+ const GSList *l;
+
+ g_return_if_fail (G_IS_SETTINGS (settings));
+ g_return_if_fail (key != NULL);
+
+ if (list != NULL)
+ {
+ gint i, len;
+
+ len = g_slist_length ((GSList *) list);
+ values = g_new (gchar *, len + 1);
+
+ for (l = list, i = 0; l != NULL; l = g_slist_next (l), i++)
+ {
+ values[i] = l->data;
+ }
+ values[i] = NULL;
+ }
+
+ g_settings_set_strv (settings, key, (const gchar * const *) values);
+ g_free (values);
+}
+
+/* ex:ts=8:noet: */
diff --git a/src/gtr-settings.h b/src/gtr-settings.h
new file mode 100644
index 0000000..d2b72a7
--- /dev/null
+++ b/src/gtr-settings.h
@@ -0,0 +1,105 @@
+/*
+ * gtr-settings.h
+ * This file is part of gtranslator
+ *
+ * Copyright (C) 2009 - Ignacio Casal Quinteiro
+ * 2002 - Paolo Maggi
+ *
+ * gtr is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gtr is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gtr; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+
+#ifndef __GTR_SETTINGS_H__
+#define __GTR_SETTINGS_H__
+
+#include <glib-object.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define GTR_TYPE_SETTINGS (gtr_settings_get_type ())
+#define GTR_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_TYPE_SETTINGS, GtrSettings))
+#define GTR_SETTINGS_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_TYPE_SETTINGS, GtrSettings const))
+#define GTR_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTR_TYPE_SETTINGS, GtrSettingsClass))
+#define GTR_IS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTR_TYPE_SETTINGS))
+#define GTR_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_SETTINGS))
+#define GTR_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTR_TYPE_SETTINGS, GtrSettingsClass))
+
+typedef struct _GtrSettings GtrSettings;
+typedef struct _GtrSettingsClass GtrSettingsClass;
+typedef struct _GtrSettingsPrivate GtrSettingsPrivate;
+
+struct _GtrSettings
+{
+ GSettings parent;
+
+ GtrSettingsPrivate *priv;
+};
+
+struct _GtrSettingsClass
+{
+ GSettingsClass parent_class;
+};
+
+GType gtr_settings_get_type (void) G_GNUC_CONST;
+
+GSettings *gtr_settings_new (void);
+
+gchar *gtr_settings_get_system_font (GtrSettings *gs);
+
+/* Utility functions */
+GSList *gtr_settings_get_list (GSettings *settings,
+ const gchar *key);
+
+void gtr_settings_set_list (GSettings *settings,
+ const gchar *key,
+ const GSList *list);
+
+/* key constants: IMPORTANT: keep them in the same order as the schema */
+#define GTR_SETTINGS_WARN_IF_CONTAINS_FUZZY "warn-if-contains-fuzzy"
+#define GTR_SETTINGS_DELETE_COMPILED "delete-compiled"
+#define GTR_SETTINGS_AUTO_SAVE "auto-save"
+#define GTR_SETTINGS_AUTO_SAVE_INTERVAL "auto-save-interval"
+#define GTR_SETTINGS_CREATE_BACKUP "create-backup"
+#define GTR_SETTINGS_USE_PROFILE_VALUES "use-profile-values"
+#define GTR_SETTINGS_HIGHLIGHT_SYNTAX "highlight-syntax"
+#define GTR_SETTINGS_VISIBLE_WHITESPACE "visible-whitespace"
+#define GTR_SETTINGS_USE_CUSTOM_FONT "use-custom-font"
+#define GTR_SETTINGS_EDITOR_FONT "editor-font"
+#define GTR_SETTINGS_UNMARK_FUZZY_WHEN_CHANGED "unmark-fuzzy-when-changed"
+#define GTR_SETTINGS_SPELLCHECK "spellcheck"
+#define GTR_SETTINGS_PO_DIRECTORY "po-directory"
+#define GTR_SETTINGS_RESTRICT_TO_FILENAME "restrict-to-filename"
+#define GTR_SETTINGS_FILENAME_RESTRICTION "filename-restriction"
+#define GTR_SETTINGS_MAX_MISSING_WORDS "max-missing-words"
+#define GTR_SETTINGS_MAX_LENGTH_DIFF "max-length-diff"
+#define GTR_SETTINGS_PANEL_SWITCHER_STYLE "panel-switcher-style"
+#define GTR_SETTINGS_COLOR_SCHEME "color-scheme"
+#define GTR_SETTINGS_SORT_ORDER "sort-order"
+#define GTR_SETTINGS_ACTIVE_PLUGINS "active-plugins"
+
+/* window state keys */
+#define GTR_SETTINGS_WINDOW_STATE "state"
+#define GTR_SETTINGS_WINDOW_SIZE "size"
+#define GTR_SETTINGS_CONTENT_PANEL_SIZE "content-panel-size"
+#define GTR_SETTINGS_CONTEXT_PANEL_SIZE "context-panel-size"
+
+G_END_DECLS
+
+#endif /* __GTR_SETTINGS_H__ */
+
+/* ex:ts=8:noet: */
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index fd898e5..489113e 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -39,8 +39,7 @@
#include "gtr-msg.h"
#include "gtr-tab.h"
#include "gtr-po.h"
-#include "gtr-prefs-manager.h"
-#include "gtr-prefs-manager-app.h"
+#include "gtr-settings.h"
#include "gtr-view.h"
#include "gtr-translation-memory.h"
#include "gtr-translation-memory-ui.h"
@@ -64,6 +63,10 @@ G_DEFINE_TYPE (GtrTab, gtr_tab, GTK_TYPE_VBOX)
struct _GtrTabPrivate
{
+ GSettings *files_settings;
+ GSettings *editor_settings;
+ GSettings *state_settings;
+
GtrPo *po;
GtkWidget *table_pane;
@@ -232,6 +235,7 @@ gtr_message_translation_update (GtkTextBuffer * textbuffer, GtrTab * tab)
GtrMsg *msg;
const gchar *check;
gchar *translation;
+ gboolean unmark_fuzzy;
gint i;
/* Work out which message this is associated with */
@@ -241,9 +245,10 @@ gtr_message_translation_update (GtkTextBuffer * textbuffer, GtrTab * tab)
msg_aux = gtr_po_get_current_message (tab->priv->po);
msg = msg_aux->data;
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tab->priv->trans_msgstr[0]));
+ unmark_fuzzy = g_settings_get_boolean (tab->priv->editor_settings,
+ GTR_SETTINGS_UNMARK_FUZZY_WHEN_CHANGED);
- if (gtr_msg_is_fuzzy (msg)
- && gtr_prefs_manager_get_unmark_fuzzy_when_changed ())
+ if (gtr_msg_is_fuzzy (msg) && unmark_fuzzy)
gtr_msg_set_fuzzy (msg, FALSE);
if (textbuffer == buf)
@@ -302,7 +307,8 @@ gtr_message_translation_update (GtkTextBuffer * textbuffer, GtrTab * tab)
static GtkWidget *
gtr_tab_append_msgstr_page (const gchar * tab_label,
- GtkWidget * box, gboolean spellcheck)
+ GtkWidget * box, gboolean spellcheck,
+ GtrTab *tab)
{
GtkWidget *scroll;
GtkWidget *label;
@@ -316,7 +322,9 @@ gtr_tab_append_msgstr_page (const gchar * tab_label,
widget = gtr_view_new ();
gtk_widget_show (widget);
- if (spellcheck && gtr_prefs_manager_get_spellcheck ())
+ if (spellcheck &&
+ g_settings_get_boolean (tab->priv->editor_settings,
+ GTR_SETTINGS_SPELLCHECK))
gtr_view_enable_spellcheck (GTR_VIEW (widget), spellcheck);
gtk_container_add (GTK_CONTAINER (scroll), widget);
@@ -494,21 +502,6 @@ update_status (GtrTab * tab, GtrMsg * msg, gpointer useless)
}
static void
-context_pane_position_changed (GObject * tab_gobject,
- GParamSpec * arg1, GtrTab * tab)
-{
- gtr_prefs_manager_set_context_pane_pos (gtk_paned_get_position (GTK_PANED (tab_gobject)));
-}
-
-static void
-content_pane_position_changed (GObject * tab_gobject,
- GParamSpec * arg1, GtrTab * tab)
-{
- gtr_prefs_manager_set_content_pane_pos (gtk_paned_get_position
- (GTK_PANED (tab_gobject)));
-}
-
-static void
gtr_tab_add_msgstr_tabs (GtrTab * tab)
{
GtrHeader *header;
@@ -527,7 +520,8 @@ gtr_tab_add_msgstr_tabs (GtrTab * tab)
label = g_strdup_printf (_("Plural %d"), i);
priv->trans_msgstr[i] = gtr_tab_append_msgstr_page (label,
priv->trans_notebook,
- TRUE);
+ TRUE,
+ tab);
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->trans_msgstr[i]));
g_signal_connect (buf, "end-user-action",
G_CALLBACK (gtr_message_translation_update), tab);
@@ -567,11 +561,11 @@ gtr_tab_draw (GtrTab * tab)
/* Content pane; this is where the message table and message area go */
priv->content_pane = gtk_vpaned_new ();
- gtk_paned_set_position (GTK_PANED (priv->content_pane),
- gtr_prefs_manager_get_content_pane_pos ());
- g_signal_connect (priv->content_pane,
- "notify::position",
- G_CALLBACK (content_pane_position_changed), tab);
+ g_settings_bind (tab->priv->state_settings,
+ GTR_SETTINGS_CONTENT_PANEL_SIZE,
+ priv->content_pane,
+ "position",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
gtk_widget_show (priv->content_pane);
/* Message table */
@@ -664,10 +658,11 @@ gtr_tab_draw (GtrTab * tab)
/* Context pane */
priv->context_pane = gtk_hpaned_new ();
- gtk_paned_set_position (GTK_PANED (priv->context_pane),
- gtr_prefs_manager_get_context_pane_pos ());
- g_signal_connect (priv->context_pane, "notify::position",
- G_CALLBACK (context_pane_position_changed), tab);
+ g_settings_bind (tab->priv->state_settings,
+ GTR_SETTINGS_CONTEXT_PANEL_SIZE,
+ priv->context_pane,
+ "position",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
gtk_widget_show (priv->context_pane);
gtk_paned_pack1 (GTK_PANED (priv->context_pane), priv->content_pane,
@@ -703,15 +698,21 @@ gtr_tab_init (GtrTab * tab)
{
tab->priv = GTR_TAB_GET_PRIVATE (tab);
+ tab->priv->files_settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
+ tab->priv->editor_settings = g_settings_new ("org.gnome.gtranslator.preferences.editor");
+ tab->priv->state_settings = g_settings_new ("org.gnome.gtranslator.state.window");
+
g_signal_connect (tab, "message-changed", G_CALLBACK (update_status), NULL);
gtr_tab_draw (tab);
/* Manage auto save data */
- tab->priv->autosave = gtr_prefs_manager_get_autosave ();
+ tab->priv->autosave = g_settings_get_boolean (tab->priv->files_settings,
+ GTR_SETTINGS_AUTO_SAVE);
tab->priv->autosave = (tab->priv->autosave != FALSE);
- tab->priv->autosave_interval = gtr_prefs_manager_get_autosave_interval ();
+ tab->priv->autosave_interval = g_settings_get_int (tab->priv->files_settings,
+ GTR_SETTINGS_AUTO_SAVE_INTERVAL);
if (tab->priv->autosave_interval <= 0)
tab->priv->autosave_interval = 1;
}
@@ -721,9 +722,6 @@ gtr_tab_finalize (GObject * object)
{
GtrTab *tab = GTR_TAB (object);
- if (tab->priv->po)
- g_object_unref (tab->priv->po);
-
if (tab->priv->timer != NULL)
g_timer_destroy (tab->priv->timer);
@@ -734,6 +732,38 @@ gtr_tab_finalize (GObject * object)
}
static void
+gtr_tab_dispose (GObject * object)
+{
+ GtrTab *tab = GTR_TAB (object);
+
+ if (tab->priv->po != NULL)
+ {
+ g_object_unref (tab->priv->po);
+ tab->priv->po = NULL;
+ }
+
+ if (tab->priv->files_settings != NULL)
+ {
+ g_object_unref (tab->priv->files_settings);
+ tab->priv->files_settings = NULL;
+ }
+
+ if (tab->priv->editor_settings != NULL)
+ {
+ g_object_unref (tab->priv->editor_settings);
+ tab->priv->editor_settings = NULL;
+ }
+
+ if (tab->priv->state_settings != NULL)
+ {
+ g_object_unref (tab->priv->state_settings);
+ tab->priv->state_settings = NULL;
+ }
+
+ G_OBJECT_CLASS (gtr_tab_parent_class)->dispose (object);
+}
+
+static void
gtr_tab_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
@@ -781,6 +811,7 @@ gtr_tab_class_init (GtrTabClass * klass)
g_type_class_add_private (klass, sizeof (GtrTabPrivate));
object_class->finalize = gtr_tab_finalize;
+ object_class->dispose = gtr_tab_dispose;
object_class->set_property = gtr_tab_set_property;
object_class->get_property = gtr_tab_get_property;
klass->message_edition_finished = gtr_tab_edition_finished;
diff --git a/src/gtr-view.c b/src/gtr-view.c
index dadca33..6ad01ae 100644
--- a/src/gtr-view.c
+++ b/src/gtr-view.c
@@ -28,9 +28,10 @@
#include <string.h>
#include "gtr-dirs.h"
-#include "gtr-prefs-manager.h"
+#include "gtr-settings.h"
#include "gtr-utils.h"
#include "gtr-view.h"
+#include "gtr-application.h"
#include <glib.h>
#include <glib/gi18n.h>
@@ -55,6 +56,9 @@ G_DEFINE_TYPE (GtrView, gtr_view, GTK_TYPE_SOURCE_VIEW)
struct _GtrViewPrivate
{
+ GSettings *editor_settings;
+ GSettings *ui_settings;
+
GtkSourceBuffer *buffer;
guint search_flags;
@@ -98,10 +102,14 @@ gtr_view_init (GtrView * view)
gchar **langs;
const gchar *const *temp;
gchar *datadir;
+ GtrViewPrivate *priv;
view->priv = GTR_VIEW_GET_PRIVATE (view);
- GtrViewPrivate *priv = view->priv;
+ priv = view->priv;
+
+ priv->editor_settings = g_settings_new ("org.gnome.gtranslator.preferences.editor");
+ priv->ui_settings = g_settings_new ("org.gnome.gtranslator.preferences.ui");
lm = gtk_source_language_manager_new ();
dirs = g_ptr_array_new ();
@@ -111,7 +119,6 @@ gtr_view_init (GtrView * view)
g_ptr_array_add (dirs, g_strdup (*temp));
datadir = gtr_dirs_get_gtr_data_dir ();
- /* FIXME: Where pkgdatadir must be free */
g_ptr_array_add (dirs, datadir);
g_ptr_array_add (dirs, NULL);
langs = (gchar **) g_ptr_array_free (dirs, FALSE);
@@ -126,24 +133,23 @@ gtr_view_init (GtrView * view)
GTK_TEXT_BUFFER (priv->buffer));
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
- //Set syntax highlight according to preferences
+ /* Set syntax highlight according to preferences */
gtk_source_buffer_set_highlight_syntax (priv->buffer,
- gtr_prefs_manager_get_highlight_syntax
- ());
-
- //Set dot char according to preferences
+ g_settings_get_boolean (priv->editor_settings,
+ GTR_SETTINGS_HIGHLIGHT_SYNTAX));
- if (gtr_prefs_manager_get_visible_whitespace ())
- gtr_view_enable_visible_whitespace (view, TRUE);
+ /* Set dot char according to preferences */
+ gtr_view_enable_visible_whitespace (view,
+ g_settings_get_boolean (priv->editor_settings,
+ GTR_SETTINGS_VISIBLE_WHITESPACE));
- /*
- * Set fonts according to preferences
- */
- if (gtr_prefs_manager_get_use_custom_font ())
+ /* Set fonts according to preferences */
+ if (g_settings_get_boolean (priv->editor_settings, GTR_SETTINGS_USE_CUSTOM_FONT))
{
gchar *editor_font;
- editor_font = g_strdup (gtr_prefs_manager_get_editor_font ());
+ editor_font = g_settings_get_string (priv->editor_settings,
+ GTR_SETTINGS_EDITOR_FONT);
gtr_view_set_font (view, FALSE, editor_font);
@@ -154,16 +160,28 @@ gtr_view_init (GtrView * view)
gtr_view_set_font (view, TRUE, NULL);
}
- /*
- * Set scheme color according to preferences
- */
+ /* Set scheme color according to preferences */
gtr_view_reload_scheme_color (view);
}
static void
-gtr_view_finalize (GObject * object)
+gtr_view_dispose (GObject * object)
{
- G_OBJECT_CLASS (gtr_view_parent_class)->finalize (object);
+ GtrView *view = GTR_VIEW (object);
+
+ if (view->priv->editor_settings)
+ {
+ g_object_unref (view->priv->editor_settings);
+ view->priv->editor_settings = NULL;
+ }
+
+ if (view->priv->ui_settings)
+ {
+ g_object_unref (view->priv->ui_settings);
+ view->priv->ui_settings = NULL;
+ }
+
+ G_OBJECT_CLASS (gtr_view_parent_class)->dispose (object);
}
static void
@@ -173,7 +191,7 @@ gtr_view_class_init (GtrViewClass * klass)
g_type_class_add_private (klass, sizeof (GtrViewPrivate));
- object_class->finalize = gtr_view_finalize;
+ object_class->dispose = gtr_view_dispose;
}
/**
@@ -382,11 +400,21 @@ gtr_view_set_font (GtrView * view, gboolean def, const gchar * font_name)
g_return_if_fail (GTR_IS_VIEW (view));
if (def)
- font_name = g_strdup ("Sans 10");
+ {
+ GSettings *gtr_settings;
+ gchar *font;
+
+ gtr_settings = _gtr_application_get_settings (GTR_APP);
+ font = gtr_settings_get_system_font (GTR_SETTINGS (gtr_settings));
- g_return_if_fail (font_name != NULL);
+ font_desc = pango_font_description_from_string (font);
+ g_free (font);
+ }
+ else
+ {
+ font_desc = pango_font_description_from_string (font_name);
+ }
- font_desc = pango_font_description_from_string (font_name);
g_return_if_fail (font_desc != NULL);
gtk_widget_modify_font (GTK_WIDGET (view), font_desc);
@@ -797,13 +825,15 @@ gtr_view_reload_scheme_color (GtrView * view)
GtkSourceBuffer *buf;
GtkSourceStyleScheme *scheme;
GtkSourceStyleSchemeManager *manager;
- const gchar *scheme_id;
+ gchar *scheme_id;
buf = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
manager = gtk_source_style_scheme_manager_get_default ();
- scheme_id = gtr_prefs_manager_get_color_scheme ();
+ scheme_id = g_settings_get_string (view->priv->ui_settings,
+ GTR_SETTINGS_COLOR_SCHEME);
scheme = gtk_source_style_scheme_manager_get_scheme (manager, scheme_id);
+ g_free (scheme_id);
gtk_source_buffer_set_style_scheme (buf, scheme);
}
diff --git a/src/gtr-window.c b/src/gtr-window.c
index 4ef6c81..5d3974b 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -33,7 +33,7 @@
#include "gtr-tab.h"
#include "gtr-plugins-engine.h"
#include "gtr-po.h"
-#include "gtr-prefs-manager-app.h"
+#include "gtr-settings.h"
#include "gtr-statusbar.h"
#include "gtr-utils.h"
#include "gtr-window.h"
@@ -78,6 +78,9 @@ G_DEFINE_TYPE (GtrWindow, gtr_window, GTK_TYPE_WINDOW)
struct _GtrWindowPrivate
{
+ GSettings *ui_settings;
+ GSettings *state_settings;
+
GtkWidget *main_box;
GtkWidget *menubar;
@@ -1738,7 +1741,9 @@ gtr_window_draw (GtrWindow * window)
priv->layout_manager = gdl_dock_layout_new (GDL_DOCK (priv->dock));
g_object_set (priv->layout_manager->master,
"switcher-style",
- gtr_prefs_manager_get_pane_switcher_style (), NULL);
+ g_settings_get_enum (priv->ui_settings,
+ GTR_SETTINGS_PANEL_SWITCHER_STYLE),
+ NULL);
g_signal_connect (priv->layout_manager,
"notify::dirty",
G_CALLBACK (on_layout_dirty_notify), window);
@@ -1774,6 +1779,9 @@ gtr_window_init (GtrWindow * window)
window->priv = GTR_WINDOW_GET_PRIVATE (window);
+ window->priv->ui_settings = g_settings_new ("org.gnome.gtranslator.preferences.ui");
+ window->priv->state_settings = g_settings_new ("org.gnome.gtranslator.state.window");
+
window->priv->destroy_has_run = FALSE;
/* Profile manager */
@@ -1852,6 +1860,18 @@ gtr_window_dispose (GObject * object)
DEBUG_PRINT ("window dispose");
+ if (priv->ui_settings)
+ {
+ g_object_unref (priv->ui_settings);
+ priv->ui_settings = NULL;
+ }
+
+ if (priv->state_settings)
+ {
+ g_object_unref (priv->state_settings);
+ priv->state_settings = NULL;
+ }
+
if (priv->ui_manager)
{
g_object_unref (priv->ui_manager);
@@ -1889,12 +1909,10 @@ save_panes_state (GtrWindow * window)
gchar *filename;
gchar *config_folder;
- if (gtr_prefs_manager_window_size_can_set ())
- gtr_prefs_manager_set_window_size (window->priv->width,
- window->priv->height);
-
- if (gtr_prefs_manager_window_state_can_set ())
- gtr_prefs_manager_set_window_state (window->priv->window_state);
+ g_settings_set (window->priv->state_settings, GTR_SETTINGS_WINDOW_SIZE, "(ii)",
+ window->priv->width, window->priv->height);
+ g_settings_set_int (window->priv->state_settings, GTR_SETTINGS_WINDOW_STATE,
+ window->priv->window_state);
config_folder = gtr_dirs_get_user_config_dir ();
filename = g_build_filename (config_folder, "gtr-layout.xml", NULL);
diff --git a/src/main.c b/src/main.c
index aada3d8..920f2c2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3,7 +3,7 @@
* Ross Golder <ross golder org>
* Gediminas Paulauskas <menesis kabalak net>
* Peeter Vois <peeter kabalak net>
- * Ignacio Casal <nacho resa gmail com>
+ * Ignacio Casal Quinteiro <nacho resa gmail com>
*
* gtranslator is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,7 +27,6 @@
#include "gtr-actions.h"
#include "gtr-application.h"
-#include "gtr-prefs-manager-app.h"
#include "gtr-plugins-engine.h"
#include "gtr-utils.h"
#include "gtr-dirs.h"
@@ -38,8 +37,6 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
-#include <gconf/gconf.h>
-
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
@@ -248,18 +245,6 @@ main (gint argc, gchar * argv[])
setup_path ();
#endif
- /* Initialize the GConf library. */
- if (!(gconf_init (argc, argv, &error)))
- {
- if (error)
- {
- g_warning (_("Error during GConf initialization: %s."),
- error->message);
- }
-
- g_clear_error (&error);
- }
-
gtk_init (&argc, &argv);
if (!g_option_context_parse (context, &argc, &argv, &error))
@@ -272,9 +257,6 @@ main (gint argc, gchar * argv[])
g_option_context_free (context);
- /* Init preferences manager */
- gtr_prefs_manager_app_init ();
-
app = _gtr_application_new ();
if (unique_app_is_running (UNIQUE_APP (app)))
@@ -324,7 +306,6 @@ main (gint argc, gchar * argv[])
gtk_main ();
g_object_unref (engine);
- gtr_prefs_manager_app_shutdown ();
g_object_unref (app);
return 0;
diff --git a/src/plugin-system/gtr-plugins-engine.c b/src/plugin-system/gtr-plugins-engine.c
index 86f2188..f89a7ad 100644
--- a/src/plugin-system/gtr-plugins-engine.c
+++ b/src/plugin-system/gtr-plugins-engine.c
@@ -35,7 +35,6 @@
#include <string.h>
#include <glib/gi18n.h>
-#include <gconf/gconf-client.h>
#include "gtr-plugins-engine.h"
#include "gtr-plugin-info-priv.h"
@@ -43,6 +42,7 @@
#include "gtr-debug.h"
#include "gtr-application.h"
#include "gtr-utils.h"
+#include "gtr-settings.h"
#include "gtr-module.h"
#ifdef ENABLE_PYTHON
@@ -51,9 +51,6 @@
#define USER_GTR_PLUGINS_LOCATION ".config/gtranslator/plugins/"
-#define GTR_PLUGINS_ENGINE_BASE_KEY "/apps/gtranslator/plugins"
-#define GTR_PLUGINS_ENGINE_KEY GTR_PLUGINS_ENGINE_BASE_KEY "/active-plugins"
-
#define PLUGIN_EXT ".plugin"
/* Signals */
@@ -67,20 +64,15 @@ enum
static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE (GtrPluginsEngine, gtr_plugins_engine, G_TYPE_OBJECT)
- struct _GtrPluginsEnginePrivate
- {
- GList *plugin_list;
- GConfClient *gconf_client;
- };
- GtrPluginsEngine *default_engine = NULL;
+struct _GtrPluginsEnginePrivate
+{
+ GList *plugin_list;
+ GSettings *settings;
+};
+
+GtrPluginsEngine *default_engine = NULL;
- static void
- gtr_plugins_engine_active_plugins_changed (GConfClient *
- client,
- guint cnxn_id,
- GConfEntry * entry,
- gpointer user_data);
static void
gtr_plugins_engine_activate_plugin_real
(GtrPluginsEngine * engine, GtrPluginInfo * info);
@@ -88,16 +80,15 @@ G_DEFINE_TYPE (GtrPluginsEngine, gtr_plugins_engine, G_TYPE_OBJECT)
gtr_plugins_engine_deactivate_plugin_real
(GtrPluginsEngine * engine, GtrPluginInfo * info);
- static void
- gtr_plugins_engine_load_dir (GtrPluginsEngine * engine,
- const gchar * dir,
- GSList * active_plugins)
+static void
+gtr_plugins_engine_load_dir (GtrPluginsEngine * engine,
+ const gchar * dir,
+ GSList * active_plugins)
{
GError *error = NULL;
GDir *d;
const gchar *dirent;
- g_return_if_fail (engine->priv->gconf_client != NULL);
g_return_if_fail (dir != NULL);
DEBUG_PRINT ("DIR: %s", dir);
@@ -163,9 +154,8 @@ gtr_plugins_engine_load_all (GtrPluginsEngine * engine)
gchar **pdirs;
int i;
- active_plugins = gconf_client_get_list (engine->priv->gconf_client,
- GTR_PLUGINS_ENGINE_KEY,
- GCONF_VALUE_STRING, NULL);
+ active_plugins = gtr_settings_get_list (engine->priv->settings,
+ GTR_SETTINGS_ACTIVE_PLUGINS);
/* load user's plugins */
home = g_get_home_dir ();
@@ -207,6 +197,40 @@ gtr_plugins_engine_load_all (GtrPluginsEngine * engine)
}
static void
+on_active_plugins_changed (GSettings *settings,
+ const gchar *key,
+ GtrPluginsEngine *engine)
+{
+ GList *pl;
+ gboolean to_activate;
+ GSList *active_plugins;
+
+ //gtr_debug (DEBUG_PLUGINS);
+
+ active_plugins = gtr_settings_get_list (settings, key);
+
+ for (pl = engine->priv->plugin_list; pl; pl = pl->next)
+ {
+ GtrPluginInfo *info = (GtrPluginInfo *) pl->data;
+
+ if (!info->available)
+ continue;
+
+ to_activate = (g_slist_find_custom (active_plugins,
+ info->module_name,
+ (GCompareFunc) strcmp) != NULL);
+
+ if (!info->active && to_activate)
+ g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
+ else if (info->active && !to_activate)
+ g_signal_emit (engine, signals[DEACTIVATE_PLUGIN], 0, info);
+ }
+
+ g_slist_foreach (active_plugins, (GFunc) g_free, NULL);
+ g_slist_free (active_plugins);
+}
+
+static void
gtr_plugins_engine_init (GtrPluginsEngine * engine)
{
//gtr_debug (DEBUG_PLUGINS);
@@ -221,17 +245,12 @@ gtr_plugins_engine_init (GtrPluginsEngine * engine)
GTR_TYPE_PLUGINS_ENGINE,
GtrPluginsEnginePrivate);
- engine->priv->gconf_client = gconf_client_get_default ();
- g_return_if_fail (engine->priv->gconf_client != NULL);
-
- gconf_client_add_dir (engine->priv->gconf_client,
- GTR_PLUGINS_ENGINE_BASE_KEY,
- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ engine->priv->settings = g_settings_new ("org.gnome.gtranslator.plugins");
- gconf_client_notify_add (engine->priv->gconf_client,
- GTR_PLUGINS_ENGINE_KEY,
- gtr_plugins_engine_active_plugins_changed,
- engine, NULL, NULL);
+ g_signal_connect (engine->priv->settings,
+ "changed::active-plugins",
+ G_CALLBACK (on_active_plugins_changed),
+ engine);
gtr_plugins_engine_load_all (engine);
}
@@ -267,13 +286,12 @@ gtr_plugins_engine_finalize (GObject * object)
gtr_python_shutdown ();
#endif
- g_return_if_fail (engine->priv->gconf_client != NULL);
-
g_list_foreach (engine->priv->plugin_list,
(GFunc) _gtr_plugin_info_unref, NULL);
g_list_free (engine->priv->plugin_list);
- g_object_unref (engine->priv->gconf_client);
+ if (engine->priv->settings)
+ g_object_unref (engine->priv->settings);
}
static void
@@ -410,7 +428,6 @@ save_active_plugin_list (GtrPluginsEngine * engine)
{
GSList *active_plugins = NULL;
GList *l;
- gboolean res;
for (l = engine->priv->plugin_list; l != NULL; l = l->next)
{
@@ -422,12 +439,9 @@ save_active_plugin_list (GtrPluginsEngine * engine)
}
}
- res = gconf_client_set_list (engine->priv->gconf_client,
- GTR_PLUGINS_ENGINE_KEY,
- GCONF_VALUE_STRING, active_plugins, NULL);
-
- if (!res)
- g_warning ("Error saving the list of active plugins.");
+ gtr_settings_set_list (engine->priv->settings,
+ GTR_SETTINGS_ACTIVE_PLUGINS,
+ active_plugins);
g_slist_free (active_plugins);
}
@@ -591,54 +605,3 @@ gtr_plugins_engine_configure_plugin (GtrPluginsEngine *
gtk_window_set_modal (GTK_WINDOW (conf_dlg), TRUE);
gtk_widget_show (conf_dlg);
}
-
-static void
-gtr_plugins_engine_active_plugins_changed (GConfClient * client,
- guint cnxn_id,
- GConfEntry * entry,
- gpointer user_data)
-{
- GtrPluginsEngine *engine;
- GList *pl;
- gboolean to_activate;
- GSList *active_plugins;
-
- //gtr_debug (DEBUG_PLUGINS);
-
- g_return_if_fail (entry->key != NULL);
- g_return_if_fail (entry->value != NULL);
-
- engine = GTR_PLUGINS_ENGINE (user_data);
-
- if (!((entry->value->type == GCONF_VALUE_LIST) &&
- (gconf_value_get_list_type (entry->value) == GCONF_VALUE_STRING)))
- {
- g_warning ("The gconf key '%s' may be corrupted.",
- GTR_PLUGINS_ENGINE_KEY);
- return;
- }
-
- active_plugins = gconf_client_get_list (engine->priv->gconf_client,
- GTR_PLUGINS_ENGINE_KEY,
- GCONF_VALUE_STRING, NULL);
-
- for (pl = engine->priv->plugin_list; pl; pl = pl->next)
- {
- GtrPluginInfo *info = (GtrPluginInfo *) pl->data;
-
- if (!info->available)
- continue;
-
- to_activate = (g_slist_find_custom (active_plugins,
- info->module_name,
- (GCompareFunc) strcmp) != NULL);
-
- if (!info->active && to_activate)
- g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
- else if (info->active && !to_activate)
- g_signal_emit (engine, signals[DEACTIVATE_PLUGIN], 0, info);
- }
-
- g_slist_foreach (active_plugins, (GFunc) g_free, NULL);
- g_slist_free (active_plugins);
-}
diff --git a/src/translation-memory/gtr-translation-memory-ui.c b/src/translation-memory/gtr-translation-memory-ui.c
index 69de7f7..2e1b49c 100644
--- a/src/translation-memory/gtr-translation-memory-ui.c
+++ b/src/translation-memory/gtr-translation-memory-ui.c
@@ -24,7 +24,6 @@
#include "gtr-application.h"
#include "gtr-po.h"
-#include "gtr-prefs-manager.h"
#include "gtr-translation-memory.h"
#include "gtr-translation-memory-ui.h"
#include "gtr-tab.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]