[evince] Use a global array for view accel action and a loop to change their sensitivity



commit d15eeda3af418885ac457f9c5b95a6f2ada578b0
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Sun Jun 26 11:40:19 2011 +0200

    Use a global array for view accel action and a loop to change their sensitivity

 shell/ev-window.c |   48 ++++++++++++++++++++++++++----------------------
 1 files changed, 26 insertions(+), 22 deletions(-)
---
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 29d2fa8..ca3c1bb 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -557,33 +557,37 @@ ev_window_update_actions (EvWindow *ev_window)
 	}
 }
 
+static const gchar *view_accels[] = {
+	"PageDown",
+	"PageUp",
+	"Space",
+	"ShiftSpace",
+	"BackSpace",
+	"ShiftBackSpace",
+	"Return",
+	"ShiftReturn",
+	"Plus",
+	"Minus",
+	"KpPlus",
+	"KpMinus",
+	"Equal",
+	"p"
+};
+
 static void
 ev_window_set_view_accels_sensitivity (EvWindow *window, gboolean sensitive)
 {
 	gboolean can_find;
+	gint     i;
 
-	can_find = window->priv->document && 
-	    EV_IS_DOCUMENT_FIND (window->priv->document);
-
-	if (window->priv->action_group) {
-		ev_window_set_action_sensitive (window, "PageDown", sensitive);
-		ev_window_set_action_sensitive (window, "PageUp", sensitive);
-		ev_window_set_action_sensitive (window, "Space", sensitive);
-		ev_window_set_action_sensitive (window, "ShiftSpace", sensitive);
-		ev_window_set_action_sensitive (window, "BackSpace", sensitive);
-		ev_window_set_action_sensitive (window, "ShiftBackSpace", sensitive);
-		ev_window_set_action_sensitive (window, "Return", sensitive);
-		ev_window_set_action_sensitive (window, "ShiftReturn", sensitive);
-		ev_window_set_action_sensitive (window, "Plus", sensitive);
-		ev_window_set_action_sensitive (window, "Minus", sensitive);
-		ev_window_set_action_sensitive (window, "KpPlus", sensitive);
-		ev_window_set_action_sensitive (window, "KpMinus", sensitive);
-		ev_window_set_action_sensitive (window, "Equal", sensitive);
-		ev_window_set_action_sensitive (window, "p", sensitive);
-		ev_window_set_action_sensitive (window, "n", sensitive);
-
-		ev_window_set_action_sensitive (window, "Slash", sensitive && can_find);
-	}
+	if (!window->priv->action_group)
+		return;
+
+	for (i = 0; i < G_N_ELEMENTS (view_accels); i++)
+		ev_window_set_action_sensitive (window, view_accels[i], sensitive);
+
+	can_find = window->priv->document && EV_IS_DOCUMENT_FIND (window->priv->document);
+	ev_window_set_action_sensitive (window, "Slash", sensitive && can_find);
 }
 
 static void



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