Commit 0d8bb512 authored by Shaun McCance's avatar Shaun McCance

Use GSettings for show-cursor and font-adjustment preferences

parent 29e4dcbe
......@@ -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)
......
......@@ -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
......
<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>
......@@ -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);
......
......@@ -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);
......
......@@ -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");
......@@ -547,16 +543,6 @@ window_font_adjustment (GtkAction *action,
g_str_equal (gtk_action_get_name (action), "LargerText") ? 1 : -1);
}
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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment