[TxMt] tm_dialog: add FileSelect + Appending Accessory Views
Hans-Jörg Bibiko
bibiko at eva.mpg.de
Thu Aug 2 19:29:51 UTC 2007
Hi,
so far I did the following:
Usage (internal panel): tm_dialog [-cdp] -I open|save|color
{custom_view_nib_file}
Internal Panel Options:
-I, --internal-panel aPanel <plist> <nib_file> Show internal panel.
aPanel: open, save, color [:= Open File, Save File, Color
Picker Dialog]
open - Parameters: windowTitle, startDir, button1,
message, allowMultipleSelection
fileType [string or array],
canChooseDir, file
save - Parameters: windowTitle, startDir, button1,
message, allowOtherFileTypes
fileType [string or array], label, file
color - Parameters: windowTitle, message, color [string of
#RRGGBB notation]
-- a custom view is not supported
nib_file: contains a customm view with control elements which
will be shown
at the bottom of the open/save dialog
Returned plist:
open/save:
<dict>
<key>buttonClick</key>
<integer>1</integer>
<key>result</key>
<dict>
<key>URL</key>
<string>file://localhost/usr/share/doc/bash/article.pdf</string>
<key>absoluteFileName</key>
<string>/usr/share/doc/bash/article.pdf</string>
<key>directory</key>
<string>/usr/share/doc/bash</string>
<key>pathExtension</key>
<string>pdf</string>
</dict>
</dict>
open with parameter allowMultipleSelection:
<dict>
<key>buttonClick</key>
<integer>1</integer>
<key>result</key>
<dict>
<key>absoluteFileNames</key>
<array>
<string>/Users/Bibiko/DialogPlugin.zip</string>
<string>/Users/Bibiko/fehlerrate.pdf</string>
</array>
</dict>
</dict>
open/save with a custom view with a checkbox - selection key = 'Check':
<dict>
<key>buttonClick</key>
<integer>1</integer>
<key>result</key>
<dict>
<key>URL</key>
<string>file://localhost/usr/share/doc/bash/article.pdf</string>
<key>absoluteFileName</key>
<string>/usr/share/doc/bash/article.pdf</string>
<key>directory</key>
<string>/usr/share/doc/bash</string>
<key>pathExtension</key>
<string>pdf</string>
<key>Check</key>
<integer>1</integer>
</dict>
</dict>
color:
<dict>
<key>color</key>
<string>#00C960</string>
<key>result</key>
<dict>
<key>returnArgument</key>
<string>#00C960</string>
</dict>
</dict>
Notes:
The parameters allowMultipleSelection, canChooseDir, and
allowOtherFileTypes are boolean in such a way that if one write them
in a plist they'll be set to YES automatically regardingless what
value the key has!
E.g. {canChooseDir;} == {canChooseDir="1";} == {canChooseDir=0;} === YES
That also means that these parameters are set to NO as default.
The default of the parameter 'startDir' is, if not set, $HOME. You
can set - startDir="nil"; - to set it automatically to the last path
which was chosen.
The parameter 'fileType' can be a single string like fileType="txt";
or an array fileType=("txt","tab"); .
The Color Picker is realized by a nib file which is stored in
$TM_SUPPORT_PATH/nibs. If one invoke it a dialog with a ColorWell
appears and the ColorPanel pops up automatically. If one press OK/
Cancel the ColorPanel will also closed.
If one want to preset a file in open/save you can use the parameters
'startDir' and 'file'. 'file' is only the file name without the path!
A humble screenshot of a customized Open File Dialog can be seen at
http://email.eva.mpg.de/~bibiko/dt/open.jpg .
########
My question for now is whether I should change something before I
post the code to Alan?
Hans
PS I found my fault with the value transformer. Now it works
perfectly ;)
More information about the textmate
mailing list