[evince] shell: Add shortcut for default zoom (1:1)



commit 1827b706b08f01bb13ad598a4b38298f4bd579c2
Author: Germán Poo-Caamaño <gpoo gnome org>
Date:   Wed Jul 11 16:42:56 2018 -0400

    shell: Add shortcut for default zoom (1:1)
    
    Document centric applications usually have a mechanism to zoom
    the document to 100%, and the typical shortcut (e.g. web browsers)
    is Ctrl+0.
    
    Fixes #19

 shell/ev-application.c |  1 +
 shell/ev-window.c      | 13 +++++++++++++
 shell/help-overlay.ui  |  7 +++++++
 3 files changed, 21 insertions(+)
---
diff --git a/shell/ev-application.c b/shell/ev-application.c
index 953964ef..96ceea11 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -966,6 +966,7 @@ ev_application_startup (GApplication *gapplication)
           "win.sizing-mode::fit-page",  "f", NULL,
           "win.sizing-mode::fit-width", "w", NULL,
           "win.sizing-mode::automatic", "a", NULL,
+          "win.default-zoom",           "<Ctrl>0", NULL,
           "win.open-menu",              "F10", NULL,
           "win.caret-navigation",       "F7", NULL,
           "win.zoom-in",                "plus", "<Ctrl>plus", "KP_Add", "<Ctrl>KP_Add", "equal", 
"<Ctrl>equal", NULL,
diff --git a/shell/ev-window.c b/shell/ev-window.c
index eaeaad8e..dbb6e74a 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -4035,6 +4035,18 @@ ev_window_cmd_view_zoom (GSimpleAction *action,
                                     zoom * get_screen_dpi (ev_window) / 72.0);
 }
 
+static void
+ev_window_cmd_set_default_zoom (GSimpleAction *action,
+                               GVariant      *parameter,
+                               gpointer       user_data)
+{
+       EvWindow *ev_window = user_data;
+
+       ev_document_model_set_sizing_mode (ev_window->priv->model, EV_SIZING_FREE);
+       ev_document_model_set_scale (ev_window->priv->model,
+                                    1. * get_screen_dpi (ev_window) / 72.0);
+}
+
 static void
 ev_window_cmd_edit_select_all (GSimpleAction *action,
                               GVariant      *parameter,
@@ -5974,6 +5986,7 @@ static const GActionEntry actions[] = {
        { "scroll-backwards", ev_window_cmd_scroll_backwards },
        { "sizing-mode", NULL, "s", "'free'", ev_window_change_sizing_mode_action_state },
        { "zoom", ev_window_cmd_view_zoom, "d" },
+       { "default-zoom", ev_window_cmd_set_default_zoom },
        { "escape", ev_window_cmd_escape },
        { "open-menu", ev_window_cmd_action_menu },
        { "caret-navigation", NULL, NULL, "false", ev_window_cmd_view_toggle_caret_navigation },
diff --git a/shell/help-overlay.ui b/shell/help-overlay.ui
index 7e4e70cd..2e9e29de 100644
--- a/shell/help-overlay.ui
+++ b/shell/help-overlay.ui
@@ -235,6 +235,13 @@
                 <property name="accelerator">&lt;Primary&gt;minus</property>
               </object>
                  </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">Zoom 1:1</property>
+                <property name="accelerator">&lt;Primary&gt;0</property>
+              </object>
+            </child>
                  <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>


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