summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2017-11-22 10:46:01 +0100
committerraveit65 <[email protected]>2017-11-22 17:51:12 +0100
commit072541b9457cdb0ca41fa5948803b1b7d8d17a11 (patch)
tree9fdbbcba149562839fb7cc04ba4f6c4745a89ced /shell
parent735bf5604c0acaec33b8e3127e32a5794ffa6a94 (diff)
downloadatril-072541b9457cdb0ca41fa5948803b1b7d8d17a11.tar.bz2
atril-072541b9457cdb0ca41fa5948803b1b7d8d17a11.tar.xz
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
Diffstat (limited to 'shell')
-rw-r--r--shell/ev-window.c38
1 files changed, 23 insertions, 15 deletions
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