X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ffb5937e89927b621128789401db8921fe580f..1a70c9e2bf5f683c8e7adbd4a0c3299accac9c06:/src/gtk1/clipbrd.cpp diff --git a/src/gtk1/clipbrd.cpp b/src/gtk1/clipbrd.cpp index 4a918060df..1d1e0bc844 100644 --- a/src/gtk1/clipbrd.cpp +++ b/src/gtk1/clipbrd.cpp @@ -4,13 +4,9 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "clipbrd.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -78,6 +74,7 @@ struct _GtkSelectionData // "selection_received" for targets //----------------------------------------------------------------------------- +extern "C" { static void targets_selection_received( GtkWidget *WXUNUSED(widget), GtkSelectionData *selection_data, @@ -133,11 +130,13 @@ targets_selection_received( GtkWidget *WXUNUSED(widget), clipboard->m_waiting = FALSE; } +} //----------------------------------------------------------------------------- // "selection_received" for the actual data //----------------------------------------------------------------------------- +extern "C" { static void selection_received( GtkWidget *WXUNUSED(widget), GtkSelectionData *selection_data, @@ -189,11 +188,13 @@ selection_received( GtkWidget *WXUNUSED(widget), wxTheClipboard->m_formatSupported = TRUE; clipboard->m_waiting = FALSE; } +} //----------------------------------------------------------------------------- // "selection_clear" //----------------------------------------------------------------------------- +extern "C" { static gint selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event ) { @@ -230,11 +231,13 @@ selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event ) wxTheClipboard->m_waiting = FALSE; return TRUE; } +} //----------------------------------------------------------------------------- // selection handler for supplying data //----------------------------------------------------------------------------- +extern "C" { static void selection_handler( GtkWidget *WXUNUSED(widget), GtkSelectionData *selection_data, @@ -250,6 +253,16 @@ selection_handler( GtkWidget *WXUNUSED(widget), wxDataFormat format( selection_data->target ); +#ifdef __WXDEBUG__ + wxLogTrace(TRACE_CLIPBOARD, + _T("clipboard data in format %s, GtkSelectionData is target=%s type=%s selection=%s"), + format.GetId().c_str(), + wxString::FromAscii(gdk_atom_name(selection_data->target)).c_str(), + wxString::FromAscii(gdk_atom_name(selection_data->type)).c_str(), + wxString::FromAscii(gdk_atom_name(selection_data->selection)).c_str() + ); +#endif + if (!data->IsSupportedFormat( format )) return; int size = data->GetDataSize( format ); @@ -261,15 +274,31 @@ selection_handler( GtkWidget *WXUNUSED(widget), // Text data will be in UTF8 in Unicode mode. data->GetDataHere( selection_data->target, d ); - gtk_selection_data_set( - selection_data, - GDK_SELECTION_TYPE_STRING, - 8*sizeof(gchar), - (unsigned char*) d, - size ); +#ifdef __WXGTK20__ + // NB: GTK+ requires special treatment of UTF8_STRING data, the text + // would show as UTF-8 data interpreted as latin1 (?) in other + // GTK+ apps if we used gtk_selection_data_set() + if (format == wxDataFormat(wxDF_UNICODETEXT)) + { + gtk_selection_data_set_text( + selection_data, + (const gchar*)d, + size-1 ); + } + else +#endif + { + gtk_selection_data_set( + selection_data, + GDK_SELECTION_TYPE_STRING, + 8*sizeof(gchar), + (unsigned char*) d, + size-1 ); + } free(d); } +} //----------------------------------------------------------------------------- // wxClipboard @@ -478,11 +507,9 @@ bool wxClipboard::IsSupported( const wxDataFormat& format ) /* store requested format to be asked for by callbacks */ m_targetRequested = format; -#if 0 wxLogTrace( TRACE_CLIPBOARD, wxT("wxClipboard:IsSupported: requested format: %s"), format.GetId().c_str() ); -#endif wxCHECK_MSG( m_targetRequested, FALSE, wxT("invalid clipboard format") ); @@ -515,9 +542,7 @@ bool wxClipboard::IsSupported( const wxDataFormat& format ) } #endif - if (!m_formatSupported) return FALSE; - - return TRUE; + return m_formatSupported; } bool wxClipboard::GetData( wxDataObject& data )