summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorAntia Puentes <[email protected]>2013-07-26 14:42:32 +0200
committerraveit65 <[email protected]>2017-09-06 21:19:51 +0200
commit62bc1f7c30631da0fd7a0ee1294050c697e2b35b (patch)
tree119eafb82479babbbda9639a2e62dc13b961976e /shell
parent534bb05456ae915bd4ab8fab0183eb14dd479d24 (diff)
downloadatril-62bc1f7c30631da0fd7a0ee1294050c697e2b35b.tar.bz2
atril-62bc1f7c30631da0fd7a0ee1294050c697e2b35b.tar.xz
shell: Enable/disable the caret navigation with F7
https://bugzilla.gnome.org/show_bug.cgi?id=702079 origin commit: https://git.gnome.org/browse/evince/commit/?h=gnome-3-10&id=fc9b6d1
Diffstat (limited to 'shell')
-rw-r--r--shell/ev-window.c97
1 files changed, 96 insertions, 1 deletions
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 0555d95f..9ad35037 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -227,6 +227,9 @@ struct _EvWindowPrivate {
guint dbus_object_id;
gchar *dbus_object_path;
#endif
+
+ /* Caret navigation */
+ GtkWidget *ask_caret_navigation_check;
};
#define EV_WINDOW_GET_PRIVATE(object) \
@@ -600,6 +603,11 @@ ev_window_update_actions (EvWindow *ev_window)
ev_window_set_action_sensitive (ev_window, "GoLastPage", FALSE);
}
+ ev_window_set_action_sensitive (ev_window, "F7",
+ has_pages &&
+ ev_view_supports_caret_navigation (view) &&
+ !presentation_mode);
+
sizing_mode = ev_document_model_get_sizing_mode (ev_window->priv->model);
if (has_pages && sizing_mode != EV_SIZING_FIT_WIDTH && sizing_mode != EV_SIZING_FIT_PAGE) {
GtkAction *action;
@@ -1379,7 +1387,7 @@ setup_size_from_metadata (EvWindow *window)
static void
setup_view_from_metadata (EvWindow *window)
{
- gboolean presentation;
+ gboolean presentation, caret_navigation;
if (!window->priv->metadata)
return;
@@ -1395,6 +1403,12 @@ setup_view_from_metadata (EvWindow *window)
}
}
}
+
+ /* Caret navigation mode */
+ if (ev_view_supports_caret_navigation (EV_VIEW (window->priv->view)) &&
+ ev_metadata_get_boolean (window->priv->metadata, "caret-navigation", &caret_navigation)) {
+ ev_view_set_caret_navigation_enabled (EV_VIEW (window->priv->view), caret_navigation);
+ }
}
static void
@@ -5830,6 +5844,85 @@ ev_window_finalize (GObject *object)
}
static void
+ev_window_set_caret_navigation_enabled (EvWindow *window,
+ gboolean enabled)
+{
+ if (window->priv->metadata)
+ ev_metadata_set_boolean (window->priv->metadata, "caret-navigation", enabled);
+
+ ev_view_set_caret_navigation_enabled (EV_VIEW (window->priv->view), enabled);
+}
+
+static void
+ev_window_caret_navigation_message_area_response_cb (EvMessageArea *area,
+ gint response_id,
+ EvWindow *window)
+{
+ /* Turn the caret navigation mode on */
+ if (response_id == GTK_RESPONSE_YES)
+ ev_window_set_caret_navigation_enabled (window, TRUE);
+
+ /* Turn the confirmation dialog off if the user has requested not to show it again */
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (window->priv->ask_caret_navigation_check))) {
+ g_settings_set_boolean (ev_window_ensure_settings (window), "show-caret-navigation-message", FALSE);
+ g_settings_apply (window->priv->settings);
+ }
+
+ window->priv->ask_caret_navigation_check = NULL;
+ ev_window_set_message_area (window, NULL);
+ gtk_widget_grab_focus (window->priv->view);
+}
+
+static void
+ev_window_cmd_view_toggle_caret_navigation (GtkAction *action,
+ EvWindow *window)
+{
+ GtkWidget *message_area;
+ GtkWidget *box;
+ GtkWidget *hbox;
+ gboolean enabled;
+
+ /* Don't ask for user confirmation to turn the caret navigation off when it is active,
+ * or to turn it on when the confirmation dialog is not to be shown per settings */
+ enabled = ev_view_is_caret_navigation_enabled (EV_VIEW (window->priv->view));
+ if (enabled || !g_settings_get_boolean (ev_window_ensure_settings (window), "show-caret-navigation-message")) {
+ ev_window_set_caret_navigation_enabled (window, !enabled);
+ return;
+ }
+
+ /* Ask for user confirmation to turn the caret navigation mode on */
+ if (window->priv->message_area)
+ return;
+
+ message_area = ev_message_area_new (GTK_MESSAGE_QUESTION,
+ _("Enable caret navigation?"),
+ GTK_STOCK_NO, GTK_RESPONSE_NO,
+ "_Enable", GTK_RESPONSE_YES,
+ NULL);
+ ev_message_area_set_secondary_text (EV_MESSAGE_AREA (message_area),
+ _("Pressing F7 turns the caret navigation on or off. "
+ "This feature places a moveable cursor in text pages, "
+ "allowing you to move around and select text with your keyboard. "
+ "Do you want to enable the caret navigation on?"));
+
+ window->priv->ask_caret_navigation_check = gtk_check_button_new_with_label (_("Don't show this message again"));
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_box_pack_start (GTK_BOX (hbox), window->priv->ask_caret_navigation_check,
+ TRUE, TRUE, 0);
+ gtk_widget_show_all (hbox);
+
+ box = _ev_message_area_get_main_box (EV_MESSAGE_AREA (message_area));
+ gtk_box_pack_start (GTK_BOX (box), hbox, TRUE, TRUE, 0);
+
+ g_signal_connect (message_area, "response",
+ G_CALLBACK (ev_window_caret_navigation_message_area_response_cb),
+ window);
+
+ gtk_widget_show (message_area);
+ ev_window_set_message_area (window, message_area);
+}
+
+static void
ev_window_dispose (GObject *object)
{
EvWindow *window = EV_WINDOW (object);
@@ -6292,6 +6385,8 @@ static const GtkActionEntry entries[] = {
G_CALLBACK (ev_window_cmd_fit_page) },
{ "FitWidth", EV_STOCK_ZOOM_WIDTH, NULL, "w", NULL,
G_CALLBACK (ev_window_cmd_fit_width) },
+ { "F7", NULL, "", "F7", NULL,
+ G_CALLBACK (ev_window_cmd_view_toggle_caret_navigation) },
};
/* Toggle items */