[Openmcl-devel] default directory

Joakim Sandgren joakim at joakimsandgren.com
Sun May 3 13:39:49 PDT 2009


thank you gary,
I did looked at the methods in the openNSPANEL class but I didnt find  
anything mentioning "directory"...
but then i'm not at cocoa expert... (either..;-))
I will look at this and try to figure it out.

it seems to me that easygui is a package that is made a little ad hoc,  
"for now", to resolve urgent needs now. and the gui package is part of  
the "real" cocoa communication in clozure ccl...
and perhaps in a future better version the easygui will be obsolete  
but the gui package not...

I am of course still waiting for some window functions in ccl, and for  
the moment being I dont know on wich horse I should bet...
could someone enlighten me?

Very Sincerely
Joakim



Le 3 mai 09 à 22:15, Gary Byers a écrit :

> (#/runModalForTypes: panel <possibly null NSArray of file types>)
>
> is equivalent to:
>
> (#/runModalForDirectory:file:types: panel +null-ptr+ +null-ptr+  
> <possibly-null-types-array>)
>
> As one would guess from the method name, the two extra arguments  
> accepted by the
> second function are an NSString denoting an absolute directory name  
> and an NSString
> denoting a file in that directory.  So the general idea is:
>
> (defun choose-directory-dialog (&optional default-directory)
>  (execute-in-gui #'(lambda ()
>                      ...
>                      (let* ((dirname (if default-directory
>                                        (#/autorelease
>                                          (ccl::%make-nsstring
>                                           (namestring (truename  
> default-directory))))
>                                        +null-ptr+)))
>                             ...
>                             (when (eql (#/ 
> runModalForDirectory:file:types:
>                                          panel
>                                          dirname
>                                          +null-pointer+
>                                          +null-pointer+)
>                                        #$NSOKButton)
>                               ...)))))
>
> <http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSOpenPanel_Class/Reference/Reference.html 
> >
> is actually a good description of the functionality that NSOpenPanel  
> offers; if
> you have Xcode installed, a local copy of the reference  
> documentation is buried
> somewhere inside the Xcode installation directory (usually / 
> Developer) someplace,
> and you may be able to find it ...
>
> Since it hasn't been plugged for a while, this seems like a good  
> time to mention
> AppKido (<http://homepage.mac.com/aglee/downloads/appkido.html>),  
> which is a good,
> free (well, the author accepts donations via PayPal now) tool for  
> browsing a local
> copy of the Cocoa documentation.
>
> On Sun, 3 May 2009, Joakim Sandgren wrote:
>
>> Hi, and thank you all for helping so much with my questions.
>> here's another:
>> based on the function  choose-directory-dialog in the GUI package I  
>> have done another function adding some title strings, one for the  
>> panel one for the button.
>> Now I would like to add the functionality that the panel opens in a  
>> default directory choosen by me.
>> How do I do that?
>>
>> Sincerely
>>
>> Joakim
>>
>>
>> (defun choose-directory-dialog ()
>> (execute-in-gui #'(lambda ()
>>                    (let ((op (#/openPanel ns:ns-open-panel)))
>>                      (#/setAllowsMultipleSelection: op nil)
>>                      (#/setCanChooseDirectories: op t)
>>                      (#/setCanChooseFiles: op nil)
>>                      (when (eql (#/runModalForTypes: op +null-ptr+)  
>> #$NSOKButton)
>>                        ;; #/stringByStandardizingPath seems to  
>> strip trailing slashes
>>                       (let* ((path (#/retain (#/ 
>> stringByAppendingString:
>>                                      (#/stringByStandardizingPath
>>                                       (#/objectAtIndex: (#/ 
>> filenames op) 0))
>>                                      #@"/"))))
>>                          path))))))
>>
>> (defmethod choose-directory-dialog-with-strings ((dialogtitle  
>> string) (buttonstring string))
>> (gui::lisp-string-from-nsstring
>> (gui::execute-in-gui #'(lambda ()
>>                          (let ((op (#/openPanel ns:ns-open-panel)))
>>                            (#/setAllowsMultipleSelection: op nil)
>>                            (#/setCanChooseDirectories: op t)
>>                            (#/setCanChooseFiles: op nil)
>>                            (#/setPrompt: op (ccl::%make-nsstring  
>> buttonstring))
>>                            (#/setTitle: op (ccl::%make-nsstring  
>> dialogtitle))
>>                            (when (eql (#/runModalForTypes: op +null- 
>> ptr+) #$NSOKButton)
>>                              ;; #/stringByStandardizingPath seems  
>> to strip trailing slashes
>>                              (let* ((path (#/retain (#/ 
>> stringByAppendingString:
>>                                                      (#/ 
>> stringByStandardizingPath
>>                                                       (#/ 
>> objectAtIndex: (#/filenames op) 0))
>>                                                      #@"/"))))
>>                                path)))))))
>>
>>
>> Joakim Sandgren
>> joakim sandgren musik
>> 42, rue de Maubeuge
>> 75009 Paris
>> France
>> +33 (0)1 45 26 43 90
>> info at joakimsandgren.com
>> http://www.joakimsandgren.com
>>
>




Joakim Sandgren
joakim sandgren musik
42, rue de Maubeuge
75009 Paris
France
+33 (0)1 45 26 43 90
info at joakimsandgren.com
http://www.joakimsandgren.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20090503/d06a55d6/attachment.htm>


More information about the Openmcl-devel mailing list