pidgin: f58ff650: I think this works around the problem wi...
datallah at pidgin.im
datallah at pidgin.im
Wed Mar 10 09:42:21 EST 2010
-----------------------------------------------------------------
Revision: f58ff650d986dbea2feedcfc103e1737994d45fe
Ancestor: a9876c2b74baddb4b0fd99eede7daef1d346604b
Author: datallah at pidgin.im
Date: 2010-03-10T14:35:56
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/f58ff650d986dbea2feedcfc103e1737994d45fe
Modified files:
pidgin/gtkimhtml.c
ChangeLog:
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
The problem appears to be that GTK+ doesn't choose the right (newest) clipboard
contents when there are multiple available. The scenario I've seen is that I
have a plain text clipboard that is newer than what was copied into a HTML
clipboard, but the HTML is pasted instead of the plain text.
(it is actually more complicated than that)
-------------- next part --------------
============================================================
--- pidgin/gtkimhtml.c f8000b0122ce33b10116b68fd8fc37599a4ad572
+++ pidgin/gtkimhtml.c d84b3f6d60897bd416858137f6a4c66e16a409d4
@@ -191,7 +191,7 @@ clipboard_win32_to_html(char *clipboard)
purple_debug_info("imhtml clipboard", "from clipboard: %s\n", clipboard);
- fd = g_fopen("e:\\purplecb.txt", "wb");
+ fd = g_fopen("c:\\purplecb.txt", "wb");
fprintf(fd, "%s", clipboard);
fclose(fd);
#endif
@@ -1188,6 +1188,14 @@ static void paste_received_cb (GtkClipbo
memcpy(text, selection_data->data, selection_data->length);
}
+#ifdef _WIN32
+ if (gtk_selection_data_get_data_type(selection_data) == gdk_atom_intern("HTML Format", FALSE)) {
+ char *tmp = clipboard_win32_to_html(text);
+ g_free(text);
+ text = tmp;
+ }
+#endif
+
if (selection_data->length >= 2 &&
(*(guint16 *)text == 0xfeff || *(guint16 *)text == 0xfffe)) {
/* This is UTF-16 */
@@ -1247,13 +1255,16 @@ static void paste_clipboard_cb(GtkIMHtml
#ifdef _WIN32
/* If we're on windows, let's see if we can get data from the HTML Format
clipboard before we try to paste from the GTK buffer */
- if (!clipboard_paste_html_win32(imhtml))
-#endif
- {
+ if (!clipboard_paste_html_win32(imhtml)) {
+ GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD);
+ gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml);
+
+ }
+#else
GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD);
gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE),
paste_received_cb, imhtml);
- }
+#endif
g_signal_stop_emission_by_name(imhtml, "paste-clipboard");
}
@@ -1679,8 +1690,10 @@ static void gtk_imhtml_init (GtkIMHtml *
g_signal_connect_after(G_OBJECT(imhtml), "realize", G_CALLBACK(imhtml_realized_remove_primary), NULL);
g_signal_connect(G_OBJECT(imhtml), "unrealize", G_CALLBACK(imhtml_destroy_add_primary), NULL);
+#ifndef _WIN32
g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set",
G_CALLBACK(mark_set_so_update_selection_cb), imhtml);
+#endif
gtk_widget_add_events(GTK_WIDGET(imhtml),
GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK);
More information about the Commits
mailing list