Commit c014ad39084a87982e716626ad8026d2801cfb95
1 parent
60fda04e
Exists in
master
and in
1 other branch
Modificando tratamento do clipboard em windows para identificar falha no processo de "paste"
Showing
1 changed file
with
41 additions
and
10 deletions
Show diff stats
selection.c
@@ -346,6 +346,47 @@ void v3270_copy(GtkWidget *widget, V3270_SELECT_FORMAT mode, gboolean cut) | @@ -346,6 +346,47 @@ void v3270_copy(GtkWidget *widget, V3270_SELECT_FORMAT mode, gboolean cut) | ||
346 | update_system_clipboard(widget); | 346 | update_system_clipboard(widget); |
347 | } | 347 | } |
348 | 348 | ||
349 | +#ifdef _WIN32 | ||
350 | + | ||
351 | +void v3270_paste(GtkWidget *widget) | ||
352 | +{ | ||
353 | + HGLOBAL hglb; | ||
354 | + | ||
355 | + if (!IsClipboardFormatAvailable(CF_TEXT)) | ||
356 | + return; | ||
357 | + | ||
358 | + if (!OpenClipboard(NULL)) | ||
359 | + return; | ||
360 | + | ||
361 | + hglb = GetClipboardData(CF_TEXT); | ||
362 | + if (hglb != NULL) | ||
363 | + { | ||
364 | + LPTSTR lptstr = GlobalLock(hglb); | ||
365 | + if (lptstr != NULL) | ||
366 | + { | ||
367 | + v3270_paste_string(widget,lptstr,"CP1252"); | ||
368 | + GlobalUnlock(hglb); | ||
369 | + } | ||
370 | + } | ||
371 | + | ||
372 | + CloseClipboard(); | ||
373 | + | ||
374 | +} | ||
375 | + | ||
376 | +#else | ||
377 | + | ||
378 | +static void text_received(GtkClipboard *clipboard, const gchar *text, GtkWidget *widget) | ||
379 | +{ | ||
380 | + v3270_paste_string(widget,text,"UTF-8"); | ||
381 | +} | ||
382 | + | ||
383 | +void v3270_paste(GtkWidget *widget) | ||
384 | +{ | ||
385 | + gtk_clipboard_request_text(gtk_widget_get_clipboard(widget,GDK_SELECTION_CLIPBOARD),(GtkClipboardTextReceivedFunc) text_received,(gpointer) widget); | ||
386 | +} | ||
387 | + | ||
388 | +#endif // _WIN32 | ||
389 | + | ||
349 | void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encoding) | 390 | void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encoding) |
350 | { | 391 | { |
351 | gchar * buffer = NULL; | 392 | gchar * buffer = NULL; |
@@ -472,16 +513,6 @@ void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encod | @@ -472,16 +513,6 @@ void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encod | ||
472 | 513 | ||
473 | } | 514 | } |
474 | 515 | ||
475 | -static void text_received(GtkClipboard *clipboard, const gchar *text, GtkWidget *widget) | ||
476 | -{ | ||
477 | - v3270_paste_string(widget,text,"UTF-8"); | ||
478 | -} | ||
479 | - | ||
480 | -void v3270_paste(GtkWidget *widget) | ||
481 | -{ | ||
482 | - gtk_clipboard_request_text(gtk_widget_get_clipboard(widget,GDK_SELECTION_CLIPBOARD),(GtkClipboardTextReceivedFunc) text_received,(gpointer) widget); | ||
483 | -} | ||
484 | - | ||
485 | void v3270_unselect(GtkWidget *widget) | 516 | void v3270_unselect(GtkWidget *widget) |
486 | { | 517 | { |
487 | v3270_disable_updates(widget); | 518 | v3270_disable_updates(widget); |