aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--src/ephy-tab.c43
2 files changed, 47 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index ee427455c..52cde5d53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
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.
+
+2004-02-09 Christian Persch <chpe@cvs.gnome.org>
+
* lib/egg/egg-editable-toolbar.c:
* embed/ephy-embed-popup-control.c:
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