X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/27b2dd53f629a78266c51d1b0b5db918401dcd4f..4ab2824cc67d6fe75e5a377f36ea35f131c4e137:/src/gtk/filedlg.cpp?ds=sidebyside diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index 78e2ebcadd..1240658ca2 100644 --- a/src/gtk/filedlg.cpp +++ b/src/gtk/filedlg.cpp @@ -21,6 +21,7 @@ #include "wx/intl.h" #include "wx/filename.h" #include "wx/msgdlg.h" +#include "wx/log.h" #include @@ -38,11 +39,18 @@ extern bool g_isIdle; // "clicked" for OK-button //----------------------------------------------------------------------------- +extern "C" { static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog) { int style = dialog->GetStyle(); gchar* text = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); wxString filename(wxGTK_CONV_BACK(text)); + if ( filename.empty() ) + { + // this is totally lame but better than silent error + wxLogWarning(_("This filename can't be used by wxWidgets because it contains invalid UTF-8 characters, please rename the file.")); + return; + } if ((style & wxSAVE) && (style & wxOVERWRITE_PROMPT)) { @@ -91,11 +99,13 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog) event.SetEventObject(dialog); dialog->GetEventHandler()->ProcessEvent(event); } +} //----------------------------------------------------------------------------- // "clicked" for Cancel-button //----------------------------------------------------------------------------- +extern "C" { static void gtk_filedialog_cancel_callback(GtkWidget *WXUNUSED(w), wxFileDialog *dialog) { @@ -103,7 +113,9 @@ static void gtk_filedialog_cancel_callback(GtkWidget *WXUNUSED(w), event.SetEventObject(dialog); dialog->GetEventHandler()->ProcessEvent(event); } +} +extern "C" { static void gtk_filedialog_response_callback(GtkWidget *w, int response, wxFileDialog *dialog) @@ -120,7 +132,9 @@ static void gtk_filedialog_response_callback(GtkWidget *w, dialog->m_destroyed_by_delete = true; } } -#endif +} + +#endif // __WXGTK24__ //----------------------------------------------------------------------------- // wxFileDialog @@ -285,7 +299,8 @@ void wxFileDialog::GetPaths(wxArrayString& paths) const if (gpaths) g_slist_free(gpaths); } - else + + if ( paths.IsEmpty() ) { paths.Add(m_fileName); }