X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/670f9935630beb2123a5ca62894ae92a3f0efa4f..8ca1a013e4e699724040ff1f514dab3b4a11d3c9:/src/gtk/dataobj.cpp diff --git a/src/gtk/dataobj.cpp b/src/gtk/dataobj.cpp index c9e08da558..32288359f1 100644 --- a/src/gtk/dataobj.cpp +++ b/src/gtk/dataobj.cpp @@ -17,14 +17,13 @@ #ifndef WX_PRECOMP #include "wx/log.h" #include "wx/app.h" + #include "wx/image.h" #endif -#include "wx/debug.h" #include "wx/mstream.h" -#include "wx/image.h" #include "wx/uri.h" -#include +#include "wx/gtk/private.h" //------------------------------------------------------------------------- // global data @@ -59,13 +58,7 @@ wxDataFormat::wxDataFormat( wxDataFormatId type ) SetType( type ); } -wxDataFormat::wxDataFormat( const wxChar *id ) -{ - PrepareFormats(); - SetId( id ); -} - -wxDataFormat::wxDataFormat( const wxString &id ) +void wxDataFormat::InitFromString( const wxString &id ) { PrepareFormats(); SetId( id ); @@ -111,10 +104,8 @@ wxDataFormatId wxDataFormat::GetType() const wxString wxDataFormat::GetId() const { - gchar* atom_name = gdk_atom_name( m_format ); - wxString ret = wxString::FromAscii( atom_name ); - g_free(atom_name); - return ret; + wxGtkString atom_name(gdk_atom_name(m_format)); + return wxString::FromAscii(atom_name); } void wxDataFormat::SetId( NativeFormat format ) @@ -141,12 +132,11 @@ void wxDataFormat::SetId( NativeFormat format ) m_type = wxDF_PRIVATE; } -void wxDataFormat::SetId( const wxChar *id ) +void wxDataFormat::SetId( const wxString& id ) { PrepareFormats(); m_type = wxDF_PRIVATE; - wxString tmp( id ); - m_format = gdk_atom_intern( (const char*) tmp.ToAscii(), FALSE ); + m_format = gdk_atom_intern( id.ToAscii(), FALSE ); } void wxDataFormat::PrepareFormats() @@ -237,7 +227,7 @@ bool wxFileDataObject::GetDataHere(void *buf) const filenames += wxT("\r\n"); } - memcpy( buf, filenames.mbc_str(), filenames.Len() + 1 ); + memcpy( buf, filenames.mbc_str(), filenames.length() + 1 ); return true; } @@ -249,7 +239,7 @@ size_t wxFileDataObject::GetDataSize() const for (size_t i = 0; i < m_filenames.GetCount(); i++) { // This is junk in UTF-8 - res += m_filenames[i].Len(); + res += m_filenames[i].length(); res += 5 + 2; // "file:" (5) + "\r\n" (2) } @@ -282,7 +272,12 @@ bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf) lenPrefix += 2; } - AddFile(wxURI::Unescape(filename.c_str() + lenPrefix)); + // It would probably be nicer to use a GTK or Glib + // function to unescape the 8-bit strings pointed to + // by buf, but this does the same in wx code. + wxString filename_unicode = wxURI::Unescape(filename.c_str() + lenPrefix); + wxCharBuffer filename_8bit = filename_unicode.mb_str(wxConvISO8859_1); + AddFile(wxString(filename_8bit, *wxConvFileName)); filename.Empty(); } else if ( !filename.empty() ) @@ -299,6 +294,7 @@ bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf) } else { + // The string is in ISO-8859-1 according to XDND spec filename += *p; } }