- int ret = wxDialog::ShowModal();
-
- if (ret == wxID_OK)
- {
- m_fileName = gtk_file_selection_get_filename( GTK_FILE_SELECTION(m_widget) );
- m_path = gtk_file_selection_get_filename( GTK_FILE_SELECTION(m_widget) );
- };
- return ret;
-};
-
-
-char *wxFileSelector(const char *title,
- const char *defaultDir, const char *defaultFileName,
- const char *defaultExtension, const char *filter, int flags,
- wxWindow *parent, int x, int y)
-{
- wxString filter2("");
- if ( defaultExtension && !filter )
- filter2 = wxString("*.") + wxString(defaultExtension) ;
- else if ( filter )
- filter2 = filter;
-
- wxString defaultDirString;
- if (defaultDir)
- defaultDirString = defaultDir;
- else
- defaultDirString = "";
-
- wxString defaultFilenameString;
- if (defaultFileName)
- defaultFilenameString = defaultFileName;
- else
- defaultFilenameString = "";
-
- wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString,
- filter2, flags, wxPoint(x, y));
-
- if ( fileDialog.ShowModal() == wxID_OK )
- {
- strcpy(wxBuffer, (const char *)fileDialog.GetPath());
- return wxBuffer;
- }
- else
- return NULL;
-};
-
-char* wxLoadFileSelector(const char *what, const char *extension, const char *default_name,
- wxWindow *parent )
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ int style = dialog->GetStyle();
+
+ GtkFileSelection *filedlg = GTK_FILE_SELECTION(dialog->m_widget);
+ char *filename = gtk_file_selection_get_filename(filedlg);
+
+ if ( (style & wxSAVE) && ( style & wxOVERWRITE_PROMPT ) )
+ {
+ if (wxFileExists( filename ))
+ {
+ wxString msg;
+ msg.Printf( _("File '%s' already exists, do you really want to "
+ "overwrite it?"), filename);
+
+ if (wxMessageBox(msg, _("Confirm"), wxYES_NO) != wxYES)
+ return;
+ }
+ }
+ else if ( (style & wxOPEN) && ( style & wxFILE_MUST_EXIST) )
+ {
+ if ( !wxFileExists( filename ) )
+ {
+ wxMessageBox(_("Please choose an existing file."), _("Error"), wxOK);
+
+ return;
+ }
+ }
+
+ // change to the directory where the user went if asked
+ if ( style & wxCHANGE_DIR )
+ {
+ wxString cwd;
+ wxSplitPath(filename, &cwd, NULL, NULL);
+
+ if ( cwd != wxGetWorkingDirectory() )
+ {
+ wxSetWorkingDirectory(cwd);
+ }
+ }
+
+ dialog->SetPath( filename );
+
+ wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
+ event.SetEventObject( dialog );
+ dialog->GetEventHandler()->ProcessEvent( event );
+}
+
+//-----------------------------------------------------------------------------
+// "clicked" for Cancel-button
+//-----------------------------------------------------------------------------
+
+static
+void gtk_filedialog_cancel_callback( GtkWidget *WXUNUSED(w), wxFileDialog *dialog )