summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/atril-ui.xml1
-rw-r--r--data/org.mate.Atril.gschema.xml5
-rw-r--r--shell/ev-window.c97
3 files changed, 101 insertions, 2 deletions
diff --git a/data/atril-ui.xml b/data/atril-ui.xml
index 182082f3..a2647426 100644
--- a/data/atril-ui.xml
+++ b/data/atril-ui.xml
@@ -129,6 +129,7 @@
<accelerator name="CtrlInsertAccel" action="CtrlInsert" />
<accelerator name="FitPageAccel" action ="FitPage" />
<accelerator name="FitWidthAccel" action ="FitWidth" />
+ <accelerator name="F7Accel" action="F7" />
<toolbar name="FullscreenToolbar">
<toolitem name="GoPreviousPage" action="GoPreviousPage"/>
diff --git a/data/org.mate.Atril.gschema.xml b/data/org.mate.Atril.gschema.xml
index f2db7253..1a1c1803 100644
--- a/data/org.mate.Atril.gschema.xml
+++ b/data/org.mate.Atril.gschema.xml
@@ -30,7 +30,10 @@
<summary>Page cache size in MiB</summary>
<description>The maximum size that will be used to cache rendered pages, limits maximum zoom level.</description>
</key>
-
+ <key name="show-caret-navigation-message" type="b">
+ <default>true</default>
+ <summary>Show a dialog to confirm that the user wants to activate the caret navigation.</summary>
+ </key>
<child name="default" schema="org.mate.Atril.Default"/>
</schema>
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 */