From c014ad39084a87982e716626ad8026d2801cfb95 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Thu, 5 Apr 2018 14:38:38 -0300 Subject: [PATCH] Modificando tratamento do clipboard em windows para identificar falha no processo de "paste" --- selection.c | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/selection.c b/selection.c index d2d836e..d636bbf 100644 --- a/selection.c +++ b/selection.c @@ -346,6 +346,47 @@ void v3270_copy(GtkWidget *widget, V3270_SELECT_FORMAT mode, gboolean cut) update_system_clipboard(widget); } +#ifdef _WIN32 + +void v3270_paste(GtkWidget *widget) +{ + HGLOBAL hglb; + + if (!IsClipboardFormatAvailable(CF_TEXT)) + return; + + if (!OpenClipboard(NULL)) + return; + + hglb = GetClipboardData(CF_TEXT); + if (hglb != NULL) + { + LPTSTR lptstr = GlobalLock(hglb); + if (lptstr != NULL) + { + v3270_paste_string(widget,lptstr,"CP1252"); + GlobalUnlock(hglb); + } + } + + CloseClipboard(); + +} + +#else + +static void text_received(GtkClipboard *clipboard, const gchar *text, GtkWidget *widget) +{ + v3270_paste_string(widget,text,"UTF-8"); +} + +void v3270_paste(GtkWidget *widget) +{ + gtk_clipboard_request_text(gtk_widget_get_clipboard(widget,GDK_SELECTION_CLIPBOARD),(GtkClipboardTextReceivedFunc) text_received,(gpointer) widget); +} + +#endif // _WIN32 + void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encoding) { gchar * buffer = NULL; @@ -472,16 +513,6 @@ void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encod } -static void text_received(GtkClipboard *clipboard, const gchar *text, GtkWidget *widget) -{ - v3270_paste_string(widget,text,"UTF-8"); -} - -void v3270_paste(GtkWidget *widget) -{ - gtk_clipboard_request_text(gtk_widget_get_clipboard(widget,GDK_SELECTION_CLIPBOARD),(GtkClipboardTextReceivedFunc) text_received,(gpointer) widget); -} - void v3270_unselect(GtkWidget *widget) { v3270_disable_updates(widget); -- libgit2 0.21.2