1Index: /wxWidgets/trunk/src/gtk/dirdlg.cpp 2=================================================================== 3--- /wxWidgets/trunk/src/gtk/dirdlg.cpp (revision 72605) 4+++ /wxWidgets/trunk/src/gtk/dirdlg.cpp (revision 72779) 5@@ -36,47 +36,13 @@ 6 #endif 7 8-//----------------------------------------------------------------------------- 9-// "clicked" for OK-button 10-//----------------------------------------------------------------------------- 11- 12 extern "C" { 13-static void gtk_dirdialog_ok_callback(GtkWidget *widget, wxDirDialog *dialog) 14-{ 15- // change to the directory where the user went if asked 16- if (dialog->HasFlag(wxDD_CHANGE_DIR)) 17- { 18- wxGtkString filename(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget))); 19- chdir(filename); 20- } 21- 22- wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK); 23- event.SetEventObject(dialog); 24- dialog->HandleWindowEvent(event); 25-} 26-} 27- 28-//----------------------------------------------------------------------------- 29-// "clicked" for Cancel-button 30-//----------------------------------------------------------------------------- 31- 32-extern "C" { 33-static void gtk_dirdialog_cancel_callback(GtkWidget *WXUNUSED(w), 34- wxDirDialog *dialog) 35-{ 36- wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); 37- event.SetEventObject(dialog); 38- dialog->HandleWindowEvent(event); 39-} 40-} 41- 42-extern "C" { 43-static void gtk_dirdialog_response_callback(GtkWidget *w, 44+static void gtk_dirdialog_response_callback(GtkWidget * WXUNUSED(w), 45 gint response, 46 wxDirDialog *dialog) 47 { 48 if (response == GTK_RESPONSE_ACCEPT) 49- gtk_dirdialog_ok_callback(w, dialog); 50+ dialog->GTKOnAccept(); 51 else // GTK_RESPONSE_CANCEL or GTK_RESPONSE_NONE 52- gtk_dirdialog_cancel_callback(w, dialog); 53+ dialog->GTKOnCancel(); 54 } 55 } 56@@ -87,8 +53,4 @@ 57 58 IMPLEMENT_DYNAMIC_CLASS(wxDirDialog, wxDialog) 59- 60-BEGIN_EVENT_TABLE(wxDirDialog, wxDirDialogBase) 61- EVT_BUTTON(wxID_OK, wxDirDialog::OnFakeOk) 62-END_EVENT_TABLE() 63 64 wxDirDialog::wxDirDialog(wxWindow* parent, 65@@ -157,13 +119,26 @@ 66 67 if ( !defaultPath.empty() ) 68- gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget), 69- wxGTK_CONV_FN(defaultPath) ); 70+ SetPath(defaultPath); 71 72 return true; 73 } 74 75-void wxDirDialog::OnFakeOk(wxCommandEvent& WXUNUSED(event)) 76+void wxDirDialog::GTKOnAccept() 77 { 78+ wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget))); 79+ m_selectedDirectory = wxString::FromUTF8(str); 80+ 81+ // change to the directory where the user went if asked 82+ if (HasFlag(wxDD_CHANGE_DIR)) 83+ { 84+ chdir(m_selectedDirectory); 85+ } 86+ 87 EndDialog(wxID_OK); 88+} 89+ 90+void wxDirDialog::GTKOnCancel() 91+{ 92+ EndDialog(wxID_CANCEL); 93 } 94 95@@ -187,6 +162,5 @@ 96 wxString wxDirDialog::GetPath() const 97 { 98- wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget))); 99- return wxString::FromUTF8(str); 100+ return m_selectedDirectory; 101 } 102 103Index: /wxWidgets/trunk/include/wx/gtk/dirdlg.h 104=================================================================== 105--- /wxWidgets/trunk/include/wx/gtk/dirdlg.h (revision 70898) 106+++ /wxWidgets/trunk/include/wx/gtk/dirdlg.h (revision 72779) 107@@ -43,4 +43,9 @@ 108 109 110+ // Implementation only. 111+ 112+ void GTKOnAccept(); 113+ void GTKOnCancel(); 114+ 115 protected: 116 // override this from wxTLW since the native 117@@ -52,8 +57,7 @@ 118 119 private: 120- void OnFakeOk( wxCommandEvent &event ); 121+ wxString m_selectedDirectory; 122 123 DECLARE_DYNAMIC_CLASS(wxDirDialog) 124- DECLARE_EVENT_TABLE() 125 }; 126 127