]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/filedlg.cpp
fix icoinse bug
[wxWidgets.git] / src / gtk / filedlg.cpp
index 78e2ebcadd2d422a129d5d1737a5003d3f290ec3..1240658ca2cdab2ede48d2971d7484f1a338cc98 100644 (file)
@@ -21,6 +21,7 @@
 #include "wx/intl.h"
 #include "wx/filename.h"
 #include "wx/msgdlg.h"
 #include "wx/intl.h"
 #include "wx/filename.h"
 #include "wx/msgdlg.h"
+#include "wx/log.h"
 
 #include <gtk/gtk.h>
 
 
 #include <gtk/gtk.h>
 
@@ -38,11 +39,18 @@ extern bool g_isIdle;
 // "clicked" for OK-button
 //-----------------------------------------------------------------------------
 
 // "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));
 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))
     {
 
     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);
 }
     event.SetEventObject(dialog);
     dialog->GetEventHandler()->ProcessEvent(event);
 }
+}
 
 //-----------------------------------------------------------------------------
 // "clicked" for Cancel-button
 //-----------------------------------------------------------------------------
 
 
 //-----------------------------------------------------------------------------
 // "clicked" for Cancel-button
 //-----------------------------------------------------------------------------
 
+extern "C" {
 static void gtk_filedialog_cancel_callback(GtkWidget *WXUNUSED(w),
                                            wxFileDialog *dialog)
 {
 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);
 }
     event.SetEventObject(dialog);
     dialog->GetEventHandler()->ProcessEvent(event);
 }
+}
 
 
+extern "C" {
 static void gtk_filedialog_response_callback(GtkWidget *w,
                                              int response,
                                              wxFileDialog *dialog)
 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;
     }
 }
         dialog->m_destroyed_by_delete = true;
     }
 }
-#endif
+}
+
+#endif // __WXGTK24__
 
 //-----------------------------------------------------------------------------
 // wxFileDialog
 
 //-----------------------------------------------------------------------------
 // wxFileDialog
@@ -285,7 +299,8 @@ void wxFileDialog::GetPaths(wxArrayString& paths) const
             if (gpaths)
                 g_slist_free(gpaths);
         }
             if (gpaths)
                 g_slist_free(gpaths);
         }
-        else
+
+        if ( paths.IsEmpty() )
         {
             paths.Add(m_fileName);
         }
         {
             paths.Add(m_fileName);
         }