diff options
author | infirit <[email protected]> | 2014-12-09 12:34:38 +0100 |
---|---|---|
committer | infirit <[email protected]> | 2014-12-09 23:02:27 +0100 |
commit | 2c4ce19338e74f69e3f36f890afdeb9d86a7f87d (patch) | |
tree | 6ee920b11959d8de0af667552caa691f312cee82 | |
parent | b7918f40bd6a2c6b63bca6d4e095194160c08a5b (diff) | |
download | atril-2c4ce19338e74f69e3f36f890afdeb9d86a7f87d.tar.bz2 atril-2c4ce19338e74f69e3f36f890afdeb9d86a7f87d.tar.xz |
[shell] Use new methods to get page and page label from a link
Instead of ev_link_get_page() that doesn't work for named destinations.
Based on evince commits:
eb1c4c8ab5f0a179a3e5836f4540a70859cba106
a5ebb853858e5e2121a35a369d52fc8dd86c92ae
From: Carlos Garcia Campos <[email protected]>
-rw-r--r-- | libdocument/ev-document-links.c | 38 | ||||
-rw-r--r-- | libdocument/ev-document-links.h | 4 | ||||
-rw-r--r-- | shell/ev-sidebar-links.c | 41 |
3 files changed, 64 insertions, 19 deletions
diff --git a/libdocument/ev-document-links.c b/libdocument/ev-document-links.c index 1c8eb03e..bd4afb01 100644 --- a/libdocument/ev-document-links.c +++ b/libdocument/ev-document-links.c @@ -141,3 +141,41 @@ ev_document_links_get_dest_page_label (EvDocumentLinks *document_links, return label; } + +static EvLinkDest * +get_link_dest (EvLink *link) +{ + EvLinkAction *action; + + action = ev_link_get_action (link); + if (!action) + return NULL; + + if (ev_link_action_get_action_type (action) != + EV_LINK_ACTION_TYPE_GOTO_DEST) + return NULL; + + return ev_link_action_get_dest (action); +} + +gint +ev_document_links_get_link_page (EvDocumentLinks *document_links, + EvLink *link) +{ + EvLinkDest *dest; + + dest = get_link_dest (link); + + return dest ? ev_document_links_get_dest_page (document_links, dest) : -1; +} + +gchar * +ev_document_links_get_link_page_label (EvDocumentLinks *document_links, + EvLink *link) +{ + EvLinkDest *dest; + + dest = get_link_dest (link); + + return dest ? ev_document_links_get_dest_page_label (document_links, dest) : NULL; +} diff --git a/libdocument/ev-document-links.h b/libdocument/ev-document-links.h index 75cba6a1..6b561c0e 100644 --- a/libdocument/ev-document-links.h +++ b/libdocument/ev-document-links.h @@ -85,6 +85,10 @@ gint ev_document_links_get_dest_page (EvDocumentLinks *document_ EvLinkDest *dest); gchar *ev_document_links_get_dest_page_label (EvDocumentLinks *document_links, EvLinkDest *dest); +gint ev_document_links_get_link_page (EvDocumentLinks *document_links, + EvLink *link); +gchar *ev_document_links_get_link_page_label (EvDocumentLinks *document_links, + EvLink *link); G_END_DECLS diff --git a/shell/ev-sidebar-links.c b/shell/ev-sidebar-links.c index 4716ac92..c2174e68 100644 --- a/shell/ev-sidebar-links.c +++ b/shell/ev-sidebar-links.c @@ -284,6 +284,7 @@ print_section_cb (GtkWidget *menuitem, EvSidebarLinks *sidebar) if (gtk_tree_selection_get_selected (selection, &model, &iter)) { EvLink *link; int first_page, last_page = -1; + EvDocumentLinks *document_links; gtk_tree_model_get (model, &iter, EV_DOCUMENT_LINKS_COLUMN_LINK, &link, @@ -292,7 +293,9 @@ print_section_cb (GtkWidget *menuitem, EvSidebarLinks *sidebar) if (!link) return; - first_page = ev_link_get_page (link); + document_links = EV_DOCUMENT_LINKS (sidebar->priv->document); + + first_page = ev_document_links_get_link_page (document_links, link); if (first_page == -1) { g_object_unref (link); return; @@ -307,7 +310,7 @@ print_section_cb (GtkWidget *menuitem, EvSidebarLinks *sidebar) -1); if (link) { - last_page = ev_link_get_page (link); + last_page = ev_document_links_get_link_page (document_links, link);; g_object_unref (link); } } else { @@ -453,14 +456,14 @@ ev_sidebar_links_init (EvSidebarLinks *ev_sidebar_links) } static gboolean -fill_page_labels (GtkTreeModel *tree_model, - GtkTreePath *path, - GtkTreeIter *iter, - EvSidebarLinks *sidebar_links) +fill_page_labels (GtkTreeModel *tree_model, + GtkTreePath *path, + GtkTreeIter *iter, + EvSidebarLinks *sidebar_links) { - EvLink *link; - gint page; - gchar *page_label; + EvDocumentLinks *document_links; + EvLink *link; + gchar *page_label; gtk_tree_model_get (tree_model, iter, EV_DOCUMENT_LINKS_COLUMN_LINK, &link, @@ -469,20 +472,18 @@ fill_page_labels (GtkTreeModel *tree_model, if (!link) return FALSE; - page = ev_link_get_page (link); - - if (page < 0) + document_links = EV_DOCUMENT_LINKS (sidebar_links->priv->document); + page_label = ev_document_links_get_link_page_label (document_links, link); + if (!page_label) return FALSE; - - page_label = ev_document_get_page_label (sidebar_links->priv->document, - page); + gtk_tree_store_set (GTK_TREE_STORE (tree_model), iter, - EV_DOCUMENT_LINKS_COLUMN_PAGE_LABEL, page_label, + EV_DOCUMENT_LINKS_COLUMN_PAGE_LABEL, page_label, -1); g_free (page_label); - g_object_unref (link); + return FALSE; } @@ -514,8 +515,9 @@ update_page_callback_foreach (GtkTreeModel *model, if (link) { int current_page; int dest_page; + EvDocumentLinks *document_links = EV_DOCUMENT_LINKS (sidebar_links->priv->document); - dest_page = ev_link_get_page (link); + dest_page = ev_document_links_get_link_page (document_links, link); g_object_unref (link); current_page = ev_document_model_get_page (sidebar_links->priv->doc_model); @@ -555,8 +557,9 @@ ev_sidebar_links_set_current_page (EvSidebarLinks *sidebar_links, -1); if (link) { gint dest_page; + EvDocumentLinks *document_links = EV_DOCUMENT_LINKS (sidebar_links->priv->document); - dest_page = ev_link_get_page (link); + dest_page = ev_document_links_get_link_page (document_links, link); g_object_unref (link); if (dest_page == current_page) |