Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/ev-window.c
diff options
context:
space:
mode:
authorNickolay V. Shmyrev <nshmyrev@yandex.ru>2007-01-28 20:43:21 (GMT)
committer Nickolay V. Shmyrev <nshmyrev@src.gnome.org>2007-01-28 20:43:21 (GMT)
commit4bb9bc83e2de5cd88fa2e3f81a7da6e7d81cbf99 (patch)
tree383ed65fe7f662c84084859ec42a655a1772f058 /shell/ev-window.c
parent40bdbed8a127356fadf9790aa0b479854c1c1d22 (diff)
Implements another history variant
2007-01-28 Nickolay V. Shmyrev <nshmyrev@yandex.ru> * NOTES: * backend/djvu/djvu-links.c: (djvu_links_get_links_model): * backend/pdf/ev-poppler.cc: * libdocument/ev-document-links.h: * libdocument/ev-link.c: (ev_link_get_page): * libdocument/ev-link.h: * shell/ev-history.c: (ev_history_init), (ev_history_class_init), (ev_history_add_link): * shell/ev-history.h: * shell/ev-navigation-action.c: (activate_menu_item_cb), (new_history_menu_item), (build_menu): * shell/ev-page-cache.c: (ev_page_cache_set_current_page_history): * shell/ev-sidebar-links.c: (create_loading_model), (print_section_cb), (ev_sidebar_links_construct), (fill_page_labels), (update_page_callback_foreach), (update_page_callback), (job_finished_callback): * shell/ev-view.c: (ev_view_handle_link): * shell/ev-window.c: (ev_window_find_chapter), (ev_window_add_history), (view_handle_link_cb), (history_changed_cb): Implements another history variant svn path=/trunk/; revision=2264
Diffstat (limited to 'shell/ev-window.c')
-rw-r--r--shell/ev-window.c118
1 files changed, 102 insertions, 16 deletions
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 8e414a5..1680b42 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -643,13 +643,112 @@ page_changed_cb (EvPageCache *page_cache,
if (!ev_window_is_empty (ev_window))
ev_metadata_manager_set_int (ev_window->priv->uri, "page", page);
}
+
+typedef struct _FindTask {
+ gchar *page_label;
+ gchar *chapter;
+} FindTask;
+
+static gboolean
+ev_window_find_chapter (GtkTreeModel *tree_model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ FindTask *task = (FindTask *)data;
+ gchar *page_string;
+
+ gtk_tree_model_get (tree_model, iter,
+ EV_DOCUMENT_LINKS_COLUMN_PAGE_LABEL, &page_string,
+ -1);
+
+ if (!page_string)
+ return FALSE;
+
+ if (!strncmp (page_string + strlen ("<i>"), task->page_label, strlen (task->page_label))) {
+ gtk_tree_model_get (tree_model, iter,
+ EV_DOCUMENT_LINKS_COLUMN_MARKUP, &task->chapter,
+ -1);
+ g_free (page_string);
+ return TRUE;
+ }
+
+ g_free (page_string);
+ return FALSE;
+}
+
+static void
+ev_window_add_history (EvWindow *window, gint page, EvLink *link)
+{
+ gchar *page_label;
+ gchar *link_title;
+ FindTask find_task;
+
+ EvLink *real_link;
+ EvLinkAction *action;
+ EvLinkDest *dest;
+
+ if (link) {
+ action = g_object_ref (ev_link_get_action (link));
+ dest = ev_link_action_get_dest (action);
+ page = ev_link_dest_get_page (dest);
+ } else {
+ dest = ev_link_dest_new_page (page);
+ action = ev_link_action_new_dest (dest);
+ }
+
+ if (page < 0)
+ return;
+
+ page_label = ev_page_cache_get_page_label (window->priv->page_cache, page);
+
+ find_task.page_label = page_label;
+ find_task.chapter = NULL;
+
+ if (EV_IS_DOCUMENT_LINKS (window->priv->document)) {
+ GtkTreeModel *model;
+
+ g_object_get (G_OBJECT (window->priv->sidebar_links), "model", &model, NULL);
+
+ gtk_tree_model_foreach (model,
+ ev_window_find_chapter,
+ &find_task);
+
+ g_object_unref (model);
+ }
+
+ if (find_task.chapter)
+ link_title = g_strdup_printf (_("Page %s - %s"), page_label, find_task.chapter);
+ else
+ link_title = g_strdup_printf (_("Page %s"), page_label);
+
+ real_link = ev_link_new (link_title, action);
+
+ ev_history_add_link (window->priv->history, real_link);
+
+ g_free (link_title);
+ g_object_unref (real_link);
+}
+
+static void
+view_handle_link_cb (EvView *view, EvLink *link, EvWindow *window)
+{
+ int current_page = ev_page_cache_get_current_page (window->priv->page_cache);
+
+ ev_window_add_history (window, 0, link);
+ ev_window_add_history (window, current_page, NULL);
+}
+
static void
history_changed_cb (EvPageCache *page_cache,
gint page,
- EvWindow *ev_window)
+ EvWindow *window)
{
- ev_history_add_page (ev_window->priv->history, page,
- ev_page_cache_get_page_label (ev_window->priv->page_cache, page));
+ int current_page = ev_page_cache_get_current_page (window->priv->page_cache);
+
+ ev_window_add_history (window, page, NULL);
+ ev_window_add_history (window, current_page, NULL);
+
return;
}
@@ -4045,11 +4144,7 @@ static void
navigation_action_activate_link_cb (EvNavigationAction *action, EvLink *link, EvWindow *window)
{
- g_signal_handlers_block_by_func
- (window->priv->view, G_CALLBACK (view_handle_link_cb), window);
ev_view_handle_link (EV_VIEW (window->priv->view), link);
- g_signal_handlers_unblock_by_func
- (window->priv->view, G_CALLBACK (view_handle_link_cb), window);
gtk_widget_grab_focus (window->priv->view);
}
@@ -4338,15 +4433,6 @@ do_action_named (EvWindow *window, EvLinkAction *action)
}
static void
-view_handle_link_cb (EvView *view, EvLink *link, EvWindow *window)
-{
- int current_page = ev_page_cache_get_current_page (window->priv->page_cache);
- ev_history_add_page (window->priv->history,
- current_page,
- ev_page_cache_get_page_label (window->priv->page_cache, current_page));
-}
-
-static void
view_external_link_cb (EvView *view, EvLinkAction *action, EvWindow *window)
{
switch (ev_link_action_get_action_type (action)) {