[gitg] Port gitg to gsettings.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Port gitg to gsettings.
- Date: Sun, 2 Jan 2011 14:58:11 +0000 (UTC)
commit c61d7d781828bf920cc5c2d4a0a2ee629aa15f1b
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Fri Dec 31 00:47:23 2010 +0100
Port gitg to gsettings.
configure.ac | 5 +-
data/Makefile.am | 35 +--
data/gitg.schemas.in | 127 ---------
data/org.gnome.gitg.gschema.xml.in.in | 151 ++++++++++
gitg/Makefile.am | 8 +-
gitg/gitg-commit-view.c | 48 ++--
gitg/gitg-preferences-dialog.c | 253 +++++++++++------
gitg/gitg-preferences.c | 499 ---------------------------------
gitg/gitg-preferences.h | 66 -----
gitg/gitg-revision-changes-panel.c | 22 +-
gitg/gitg-settings.c | 179 ------------
gitg/gitg-settings.h | 91 ------
gitg/gitg-utils.c | 10 +-
gitg/gitg-window.c | 300 ++++++++++----------
gitg/gitg.c | 4 -
15 files changed, 530 insertions(+), 1268 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4860a42..0f74ac8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -92,7 +92,7 @@ PKG_CHECK_MODULES(GITG, [
PKG_CHECK_MODULES(PACKAGE, [
$GTKSOURCEVIEW_REQUIRED >= $GTKSOURCEVIEW_REQUIRED_VERSION
- gconf-2.0
+ gsettings-desktop-schemas
])
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
@@ -147,7 +147,7 @@ PACKAGE_LIBS="$PACKAGE_LIBS -lm"
AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS)
-AM_GCONF_SOURCE_2
+GLIB_GSETTINGS
AC_CONFIG_FILES([
Makefile
@@ -157,6 +157,7 @@ gitg/Makefile
data/Makefile
data/gitg.desktop.in
data/icons/Makefile
+data/org.gnome.gitg.gschema.xml.in
po/Makefile.in
tests/Makefile
tools/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index 4faf5fb..e7127fe 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -5,11 +5,6 @@ desktop_in_files = gitg.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
-schemasdir = $(GCONF_SCHEMA_FILE_DIR)
-schemas_in_files = gitg.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
- INTLTOOL_SCHEMAS_RULE@
-
man_MANS = gitg.1
gitglangsdir = $(datadir)/gitg/language-specs
@@ -18,27 +13,25 @@ gitglangs_DATA = gitgdiff.lang
gitgstylesdir = $(datadir)/gitg/styles
gitgstyles_DATA = gitgstyle.xml
-if GCONF_SCHEMAS_INSTALL
-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
-else
-install-data-local:
-endif
-
-EXTRA_DIST = \
+gsettings_SCHEMAS = org.gnome.gitg.gschema.xml
+
+ INTLTOOL_XML_NOMERGE_RULE@
+
+ GSETTINGS_RULES@
+
+EXTRA_DIST = \
$(desktop_in_files) \
- $(schemas_in_files) \
$(gitglangs_DATA) \
$(gitgstyles_DATA) \
- $(man_MANS)
+ $(man_MANS) \
+ org.gnome.gitg.gschema.xml.in.in
-CLEANFILES = \
+CLEANFILES = \
$(desktop_DATA) \
- $(schemas_DATA)
+ $(gsettings_SCHEMAS)
+DISTCLEANFILES = \
+ $(desktop_DATA) \
+ $(gsettings_SCHEMAS)
-include $(top_srcdir)/git.mk
diff --git a/data/org.gnome.gitg.gschema.xml.in.in b/data/org.gnome.gitg.gschema.xml.in.in
new file mode 100644
index 0000000..a8ffca1
--- /dev/null
+++ b/data/org.gnome.gitg.gschema.xml.in.in
@@ -0,0 +1,151 @@
+<schemalist>
+ <enum id="org.gnome.gitg.Layout">
+ <value nick="horizontal" value="0"/>
+ <value nick="vertical" value="1"/>
+ </enum>
+
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences" path="/apps/gitg/preferences/">
+ <child name="view" schema="org.gnome.gitg.preferences.view" />
+ <child name="commit" schema="org.gnome.gitg.preferences.commit" />
+ <child name="diff" schema="org.gnome.gitg.preferences.diff" />
+ <child name="hidden" schema="org.gnome.gitg.preferences.hidden" />
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.view" path="/apps/gitg/preferences/view/">
+ <child name="history" schema="org.gnome.gitg.preferences.view.history" />
+ <child name="main" schema="org.gnome.gitg.preferences.view.main" />
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.view.history" path="/apps/gitg/preferences/view/history/">
+ <key name="search-filter" type="b">
+ <default>false</default>
+ <summary>Filter Revisions When Searching</summary>
+ <description>
+ Whether searching filters the revisions in the history view instead of
+ jumping to the first match.
+ </description>
+ </key>
+ <key name="collapse-inactive-lanes" type="i">
+ <default>2</default>
+ <summary>When to Collapse Inactive Lanes</summary>
+ <description>
+ Setting that indicates when an inactive lane should be collapsed.
+ Valid values are 0 - 4, where 0 indicates 'early' and 4 indicates 'late'.
+ </description>
+ </key>
+ <key name="collapse-inactive-lanes-active" type="b">
+ <default>true</default>
+ <!-- TODO: add descriptions -->
+ </key>
+ <key name="topo-order" type="b">
+ <default>false</default>
+ <summary>Show History in Topological Order</summary>
+ <description>
+ Setting that indicates whether to show the history in topological order.
+ </description>
+ </key>
+ <key name="show-virtual-stash" type="b">
+ <default>true</default>
+ <!-- TODO: add descriptions -->
+ </key>
+ <key name="show-virtual-staged" type="b">
+ <default>true</default>
+ <!-- TODO: add descriptions -->
+ </key>
+ <key name="show-virtual-unstaged" type="b">
+ <default>true</default>
+ <!-- TODO: add descriptions -->
+ </key>
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.view.main" path="/apps/gitg/preferences/view/main/">
+ <key name="layout-vertical" enum="org.gnome.gitg.Layout">
+ <default>'vertical'</default>
+ <summary>Show Main View in Vertical or Horizontal Layout</summary>
+ <description>
+ Setting that sets the orientation layout of the main view.
+ </description>
+ </key>
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.commit" path="/apps/gitg/preferences/commit/">
+ <child name="message" schema="org.gnome.gitg.preferences.commit.message" />
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.commit.message" path="/apps/gitg/preferences/commit/message/">
+ <key name="show-right-margin" type="b">
+ <default>true</default>
+ <summary>Show Right Margin in Commit Message View</summary>
+ <description>
+ Show a right margin indicator in the commit message view.
+ This can be used to easily see where to break the commit message at
+ a particular column.
+ </description>
+ </key>
+ <key name="right-margin-at" type="i">
+ <default>72</default>
+ <summary>Column at Which Right Margin is Shown</summary>
+ <description>
+ The column at which the right margin is shown if the right-margin
+ preference is set to TRUE.
+ </description>
+ </key>
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.diff" path="/apps/gitg/preferences/diff/">
+ <key name="external" type="b">
+ <default>false</default>
+ <summary>Allow External Diff Program</summary>
+ <description>
+ Allow an external diff program to be used when viewing diffs in gitg.
+ </description>
+ </key>
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.hidden" path="/apps/gitg/preferences/hidden/">
+ <key name="sign-tag" type="b">
+ <default>true</default>
+ <!-- TODO description -->
+ </key>
+ </schema>
+ <schema id="org.gnome.gitg.state" path="/apps/gitg/state/">
+ <child name="window" schema="org.gnome.gitg.state.window"/>
+ </schema>
+ <schema id="org.gnome.gitg.state.window" path="/apps/gitg/state/window/">
+ <key name="state" type="i">
+ <default>0</default>
+ </key>
+ <key name="size" type="(ii)">
+ <default>(650, 500)</default>
+ </key>
+ <key name="vpaned-main-position" type="i">
+ <default>200</default>
+ </key>
+ <key name="hpaned-commit1-position" type="i">
+ <default>200</default>
+ </key>
+ <key name="hpaned-commit2-position" type="i">
+ <default>200</default>
+ </key>
+ <key name="vpaned-commit-position" type="i">
+ <default>200</default>
+ </key>
+ <key name="revision-tree-view-position" type="i">
+ <default>200</default>
+ </key>
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.desktop.url-handlers.gitg" path="/desktop/gnome/url-handlers/gitg/">
+ <key name="command" type="s">
+ <default>'gitg "%s"'</default>
+ <summary>The command to handle GITG scheme URLs</summary>
+ <description>The command to handle GITG scheme URLs.</description>
+ </key>
+ <key name="needs-terminal" type="b">
+ <default>false</default>
+ <summary>Whether command to handle GITG scheme URLs needs a terminal</summary>
+ <description>
+ Whether command to handle GITG scheme URLs needs a terminal.
+ </description>
+ </key>
+ <key name="enabled" type="b">
+ <default>true</default>
+ <summary>Whether command to handle GITG scheme URLs is enabled</summary>
+ <description>
+ Whether command to handle GITG scheme URLs is enabled.
+ </description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/gitg/Makefile.am b/gitg/Makefile.am
index 422dc38..5aa8e35 100644
--- a/gitg/Makefile.am
+++ b/gitg/Makefile.am
@@ -11,7 +11,7 @@ AM_CPPFLAGS = \
-DGITG_DATADIR=\""$(datadir)/gitg"\" \
-DGITG_LOCALEDIR=\""$(datadir)/locale"\"
-NOINST_H_FILES = \
+NOINST_H_FILES = \
gitg-activatable.h \
gitg-branch-actions.h \
gitg-cell-renderer-path.h \
@@ -22,20 +22,18 @@ NOINST_H_FILES = \
gitg-dnd.h \
gitg-label-renderer.h \
gitg-preferences-dialog.h \
- gitg-preferences.h \
gitg-repository-dialog.h \
gitg-revision-panel.h \
gitg-revision-details-panel.h \
gitg-revision-files-panel.h \
gitg-revision-changes-panel.h \
- gitg-settings.h \
gitg-stat-view.h \
gitg-uri.h \
gitg-utils.h \
gitg-window.h \
gseal-gtk-compat.h
-gitg_SOURCES = \
+gitg_SOURCES = \
$(BUILT_SOURCES) \
gitg.c \
gitg-activatable.c \
@@ -47,14 +45,12 @@ gitg_SOURCES = \
gitg-dirs.c \
gitg-dnd.c \
gitg-label-renderer.c \
- gitg-preferences.c \
gitg-preferences-dialog.c \
gitg-repository-dialog.c \
gitg-revision-panel.c \
gitg-revision-details-panel.c \
gitg-revision-files-panel.c \
gitg-revision-changes-panel.c \
- gitg-settings.c \
gitg-stat-view.c \
gitg-uri.c \
gitg-utils.c \
diff --git a/gitg/gitg-commit-view.c b/gitg/gitg-commit-view.c
index 5b3d273..ee82ce0 100644
--- a/gitg/gitg-commit-view.c
+++ b/gitg/gitg-commit-view.c
@@ -30,7 +30,6 @@
#include "gitg-commit-view.h"
#include "gitg-diff-view.h"
-#include "gitg-preferences.h"
#include "gitg-utils.h"
#include "gseal-gtk-compat.h"
@@ -93,6 +92,9 @@ struct _GitgCommitViewPrivate
GtkActionGroup *group_context;
GtkTextMark *highlight_mark;
GtkTextTag *highlight_tag;
+
+ GSettings *message_settings;
+ GSettings *diff_settings;
};
static void gitg_commit_view_buildable_iface_init(GtkBuildableIface *iface);
@@ -500,10 +502,8 @@ unstaged_selection_changed (GtkTreeSelection *selection,
gchar ct[10];
g_snprintf (ct, sizeof(ct), "-U%d", view->priv->context_size);
- g_object_get (gitg_preferences_get_default (),
- "diff-external",
- &allow_external,
- NULL);
+ allow_external = g_settings_get_boolean (view->priv->diff_settings,
+ "external");
gitg_shell_run (view->priv->shell,
gitg_command_new (view->priv->repository,
@@ -600,10 +600,8 @@ staged_selection_changed (GtkTreeSelection *selection, GitgCommitView *view)
gchar ct[10];
g_snprintf (ct, sizeof(ct), "-U%d", view->priv->context_size);
- g_object_get (gitg_preferences_get_default (),
- "diff-external",
- &allow_external,
- NULL);
+ allow_external = g_settings_get_boolean (view->priv->diff_settings,
+ "external");
gitg_shell_run (view->priv->shell,
gitg_command_new (view->priv->repository,
@@ -1409,15 +1407,17 @@ gitg_commit_view_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
self->priv->check_button_signed_off_by = GTK_CHECK_BUTTON(gtk_builder_get_object(builder, "check_button_signed_off_by"));
self->priv->check_button_amend = GTK_CHECK_BUTTON(gtk_builder_get_object(builder, "check_button_amend"));
- GitgPreferences *preferences = gitg_preferences_get_default();
+ g_settings_bind (self->priv->message_settings,
+ "show-right-margin",
+ self->priv->comment_view,
+ "show-right-margin",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_object_bind_property (preferences, "message-show-right-margin",
- self->priv->comment_view, "show-right-margin",
- G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (preferences, "message-right-margin-at",
- self->priv->comment_view, "right-margin-position",
- G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+ g_settings_bind (self->priv->message_settings,
+ "right-margin-at",
+ self->priv->comment_view,
+ "right-margin-position",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
self->priv->hscale_context = GTK_HSCALE(gtk_builder_get_object(builder, "hscale_context"));
gtk_range_set_value (GTK_RANGE (self->priv->hscale_context), 3);
@@ -1565,6 +1565,18 @@ gitg_commit_view_dispose(GObject *object)
{
GitgCommitView *self = GITG_COMMIT_VIEW(object);
+ if (self->priv->message_settings)
+ {
+ g_object_unref (self->priv->message_settings);
+ self->priv->message_settings = NULL;
+ }
+
+ if (self->priv->diff_settings)
+ {
+ g_object_unref (self->priv->diff_settings);
+ self->priv->diff_settings = NULL;
+ }
+
if (self->priv->repository)
{
g_object_unref(self->priv->repository);
@@ -1684,6 +1696,8 @@ gitg_commit_view_init (GitgCommitView *self)
{
self->priv = GITG_COMMIT_VIEW_GET_PRIVATE (self);
+ self->priv->message_settings = g_settings_new ("org.gnome.gitg.preferences.commit.message");
+ self->priv->diff_settings = g_settings_new ("org.gnome.gitg.preferences.diff");
self->priv->shell = gitg_shell_new (10000);
gitg_shell_set_preserve_line_endings (self->priv->shell, TRUE);
diff --git a/gitg/gitg-preferences-dialog.c b/gitg/gitg-preferences-dialog.c
index 8216d66..a9ef83e 100644
--- a/gitg/gitg-preferences-dialog.c
+++ b/gitg/gitg-preferences-dialog.c
@@ -22,7 +22,6 @@
#include "gitg-preferences-dialog.h"
-#include "gitg-preferences.h"
#include "gitg-utils.h"
#include <libgitg/gitg-config.h>
@@ -77,6 +76,11 @@ struct _GitgPreferencesDialogPrivate
GtkWidget *table;
gint prev_value;
+
+ GSettings *history_settings;
+ GSettings *message_settings;
+ GSettings *view_settings;
+ GSettings *diff_settings;
};
G_DEFINE_TYPE(GitgPreferencesDialog, gitg_preferences_dialog, GTK_TYPE_DIALOG)
@@ -90,13 +94,35 @@ round_val(gdouble val)
}
static void
-gitg_preferences_dialog_finalize(GObject *object)
+gitg_preferences_dialog_dispose (GObject *object)
{
GitgPreferencesDialog *dialog = GITG_PREFERENCES_DIALOG (object);
- g_object_unref (dialog->priv->config);
+ if (dialog->priv->config)
+ {
+ g_object_unref (dialog->priv->config);
+ dialog->priv->config = NULL;
+ }
+
+ if (dialog->priv->message_settings)
+ {
+ g_object_unref (dialog->priv->message_settings);
+ dialog->priv->message_settings = NULL;
+ }
+
+ if (dialog->priv->view_settings)
+ {
+ g_object_unref (dialog->priv->view_settings);
+ dialog->priv->view_settings = NULL;
+ }
+
+ if (dialog->priv->diff_settings)
+ {
+ g_object_unref (dialog->priv->diff_settings);
+ dialog->priv->diff_settings = NULL;
+ }
- G_OBJECT_CLASS(gitg_preferences_dialog_parent_class)->finalize(object);
+ G_OBJECT_CLASS (gitg_preferences_dialog_parent_class)->dispose (object);
}
static void
@@ -104,7 +130,7 @@ gitg_preferences_dialog_class_init(GitgPreferencesDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
- object_class->finalize = gitg_preferences_dialog_finalize;
+ object_class->dispose = gitg_preferences_dialog_dispose;
g_type_class_add_private(object_class, sizeof(GitgPreferencesDialogPrivate));
}
@@ -115,6 +141,10 @@ gitg_preferences_dialog_init(GitgPreferencesDialog *self)
self->priv = GITG_PREFERENCES_DIALOG_GET_PRIVATE(self);
self->priv->config = gitg_config_new (NULL);
+ self->priv->history_settings = g_settings_new ("org.gnome.gitg.preferences.view.history");
+ self->priv->message_settings = g_settings_new ("org.gnome.gitg.preferences.commit.message");
+ self->priv->view_settings = g_settings_new ("org.gnome.gitg.preferences.view.main");
+ self->priv->diff_settings = g_settings_new ("org.gnome.gitg.preferences.diff");
}
static void
@@ -123,30 +153,20 @@ on_response(GtkWidget *dialog, gint response, gpointer data)
gtk_widget_destroy(dialog);
}
-static gboolean
-unconvert_collapsed (GBinding *binding,
- const GValue *source_value,
- GValue *target_value,
- gpointer userdata)
-{
- return g_value_transform (source_value, target_value);
-}
-
-static gboolean
-convert_collapsed (GBinding *binding,
- const GValue *source_value,
- GValue *target_value,
- gpointer userdata)
+static GVariant *
+convert_collapsed (const GValue *value,
+ const GVariantType *expected_type,
+ gpointer userdata)
{
GitgPreferencesDialog *dialog = GITG_PREFERENCES_DIALOG (userdata);
- gint val = round_val (g_value_get_double (source_value));
+ gint val = round_val (g_value_get_double (value));
if (val == dialog->priv->prev_value)
- return FALSE;
+ return NULL;
dialog->priv->prev_value = val;
- return g_value_transform (source_value, target_value);
+ return g_variant_new_int32 (val);
}
static void
@@ -165,11 +185,52 @@ on_check_button_show_right_margin_toggled(GtkToggleButton *button, GitgPreferenc
gtk_widget_set_sensitive(GTK_WIDGET(dialog->priv->spin_button_right_margin), active);
}
+static gboolean
+orientation_to_layout_vertical (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
+{
+ const gchar *orientation;
+ gboolean val;
+
+ orientation = g_variant_get_string (variant, NULL);
+
+ if (strcmp (orientation, "vertical") == 0)
+ {
+ val = TRUE;
+ }
+ else
+ {
+ val = FALSE;
+ }
+
+ g_value_set_boolean (value, val);
+
+ return TRUE;
+}
+
+static GVariant *
+layout_vertical_to_orientation (const GValue *value,
+ const GVariantType *expected_type,
+ gpointer user_data)
+{
+ GVariant *orientation;
+
+ if (g_value_get_boolean (value))
+ {
+ orientation = g_variant_new_string ("vertical");
+ }
+ else
+ {
+ orientation = g_variant_new_string ("horizontal");
+ }
+
+ return orientation;
+}
+
static void
initialize_view(GitgPreferencesDialog *dialog)
{
- GitgPreferences *preferences = gitg_preferences_get_default();
-
g_signal_connect (dialog->priv->check_button_collapse_inactive,
"toggled",
G_CALLBACK (on_collapse_inactive_toggled),
@@ -180,75 +241,79 @@ initialize_view(GitgPreferencesDialog *dialog)
G_CALLBACK (on_check_button_show_right_margin_toggled),
dialog);
- g_object_bind_property (preferences,
- "history-search-filter",
- dialog->priv->history_search_filter,
- "active",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
- g_object_bind_property_full (preferences,
- "history-collapse-inactive-lanes",
- dialog->priv->collapse_inactive_lanes,
- "value",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE,
- unconvert_collapsed,
- convert_collapsed,
- dialog,
- NULL);
-
- g_object_bind_property (preferences,
- "history-collapse-inactive-lanes-active",
- dialog->priv->check_button_collapse_inactive,
- "active",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (preferences,
- "history-show-virtual-stash",
- dialog->priv->history_show_virtual_stash,
- "active",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (preferences,
- "history-show-virtual-staged",
- dialog->priv->history_show_virtual_staged,
- "active",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (preferences,
- "history-show-virtual-unstaged",
- dialog->priv->history_show_virtual_unstaged,
- "active",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (preferences,
- "history-topo-order",
- dialog->priv->history_topo_order,
- "active",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (preferences,
- "message-show-right-margin",
- dialog->priv->check_button_show_right_margin,
- "active",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (preferences,
- "message-right-margin-at",
- dialog->priv->spin_button_right_margin,
- "value",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (preferences,
- "main-layout-vertical",
- dialog->priv->main_layout_vertical,
- "active",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (preferences,
- "diff-external",
- dialog->priv->check_button_external_diff,
- "active",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+ g_settings_bind (dialog->priv->history_settings,
+ "search-filter",
+ dialog->priv->history_search_filter,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind_with_mapping (dialog->priv->history_settings,
+ "collapse-inactive-lanes",
+ dialog->priv->collapse_inactive_lanes,
+ "value",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET,
+ NULL,
+ convert_collapsed,
+ dialog,
+ NULL);
+
+ g_settings_bind (dialog->priv->history_settings,
+ "collapse-inactive-lanes-active",
+ dialog->priv->check_button_collapse_inactive,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dialog->priv->history_settings,
+ "topo-order",
+ dialog->priv->history_topo_order,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dialog->priv->history_settings,
+ "show-virtual-stash",
+ dialog->priv->history_show_virtual_stash,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dialog->priv->history_settings,
+ "show-virtual-staged",
+ dialog->priv->history_show_virtual_staged,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dialog->priv->history_settings,
+ "show-virtual-unstaged",
+ dialog->priv->history_show_virtual_unstaged,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dialog->priv->message_settings,
+ "show-right-margin",
+ dialog->priv->check_button_show_right_margin,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dialog->priv->message_settings,
+ "right-margin-at",
+ dialog->priv->spin_button_right_margin,
+ "value",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind_with_mapping (dialog->priv->view_settings,
+ "layout-vertical",
+ dialog->priv->main_layout_vertical,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET,
+ orientation_to_layout_vertical,
+ layout_vertical_to_orientation,
+ NULL,
+ NULL);
+
+ g_settings_bind (dialog->priv->diff_settings,
+ "external",
+ dialog->priv->check_button_external_diff,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
}
static void
diff --git a/gitg/gitg-revision-changes-panel.c b/gitg/gitg-revision-changes-panel.c
index d8fe9a2..02bbdd8 100644
--- a/gitg/gitg-revision-changes-panel.c
+++ b/gitg/gitg-revision-changes-panel.c
@@ -10,7 +10,6 @@
#include <libgitg/gitg-hash.h>
#include "gitg-diff-view.h"
#include "gitg-utils.h"
-#include "gitg-preferences.h"
#include <glib/gi18n.h>
@@ -36,6 +35,8 @@ struct _GitgRevisionChangesPanelPrivate
GSList *cached_headers;
gchar *selection;
+
+ GSettings *diff_settings;
};
typedef enum
@@ -522,6 +523,12 @@ gitg_revision_changes_panel_dispose (GObject *object)
set_revision (changes_panel, NULL, NULL);
+ if (changes_panel->priv->diff_settings)
+ {
+ g_object_unref (changes_panel->priv->diff_settings);
+ changes_panel->priv->diff_settings = NULL;
+ }
+
if (changes_panel->priv->diff_files_shell)
{
g_object_unref (changes_panel->priv->diff_files_shell);
@@ -596,10 +603,8 @@ reload_diff (GitgRevisionChangesPanel *changes_panel)
gchar sign = gitg_revision_get_sign (changes_panel->priv->revision);
gboolean allow_external;
- g_object_get (gitg_preferences_get_default (),
- "diff-external",
- &allow_external,
- NULL);
+ allow_external = g_settings_get_boolean (changes_panel->priv->diff_settings,
+ "external");
switch (sign)
{
@@ -844,10 +849,8 @@ on_diff_end_loading (GitgShell *shell,
gchar sign = gitg_revision_get_sign (self->priv->revision);
gboolean allow_external;
- g_object_get (gitg_preferences_get_default (),
- "diff-external",
- &allow_external,
- NULL);
+ allow_external = g_settings_get_boolean (self->priv->diff_settings,
+ "external");
if (sign == 't' || sign == 'u')
{
@@ -911,6 +914,7 @@ gitg_revision_changes_panel_init (GitgRevisionChangesPanel *self)
{
self->priv = GITG_REVISION_CHANGES_PANEL_GET_PRIVATE (self);
+ self->priv->diff_settings = g_settings_new ("org.gnome.gitg.preferences.diff");
self->priv->diff_shell = gitg_shell_new (2000);
g_signal_connect (self->priv->diff_shell,
diff --git a/gitg/gitg-utils.c b/gitg/gitg-utils.c
index edfe6ae..dd0e119 100644
--- a/gitg/gitg-utils.c
+++ b/gitg/gitg-utils.c
@@ -23,7 +23,6 @@
#include "gitg-dirs.h"
#include "gitg-utils.h"
-#include <gconf/gconf-client.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
@@ -138,10 +137,13 @@ gitg_utils_get_language(gchar const *filename, gchar const *content_type)
gchar *
gitg_utils_get_monospace_font_name(void)
{
- GConfClient *client = gconf_client_get_default();
- gchar *name = gconf_client_get_string(client, "/desktop/gnome/interface/monospace_font_name", NULL);
+ GSettings *interface;
+ gchar *name;
- g_object_unref(client);
+ interface = g_settings_new ("org.gnome.desktop.interface");
+ name = g_settings_get_string (interface, "monospace-font-name");
+
+ g_object_unref (interface);
return name;
}
diff --git a/gitg/gitg-window.c b/gitg/gitg-window.c
index f03f21b..4a90bd6 100644
--- a/gitg/gitg-window.c
+++ b/gitg/gitg-window.c
@@ -34,12 +34,10 @@
#include "gitg-window.h"
#include "gitg-cell-renderer-path.h"
#include "gitg-commit-view.h"
-#include "gitg-settings.h"
#include "gitg-preferences-dialog.h"
#include "gitg-repository-dialog.h"
#include "gitg-dnd.h"
#include "gitg-branch-actions.h"
-#include "gitg-preferences.h"
#include "gitg-utils.h"
#include "gitg-revision-panel.h"
#include "gitg-revision-details-panel.h"
@@ -108,6 +106,11 @@ struct _GitgWindowPrivate
GSList *revision_panels;
GSList *activatables;
+
+ GSettings *state_settings;
+ GSettings *view_settings;
+ GSettings *history_settings;
+ GSettings *hidden_settings;
};
static gboolean on_tree_view_motion (GtkTreeView *treeview,
@@ -205,6 +208,38 @@ gitg_window_finalize (GObject *object)
}
static void
+gitg_window_dispose (GObject *object)
+{
+ GitgWindow *self = GITG_WINDOW (object);
+
+ if (self->priv->state_settings)
+ {
+ g_object_unref (self->priv->state_settings);
+ self->priv->state_settings = NULL;
+ }
+
+ if (self->priv->view_settings)
+ {
+ g_object_unref (self->priv->view_settings);
+ self->priv->view_settings = NULL;
+ }
+
+ if (self->priv->history_settings)
+ {
+ g_object_unref (self->priv->history_settings);
+ self->priv->history_settings = NULL;
+ }
+
+ if (self->priv->hidden_settings)
+ {
+ g_object_unref (self->priv->hidden_settings);
+ self->priv->hidden_settings = NULL;
+ }
+
+ G_OBJECT_CLASS (gitg_window_parent_class)->dispose (object);
+}
+
+static void
on_revision_panel_mapped (GtkWidget *page,
GitgWindow *window)
{
@@ -666,32 +701,32 @@ build_branches_combo (GitgWindow *window,
static void
restore_state (GitgWindow *window)
{
- GitgSettings *settings = gitg_settings_get_default ();
- gint dw;
- gint dh;
+ gint width;
+ gint height;
- gtk_window_get_default_size (GTK_WINDOW(window), &dw, &dh);
+ g_settings_get (window->priv->state_settings, "size", "(ii)", &width, &height);
gtk_window_set_default_size (GTK_WINDOW(window),
- gitg_settings_get_window_width (settings,
- dw),
- gitg_settings_get_window_height (settings,
- dh));
+ width, height);
gitg_utils_restore_pane_position (GTK_PANED(window->priv->vpaned_main),
- gitg_settings_get_vpaned_main_position (settings, -1),
+ g_settings_get_int (window->priv->state_settings,
+ "vpaned-main-position"),
FALSE);
gitg_utils_restore_pane_position (GTK_PANED(window->priv->vpaned_commit),
- gitg_settings_get_vpaned_commit_position (settings, -1),
+ g_settings_get_int (window->priv->state_settings,
+ "vpaned-commit-position"),
FALSE);
gitg_utils_restore_pane_position (GTK_PANED(window->priv->hpaned_commit1),
- gitg_settings_get_hpaned_commit1_position (settings, 200),
+ g_settings_get_int (window->priv->state_settings,
+ "hpaned-commit1-position"),
FALSE);
gitg_utils_restore_pane_position (GTK_PANED(window->priv->hpaned_commit2),
- gitg_settings_get_hpaned_commit2_position (settings, 200),
+ g_settings_get_int (window->priv->state_settings,
+ "hpaned-commit2-position"),
TRUE);
}
@@ -868,19 +903,6 @@ init_tree_view (GitgWindow *window,
}
static void
-on_main_layout_vertical_cb (GitgWindow *window)
-{
- GitgPreferences *preferences = gitg_preferences_get_default ();
- gboolean vertical;
-
- g_object_get (preferences, "main-layout-vertical", &vertical, NULL);
- g_object_set (window->priv->vpaned_main,
- "orientation",
- vertical ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL,
- NULL);
-}
-
-static void
gitg_window_parser_finished (GtkBuildable *buildable,
GtkBuilder *builder)
{
@@ -919,6 +941,12 @@ gitg_window_parser_finished (GtkBuildable *buildable,
window->priv->vpaned_main = GTK_WIDGET (gtk_builder_get_object (builder,
"vpaned_main"));
+ g_settings_bind (window->priv->view_settings,
+ "layout-vertical",
+ window->priv->vpaned_main,
+ "orientation",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
window->priv->hpaned_commit1 = GTK_WIDGET (gtk_builder_get_object (builder,
"hpaned_commit1"));
@@ -984,15 +1012,6 @@ gitg_window_parser_finished (GtkBuildable *buildable,
"button-release-event",
G_CALLBACK(on_tree_view_button_release),
window);
-
- GitgPreferences *preferences = gitg_preferences_get_default ();
-
- g_signal_connect_swapped (preferences,
- "notify::main-layout-vertical",
- G_CALLBACK (on_main_layout_vertical_cb),
- window);
-
- on_main_layout_vertical_cb (window);
}
static void
@@ -1006,34 +1025,33 @@ gitg_window_buildable_iface_init (GtkBuildableIface *iface)
static void
save_state (GitgWindow *window)
{
- GitgSettings *settings = gitg_settings_get_default ();
GtkAllocation allocation;
gint position;
- gtk_widget_get_allocation (GTK_WIDGET(window), &allocation);
+ gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
- gitg_settings_set_window_width (settings, allocation.width);
- gitg_settings_set_window_height (settings, allocation.height);
+ g_settings_set (window->priv->state_settings, "size", "(ii)",
+ allocation.width, allocation.height);
if (gtk_widget_get_mapped (window->priv->vpaned_main))
{
position = gtk_paned_get_position (GTK_PANED (window->priv->vpaned_main));
- gitg_settings_set_vpaned_main_position (settings,
- position);
+ g_settings_set_int (window->priv->state_settings, "vpaned-main-position",
+ position);
}
if (gtk_widget_get_mapped (window->priv->vpaned_commit))
{
position = gtk_paned_get_position (GTK_PANED (window->priv->vpaned_commit));
- gitg_settings_set_vpaned_commit_position (settings,
- position);
+ g_settings_set_int (window->priv->state_settings, "vpaned-commit-position",
+ position);
}
if (gtk_widget_get_mapped (window->priv->hpaned_commit1))
{
position = gtk_paned_get_position (GTK_PANED (window->priv->hpaned_commit1));
- gitg_settings_set_hpaned_commit1_position (settings,
- position);
+ g_settings_set_int (window->priv->state_settings, "hpaned-commit1-position",
+ position);
}
if (gtk_widget_get_mapped (window->priv->hpaned_commit2))
@@ -1044,13 +1062,9 @@ save_state (GitgWindow *window)
&alloc);
position = gtk_paned_get_position (GTK_PANED (window->priv->hpaned_commit2));
-
- gitg_settings_set_hpaned_commit2_position (settings,
- alloc.width -
- position);
+ g_settings_set_int (window->priv->state_settings, "hpaned-commit2-position",
+ alloc.width - position);
}
-
- gitg_settings_save (settings);
}
static gboolean
@@ -1114,8 +1128,8 @@ gitg_window_window_state_event (GtkWidget *widget,
gtk_statusbar_set_has_resize_grip (window->priv->statusbar, show);
}
- GitgSettings *settings = gitg_settings_get_default ();
- gitg_settings_set_window_state (settings, event->new_window_state);
+ /* Save the window state */
+ g_settings_set_int (window->priv->state_settings, "state", event->new_window_state);
return FALSE;
}
@@ -1175,6 +1189,7 @@ gitg_window_class_init (GitgWindowClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gitg_window_finalize;
+ object_class->dispose = gitg_window_dispose;
gtkobject_class->destroy = gitg_window_destroy;
widget_class->delete_event = gitg_window_delete_event;
@@ -1191,6 +1206,10 @@ gitg_window_init (GitgWindow *self)
self->priv->load_timer = g_timer_new ();
self->priv->hand = gdk_cursor_new (GDK_HAND1);
+ self->priv->state_settings = g_settings_new ("org.gnome.gitg.state.window");
+ self->priv->view_settings = g_settings_new ("org.gnome.gitg.preferences.view.main");
+ self->priv->history_settings = g_settings_new ("org.gnome.gitg.preferences.view.history");
+ self->priv->hidden_settings = g_settings_new ("org.gnome.gitg.preferences.hidden");
}
static void
@@ -1249,45 +1268,33 @@ gitg_window_set_select_on_load (GitgWindow *window,
}
static gboolean
-convert_setting_to_inactive_max (GBinding *binding,
- const GValue *source_value,
- GValue *target_value,
- gpointer userdata)
+convert_setting_to_inactive_max (GValue *value,
+ GVariant *variant,
+ gpointer userdata)
{
- g_return_val_if_fail (G_VALUE_HOLDS (source_value, G_TYPE_INT), FALSE);
- g_return_val_if_fail (G_VALUE_HOLDS (target_value, G_TYPE_INT), FALSE);
-
- gint s = g_value_get_int (source_value);
- g_value_set_int (target_value, 2 + s * 8);
+ gint s = g_variant_get_int32 (variant);
+ g_value_set_int (value, 2 + s * 8);
return TRUE;
}
static gboolean
-convert_setting_to_inactive_collapse (GBinding *binding,
- const GValue *source_value,
- GValue *target_value,
- gpointer userdata)
+convert_setting_to_inactive_collapse (GValue *value,
+ GVariant *variant,
+ gpointer userdata)
{
- g_return_val_if_fail (G_VALUE_HOLDS (source_value, G_TYPE_INT), FALSE);
- g_return_val_if_fail (G_VALUE_HOLDS (target_value, G_TYPE_INT), FALSE);
-
- gint s = g_value_get_int (source_value);
- g_value_set_int (target_value, 1 + s * 3);
+ gint s = g_variant_get_int32 (variant);
+ g_value_set_int (value, 1 + s * 3);
return TRUE;
}
static gboolean
-convert_setting_to_inactive_gap (GBinding *binding,
- const GValue *source_value,
- GValue *target_value,
- gpointer userdata)
+convert_setting_to_inactive_gap (GValue *value,
+ GVariant *variant,
+ gpointer userdata)
{
- g_return_val_if_fail (G_VALUE_HOLDS (source_value, G_TYPE_INT), FALSE);
- g_return_val_if_fail (G_VALUE_HOLDS (target_value, G_TYPE_INT), FALSE);
-
- g_value_set_int (target_value, 10);
+ g_value_set_int (value, 10);
return TRUE;
}
@@ -1295,72 +1302,68 @@ convert_setting_to_inactive_gap (GBinding *binding,
static void
bind_repository (GitgWindow *window)
{
- GitgPreferences *preferences;
-
if (window->priv->repository == NULL)
return;
- preferences = gitg_preferences_get_default ();
-
- g_object_bind_property_full (preferences,
- "history-collapse-inactive-lanes",
- window->priv->repository,
- "inactive-max",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE,
- convert_setting_to_inactive_max,
- NULL,
- window,
- NULL);
-
- g_object_bind_property (preferences,
- "history-show-virtual-stash",
- window->priv->repository,
- "show-stash",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (preferences,
- "history-show-virtual-staged",
- window->priv->repository,
- "show-staged",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (preferences,
- "history-show-virtual-unstaged",
- window->priv->repository,
- "show-unstaged",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (preferences,
- "history-topo-order",
- window->priv->repository,
- "topo-order",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
- g_object_bind_property_full (preferences,
- "history-collapse-inactive-lanes",
- window->priv->repository,
- "inactive-collapse",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE,
- convert_setting_to_inactive_collapse,
- NULL,
- window,
- NULL);
-
- g_object_bind_property_full (preferences,
- "history-collapse-inactive-lanes",
- window->priv->repository,
- "inactive-gap",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE,
- convert_setting_to_inactive_gap,
- NULL,
- window,
- NULL);
-
- g_object_bind_property (preferences,
- "history-collapse-inactive-lanes-active",
- window->priv->repository,
- "inactive-enabled",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+ g_settings_bind_with_mapping (window->priv->history_settings,
+ "collapse-inactive-lanes",
+ window->priv->repository,
+ "inactive-max",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET,
+ convert_setting_to_inactive_max,
+ NULL,
+ window,
+ NULL);
+
+ g_settings_bind (window->priv->history_settings,
+ "show-virtual-stash",
+ window->priv->repository,
+ "show-stash",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (window->priv->history_settings,
+ "show-virtual-staged",
+ window->priv->repository,
+ "show-staged",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (window->priv->history_settings,
+ "show-virtual-unstaged",
+ window->priv->repository,
+ "show-unstaged",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (window->priv->history_settings,
+ "topo-order",
+ window->priv->repository,
+ "topo-order",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind_with_mapping (window->priv->history_settings,
+ "collapse-inactive-lanes",
+ window->priv->repository,
+ "inactive-collapse",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET,
+ convert_setting_to_inactive_collapse,
+ NULL,
+ window,
+ NULL);
+
+ g_settings_bind_with_mapping (window->priv->history_settings,
+ "collapse-inactive-lanes",
+ window->priv->repository,
+ "inactive-gap",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET,
+ convert_setting_to_inactive_gap,
+ NULL,
+ window,
+ NULL);
+
+ g_settings_bind (window->priv->history_settings,
+ "collapse-inactive-lanes-active",
+ window->priv->repository,
+ "inactive-enabled",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
}
static gboolean
@@ -3357,8 +3360,8 @@ on_tag_dialog_response (GtkWidget *dialog,
g_free (sha1);
- GitgPreferences *preferences = gitg_preferences_get_default ();
- g_object_set (preferences, "hidden-sign-tag", sign, NULL);
+ g_settings_set_boolean (info->window->priv->hidden_settings,
+ "sign-tag", sign);
}
g_free (message);
@@ -3562,8 +3565,6 @@ on_revision_tag_activate (GtkAction *action,
selection = gtk_tree_view_get_selection (window->priv->tree_view);
GList *rows = gtk_tree_selection_get_selected_rows (selection, &model);
- GitgPreferences *preferences = gitg_preferences_get_default ();
-
if (rows && !rows->next)
{
GtkBuilder *builder = gitg_utils_new_builder ("gitg-tag.ui");
@@ -3571,9 +3572,10 @@ on_revision_tag_activate (GtkAction *action,
GtkToggleButton *toggle = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "check_button_sign"));
- gboolean active = TRUE;
+ gboolean active;
- g_object_get (preferences, "hidden-sign-tag", &active, NULL);
+ active = g_settings_get_boolean (window->priv->hidden_settings,
+ "sign-tag");
gtk_toggle_button_set_active (toggle, active);
gtk_window_set_transient_for (GTK_WINDOW (widget), GTK_WINDOW (window));
diff --git a/gitg/gitg.c b/gitg/gitg.c
index 9b925ba..e2676f4 100644
--- a/gitg/gitg.c
+++ b/gitg/gitg.c
@@ -31,7 +31,6 @@
#include "gitg-window.h"
#include "config.h"
-#include "gitg-settings.h"
#include "gitg-dirs.h"
#include "gitg-utils.h"
#include "gitg-uri.h"
@@ -245,7 +244,6 @@ main (int argc, char **argv)
set_style_scheme_search_path ();
set_icons ();
- GitgSettings *settings = gitg_settings_get_default ();
GitgWindow *window = build_ui ();
ret = gitg_window_load_repository_for_command_line (window,
@@ -264,7 +262,5 @@ main (int argc, char **argv)
gtk_main ();
- /* Finalize settings */
- g_object_unref (settings);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]