From fee432432d60afeffd046c7d7580702bf495ebcc Mon Sep 17 00:00:00 2001 From: James Willcox Date: Wed, 12 Aug 2009 14:59:08 +0000 Subject: Follow external links in browser plugin, fixes bug 1392 --- diff --git a/browser-plugin/plugin.cpp b/browser-plugin/plugin.cpp index 6dcbb35..ffdc767 100644 --- a/browser-plugin/plugin.cpp +++ b/browser-plugin/plugin.cpp @@ -18,6 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ +#include #include "evince-view.h" #include "plugin.h" #include "scriptable.h" @@ -35,6 +36,12 @@ Plugin::Plugin (NPP instance) : mInstance (instance), G_CALLBACK (Plugin::SizingModeCallback), reinterpret_cast(this)); + g_signal_connect (G_OBJECT (mView), + "external-link", + G_CALLBACK (Plugin::ExternalLinkCallback), + reinterpret_cast(this)); + + /* FIXME should be set automatically in EvView. It seem to be currently used only to calculate the minimum and maximux allowed zoom level. */ ev_view_set_screen_dpi (EV_VIEW(mView), 96); @@ -189,6 +196,26 @@ Plugin::SizingModeCallback (EvView *view, GParamSpec *pspec, gpointer data) } void +Plugin::ExternalLinkCallback (EvView *view, EvLinkAction *action, gpointer data) +{ + Plugin *plugin = reinterpret_cast (data); + const char *uri = NULL; + + switch (ev_link_action_get_action_type (action)) { + case EV_LINK_ACTION_TYPE_EXTERNAL_URI: + uri = ev_link_action_get_uri (action); + + if (g_strstr_len (uri, strlen (uri), "http")) { + NPN_GetURL (plugin->mInstance, uri, "_blank"); + } + + break; + default: + break; + } +} + +void Plugin::LoadJobFinishedCallback (EvJob *job, gpointer data) { Plugin *plugin = reinterpret_cast (data); diff --git a/browser-plugin/plugin.h b/browser-plugin/plugin.h index a4cd560..5802aab 100644 --- a/browser-plugin/plugin.h +++ b/browser-plugin/plugin.h @@ -47,6 +47,9 @@ class Plugin { static void SizingModeCallback (EvView *view, GParamSpec *pspec, gpointer data); + static void ExternalLinkCallback (EvView *view, + EvLinkAction *action, + gpointer data); static void LoadJobFinishedCallback (EvJob *job, gpointer data); -- cgit v0.9.1