summaryrefslogtreecommitdiff
path: root/backend/djvu/djvu-links.c
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-12-09 12:44:15 +0100
committerinfirit <[email protected]>2014-12-09 23:02:27 +0100
commit21b6463cd687edfbf40bbb6df1cca239d7a6b925 (patch)
tree1e4362ae5085e6a5d1a2092c41884f7617181e84 /backend/djvu/djvu-links.c
parent07ac65d00384adeec314e677a66a5bb2dcb90cd0 (diff)
downloadatril-21b6463cd687edfbf40bbb6df1cca239d7a6b925.tar.bz2
atril-21b6463cd687edfbf40bbb6df1cca239d7a6b925.tar.xz
[djvu] Implement document_links_find_link_page()
Taken from evince commit: 4f13859ce0aa0918a5c6a0a24686d97ffd7d2ee2 From: Carlos Garcia Campos <[email protected]>
Diffstat (limited to 'backend/djvu/djvu-links.c')
-rw-r--r--backend/djvu/djvu-links.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/backend/djvu/djvu-links.c b/backend/djvu/djvu-links.c
index c5e72870..5999ebcd 100644
--- a/backend/djvu/djvu-links.c
+++ b/backend/djvu/djvu-links.c
@@ -60,8 +60,8 @@ static gboolean number_from_string_10(const gchar *str, guint64 *number)
}
}
-static EvLinkDest *
-get_djvu_link_dest (const DjvuDocument *djvu_document, const gchar *link_name, int base_page)
+static guint64
+get_djvu_link_page (const DjvuDocument *djvu_document, const gchar *link_name, int base_page)
{
guint64 page_num = 0;
@@ -69,22 +69,28 @@ get_djvu_link_dest (const DjvuDocument *djvu_document, const gchar *link_name, i
if (g_str_has_prefix (link_name, "#")) {
if (base_page > 0 && g_str_has_prefix (link_name+1, "+")) {
if (number_from_string_10 (link_name + 2, &page_num)) {
- return ev_link_dest_new_page (base_page + page_num);
+ return base_page + page_num;
}
} else if (base_page > 0 && g_str_has_prefix (link_name+1, "-")) {
if (number_from_string_10 (link_name + 2, &page_num)) {
- return ev_link_dest_new_page (base_page - page_num);
+ return base_page - page_num;
}
} else {
if (number_from_string_10 (link_name + 1, &page_num)) {
- return ev_link_dest_new_page (page_num - 1);
+ return page_num - 1;
}
}
} else {
/* FIXME: component file identifiers */
}
- return NULL;
+ return page_num;
+}
+
+static EvLinkDest *
+get_djvu_link_dest (const DjvuDocument *djvu_document, const gchar *link_name, int base_page)
+{
+ return ev_link_dest_new_page (get_djvu_link_page (djvu_document, link_name, base_page));
}
static EvLinkAction *
@@ -409,6 +415,22 @@ djvu_links_find_link_dest (EvDocumentLinks *document_links,
return ev_dest;
}
+gint
+djvu_links_find_link_page (EvDocumentLinks *document_links,
+ const gchar *link_name)
+{
+ DjvuDocument *djvu_document = DJVU_DOCUMENT (document_links);
+ gint page;
+
+ page = get_djvu_link_page (djvu_document, link_name, -1);
+
+ if (page == -1) {
+ g_warning ("DjvuLibre error: unknown link destination %s", link_name);
+ }
+
+ return page;
+}
+
GtkTreeModel *
djvu_links_get_links_model (EvDocumentLinks *document_links)
{