X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/72a7edf007f57bc9dacea77c408adb86a57d41f7..88594d02eb59a55ac85d3210a49d02918124617b:/src/gtk/clipbrd.cpp?ds=sidebyside diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index 32d0991d3e..881b0dce87 100644 --- a/src/gtk/clipbrd.cpp +++ b/src/gtk/clipbrd.cpp @@ -42,7 +42,7 @@ GdkAtom g_targetsAtom = 0; // the trace mask we use with wxLogTrace() - call // wxLog::AddTraceMask(TRACE_CLIPBOARD) to enable the trace messages from here // (there will be a *lot* of them!) -static const char *TRACE_CLIPBOARD = _T("clipboard"); +static const wxChar *TRACE_CLIPBOARD = _T("clipboard"); //----------------------------------------------------------------------------- // reminder @@ -212,7 +212,7 @@ selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event ) /* the clipboard is no longer in our hands. we can the delete clipboard data. */ if (wxTheClipboard->m_data) { - wxLogDebug( wxT("wxClipboard will get cleared" ) ); + wxLogTrace(TRACE_CLIPBOARD, wxT("wxClipboard will get cleared" )); delete wxTheClipboard->m_data; wxTheClipboard->m_data = (wxDataObject*) NULL; @@ -244,36 +244,28 @@ selection_handler( GtkWidget *WXUNUSED(widget), if (!data->IsSupportedFormat( format )) return; - /* this will fail for composite formats */ - if (format.GetType() == wxDF_TEXT) - { - wxTextDataObject *text_object = (wxTextDataObject*) data; - wxString text( text_object->GetText() ); - -#if wxUSE_UNICODE - const wxWX2MBbuf s = text.mbc_str(); - int len = strlen(s); -#else // more efficient in non-Unicode - const char *s = text.c_str(); - int len = (int) text.Length(); -#endif - gtk_selection_data_set( - selection_data, - GDK_SELECTION_TYPE_STRING, - 8*sizeof(gchar), - (unsigned char*) (const char*) s, - len ); - - return; - } - int size = data->GetDataSize( format ); if (size == 0) return; - char *d = new char[size]; + void *d = malloc(size); - data->GetDataHere( selection_data->target, (void*) d ); + data->GetDataHere( selection_data->target, d ); + + // transform Unicode text into multibyte before putting it on clipboard +#if wxUSE_UNICODE + if ( format.GetType() == wxDF_TEXT ) + { + const wchar_t *wstr = (const wchar_t *)d; + size_t len = wxConvCurrent->WC2MB(NULL, wstr, 0); + char *str = malloc(len + 1); + wxConvCurrent->WC2MB(str, wstr, len); + str[len] = '\0'; + + free(d); + d = str; + } +#endif // wxUSE_UNICODE gtk_selection_data_set( selection_data, @@ -281,6 +273,8 @@ selection_handler( GtkWidget *WXUNUSED(widget), 8*sizeof(gchar), (unsigned char*) d, size ); + + free(d); } //----------------------------------------------------------------------------- @@ -590,7 +584,8 @@ bool wxClipboard::GetData( wxDataObject& data ) m_waiting = TRUE; - wxLogDebug( wxT("wxClipboard::GetData: format found, start convert") ); + wxLogTrace( TRACE_CLIPBOARD, + wxT("wxClipboard::GetData: format found, start convert") ); gtk_selection_convert( m_clipboardWidget, m_usePrimary ? (GdkAtom)GDK_SELECTION_PRIMARY @@ -608,7 +603,8 @@ bool wxClipboard::GetData( wxDataObject& data ) return TRUE; } - wxLogDebug( wxT("wxClipboard::GetData: format not found") ); + wxLogTrace( TRACE_CLIPBOARD, + wxT("wxClipboard::GetData: format not found") ); /* return failure */ delete[] array;