Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ev-document-links.c
Go to the documentation of this file.
1 /* ev-document-links.h
2  * this file is part of evince, a gnome document_links viewer
3  *
4  * Copyright (C) 2004 Red Hat, Inc.
5  *
6  * Author:
7  * Jonathan Blandford <jrb@alum.mit.edu>
8  *
9  * Evince is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Evince is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22  */
23 
24 #include "config.h"
25 
26 #include "ev-document-links.h"
27 
28 G_DEFINE_INTERFACE (EvDocumentLinks, ev_document_links, 0)
29 
30 static void
32 {
33 }
34 
35 gboolean
37 {
38  EvDocumentLinksInterface *iface = EV_DOCUMENT_LINKS_GET_IFACE (document_links);
39  gboolean retval;
40 
41  retval = iface->has_document_links (document_links);
42 
43  return retval;
44 }
45 
52 GtkTreeModel *
54 {
55  EvDocumentLinksInterface *iface = EV_DOCUMENT_LINKS_GET_IFACE (document_links);
56  GtkTreeModel *retval;
57 
58  retval = iface->get_links_model (document_links);
59 
60  return retval;
61 }
62 
65  EvPage *page)
66 {
67  EvDocumentLinksInterface *iface = EV_DOCUMENT_LINKS_GET_IFACE (document_links);
68 
69  return iface->get_links (document_links, page);
70 }
71 
79 EvLinkDest *
81  const gchar *link_name)
82 {
83  EvDocumentLinksInterface *iface = EV_DOCUMENT_LINKS_GET_IFACE (document_links);
84  EvLinkDest *retval;
85 
87  retval = iface->find_link_dest (document_links, link_name);
89 
90  return retval;
91 }
92 
93 gint
95  const gchar *link_name)
96 {
97  EvDocumentLinksInterface *iface = EV_DOCUMENT_LINKS_GET_IFACE (document_links);
98  gint retval;
99 
101  retval = iface->find_link_page (document_links, link_name);
103 
104  return retval;
105 }
106 
107 /* Helper functions */
108 gint
110  EvLinkDest *dest)
111 {
112  gint page = -1;
113 
114  switch (ev_link_dest_get_dest_type (dest)) {
116  page = ev_document_links_find_link_page (document_links,
118  }
119  break;
123  &page);
124  break;
125  default:
126  page = ev_link_dest_get_page (dest);
127  }
128 
129  return page;
130 }
131 
132 gchar *
134  EvLinkDest *dest)
135 {
136  gchar *label = NULL;
137 
139  label = g_strdup (ev_link_dest_get_page_label (dest));
140  } else {
141  gint page;
142 
143  page = ev_document_links_get_dest_page (document_links, dest);
144  if (page != -1)
145  label = ev_document_get_page_label (EV_DOCUMENT (document_links),
146  page);
147  }
148 
149  return label;
150 }
151 
152 static EvLinkDest *
154 {
155  EvLinkAction *action;
156 
157  action = ev_link_get_action (link);
158  if (!action)
159  return NULL;
160 
161  if (ev_link_action_get_action_type (action) !=
163  return NULL;
164 
165  return ev_link_action_get_dest (action);
166 }
167 
168 gint
170  EvLink *link)
171 {
172  EvLinkDest *dest;
173 
174  dest = get_link_dest (link);
175 
176  return dest ? ev_document_links_get_dest_page (document_links, dest) : -1;
177 }
178 
179 gchar *
181  EvLink *link)
182 {
183  EvLinkDest *dest;
184 
185  dest = get_link_dest (link);
186 
187  return dest ? ev_document_links_get_dest_page_label (document_links, dest) : NULL;
188 }