+ // gtk_widget_hide_on_delete is used here to avoid that Gtk automatically
+ // destroys the dialog when the user press ESC on the dialog: in that case
+ // a second call to ShowModal() would result in a bunch of Gtk-CRITICAL
+ // errors...
+ g_signal_connect (G_OBJECT(m_widget),
+ "delete_event",
+ G_CALLBACK (gtk_widget_hide_on_delete),
+ (gpointer)this);
+
+ // local-only property could be set to false to allow non-local files to be
+ // loaded. In that case get/set_uri(s) should be used instead of
+ // get/set_filename(s) everywhere and the GtkFileChooserDialog should
+ // probably also be created with a backend, e.g "gnome-vfs", "default", ...
+ // (gtk_file_chooser_dialog_new_with_backend). Currently local-only is kept
+ // as the default - true:
+ // gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(m_widget), true);
+
+ g_signal_connect (m_widget, "response",
+ G_CALLBACK (gtk_filedialog_response_callback), this);
+
+ SetWildcard(wildCard);
+
+ // if defaultDir is specified it should contain the directory and
+ // defaultFileName should contain the default name of the file, however if
+ // directory is not given, defaultFileName contains both
+ wxFileName fn;
+ if ( defaultDir.empty() )
+ fn.Assign(defaultFileName);
+ else if ( !defaultFileName.empty() )
+ fn.Assign(defaultDir, defaultFileName);
+ else
+ fn.AssignDir(defaultDir);
+
+ // set the initial file name and/or directory
+ fn.MakeAbsolute(); // GTK+ needs absolute path
+ const wxString dir = fn.GetPath();
+ if ( !dir.empty() )
+ {
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
+ dir.fn_str());
+ }
+
+ const wxString fname = fn.GetFullName();
+ if ( style & wxFD_SAVE )
+ {
+ if ( !fname.empty() )
+ {
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
+ fname.fn_str());
+ }
+
+#if GTK_CHECK_VERSION(2,7,3)
+ if ((style & wxFD_OVERWRITE_PROMPT) && !gtk_check_version(2,7,3))
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(m_widget), TRUE);
+#endif
+ }
+ else // wxFD_OPEN
+ {
+ if ( !fname.empty() )
+ {
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
+ fn.GetFullPath().fn_str());
+ }
+ }
+
+#if GTK_CHECK_VERSION(2,4,0)
+ if ( style & wxFD_PREVIEW )
+ {
+ GtkWidget *previewImage = gtk_image_new();
+
+ gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(m_widget),
+ previewImage);
+ g_signal_connect(m_widget, "update-preview",
+ G_CALLBACK(gtk_filedialog_update_preview_callback),
+ previewImage);
+ }
+#endif // GTK+ 2.4+
+}
+
+void wxFileDialog::OnFakeOk( wxCommandEvent &event )
+{
+ if (!gtk_check_version(2,4,0))
+ EndDialog(wxID_OK);
+ else
+ wxGenericFileDialog::OnListOk( event );
+}
+
+int wxFileDialog::ShowModal()
+{
+ if (!gtk_check_version(2,4,0))
+ return wxDialog::ShowModal();
+ else
+ return wxGenericFileDialog::ShowModal();
+}
+
+bool wxFileDialog::Show( bool show )
+{
+ if (!gtk_check_version(2,4,0))
+ return wxDialog::Show( show );
+ else
+ return wxGenericFileDialog::Show( show );
+}
+
+void wxFileDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags )
+{
+ if (!m_wxwindow)
+ return;
+ else
+ wxGenericFileDialog::DoSetSize( x, y, width, height, sizeFlags );
+}
+
+wxString wxFileDialog::GetPath() const
+{
+ if (!gtk_check_version(2,4,0))
+ {
+ wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
+ return wxString(str, *wxConvFileName);
+ }
+
+ return wxGenericFileDialog::GetPath();
+}
+
+void wxFileDialog::GetFilenames(wxArrayString& files) const
+{
+ if (!gtk_check_version(2,4,0))
+ {
+ GetPaths(files);
+ for (size_t n = 0; n < files.GetCount(); ++n )
+ {
+ wxFileName file(files[n]);
+ files[n] = file.GetFullName();
+ }
+ }
+ else
+ wxGenericFileDialog::GetFilenames( files );
+}
+
+void wxFileDialog::GetPaths(wxArrayString& paths) const