]> www.fi.muni.cz Git - evince.git/commitdiff
Fix several history bugs
authorMarco Pesenti Gritti <marco@gnome.org>
Tue, 11 Jan 2005 00:39:16 +0000 (00:39 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Tue, 11 Jan 2005 00:39:16 +0000 (00:39 +0000)
2005-01-11  Marco Pesenti Gritti  <marco@gnome.org>

        * shell/ev-history.c: (ev_history_init), (ev_history_add_link):
        * shell/ev-view.c: (ev_view_set_document), (ev_view_go_back),
        (ev_view_go_forward):
        * shell/ev-window.c: (register_custom_actions):

        Fix several history bugs

ChangeLog
shell/ev-history.c
shell/ev-view.c
shell/ev-window.c

index 6fc87010b8ff541b894b0aa56072d89df97e2506..da76f704b0f820ec01d29a1260db5c1023db7891 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-01-11  Marco Pesenti Gritti  <marco@gnome.org>
+
+       * shell/ev-history.c: (ev_history_init), (ev_history_add_link):
+       * shell/ev-view.c: (ev_view_set_document), (ev_view_go_back),
+       (ev_view_go_forward):
+       * shell/ev-window.c: (register_custom_actions):
+
+       Fix several history bugs
+
 2005-01-11  Kjartan Maraas  <kmaraas@gnome.org>
 
        * configure.ac: Add «nb» to ALL_LINGUAS.
index 267b41b69d09e76ab3a0539905790e3b3b5a69c2..a1e79543bb4e8a9bd35e97c4fefc495f77d1406d 100644 (file)
@@ -45,6 +45,7 @@ ev_history_init (EvHistory *history)
        history->priv = EV_HISTORY_GET_PRIVATE (history);
 
        history->priv->links = NULL;
+       history->priv->current_index = -1;
 }
 
 static void
@@ -84,14 +85,26 @@ ev_history_add_link (EvHistory *history, EvLink *link)
        g_return_if_fail (EV_IS_HISTORY (history));
        g_return_if_fail (EV_IS_LINK (link));
 
+       length = g_list_length (history->priv->links);
+       if (history->priv->current_index < length - 1) {
+               GList *l = g_list_nth (history->priv->links,
+                                      history->priv->current_index + 1);
+               
+               if (l->prev) {
+                       l->prev->next = NULL;
+                       free_links_list (l);
+               } else {
+                       free_links_list (history->priv->links);
+                       history->priv->links = NULL;
+               }
+       }
+
        g_object_ref (link);
        history->priv->links = g_list_append (history->priv->links,
                                              link);
 
        length = g_list_length (history->priv->links);
        history->priv->current_index = length - 1;
-
-       g_print ("Set current\n");
 }
 
 void
index 2b04c87576e1aae4b22a0b30e182a0f6ac61ad11..cf2c4695c7c0280476af8c300d003a20da278f9b 100644 (file)
@@ -910,6 +910,7 @@ ev_view_set_document (EvView     *view,
                        g_object_unref (view->history);
                }
                view->history = ev_history_new ();
+               ev_history_add_page (view->history, ev_view_get_page (view));
        }
 }
 
@@ -964,15 +965,18 @@ go_to_index (EvView *view, int index)
 void
 ev_view_go_back        (EvView *view)
 {
-       int index;
+       int index, n;
 
        g_return_if_fail (EV_IS_HISTORY (view->history));
 
        index = ev_history_get_current_index (view->history);
-       index = MAX (0, index - 1);
+       n = ev_history_get_n_links (view->history);
 
-       ev_history_set_current_index (view->history, index);
-       go_to_index (view, index);
+       if (n > 0) {
+               index = MAX (0, index - 1);
+               ev_history_set_current_index (view->history, index);
+               go_to_index (view, index);
+       }
 }
 
 void
@@ -985,10 +989,11 @@ ev_view_go_forward (EvView *view)
        index = ev_history_get_current_index (view->history);
        n = ev_history_get_n_links (view->history);
 
-       index = MIN (n - 1, index + 1);
-
-       ev_history_set_current_index (view->history, index);
-       go_to_index (view, index);
+       if (n > 0) {
+               index = MIN (n - 1, index + 1);
+               ev_history_set_current_index (view->history, index);
+               go_to_index (view, index);
+       }
 }
 
 
index f4a9288f4d795abfb55e8b8907d68ebd26a8dcea..64b80c33abdd79d5002eea9572012af1d383b783 100644 (file)
@@ -1364,7 +1364,7 @@ register_custom_actions (EvWindow *window, GtkActionGroup *group)
                               "direction", EV_NAVIGATION_DIRECTION_FORWARD,
                               NULL);
        g_signal_connect (action, "activate",
-                         G_CALLBACK (ev_window_cmd_go_back), window);
+                         G_CALLBACK (ev_window_cmd_go_forward), window);
        gtk_action_group_add_action (group, action);
        g_object_unref (action);