Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/ev-view.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2005-01-09 19:30:55 (GMT)
committer Marco Pesenti Gritti <marco@src.gnome.org>2005-01-09 19:30:55 (GMT)
commit2c91588d544c80f08526a54c98b25aabe3777ef7 (patch)
tree28a0061c839eecd72de3fd09206fd8e292ea9fe0 /shell/ev-view.c
parentd0984533fa0524131d765b56b3b2842216bf82d2 (diff)
Initial history implementation. Needs work.
2005-01-09 Marco Pesenti Gritti <marco@gnome.org> * shell/Makefile.am: * shell/ev-application.c: (ev_application_open_bookmark): * shell/ev-application.h: * shell/ev-history.c: (ev_history_init), (free_links_list), (ev_history_finalize), (ev_history_class_init), (ev_history_add_link), (ev_history_add_page), (ev_history_get_link_nth), (ev_history_get_n_links), (ev_history_get_current_index), (ev_history_set_current_index), (ev_history_new): * shell/ev-history.h: * shell/ev-sidebar-bookmarks.c: (selection_changed_cb): * shell/ev-view.c: (ev_view_finalize), (ev_view_set_document), (set_document_page), (go_to_bookmark), (ev_view_go_to_bookmark), (go_to_index), (ev_view_go_back), (ev_view_go_forward), (ev_view_set_page): * shell/ev-view.h: * shell/ev-window.c: (ev_window_open_bookmark), (ev_window_cmd_go_back), (ev_window_cmd_go_forward), (goto_page_cb), (register_custom_actions): * shell/ev-window.h: Initial history implementation. Needs work.
Diffstat (limited to 'shell/ev-view.c')
-rw-r--r--shell/ev-view.c91
1 files changed, 87 insertions, 4 deletions
diff --git a/shell/ev-view.c b/shell/ev-view.c
index 0848c96..678770b 100644
--- a/shell/ev-view.c
+++ b/shell/ev-view.c
@@ -28,6 +28,7 @@
#include "ev-marshal.h"
#include "ev-view.h"
#include "ev-document-find.h"
+#include "ev-history.h"
#define EV_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EV_TYPE_VIEW, EvViewClass))
#define EV_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EV_TYPE_VIEW))
@@ -52,6 +53,7 @@ struct _EvView {
GtkWidget parent_instance;
EvDocument *document;
+ EvHistory *history;
GdkWindow *bin_window;
@@ -91,7 +93,7 @@ static guint page_changed_signal = 0;
static void ev_view_set_scroll_adjustments (EvView *view,
GtkAdjustment *hadjustment,
GtkAdjustment *vadjustment);
-
+
G_DEFINE_TYPE (EvView, ev_view, GTK_TYPE_WIDGET)
/*** Helper functions ***/
@@ -168,6 +170,9 @@ ev_view_finalize (GObject *object)
if (view->document)
g_object_unref (view->document);
+ if (view->history)
+ g_object_unref (view->history);
+
ev_view_set_scroll_adjustments (view, NULL, NULL);
g_array_free (view->find_results, TRUE);
@@ -900,12 +905,16 @@ ev_view_set_document (EvView *view,
if (old_page != ev_view_get_page (view))
g_signal_emit (view, page_changed_signal, 0);
+
+ if (view->history) {
+ g_object_unref (view->history);
+ }
+ view->history = ev_history_new ();
}
}
-void
-ev_view_set_page (EvView *view,
- int page)
+static void
+set_document_page (EvView *view, int page)
{
if (view->document) {
int old_page = ev_document_get_page (view->document);
@@ -920,6 +929,80 @@ ev_view_set_page (EvView *view,
}
}
+static void
+go_to_bookmark (EvView *view, EvBookmark *bookmark)
+{
+ EvBookmarkType type;
+ int page;
+
+ type = ev_bookmark_get_bookmark_type (bookmark);
+
+ if (type == EV_BOOKMARK_TYPE_LINK) {
+ page = ev_bookmark_get_page (bookmark);
+ set_document_page (view, page);
+ }
+}
+
+void
+ev_view_go_to_bookmark (EvView *view, EvBookmark *bookmark)
+{
+ go_to_bookmark (view, bookmark);
+ ev_history_add_link (view->history, bookmark);
+}
+
+static void
+go_to_index (EvView *view, int index)
+{
+ EvBookmark *bookmark;
+
+ bookmark = ev_history_get_link_nth (view->history, index);
+ g_return_if_fail (bookmark != NULL);
+
+ go_to_bookmark (view, bookmark);
+}
+
+void
+ev_view_go_back (EvView *view)
+{
+ int index;
+
+ g_return_if_fail (EV_IS_HISTORY (view->history));
+
+ index = ev_history_get_current_index (view->history);
+ index = MAX (0, index - 1);
+
+ ev_history_set_current_index (view->history, index);
+ go_to_index (view, index);
+}
+
+void
+ev_view_go_forward (EvView *view)
+{
+ int index, n;
+
+ g_return_if_fail (EV_IS_HISTORY (view->history));
+
+ 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);
+}
+
+
+void
+ev_view_set_page (EvView *view,
+ int page)
+{
+ g_return_if_fail (EV_IS_VIEW (view));
+ g_return_if_fail (EV_IS_HISTORY (view->history));
+
+ set_document_page (view, page);
+ ev_history_add_page (view->history, page);
+}
+
int
ev_view_get_page (EvView *view)
{