[yelp] Use GSettings for show-cursor and font-adjustment preferences
- From: Shaun McCance <shaunm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp] Use GSettings for show-cursor and font-adjustment preferences
- Date: Fri, 23 Apr 2010 20:21:44 +0000 (UTC)
commit 0d8bb5128dfce4c8c8411a4f7b2d610c6342ac01
Author: Shaun McCance <shaunm gnome org>
Date: Wed Apr 21 15:42:37 2010 -0500
Use GSettings for show-cursor and font-adjustment preferences
configure.in | 4 ++-
data/Makefile.am | 7 +++++
data/org.gnome.yelp.gschema.xml | 14 ++++++++++
src/yelp-application.c | 53 ++++++++++++++-------------------------
src/yelp-application.h | 2 -
src/yelp-window.c | 14 ----------
6 files changed, 43 insertions(+), 51 deletions(-)
---
diff --git a/configure.in b/configure.in
index 9393e43..7a4d3f9 100644
--- a/configure.in
+++ b/configure.in
@@ -50,7 +50,7 @@ AM_GLIB_DEFINE_LOCALEDIR([GNOMELOCALEDIR])
PKG_CHECK_MODULES(YELP,
[
- gio-2.0
+ gio-2.0 >= 2.25.2
gio-unix-2.0
gtk+-unix-print-2.0
gtk+-2.0 >= 2.16.0
@@ -79,6 +79,8 @@ AC_SUBST([YELP_LIBS])
AC_PATH_PROGS(SED, gsed sed)
+AM_GSETTINGS
+
XSL_PATH="`$PKG_CONFIG --variable=xsltdir yelp-xsl`"
XSL_DB_TITLE="$XSLT_PATH""/docbook/common/db-title.xsl"
AC_SUBST(XSL_DB_TITLE)
diff --git a/data/Makefile.am b/data/Makefile.am
index 0459f73..c6667d1 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -3,6 +3,13 @@ SUBDIRS = icons ui
@INTLTOOL_XML_RULE@
@INTLTOOL_SCHEMAS_RULE@
+gsettingsschema_DATA = org.gnome.yelp.gschema.xml
+ GSETTINGS_CHECK_RULE@
+if GSETTINGS_SCHEMAS_INSTALL
+install-data-hook:
+ $(gschema_compile) $(DESTDIR)$(gsettingsschemadir)
+endif
+
tocdir = $(datadir)/yelp
toc_DATA = man.xml toc.xml scrollkeeper.xml info.xml
diff --git a/data/org.gnome.yelp.gschema.xml b/data/org.gnome.yelp.gschema.xml
new file mode 100644
index 0000000..4725ec9
--- /dev/null
+++ b/data/org.gnome.yelp.gschema.xml
@@ -0,0 +1,14 @@
+<schemalist>
+<schema id="org.gnome.yelp" path="/org/gnome/yelp">
+ <key name="show-cursor" type="b">
+ <default>false</default>
+ </key>
+ <key name="font-adjustment" type="i">
+ <default>0</default>
+ <range>
+ <min>-3</min>
+ <max>10</max>
+ </range>
+ </key>
+</schema>
+</schemalist>
diff --git a/src/yelp-application.c b/src/yelp-application.c
index dda2214..6693199 100644
--- a/src/yelp-application.c
+++ b/src/yelp-application.c
@@ -75,19 +75,26 @@ struct _YelpApplicationPrivate {
GHashTable *windows_by_document;
- gboolean show_text_cursor;
- gboolean map_show_text_cursor;
+ GSettings *gsettings;
};
static void
yelp_application_init (YelpApplication *app)
{
+ YelpSettings *settings = yelp_settings_get_default ();
YelpApplicationPrivate *priv = GET_PRIV (app);
priv->windows_by_document = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
NULL);
+ priv->gsettings = g_settings_new ("org.gnome.yelp");
+ g_settings_bind (priv->gsettings, "show-cursor",
+ settings, "show-text-cursor",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (priv->gsettings, "font-adjustment",
+ settings, "font-adjustment",
+ G_SETTINGS_BIND_DEFAULT);
}
static void
@@ -114,6 +121,11 @@ yelp_application_dispose (GObject *object)
priv->connection = NULL;
}
+ if (priv->gsettings) {
+ g_object_unref (priv->gsettings);
+ priv->gsettings = NULL;
+ }
+
G_OBJECT_CLASS (yelp_application_parent_class)->dispose (object);
}
@@ -138,8 +150,8 @@ yelp_application_adjust_font (YelpApplication *app,
YelpSettings *settings = yelp_settings_get_default ();
GParamSpec *spec = g_object_class_find_property ((GObjectClass *) YELP_SETTINGS_GET_CLASS (settings),
"font-adjustment");
- gint adjustment = yelp_settings_get_font_adjustment (settings);
YelpApplicationPrivate *priv = GET_PRIV (app);
+ gint adjustment = g_settings_get_int (priv->gsettings, "font-adjustment");
if (!G_PARAM_SPEC_INT (spec)) {
g_warning ("Expcected integer param spec for font-adjustment");
@@ -147,7 +159,7 @@ yelp_application_adjust_font (YelpApplication *app,
}
adjustment += adjust;
- yelp_settings_set_font_adjustment (settings, adjustment);
+ g_settings_set_int (priv->gsettings, "font-adjustment", adjustment);
for (cur = priv->windows; cur != NULL; cur = cur->next) {
YelpWindow *win = (YelpWindow *) cur->data;
@@ -162,32 +174,6 @@ yelp_application_adjust_font (YelpApplication *app,
}
}
-void
-yelp_application_set_show_text_cursor (YelpApplication *app,
- gboolean show)
-{
- GSList *cur;
- YelpSettings *settings = yelp_settings_get_default ();
- YelpApplicationPrivate *priv = GET_PRIV (app);
-
- /* We get callbacks in the loop. Ignore them. */
- if (priv->map_show_text_cursor)
- return;
-
- priv->show_text_cursor = show;
- yelp_settings_set_show_text_cursor (settings, show);
- priv->map_show_text_cursor = TRUE;
- for (cur = priv->windows; cur != NULL; cur = cur->next) {
- YelpWindow *win = (YelpWindow *) cur->data;
- GtkActionGroup *group = yelp_window_get_action_group (win);
- GtkAction *action;
-
- action = gtk_action_group_get_action (group, "ShowTextCursor");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show);
- }
- priv->map_show_text_cursor = FALSE;
-}
-
/******************************************************************************/
YelpApplication *
@@ -362,10 +348,9 @@ application_uri_resolved (YelpUri *uri,
group = yelp_window_get_action_group (window);
action = gtk_action_group_get_action (group, "ShowTextCursor");
- priv->map_show_text_cursor = TRUE;
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- priv->show_text_cursor);
- priv->map_show_text_cursor = FALSE;
+ g_settings_bind (priv->gsettings, "show-cursor",
+ action, "active",
+ G_SETTINGS_BIND_DEFAULT);
if (!data->new) {
g_hash_table_insert (priv->windows_by_document, doc_uri, window);
diff --git a/src/yelp-application.h b/src/yelp-application.h
index ed48bb0..b272381 100644
--- a/src/yelp-application.h
+++ b/src/yelp-application.h
@@ -59,8 +59,6 @@ void yelp_application_new_window (YelpApplication *app,
void yelp_application_adjust_font (YelpApplication *app,
gint adjust);
-void yelp_application_set_show_text_cursor (YelpApplication *app,
- gboolean show);
void yelp_application_install_package (YelpApplication *app,
const gchar *pkg,
const gchar *alt);
diff --git a/src/yelp-window.c b/src/yelp-window.c
index 990b2bd..e60ef6b 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -57,8 +57,6 @@ static void window_open_location (GtkAction *action,
YelpWindow *window);
static void window_font_adjustment (GtkAction *action,
YelpWindow *window);
-static void window_show_text_cursor (GtkToggleAction *action,
- YelpWindow *window);
static void window_go_back (GtkAction *action,
YelpWindow *window);
static void window_go_forward (GtkAction *action,
@@ -228,8 +226,6 @@ yelp_window_init (YelpWindow *window)
action = (GtkAction *) gtk_toggle_action_new ("ShowTextCursor",
_("Show Text _Cursor"),
NULL, NULL);
- g_signal_connect (action, "activate",
- G_CALLBACK (window_show_text_cursor), window);
gtk_action_group_add_action_with_accel (priv->action_group,
action, "F7");
@@ -548,16 +544,6 @@ window_font_adjustment (GtkAction *action,
}
static void
-window_show_text_cursor (GtkToggleAction *action,
- YelpWindow *window)
-{
- YelpWindowPrivate *priv = GET_PRIV (window);
-
- yelp_application_set_show_text_cursor (priv->application,
- gtk_toggle_action_get_active (action));
-}
-
-static void
window_go_back (GtkAction *action,
YelpWindow *window)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]