]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/dirdlg.cpp
wxDC::GetHandle support for wxMSW
[wxWidgets.git] / src / gtk / dirdlg.cpp
index 8613388d29cc6bd18ee215de6b391b48624e314f..a877cbabfe792bba816c8d49cdce2972837cb80d 100644 (file)
@@ -31,7 +31,9 @@
 
 #include "wx/gtk/private.h"
 
+#ifdef __UNIX__
 #include <unistd.h> // chdir
+#endif
 
 //-----------------------------------------------------------------------------
 // "clicked" for OK-button
@@ -49,7 +51,7 @@ static void gtk_dirdialog_ok_callback(GtkWidget *widget, wxDirDialog *dialog)
 
     wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
     event.SetEventObject(dialog);
-    dialog->GetEventHandler()->ProcessEvent(event);
+    dialog->HandleWindowEvent(event);
 }
 }
 
@@ -63,7 +65,7 @@ static void gtk_dirdialog_cancel_callback(GtkWidget *WXUNUSED(w),
 {
     wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
     event.SetEventObject(dialog);
-    dialog->GetEventHandler()->ProcessEvent(event);
+    dialog->HandleWindowEvent(event);
 }
 }
 
@@ -96,17 +98,28 @@ wxDirDialog::wxDirDialog(wxWindow* parent,
                          const wxPoint& pos,
                          const wxSize& WXUNUSED(sz),
                          const wxString& WXUNUSED(name))
+{
+    Create(parent, title, defaultPath, style, pos);
+}
+
+bool wxDirDialog::Create(wxWindow* parent,
+                         const wxString& title,
+                         const wxString& defaultPath,
+                         long style,
+                         const wxPoint& pos,
+                         const wxSize& WXUNUSED(sz),
+                         const wxString& WXUNUSED(name))
 {
     m_message = title;
 
-    parent = GetParentForModalDialog(parent);
+    parent = GetParentForModalDialog(parent, style);
 
     if (!PreCreation(parent, pos, wxDefaultSize) ||
         !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style,
                 wxDefaultValidator, wxT("dirdialog")))
     {
         wxFAIL_MSG( wxT("wxDirDialog creation failed") );
-        return;
+        return false;
     }
 
     GtkWindow* gtk_parent = NULL;
@@ -120,6 +133,7 @@ wxDirDialog::wxDirDialog(wxWindow* parent,
                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                    GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                    NULL);
+    g_object_ref(m_widget);
 
     gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_ACCEPT);
 
@@ -134,7 +148,7 @@ wxDirDialog::wxDirDialog(wxWindow* parent,
     // local-only property could be set to false to allow non-local files to be loaded.
     // In that case get/set_uri(s) should be used instead of get/set_filename(s) everywhere
     // and the GtkFileChooserDialog should probably also be created with a backend,
-    // e.g "gnome-vfs", "default", ... (gtk_file_chooser_dialog_new_with_backend).
+    // e.g. "gnome-vfs", "default", ... (gtk_file_chooser_dialog_new_with_backend).
     // Currently local-only is kept as the default - true:
     // gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(m_widget), true);
 
@@ -143,7 +157,9 @@ wxDirDialog::wxDirDialog(wxWindow* parent,
 
     if ( !defaultPath.empty() )
         gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget),
-                defaultPath.fn_str() );
+                                             wxGTK_CONV_FN(defaultPath) );
+
+    return true;
 }
 
 void wxDirDialog::OnFakeOk(wxCommandEvent& WXUNUSED(event))
@@ -164,14 +180,14 @@ void wxDirDialog::SetPath(const wxString& dir)
     if (wxDirExists(dir))
     {
         gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
-                                            dir.fn_str());
+                                            wxGTK_CONV_FN(dir));
     }
 }
 
 wxString wxDirDialog::GetPath() const
 {
     wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
-    return wxString(str, *wxConvFileName);
+    return wxString::FromUTF8(str);
 }
 
 #endif // wxUSE_DIRDLG