Always use UTF-8 for file names passed to GTK+ functions under MSW.
When building wxGTK under MSW, always use UTF-8 as file name encoding because GTK+ doesn't use G_FILENAME_ENCODING there. Add a helper wxGTK_CONV_FN() macro to hide the difference between the platforms. Closes #14035. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71154 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -87,6 +87,17 @@ extern const gchar *wx_pango_version_check(int major, int minor, int micro);
|
||||
#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
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/wfstream.h"
|
||||
#include "wx/gtk/private.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -84,7 +85,7 @@ wxAnimation& wxAnimation::operator=(const wxAnimation& that)
|
||||
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();
|
||||
}
|
||||
|
||||
|
@@ -297,6 +297,7 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_)
|
||||
// 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
|
||||
@@ -345,6 +346,7 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_)
|
||||
#endif // wxUSE_INTL
|
||||
static wxConvBrokenFileNames fileconv(encName);
|
||||
wxConvFileName = &fileconv;
|
||||
#endif // __UNIX__
|
||||
|
||||
|
||||
bool init_result;
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "wx/rawbmp.h"
|
||||
|
||||
#include "wx/gtk/private/object.h"
|
||||
#include "wx/gtk/private.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -677,7 +678,7 @@ bool wxBitmap::SaveFile( const wxString &name, wxBitmapType type, const wxPalett
|
||||
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 )
|
||||
@@ -691,7 +692,7 @@ 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();
|
||||
|
@@ -157,7 +157,8 @@ bool wxDirDialog::Create(wxWindow* parent,
|
||||
|
||||
if ( !defaultPath.empty() )
|
||||
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget),
|
||||
defaultPath.fn_str() );
|
||||
wxGTK_CONV_FN(defaultPath) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -179,7 +180,7 @@ void wxDirDialog::SetPath(const wxString& dir)
|
||||
if (wxDirExists(dir))
|
||||
{
|
||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
|
||||
dir.fn_str());
|
||||
wxGTK_CONV_FN(dir));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -362,7 +362,7 @@ bool wxGtkFileCtrl::Create( wxWindow *parent,
|
||||
if ( !dir.empty() )
|
||||
{
|
||||
gtk_file_chooser_set_current_folder( m_fcWidget,
|
||||
dir.fn_str() );
|
||||
wxGTK_CONV_FN(dir) );
|
||||
}
|
||||
|
||||
const wxString fname = fn.GetFullName();
|
||||
@@ -371,7 +371,7 @@ bool wxGtkFileCtrl::Create( wxWindow *parent,
|
||||
if ( !fname.empty() )
|
||||
{
|
||||
gtk_file_chooser_set_current_name( m_fcWidget,
|
||||
fname.fn_str() );
|
||||
wxGTK_CONV_FN(fname) );
|
||||
}
|
||||
}
|
||||
else // wxFC_OPEN
|
||||
@@ -379,7 +379,7 @@ bool wxGtkFileCtrl::Create( wxWindow *parent,
|
||||
if ( !fname.empty() )
|
||||
{
|
||||
gtk_file_chooser_set_filename( m_fcWidget,
|
||||
fn.GetFullPath().fn_str() );
|
||||
wxGTK_CONV_FN(fn.GetFullPath()) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -288,7 +288,7 @@ bool wxFileDialog::Create(wxWindow *parent, const wxString& message,
|
||||
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();
|
||||
@@ -296,7 +296,7 @@ bool wxFileDialog::Create(wxWindow *parent, const wxString& message,
|
||||
{
|
||||
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)
|
||||
@@ -309,7 +309,7 @@ bool wxFileDialog::Create(wxWindow *parent, const wxString& message,
|
||||
if ( !fname.empty() )
|
||||
{
|
||||
gtk_file_chooser_set_filename(file_chooser,
|
||||
fn.GetFullPath().fn_str());
|
||||
wxGTK_CONV_FN(fn.GetFullPath()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "wx/gtk/private/string.h"
|
||||
#include "wx/gtk/private.h"
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
@@ -45,7 +46,7 @@ void wxFileHistory::AddFileToHistory(const wxString& file)
|
||||
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);
|
||||
|
Reference in New Issue
Block a user