From 072541b9457cdb0ca41fa5948803b1b7d8d17a11 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Wed, 22 Nov 2017 10:46:01 +0100 Subject: Use a global array for view accel action and a loop to change their sensitivity inspired from: https://git.gnome.org/browse/evince/commit/?h=gnome-3-2&id=d15eeda https://git.gnome.org/browse/evince/commit/?h=gnome-3-2&id=2ed0f3d https://git.gnome.org/browse/evince/commit/?h=gnome-3-2&id=793361c --- shell/ev-window.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'shell') diff --git a/shell/ev-window.c b/shell/ev-window.c index 8e679ea9..0b0ffc7c 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -635,26 +635,34 @@ ev_window_update_actions (EvWindow *ev_window) } } +static const gchar *view_accels[] = { + "PageDown", + "PageUp", + "Plus", + "Minus", + "KpPlus", + "KpMinus", + "Equal", + "p", + "n", + "FitPage", + "FitWidth" +}; + 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, "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 -- cgit v1.2.1