-#include "wx/utils.h"
-#include "wx/intl.h"
-#include "wx/filename.h"
-#include "wx/msgdlg.h"
-#include "wx/log.h"
-
-#include <gtk/gtk.h>
-
-#ifdef __WXGTK24__
-#include "wx/gtk/private.h"
-
-//-----------------------------------------------------------------------------
-// idle system
-//-----------------------------------------------------------------------------
-
-extern void wxapp_install_idle_handler();
-extern bool g_isIdle;
-
-//-----------------------------------------------------------------------------
-// "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));
- 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 (wxFileExists(filename))
- {
- wxString msg;
- msg.Printf(
- _("File '%s' already exists, do you really want to overwrite it?"),
- filename.c_str());
-
- wxMessageDialog dlg(dialog, msg, _("Confirm"),
- wxYES_NO | wxICON_QUESTION);
- if (dlg.ShowModal() != wxID_YES)
- return;
- }
- }
- else if ((style & wxOPEN) && ( style & wxFILE_MUST_EXIST))
- {
- if (!wxFileExists( filename ))
- {
- wxMessageDialog dlg(dialog,
- _("Please choose an existing file."),
- _("Error"), wxOK | wxICON_ERROR);
- dlg.ShowModal();
-
- return;
- }
- }
-
- // change to the directory where the user went if asked
- if (style & wxCHANGE_DIR)
- {
- wxString cwd;
- wxSplitPath(filename, &cwd, NULL, NULL);
-
- if (cwd != wxGetCwd())
- {
- wxSetWorkingDirectory(cwd);
- }
- }
-
- dialog->SetPath(filename);
- dialog->UpdateFromDialog();