+ if (m_extraControl)
+ {
+ // get chooser to drop its reference right now, allowing wxWindow dtor
+ // to verify that ref count drops to zero
+ gtk_file_chooser_set_extra_widget(
+ GTK_FILE_CHOOSER(m_widget), NULL);
+ }
+}
+void wxFileDialog::GTKOnAccept()
+{
+ int style = GetWindowStyle();
+ wxString filename = m_fc.GetPath();
+ m_selectedDirectory = m_fc.GetDirectory();
+
+ // gtk version numbers must be identical with the one in ctor (that calls set_do_overwrite_confirmation)
+#ifndef __WXGTK3__
+#if GTK_CHECK_VERSION(2,7,3)
+ if (gtk_check_version(2, 7, 3) != NULL)
+#endif
+ {
+ if ((style & wxFD_SAVE) && (style & wxFD_OVERWRITE_PROMPT))
+ {
+ if ( g_file_test(filename.utf8_str(), G_FILE_TEST_EXISTS) )
+ {
+ wxString msg;
+
+ msg.Printf(
+ _("File '%s' already exists, do you really want to overwrite it?"),
+ wxString::FromUTF8(filename.utf8_str()));
+
+ wxMessageDialog dlg(this, msg, _("Confirm"),
+ wxYES_NO | wxICON_QUESTION);
+ if (dlg.ShowModal() != wxID_YES)
+ return;
+ }
+ }
+ }
+#endif
+
+ if (style & wxFD_FILE_MUST_EXIST)
+ {
+ if ( !g_file_test(filename.utf8_str(), G_FILE_TEST_EXISTS) )
+ {
+ wxMessageDialog dlg( this, _("Please choose an existing file."),
+ _("Error"), wxOK| wxICON_ERROR);
+ dlg.ShowModal();
+ return;
+ }
+ }
+
+ // change to the directory where the user went if asked
+ if (style & wxFD_CHANGE_DIR)
+ {
+ // Use chdir to not care about filename encodings
+ wxGtkString folder(g_path_get_dirname(filename.utf8_str()));
+ chdir(folder);
+ }
+ EndDialog(wxID_OK);
+}
+
+void wxFileDialog::GTKOnCancel()
+{
+ EndDialog(wxID_CANCEL);