From ff47948e26ca64f7f4897299a38858594ce39ed0 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 11 Jan 2005 00:39:16 +0000 Subject: [PATCH] Fix several history bugs 2005-01-11 Marco Pesenti Gritti * 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 | 9 +++++++++ shell/ev-history.c | 17 +++++++++++++++-- shell/ev-view.c | 21 +++++++++++++-------- shell/ev-window.c | 2 +- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6fc87010..da76f704 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-01-11 Marco Pesenti Gritti + + * 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 * configure.ac: Add «nb» to ALL_LINGUAS. diff --git a/shell/ev-history.c b/shell/ev-history.c index 267b41b6..a1e79543 100644 --- a/shell/ev-history.c +++ b/shell/ev-history.c @@ -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 diff --git a/shell/ev-view.c b/shell/ev-view.c index 2b04c875..cf2c4695 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -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); + } } diff --git a/shell/ev-window.c b/shell/ev-window.c index f4a9288f..64b80c33 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -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); -- 2.43.5