+ 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::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 );
+}
+
+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))
+ {
+ return m_fc.GetPath();
+ }
+
+ return wxGenericFileDialog::GetPath();
+}
+
+void wxFileDialog::GetFilenames(wxArrayString& files) const
+{
+ if (!gtk_check_version(2,4,0))
+ {
+ m_fc.GetFilenames( files );
+ }
+ else
+ wxGenericFileDialog::GetFilenames( files );
+}
+
+void wxFileDialog::GetPaths(wxArrayString& paths) const
+{
+ if (!gtk_check_version(2,4,0))
+ {
+ m_fc.GetPaths( paths );
+ }
+ else
+ wxGenericFileDialog::GetPaths( paths );
+}
+
+void wxFileDialog::SetMessage(const wxString& message)
+{
+ if (!gtk_check_version(2,4,0))
+ {
+ m_message = message;
+ SetTitle(message);
+ }
+ else
+ wxGenericFileDialog::SetMessage( message );
+}
+
+void wxFileDialog::SetPath(const wxString& path)
+{
+ if (!gtk_check_version(2,4,0))
+ {
+ m_fc.SetPath( path );
+ }
+ else
+ wxGenericFileDialog::SetPath( path );
+}
+
+void wxFileDialog::SetDirectory(const wxString& dir)
+{
+ if (!gtk_check_version(2,4,0))
+ {
+ m_fc.SetDirectory( dir );
+ }
+ else
+ wxGenericFileDialog::SetDirectory( dir );
+}
+
+wxString wxFileDialog::GetDirectory() const
+{
+ if (!gtk_check_version(2,4,0))
+ {
+ m_fc.GetDirectory();
+ }
+
+ return wxGenericFileDialog::GetDirectory();
+}
+
+void wxFileDialog::SetFilename(const wxString& name)
+{
+ if (!gtk_check_version(2,4,0))
+ {
+ if (HasFdFlag(wxFD_SAVE))
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget), wxGTK_CONV(name));
+ else
+ SetPath(wxFileName(GetDirectory(), name).GetFullPath());
+ }
+ else
+ wxGenericFileDialog::SetFilename( name );
+}
+
+wxString wxFileDialog::GetFilename() const
+{
+ if (!gtk_check_version(2,4,0))
+ return m_fc.GetFilename();
+ else
+ return wxGenericFileDialog::GetFilename();
+}
+
+void wxFileDialog::SetWildcard(const wxString& wildCard)
+{
+ if (!gtk_check_version(2,4,0))
+ {
+ m_fc.SetWildcard( wildCard );
+ }
+ else
+ wxGenericFileDialog::SetWildcard( wildCard );
+}
+
+void wxFileDialog::SetFilterIndex(int filterIndex)
+{
+
+ if (!gtk_check_version(2,4,0))
+ {
+ m_fc.SetFilterIndex( filterIndex);
+ }
+ else
+ wxGenericFileDialog::SetFilterIndex( filterIndex );
+}
+
+int wxFileDialog::GetFilterIndex() const
+{
+ if (!gtk_check_version(2,4,0))
+ {
+ return m_fc.GetFilterIndex();
+ }
+ else
+ return wxGenericFileDialog::GetFilterIndex();
+}