+
+ // 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::OnOk( 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 );