[evince] Add keybindings to go back/forward in history



commit 2c8870e4eed1c713051569ef66757c09bdea728d
Author: Anuj Khare <khareanuj18 gmail com>
Date:   Thu Mar 20 17:09:22 2014 +0530

    Add keybindings to go back/forward in history
    
    <alt>P to go back in history
    <alt>N to go forward in history
    
    Based on Spandana's patch.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=509029

 shell/ev-window.c   |   31 +++++++++++++++++++++++++++++++
 shell/evince-ui.xml |    2 ++
 2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 5f3a909..72b136b 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -4610,6 +4610,22 @@ ev_window_cmd_view_zoom_out (GtkAction *action, EvWindow *ev_window)
 }
 
 static void
+ev_window_cmd_go_back_history (GtkAction* action, EvWindow *ev_window)
+{
+       g_return_if_fail (EV_IS_WINDOW (ev_window));
+
+       ev_history_go_back(ev_window->priv->history);
+}
+
+static void
+ev_window_cmd_go_forward_history (GtkAction* action, EvWindow* ev_window)
+{
+       g_return_if_fail (EV_IS_WINDOW (ev_window));
+
+       ev_history_go_forward(ev_window->priv->history);
+}
+
+static void
 ev_window_cmd_go_previous_page (GtkAction *action, EvWindow *ev_window)
 {
         g_return_if_fail (EV_IS_WINDOW (ev_window));
@@ -6063,6 +6079,10 @@ static const GtkActionEntry entries[] = {
          G_CALLBACK (ev_window_cmd_view_autoscroll) },
 
         /* Go menu */
+        { "GoBackHistory", NULL, "", "<alt>P", NULL,
+          G_CALLBACK (ev_window_cmd_go_back_history) },
+        { "GoForwardHistory", NULL, "", "<alt>N", NULL,
+          G_CALLBACK (ev_window_cmd_go_forward_history) },
         { "GoPreviousPage", "go-up-symbolic", N_("_Previous Page"), "<control>Page_Up",
           N_("Go to the previous page"),
           G_CALLBACK (ev_window_cmd_go_previous_page) },
@@ -6231,6 +6251,14 @@ activate_link_cb (GObject *object, EvLink *link, EvWindow *window)
 }
 
 static void
+history_changed_cb (EvHistory  *history,
+                    EvWindow   *window)
+{
+       ev_window_set_action_sensitive (window, "GoBackHistory", ev_history_can_go_back 
(window->priv->history));
+       ev_window_set_action_sensitive (window, "GoForwardHistory", ev_history_can_go_forward 
(window->priv->history));
+}
+
+static void
 sidebar_layers_visibility_changed (EvSidebarLayers *layers,
                                   EvWindow        *window)
 {
@@ -7336,6 +7364,9 @@ ev_window_init (EvWindow *ev_window)
        g_signal_connect (ev_window->priv->history, "activate-link",
                          G_CALLBACK (activate_link_cb),
                          ev_window);
+        g_signal_connect (ev_window->priv->history, "changed",
+                          G_CALLBACK (history_changed_cb),
+                          ev_window);
 
        app_info = g_app_info_get_default_for_uri_scheme ("mailto");
        ev_window->priv->has_mailto_handler = app_info != NULL;
diff --git a/shell/evince-ui.xml b/shell/evince-ui.xml
index df9c9f9..97844b3 100644
--- a/shell/evince-ui.xml
+++ b/shell/evince-ui.xml
@@ -89,6 +89,8 @@
     <placeholder name="ViewZoomItems"/>
   </popup>
 
+  <accelerator name="BackHistoryAccel" action="GoBackHistory"/>
+  <accelerator name="ForwardHistoryAccel" action="GoForwardHistory"/>
   <accelerator name="PageDownAccel" action="PageDown"/>
   <accelerator name="PageUpAccel" action="PageUp"/>
   <accelerator name="GoBackwardFastAccel" action="GoBackwardFast"/>


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