summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2010-03-16 13:12:52 -0500
committerShaun McCance <shaunm@gnome.org>2010-03-16 13:12:52 -0500
commitb6c1175886224a40fb1332446fa9cdb137d57857 (patch)
treed7fffe542ca8f38b347565e7ab7acdf801f3d8d1
parent9e5c944a4c6c055a520ab5003069b6388d2078c2 (diff)
downloadyelp-b6c1175886224a40fb1332446fa9cdb137d57857.tar.gz
[yelp-window] Let YelpApplication handle font adjustments
Font adjustments apply to all windows, so the action sensitivity has to be done in all windows' action groups. This is the first of a few things where YelpApplication will control the menus of all windows.
-rw-r--r--src/yelp-application.c35
-rw-r--r--src/yelp-application.h3
-rw-r--r--src/yelp-window.c28
-rw-r--r--src/yelp-window.h2
4 files changed, 50 insertions, 18 deletions
diff --git a/src/yelp-application.c b/src/yelp-application.c
index 14b7b05a..dbe2b70d 100644
--- a/src/yelp-application.c
+++ b/src/yelp-application.c
@@ -28,6 +28,7 @@
#include <dbus/dbus-glib.h>
#include <gtk/gtk.h>
+#include "yelp-settings.h"
#include "yelp-view.h"
#include "yelp-application.h"
@@ -115,6 +116,40 @@ yelp_application_finalize (GObject *object)
/******************************************************************************/
+void
+yelp_application_adjust_font (YelpApplication *app,
+ gint adjust)
+{
+ GSList *cur;
+ YelpSettings *settings = yelp_settings_get_default ();
+ GParamSpec *spec = g_object_class_find_property (YELP_SETTINGS_GET_CLASS (settings),
+ "font-adjustment");
+ gint adjustment = yelp_settings_get_font_adjustment (settings);
+ YelpApplicationPrivate *priv = GET_PRIV (app);
+
+ if (!G_PARAM_SPEC_INT (spec)) {
+ g_warning ("Expcected integer param spec for font-adjustment");
+ return;
+ }
+
+ adjustment += adjust;
+ yelp_settings_set_font_adjustment (settings, adjustment);
+
+ for (cur = priv->windows; cur != NULL; cur = cur->next) {
+ YelpWindow *win = (YelpWindow *) cur->data;
+ GtkActionGroup *group = yelp_window_get_action_group (win);
+ GtkAction *larger, *smaller;
+
+ larger = gtk_action_group_get_action (group, "LargerText");
+ gtk_action_set_sensitive (larger, adjustment < ((GParamSpecInt *) spec)->maximum);
+
+ smaller = gtk_action_group_get_action (group, "SmallerText");
+ gtk_action_set_sensitive (smaller, adjustment > ((GParamSpecInt *) spec)->minimum);
+ }
+}
+
+/******************************************************************************/
+
YelpApplication *
yelp_application_new (void)
{
diff --git a/src/yelp-application.h b/src/yelp-application.h
index f4514b1a..b66e02cd 100644
--- a/src/yelp-application.h
+++ b/src/yelp-application.h
@@ -55,4 +55,7 @@ gboolean yelp_application_load_uri (YelpApplication *app,
guint timestamp,
GError **error);
+void yelp_application_adjust_font (YelpApplication *app,
+ gint adjust);
+
#endif /* __YELP_APPLICATION_H__ */
diff --git a/src/yelp-window.c b/src/yelp-window.c
index 7edd54a1..7e12164a 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -376,6 +376,14 @@ yelp_window_load_uri (YelpWindow *window,
yelp_view_load_uri (priv->view, uri);
}
+GtkActionGroup *
+yelp_window_get_action_group (YelpWindow *window)
+{
+ YelpWindowPrivate *priv = GET_PRIV (window);
+
+ return priv->action_group;
+}
+
/******************************************************************************/
static void
@@ -431,26 +439,10 @@ static void
window_font_adjustment (GtkAction *action,
YelpWindow *window)
{
- GtkAction *larger, *smaller;
- YelpSettings *settings = yelp_settings_get_default ();
- GParamSpec *spec = g_object_class_find_property (YELP_SETTINGS_GET_CLASS (settings),
- "font-adjustment");
- gint adjust = yelp_settings_get_font_adjustment (settings);
YelpWindowPrivate *priv = GET_PRIV (window);
- if (!G_PARAM_SPEC_INT (spec)) {
- g_warning ("Expcected integer param spec for font-adjustment");
- return;
- }
-
- adjust += g_str_equal (gtk_action_get_name (action), "LargerText") ? 1 : -1;
- yelp_settings_set_font_adjustment (settings, adjust);
-
- larger = gtk_action_group_get_action (priv->action_group, "LargerText");
- gtk_action_set_sensitive (larger, adjust < ((GParamSpecInt *) spec)->maximum);
-
- smaller = gtk_action_group_get_action (priv->action_group, "SmallerText");
- gtk_action_set_sensitive (smaller, adjust > ((GParamSpecInt *) spec)->minimum);
+ yelp_application_adjust_font (priv->application,
+ g_str_equal (gtk_action_get_name (action), "LargerText") ? 1 : -1);
}
static void
diff --git a/src/yelp-window.h b/src/yelp-window.h
index 47d3bd96..58084dcc 100644
--- a/src/yelp-window.h
+++ b/src/yelp-window.h
@@ -51,4 +51,6 @@ YelpWindow * yelp_window_new (YelpApplication *app);
void yelp_window_load_uri (YelpWindow *window,
YelpUri *uri);
+GtkActionGroup * yelp_window_get_action_group (YelpWindow *window);
+
#endif /* __YELP_WINDOW_H__ */