aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-tab.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-02-10 02:55:54 +0800
committerChristian Persch <chpe@src.gnome.org>2004-02-10 02:55:54 +0800
commitd21bdb01f4f21037840f8482458a8ca05b2ea4c3 (patch)
treef5f9a2017970e0d1af49840ecf7377c3436472a4 /src/ephy-tab.c
parentac0caa804c62ab537c47edd30eed00f67b6e5b41 (diff)
downloadgsoc2013-epiphany-d21bdb01f4f21037840f8482458a8ca05b2ea4c3.tar
gsoc2013-epiphany-d21bdb01f4f21037840f8482458a8ca05b2ea4c3.tar.gz
gsoc2013-epiphany-d21bdb01f4f21037840f8482458a8ca05b2ea4c3.tar.bz2
gsoc2013-epiphany-d21bdb01f4f21037840f8482458a8ca05b2ea4c3.tar.lz
gsoc2013-epiphany-d21bdb01f4f21037840f8482458a8ca05b2ea4c3.tar.xz
gsoc2013-epiphany-d21bdb01f4f21037840f8482458a8ca05b2ea4c3.tar.zst
gsoc2013-epiphany-d21bdb01f4f21037840f8482458a8ca05b2ea4c3.zip
Fix the fix for the epiphany equivalent of bug #133633. Don't convert the
2004-02-09 Christian Persch <chpe@cvs.gnome.org> * src/ephy-tab.c: (clipboard_text_received_cb), (ephy_tab_dom_mouse_click_cb): Fix the fix for the epiphany equivalent of bug #133633. Don't convert the clipboard contents directly as the souurce may not offer UTF-8 text. Instead request the contents, and gtk+ will convert it for us.
Diffstat (limited to 'src/ephy-tab.c')
-rw-r--r--src/ephy-tab.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 260d58828..d05b882fa 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -54,6 +54,7 @@
#include <gtk/gtkmenu.h>
#include <gtk/gtkuimanager.h>
#include <gtk/gtkradioaction.h>
+#include <gtk/gtkclipboard.h>
#include <string.h>
#define EPHY_TAB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_TAB, EphyTabPrivate))
@@ -1008,6 +1009,27 @@ save_property_url (EphyEmbed *embed,
g_object_unref (G_OBJECT(persist));
}
+static void
+clipboard_text_received_cb (GtkClipboard *clipboard,
+ const char *text,
+ gpointer *weak_ptr)
+{
+ if (*weak_ptr != NULL && text != NULL)
+ {
+ EphyTab *tab = (EphyTab *) *weak_ptr;
+ EphyEmbed *embed = ephy_tab_get_embed (tab);
+
+ ephy_embed_load_url (embed, text);
+ }
+
+ if (*weak_ptr != NULL)
+ {
+ g_object_remove_weak_pointer (G_OBJECT (*weak_ptr), weak_ptr);
+ }
+
+ g_free (weak_ptr);
+}
+
static gboolean
ephy_tab_dom_mouse_click_cb (EphyEmbed *embed,
EphyEmbedEvent *event,
@@ -1076,11 +1098,22 @@ ephy_tab_dom_mouse_click_cb (EphyEmbed *embed,
/* middle click opens the selection url */
else if (is_middle_clickable && is_middle_click && middle_click_opens)
{
- gtk_selection_convert (GTK_WIDGET (window),
- GDK_SELECTION_PRIMARY,
- /* See bug #133633 */
- gdk_atom_intern ("UTF8_STRING", FALSE),
- GDK_CURRENT_TIME);
+ /* See bug #133633 for why we do it this way */
+
+ /* We need to make sure we know if the tab is destroyed between
+ * requesting the clipboard contents, and receiving them.
+ */
+ gpointer *weak_ptr;
+
+ weak_ptr = g_new (gpointer, 1);
+ *weak_ptr = tab;
+ g_object_add_weak_pointer (G_OBJECT (tab), weak_ptr);
+
+ gtk_clipboard_request_text
+ (gtk_widget_get_clipboard (GTK_WIDGET (tab->priv->embed),
+ GDK_SELECTION_PRIMARY),
+ (GtkClipboardTextReceivedFunc) clipboard_text_received_cb,
+ weak_ptr);
}
/* we didn't handle the event */
else