Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
Main Page
Related Pages
Data Structures
Files
File List
Globals
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
31
ev_document_links_default_init
(
EvDocumentLinksInterface
*klass)
32
{
33
}
34
35
gboolean
36
ev_document_links_has_document_links
(
EvDocumentLinks
*document_links)
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 *
53
ev_document_links_get_links_model
(
EvDocumentLinks
*document_links)
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
63
EvMappingList
*
64
ev_document_links_get_links
(
EvDocumentLinks
*document_links,
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
*
80
ev_document_links_find_link_dest
(
EvDocumentLinks
*document_links,
81
const
gchar *link_name)
82
{
83
EvDocumentLinksInterface
*iface =
EV_DOCUMENT_LINKS_GET_IFACE
(document_links);
84
EvLinkDest
*retval;
85
86
ev_document_doc_mutex_lock
();
87
retval = iface->
find_link_dest
(document_links, link_name);
88
ev_document_doc_mutex_unlock
();
89
90
return
retval;
91
}
92
93
gint
94
ev_document_links_find_link_page
(
EvDocumentLinks
*document_links,
95
const
gchar *link_name)
96
{
97
EvDocumentLinksInterface
*iface =
EV_DOCUMENT_LINKS_GET_IFACE
(document_links);
98
gint retval;
99
100
ev_document_doc_mutex_lock
();
101
retval = iface->
find_link_page
(document_links, link_name);
102
ev_document_doc_mutex_unlock
();
103
104
return
retval;
105
}
106
107
/* Helper functions */
108
gint
109
ev_document_links_get_dest_page
(
EvDocumentLinks
*document_links,
110
EvLinkDest
*dest)
111
{
112
gint page = -1;
113
114
switch
(
ev_link_dest_get_dest_type
(dest)) {
115
case
EV_LINK_DEST_TYPE_NAMED
: {
116
page =
ev_document_links_find_link_page
(document_links,
117
ev_link_dest_get_named_dest
(dest));
118
}
119
break
;
120
case
EV_LINK_DEST_TYPE_PAGE_LABEL
:
121
ev_document_find_page_by_label
(
EV_DOCUMENT
(document_links),
122
ev_link_dest_get_page_label
(dest),
123
&page);
124
break
;
125
default
:
126
page =
ev_link_dest_get_page
(dest);
127
}
128
129
return
page;
130
}
131
132
gchar *
133
ev_document_links_get_dest_page_label
(
EvDocumentLinks
*document_links,
134
EvLinkDest
*dest)
135
{
136
gchar *
label
= NULL;
137
138
if
(
ev_link_dest_get_dest_type
(dest) ==
EV_LINK_DEST_TYPE_PAGE_LABEL
) {
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
*
153
get_link_dest
(
EvLink
*link)
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) !=
162
EV_LINK_ACTION_TYPE_GOTO_DEST
)
163
return
NULL;
164
165
return
ev_link_action_get_dest
(action);
166
}
167
168
gint
169
ev_document_links_get_link_page
(
EvDocumentLinks
*document_links,
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 *
180
ev_document_links_get_link_page_label
(
EvDocumentLinks
*document_links,
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
}
evince-master
libdocument
ev-document-links.c
Generated on Thu Jul 13 2017 13:41:45 for Evince by
1.8.4