Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--browser-plugin/plugin.cpp27
-rw-r--r--browser-plugin/plugin.h3
2 files changed, 30 insertions, 0 deletions
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 <string.h>
#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<void*>(this));
+ g_signal_connect (G_OBJECT (mView),
+ "external-link",
+ G_CALLBACK (Plugin::ExternalLinkCallback),
+ reinterpret_cast<void*>(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<Plugin*> (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<Plugin*> (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);