[yelp/yelp-3-0] [yelp-window] Let YelpApplication handle font adjustments



commit b6c1175886224a40fb1332446fa9cdb137d57857
Author: Shaun McCance <shaunm gnome org>
Date:   Tue Mar 16 13:12:52 2010 -0500

    [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.

 src/yelp-application.c |   35 +++++++++++++++++++++++++++++++++++
 src/yelp-application.h |    3 +++
 src/yelp-window.c      |   28 ++++++++++------------------
 src/yelp-window.h      |    2 ++
 4 files changed, 50 insertions(+), 18 deletions(-)
---
diff --git a/src/yelp-application.c b/src/yelp-application.c
index 14b7b05..dbe2b70 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 f4514b1..b66e02c 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 7edd54a..7e12164 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 47d3bd9..58084dc 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__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]