Always use UTF-8 for GTK+ strings [backport of r63549 from trunk].

Strings returned and accepted by GTK+ functions always use UTF-8 independently
of the current locale and of the file name encoding we use. So use UTF-8
instead of wxConvFileName everywhere where we deal with GTK+ directly.

Closes #11743.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@63600 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-03-02 00:15:45 +00:00
parent 656dd3e0c4
commit 2afbd70030
2 changed files with 10 additions and 9 deletions

View File

@@ -143,7 +143,7 @@ wxDirDialog::wxDirDialog(wxWindow* parent, const wxString& title,
if ( !defaultPath.empty() )
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget),
wxConvFileName->cWX2MB(defaultPath) );
defaultPath.utf8_str() );
}
else
wxGenericDirDialog::Create(parent, title, defaultPath, style, pos, sz, name);
@@ -187,7 +187,8 @@ void wxDirDialog::SetPath(const wxString& dir)
{
if (wxDirExists(dir))
{
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(dir));
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
dir.utf8_str());
}
}
else
@@ -199,7 +200,7 @@ wxString wxDirDialog::GetPath() const
if (!gtk_check_version(2,4,0))
{
wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
return wxConvFileName->cMB2WX(str);
return wxString::FromUTF8(str);
}
return wxGenericDirDialog::GetPath();

View File

@@ -56,7 +56,7 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
msg.Printf(
_("File '%s' already exists, do you really want to overwrite it?"),
wxString(wxConvFileName->cMB2WX(filename)).c_str());
wxString(wxString::FromUTF8(filename)).c_str());
wxMessageDialog dlg(dialog, msg, _("Confirm"),
wxYES_NO | wxICON_QUESTION);
@@ -326,7 +326,7 @@ wxString wxFileDialog::GetPath() const
if (!gtk_check_version(2,4,0))
{
wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
return wxConvFileName->cMB2WX(str);
return wxString::FromUTF8(str);
}
return wxGenericFileDialog::GetPath();
@@ -358,7 +358,7 @@ void wxFileDialog::GetPaths(wxArrayString& paths) const
GSList *gpaths = gpathsi;
while (gpathsi)
{
wxString file(wxConvFileName->cMB2WX((gchar*) gpathsi->data));
wxString file(wxString::FromUTF8((gchar*) gpathsi->data));
paths.Add(file);
g_free(gpathsi->data);
gpathsi = gpathsi->next;
@@ -391,7 +391,7 @@ void wxFileDialog::SetPath(const wxString& path)
if (path.empty()) return;
wxCHECK_RET(wxIsAbsolutePath(path), wxT(" wxFileDialog::SetPath requires an absolute filepath"));
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(path));
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget), path.utf8_str());
}
else
wxGenericFileDialog::SetPath( path );
@@ -403,7 +403,7 @@ void wxFileDialog::SetDirectory(const wxString& dir)
{
if (wxDirExists(dir))
{
if (gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(dir)))
if (gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), dir.utf8_str()))
{
// Cache the dir, as gtk_file_chooser_get_current_folder()
// doesn't return anything until the dialog has been shown
@@ -420,7 +420,7 @@ wxString wxFileDialog::GetDirectory() const
if (!gtk_check_version(2,4,0))
{
wxGtkString str(gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(m_widget)));
wxString currentDir( wxConvFileName->cMB2WX(str) );
wxString currentDir( wxString::FromUTF8(str) );
if (currentDir.empty())
{
// gtk_file_chooser_get_current_folder will return empty until the dialog has been shown