Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2005-01-11 00:39:16 (GMT)
committer Marco Pesenti Gritti <marco@src.gnome.org>2005-01-11 00:39:16 (GMT)
commitff47948e26ca64f7f4897299a38858594ce39ed0 (patch)
tree0f3ee3608b7215f7eb492a33f9aa30784962cbd1 /shell
parenta84947db66adf65becd125e65c208bb87a639766 (diff)
Fix several history bugs
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
Diffstat (limited to 'shell')
-rw-r--r--shell/ev-history.c17
-rw-r--r--shell/ev-view.c21
-rw-r--r--shell/ev-window.c2
3 files changed, 29 insertions, 11 deletions
diff --git a/shell/ev-history.c b/shell/ev-history.c
index 267b41b..a1e7954 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 2b04c87..cf2c469 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 f4a9288..64b80c3 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);