GDKSplashOutputDev *out;
PSOutputDev *ps_out;
PDFDoc *doc;
+ Links *links;
UnicodeMap *umap;
gboolean page_valid;
pdf_document_find_iface_init);
});
+static void
+document_init_links (PdfDocument *pdf_document)
+{
+ Page *page;
+ Object obj;
+
+ if (pdf_document->links) {
+ delete pdf_document->links;
+ }
+ page = pdf_document->doc->getCatalog ()->getPage (pdf_document->page);
+ pdf_document->links = new Links (page->getAnnots (&obj),
+ pdf_document->doc->getCatalog ()->getBaseURI ());
+ obj.free ();
+}
+
static gboolean
document_validate_page (PdfDocument *pdf_document)
{
72 * pdf_document->scale,
0, gTrue, gTrue);
+ document_init_links (pdf_document);
+
pdf_document->page_valid = TRUE;
/* Update the search results available to the app since
return (EvDocumentLinksIter *) iter;
}
-/* FIXME This returns a new object every time, probably we should cache it
- in the iter */
static EvLink *
-pdf_document_links_get_link (EvDocumentLinks *document_links,
- EvDocumentLinksIter *links_iter)
+build_link_from_action (PdfDocument *pdf_document,
+ LinkAction *link_action,
+ const char *title)
{
- PdfDocument *pdf_document = PDF_DOCUMENT (document_links);
EvLink *link = NULL;
- LinksIter *iter = (LinksIter *)links_iter;
- OutlineItem *anItem;
- LinkAction *link_action;
- Unicode *link_title;
- const char *title;
-
- g_return_val_if_fail (PDF_IS_DOCUMENT (document_links), FALSE);
- g_return_val_if_fail (iter != NULL, FALSE);
-
- anItem = (OutlineItem *)iter->items->get(iter->index);
- link_action = anItem->getAction ();
- link_title = anItem->getTitle ();
- title = unicode_to_char (anItem, pdf_document->umap);
if (link_action == NULL) {
link = ev_link_new_title (title);
return link;
}
+/* FIXME This returns a new object every time, probably we should cache it
+ in the iter */
+static EvLink *
+pdf_document_links_get_link (EvDocumentLinks *document_links,
+ EvDocumentLinksIter *links_iter)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document_links);
+ LinksIter *iter = (LinksIter *)links_iter;
+ OutlineItem *anItem;
+ LinkAction *link_action;
+ Unicode *link_title;
+ const char *title;
+
+ g_return_val_if_fail (PDF_IS_DOCUMENT (document_links), FALSE);
+ g_return_val_if_fail (iter != NULL, FALSE);
+
+ anItem = (OutlineItem *)iter->items->get(iter->index);
+ link_action = anItem->getAction ();
+ link_title = anItem->getTitle ();
+ title = unicode_to_char (anItem, pdf_document->umap);
+
+ return build_link_from_action (pdf_document, link_action, title);
+}
+
static EvDocumentLinksIter *
pdf_document_links_get_child (EvDocumentLinks *document_links,
- EvDocumentLinksIter *links_iter)
+ EvDocumentLinksIter *links_iter)
{
LinksIter *iter = (LinksIter *)links_iter;
LinksIter *child_iter;
static gboolean
pdf_document_links_next (EvDocumentLinks *document_links,
- EvDocumentLinksIter *links_iter)
+ EvDocumentLinksIter *links_iter)
{
LinksIter *iter = (LinksIter *) links_iter;
static void
pdf_document_links_free_iter (EvDocumentLinks *document_links,
- EvDocumentLinksIter *iter)
+ EvDocumentLinksIter *iter)
{
g_return_if_fail (PDF_IS_DOCUMENT (document_links));
g_return_if_fail (iter != NULL);
{
PdfDocument *pdf_document = PDF_DOCUMENT (object);
+ if (pdf_document->links) {
+ delete pdf_document->links;
+ }
+
if (pdf_document->umap) {
pdf_document->umap->decRefCnt ();
pdf_document->umap = NULL;
return text ? g_strdup (text) : NULL;
}
+static EvLink *
+pdf_document_get_link (EvDocument *document, int x, int y)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document);
+ LinkAction *action;
+
+ action = pdf_document->links->find (x, y);
+ if (action) {
+ return build_link_from_action (pdf_document, action, "");
+ } else {
+ return NULL;
+ }
+}
+
static void
pdf_document_get_property (GObject *object,
guint prop_id,
iface->load = pdf_document_load;
iface->save = pdf_document_save;
iface->get_text = pdf_document_get_text;
+ iface->get_link = pdf_document_get_link;
iface->get_n_pages = pdf_document_get_n_pages;
iface->set_page = pdf_document_set_page;
iface->get_page = pdf_document_get_page;
the_page = pdf_document->doc->getCatalog ()->getPage (page + 1);
the_page->getThumb (&the_thumb);
-
-
if (!(the_thumb.isNull () || the_thumb.isNone())) {
/* Build the thumbnail object */
thumb = new Thumb(pdf_document->doc->getXRef (),
#include <gtk/gtkselection.h>
#include <gtk/gtkclipboard.h>
#include <gdk/gdkkeysyms.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
#include "ev-marshal.h"
#include "ev-view.h"
{
EvView *view = EV_VIEW (widget);
- ev_view_update_primary_selection (view);
+ if (view->has_selection) {
+ ev_view_update_primary_selection (view);
+ } else {
+ EvLink *link;
+
+ link = ev_document_get_link (view->document,
+ event->x,
+ event->y);
+ if (link) {
+ ev_view_go_to_link (view, link);
+ g_object_unref (link);
+ }
+ }
return FALSE;
}
go_to_link (EvView *view, EvLink *link)
{
EvLinkType type;
+ const char *uri;
int page;
type = ev_link_get_link_type (link);
-
- if (type == EV_LINK_TYPE_PAGE) {
- page = ev_link_get_page (link);
- set_document_page (view, page);
+
+ switch (type) {
+ case EV_LINK_TYPE_TITLE:
+ break;
+ case EV_LINK_TYPE_PAGE:
+ page = ev_link_get_page (link);
+ set_document_page (view, page);
+ break;
+ case EV_LINK_TYPE_EXTERNAL_URI:
+ uri = ev_link_get_uri (link);
+ gnome_vfs_url_show (uri);
+ break;
}
}
void
ev_view_go_to_link (EvView *view, EvLink *link)
{
+ EvLinkType type;
+
go_to_link (view, link);
- ev_history_add_link (view->history, link);
+
+ type = ev_link_get_link_type (link);
+ if (type == EV_LINK_TYPE_PAGE) {
+ ev_history_add_link (view->history, link);
+ }
}
static void