summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjingham <jingham>2000-04-23 03:47:13 (GMT)
committerjingham <jingham>2000-04-23 03:47:13 (GMT)
commit5de78d21c1372cc6afdd12a2dc56b4909ad3a505 (patch)
tree80482fd73a69139e652624000f1c33ca6f129f2a
parentc1eb29d0bb103e5f44b45ae8d13803ccb0921b41 (diff)
downloadtk-5de78d21c1372cc6afdd12a2dc56b4909ad3a505.zip
tk-5de78d21c1372cc6afdd12a2dc56b4909ad3a505.tar.gz
tk-5de78d21c1372cc6afdd12a2dc56b4909ad3a505.tar.bz2
2000-04-22 Jim Ingham <jingham@cygnus.com> * mac/tkMacDialog.c (Tk_MacGetOpenFile): Add empty bodies for the "-initialfile" and "-defaultextension" options. * mac/tkMacDialog.c (NavServicesGetFile): Only cons the result up into a list if multiple is true. * mac/tkMacMenus.c (SourceDialog): Use the "tk_getOpenFile" instead of hand-coding the dialog with StandardGetFile. This way we get the Navigation dialogs for free. * doc/getOpenFile.n: Document the -multiple and -message flags which are only implemented on the Mac. Also note that the -title works on the Mac with Nav Services installed.
-rw-r--r--ChangeLog17
-rw-r--r--doc/getOpenFile.n18
-rw-r--r--mac/tkMacDialog.c38
-rw-r--r--mac/tkMacMenus.c27
4 files changed, 74 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 7f364ff..b575980 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2000-04-22 Jim Ingham <jingham@cygnus.com>
+
+ * mac/tkMacDialog.c (Tk_MacGetOpenFile): Add empty bodies for the
+ "-initialfile" and "-defaultextension" options.
+
+ * mac/tkMacDialog.c (NavServicesGetFile): Only cons the result up into
+ a list if multiple is true.
+
+ * mac/tkMacMenus.c (SourceDialog): Use the "tk_getOpenFile" instead of hand-coding
+ the dialog with StandardGetFile. This way we get the Navigation dialogs for
+ free.
+
+ * doc/getOpenFile.n: Document the -multiple and -message flags which are only
+ implemented on the Mac. Also note that the -title works on the Mac with
+ Nav Services installed.
+
+
2000-04-19 Jeff Hobbs <hobbs@scriptics.com>
* win/aclocal.m4: made SC_PROG_TCLSH search specifically for
diff --git a/doc/getOpenFile.n b/doc/getOpenFile.n
index de17086..7cfe783 100644
--- a/doc/getOpenFile.n
+++ b/doc/getOpenFile.n
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: getOpenFile.n,v 1.5 2000/01/27 00:23:10 ericm Exp $
+'\" RCS: @(#) $Id: getOpenFile.n,v 1.6 2000/04/23 03:47:13 jingham Exp $
'\"
.so man.macros
.TH tk_getOpenFile n 4.2 Tk "Tk Built-In Commands"
@@ -67,7 +67,18 @@ control panel on the Mac allows the end user to override the
application default directory.
.TP
\fB\-initialfile\fR \fIfilename\fR
-Specifies a filename to be displayed in the dialog when it pops up.
+Specifies a filename to be displayed in the dialog when it pops up. This
+option is ignored on the Macintosh platform.
+.TP
+\fB\-multiple\fR
+Allows the user to choose multiple files from the Open dialog.
+This is only available on the Macintosh, and only when Navigation
+Services are installed.
+.TP
+\fB\-message\fR
+Specifies a message to include in the client area of the dialog.
+This is only available on the Macintosh, and only when Navigation
+Services are installed.
.TP
\fB\-parent\fR \fIwindow\fR
Makes \fIwindow\fR the logical parent of the file dialog. The file
@@ -75,8 +86,7 @@ dialog is displayed on top of its parent window.
.TP
\fB\-title\fR \fItitleString\fR
Specifies a string to display as the title of the dialog box. If this
-option is not specified, then a default title is displayed. This
-option is ignored on the Macintosh platform.
+option is not specified, then a default title is displayed.
.PP
If the user selects a file, both \fBtk_getOpenFile\fR and
\fBtk_getSaveFile\fR return the full pathname of this file. If the
diff --git a/mac/tkMacDialog.c b/mac/tkMacDialog.c
index 51c250c..629860c 100644
--- a/mac/tkMacDialog.c
+++ b/mac/tkMacDialog.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacDialog.c,v 1.5 2000/04/17 02:16:50 jingham Exp $
+ * RCS: @(#) $Id: tkMacDialog.c,v 1.6 2000/04/23 03:47:24 jingham Exp $
*/
#include <Gestalt.h>
@@ -305,11 +305,15 @@ Tk_GetOpenFileObjCmd(
AEDesc initialDesc = {typeNull, NULL};
FSSpec dirSpec;
static char *openOptionStrings[] = {
- "-filetypes", "-initialdir", "-message", "-multiple",
+ "-defaultextension", "-filetypes",
+ "-initialdir", "-initialfile",
+ "-message", "-multiple",
"-parent", "-title", NULL
};
enum openOptions {
- OPEN_TYPES, OPEN_INITDIR, OPEN_MESSAGE, OPEN_MULTIPLE,
+ OPEN_DEFAULT, OPEN_TYPES,
+ OPEN_INITDIR, OPEN_INITFILE,
+ OPEN_MESSAGE, OPEN_MULTIPLE,
OPEN_PARENT, OPEN_TITLE
};
@@ -349,6 +353,8 @@ Tk_GetOpenFileObjCmd(
}
switch (index) {
+ case OPEN_DEFAULT:
+ break;
case OPEN_TYPES:
choice = Tcl_GetStringFromObj(objv[i + 1], NULL);
if (TkGetFileFilters(interp, &ofd.fl, choice, 0)
@@ -365,6 +371,8 @@ Tk_GetOpenFileObjCmd(
goto end;
}
break;
+ case OPEN_INITFILE:
+ break;
case OPEN_MESSAGE:
choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
Tcl_UtfToExternal(NULL, NULL, choice, choiceLen,
@@ -898,7 +906,17 @@ NavServicesGetFile(
openFileEventUPP, NULL, NULL);
}
- theResult = Tcl_NewListObj(0, NULL);
+
+ /*
+ * Most commands assume that the file dialogs return a single
+ * item, not a list. So only build a list if multiple is true...
+ */
+
+ if (multiple) {
+ theResult = Tcl_NewListObj(0, NULL);
+ } else {
+ theResult = Tcl_NewObj();
+ }
if ( theReply.validRecord && err == noErr ) {
AEDesc resultDesc;
@@ -921,9 +939,15 @@ NavServicesGetFile(
&length, &pathHandle);
HLock(pathHandle);
Tcl_ExternalToUtfDString(NULL, (char *) *pathHandle, -1, &fileName);
- Tcl_ListObjAppendElement(interp, theResult,
- Tcl_NewStringObj(Tcl_DStringValue(&fileName),
- Tcl_DStringLength(&fileName)));
+ if (multiple) {
+ Tcl_ListObjAppendElement(interp, theResult,
+ Tcl_NewStringObj(Tcl_DStringValue(&fileName),
+ Tcl_DStringLength(&fileName)));
+ } else {
+ Tcl_SetStringObj(theResult, Tcl_DStringValue(&fileName),
+ Tcl_DStringLength(&fileName));
+ }
+
Tcl_DStringFree(&fileName);
HUnlock(pathHandle);
DisposeHandle(pathHandle);
diff --git a/mac/tkMacMenus.c b/mac/tkMacMenus.c
index 2230f7a..f83e49d 100644
--- a/mac/tkMacMenus.c
+++ b/mac/tkMacMenus.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacMenus.c,v 1.5 2000/02/10 08:56:03 jingham Exp $
+ * RCS: @(#) $Id: tkMacMenus.c,v 1.6 2000/04/23 03:47:32 jingham Exp $
*/
#include "tcl.h"
@@ -329,29 +329,26 @@ GenerateEditEvent(
static void
SourceDialog()
{
- StandardFileReply reply;
- OSType fileTypes[1];
- OSErr err;
- int length, result;
- Handle path;
+ int result;
+ char *path;
+ char openCmd[] = "tk_getOpenFile -filetypes {\
+ {{TCL Scripts} {.tcl} TEXT} {{Text Files} {} TEXT}}";
if (gInterp == NULL) {
return;
}
- fileTypes[0] = 'TEXT';
- StandardGetFile(NULL, 1, fileTypes, &reply);
- if (reply.sfGood == false) {
+ if (Tcl_Eval(gInterp, openCmd) != TCL_OK) {
return;
}
- err = FSpPathFromLocation(&reply.sfFile, &length, &path);
- if (err == noErr) {
- HLock(path);
- result = Tcl_EvalFile(gInterp, *path);
- HUnlock(path);
- DisposeHandle(path);
+ path = Tcl_GetStringResult(gInterp);
+
+ if (strlen(path) == 0) {
+ return;
}
+
+ result = Tcl_EvalFile(gInterp, path);
if (result == TCL_ERROR) {
Tcl_BackgroundError(gInterp);
}