#define wxGTK_CONV_BACK_SYS(s) wxConvertFromGTK((s))
#endif
+// Define a macro for converting wxString to char* in appropriate encoding for
+// the file names.
+#ifdef G_OS_WIN32
+ // Under MSW, UTF-8 file name encodings are always used.
+ #define wxGTK_CONV_FN(s) (s).utf8_str()
+#else
+ // Under Unix use GLib file name encoding (which is also UTF-8 by default
+ // but may be different from it).
+ #define wxGTK_CONV_FN(s) (s).fn_str()
+#endif
+
// ----------------------------------------------------------------------------
// various private helper functions
// ----------------------------------------------------------------------------
#endif
#include "wx/wfstream.h"
+#include "wx/gtk/private.h"
#include <gtk/gtk.h>
bool wxAnimation::LoadFile(const wxString &name, wxAnimationType WXUNUSED(type))
{
UnRef();
- m_pixbuf = gdk_pixbuf_animation_new_from_file(name.fn_str(), NULL);
+ m_pixbuf = gdk_pixbuf_animation_new_from_file(wxGTK_CONV_FN(name), NULL);
return IsOk();
}
// gtk+ 2.0 supports Unicode through UTF-8 strings
wxConvCurrent = &wxConvUTF8;
+#ifdef __UNIX__
// decide which conversion to use for the file names
// (1) this variable exists for the sole purpose of specifying the encoding
#endif // wxUSE_INTL
static wxConvBrokenFileNames fileconv(encName);
wxConvFileName = &fileconv;
+#endif // __UNIX__
bool init_result;
#include "wx/rawbmp.h"
#include "wx/gtk/private/object.h"
+#include "wx/gtk/private.h"
#include <gtk/gtk.h>
default: break;
}
return type_name &&
- gdk_pixbuf_save(GetPixbuf(), name.fn_str(), type_name, NULL, NULL);
+ gdk_pixbuf_save(GetPixbuf(), wxGTK_CONV_FN(name), type_name, NULL, NULL);
}
bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
{
wxUnusedVar(type); // The type is detected automatically by GDK.
- *this = wxBitmap(gdk_pixbuf_new_from_file(name.fn_str(), NULL));
+ *this = wxBitmap(gdk_pixbuf_new_from_file(wxGTK_CONV_FN(name), NULL));
}
return IsOk();
if ( !defaultPath.empty() )
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget),
- defaultPath.fn_str() );
+ wxGTK_CONV_FN(defaultPath) );
+
return true;
}
if (wxDirExists(dir))
{
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
- dir.fn_str());
+ wxGTK_CONV_FN(dir));
}
}
if ( !dir.empty() )
{
gtk_file_chooser_set_current_folder( m_fcWidget,
- dir.fn_str() );
+ wxGTK_CONV_FN(dir) );
}
const wxString fname = fn.GetFullName();
if ( !fname.empty() )
{
gtk_file_chooser_set_current_name( m_fcWidget,
- fname.fn_str() );
+ wxGTK_CONV_FN(fname) );
}
}
else // wxFC_OPEN
if ( !fname.empty() )
{
gtk_file_chooser_set_filename( m_fcWidget,
- fn.GetFullPath().fn_str() );
+ wxGTK_CONV_FN(fn.GetFullPath()) );
}
}
const wxString dir = fn.GetPath();
if ( !dir.empty() )
{
- gtk_file_chooser_set_current_folder(file_chooser, dir.fn_str());
+ gtk_file_chooser_set_current_folder(file_chooser, wxGTK_CONV_FN(dir));
}
const wxString fname = fn.GetFullName();
{
if ( !fname.empty() )
{
- gtk_file_chooser_set_current_name(file_chooser, fname.fn_str());
+ gtk_file_chooser_set_current_name(file_chooser, wxGTK_CONV_FN(fname));
}
#if GTK_CHECK_VERSION(2,7,3)
if ( !fname.empty() )
{
gtk_file_chooser_set_filename(file_chooser,
- fn.GetFullPath().fn_str());
+ wxGTK_CONV_FN(fn.GetFullPath()));
}
}
#include <glib.h>
#include <gtk/gtk.h>
#include "wx/gtk/private/string.h"
+#include "wx/gtk/private.h"
// ============================================================================
// implementation
const wxString fullPath = wxFileName(file).GetFullPath();
if ( !gtk_check_version(2,10,0) )
{
- wxGtkString uri(g_filename_to_uri(fullPath.fn_str(), NULL, NULL));
+ wxGtkString uri(g_filename_to_uri(wxGTK_CONV_FN(fullPath), NULL, NULL));
if ( uri )
gtk_recent_manager_add_item(gtk_recent_manager_get_default(), uri);