X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/516d38cdfda661f0560e8f68820715824b7c51c4..6493aacaeb7b22b9fa35c559f7753e9fec0da71f:/src/mac/carbon/dirdlg.cpp

diff --git a/src/mac/carbon/dirdlg.cpp b/src/mac/carbon/dirdlg.cpp
index 822047c4df..a17768a61b 100644
--- a/src/mac/carbon/dirdlg.cpp
+++ b/src/mac/carbon/dirdlg.cpp
@@ -9,10 +9,6 @@
 // Licence:       wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "dirdlg.h"
-#endif
-
 #include "wx/wxprec.h"
 
 #if wxUSE_DIRDLG
@@ -22,6 +18,7 @@
 #include "wx/dirdlg.h"
 
 #include "wx/cmndata.h"
+#include "wx/filename.h"
 
 #include "wx/mac/private.h"
 
@@ -33,6 +30,34 @@
 
 IMPLEMENT_CLASS(wxDirDialog, wxDialog)
 
+static pascal void NavEventProc(
+                                NavEventCallbackMessage inSelector,
+                                NavCBRecPtr ioParams,
+                                NavCallBackUserData ioUserData );
+
+static NavEventUPP sStandardNavEventFilter = NewNavEventUPP(NavEventProc);
+
+static pascal void NavEventProc(
+                                NavEventCallbackMessage inSelector,
+                                NavCBRecPtr ioParams,
+                                NavCallBackUserData ioUserData )
+{
+    wxDirDialog * data = ( wxDirDialog *) ioUserData ;
+    if ( inSelector == kNavCBStart )
+    {
+        if (data && !data->GetPath().IsEmpty() )
+        {
+            // Set default location for the modern Navigation APIs
+            // Apple Technical Q&A 1151
+            FSSpec theFSSpec;
+            wxMacFilename2FSSpec(data->GetPath(), &theFSSpec);
+            AEDesc theLocation = { typeNull, NULL };
+            if (noErr == ::AECreateDesc(typeFSS, &theFSSpec, sizeof(FSSpec), &theLocation))
+                ::NavCustomControl(ioParams->context, kNavCtlSetLocation, (void *) &theLocation);
+        }
+    }
+}
+
 wxDirDialog::wxDirDialog(wxWindow *parent,
                          const wxString& message,
                          const wxString& defaultPath,
@@ -61,7 +86,7 @@ int wxDirDialog::ShowModal()
     {
         wxMacCFStringHolder message(m_message, m_font.GetEncoding());
         options.message = message;
-        err = NavCreateChooseFolderDialog(&options, NULL, NULL, NULL, &dialog);
+        err = NavCreateChooseFolderDialog(&options, sStandardNavEventFilter , NULL,  this , &dialog);
         if (err == noErr) 
         {        
             err = NavDialogRun(dialog);