--- a/src/gtkimhtml.c Thu May 05 09:08:38 2005 -0400
+++ b/src/gtkimhtml.c Thu May 05 14:03:43 2005 -0400
@@ -41,6 +41,7 @@
+#include <gdk/gdkwin32.h> @@ -90,6 +91,7 @@
static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data);
static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data);
static void paste_plaintext_received_cb (GtkClipboard *clipboard, const gchar *text, gpointer data);
+static void imhtml_paste_insert(GtkIMHtml *imhtml, const char *text, gboolean plaintext); /* POINT_SIZE converts from AIM font sizes to a point size scale factor. */
@@ -215,6 +217,80 @@
+static void clipboard_copy_html_win32(GtkIMHtml *imhtml) { + gchar *clipboard = clipboard_html_to_win32(imhtml->clipboard_html_string); + if (clipboard != NULL) { + HWND hwnd = GDK_WINDOW_HWND(GTK_WIDGET(imhtml)->window); + if (OpenClipboard(hwnd)) { + if (EmptyClipboard()) { + gint length = strlen(clipboard); + HGLOBAL hdata = GlobalAlloc(GMEM_MOVEABLE, length); + gchar *buffer = GlobalLock(hdata); + memcpy(buffer, clipboard, length); + if (SetClipboardData(win_html_fmt, hdata) == NULL) { + g_win32_error_message(GetLastError()); + gaim_debug_info("html clipboard", + "Unable to set clipboard data: %s\n", + err_msg ? err_msg : "Unknown Error"); +static gboolean clipboard_paste_html_win32(GtkIMHtml *imhtml) { + gboolean pasted = FALSE; + if (gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml)) + && IsClipboardFormatAvailable(win_html_fmt)) { + gboolean error_reading_clipboard = FALSE; + HWND hwnd = GDK_WINDOW_HWND(GTK_WIDGET(imhtml)->window); + if (OpenClipboard(hwnd)) { + HGLOBAL hdata = GetClipboardData(win_html_fmt); + error_reading_clipboard = TRUE; + char *buffer = GlobalLock(hdata); + error_reading_clipboard = TRUE; + char *text = clipboard_win32_to_html( + imhtml_paste_insert(imhtml, text, + error_reading_clipboard = TRUE; + if (error_reading_clipboard) { + gchar *err_msg = g_win32_error_message(GetLastError()); + gaim_debug_info("html clipboard", + "Unable to read clipboard data: %s\n", + err_msg ? err_msg : "Unknown Error"); @@ -691,20 +767,7 @@
/* We're going to still copy plain text, but let's toss the "HTML Format"
we need into the windows clipboard now as well. */
- gchar *clipboard = clipboard_html_to_win32(imhtml->clipboard_html_string);
- gint length = strlen(clipboard);
- if(clipboard != NULL) {
- hdata = GlobalAlloc(GMEM_MOVEABLE, length);
- buffer = GlobalLock(hdata);
- memcpy(buffer, clipboard, length);
- SetClipboardData(win_html_fmt, hdata);
+ clipboard_copy_html_win32(imhtml); g_signal_stop_emission_by_name(imhtml, "copy-clipboard");
@@ -735,20 +798,7 @@
/* We're going to still copy plain text, but let's toss the "HTML Format"
we need into the windows clipboard now as well. */
- gchar *clipboard = clipboard_html_to_win32(imhtml->clipboard_html_string);
- gint length = strlen(clipboard);
- if(clipboard != NULL) {
- hdata = GlobalAlloc(GMEM_MOVEABLE, length);
- buffer = GlobalLock(hdata);
- memcpy(buffer, clipboard, length);
- SetClipboardData(win_html_fmt, hdata);
+ clipboard_copy_html_win32(imhtml); @@ -851,37 +901,7 @@
/* 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 (!gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml)))
- if (IsClipboardFormatAvailable(win_html_fmt)) {
- hdata = GetClipboardData(win_html_fmt);
- gaim_debug_info("html clipboard", "error number %u! See http://msdn.microsoft.com/library/en-us/debug/base/system_error_codes.asp\n", err);
- buffer = GlobalLock(hdata);
- gaim_debug_info("html clipboard", "error number %u! See http://msdn.microsoft.com/library/en-us/debug/base/system_error_codes.asp\n", err);
- text = clipboard_win32_to_html(buffer);
- imhtml_paste_insert(imhtml, text, FALSE);
+ if (!clipboard_paste_html_win32(imhtml)) { GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD);
gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE),