From 84cc52bd4fd197ec4aad845d9b09bcd5b74453d5 Mon Sep 17 00:00:00 2001 From: Tommi Komulainen Date: Tue, 25 Aug 2009 16:04:59 +0000 Subject: browser-plugin: add clipboard copy support Only supporting copy, evince doesn't support editing (at least the API is lacking cut and paste) Using property access workaround. Example: if (plugin.canCopy) { plugin.canCopy = 42; (workaround) copy selection to clipboard } --- (limited to 'browser-plugin/plugin.cpp') diff --git a/browser-plugin/plugin.cpp b/browser-plugin/plugin.cpp index 7d79100..88893c8 100644 --- a/browser-plugin/plugin.cpp +++ b/browser-plugin/plugin.cpp @@ -27,7 +27,8 @@ Plugin::Plugin (NPP instance) : mInstance (instance), mScriptableObject (0), mWindow (0), mLoadJob (0), - mTitle (0) + mTitle (0), + mHasSelection (false) { mScrolledWindow = gtk_scrolled_window_new (NULL, NULL); @@ -36,6 +37,10 @@ Plugin::Plugin (NPP instance) : mInstance (instance), "notify::sizing-mode", G_CALLBACK (Plugin::SizingModeCallback), reinterpret_cast(this)); + g_signal_connect (G_OBJECT (mView), + "notify::has-selection", + G_CALLBACK (Plugin::HasSelectionCallback), + reinterpret_cast(this)); g_signal_connect (G_OBJECT (mView), "external-link", @@ -103,6 +108,12 @@ Plugin::FindPrevious (const char *text) } void +Plugin::CopyClipboard () +{ + ev_view_copy (EV_VIEW (mView)); +} + +void Plugin::SetWindow (GdkNativeWindow window) { if (mWindow != 0) { @@ -226,6 +237,19 @@ Plugin::SizingModeCallback (EvView *view, GParamSpec *pspec, gpointer data) } void +Plugin::HasSelectionCallback (EvView *view, GParamSpec *pspec, gpointer data) +{ + Plugin *plugin = reinterpret_cast (data); + + gboolean has_selection = ev_view_get_has_selection (view); + + if (has_selection != plugin->mHasSelection) { + plugin->mHasSelection = has_selection; + plugin->CallBrowser ("onClipboardChanged"); + } +} + +void Plugin::ExternalLinkCallback (EvView *view, EvLinkAction *action, gpointer data) { Plugin *plugin = reinterpret_cast (data); -- cgit v0.9.1