summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorhobbs <hobbs>2005-08-23 22:08:26 (GMT)
committerhobbs <hobbs>2005-08-23 22:08:26 (GMT)
commit5ee2c9693927ecc7e97c25a1607e5c4cbc72a057 (patch)
tree84dd1d2f9ad4c9fc16db02966dfb6b4c04f6e4ea /macosx
parent8ed17064247a6710ff4eff1b1fb1055d8e00cbad (diff)
downloadtk-5ee2c9693927ecc7e97c25a1607e5c4cbc72a057.zip
tk-5ee2c9693927ecc7e97c25a1607e5c4cbc72a057.tar.gz
tk-5ee2c9693927ecc7e97c25a1607e5c4cbc72a057.tar.bz2
* macosx/tkMacOSXDialog.c: make dialogs ignore -initialfile "" and
-initialdir "" instead of error.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXDialog.c90
1 files changed, 48 insertions, 42 deletions
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index d94b945..bc7b3c8 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.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: tkMacOSXDialog.c,v 1.4.2.6 2005/08/22 11:55:15 das Exp $
+ * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.4.2.7 2005/08/23 22:08:27 hobbs Exp $
*/
#include <Carbon/Carbon.h>
@@ -87,7 +87,7 @@ static int HandleInitialDirectory (Tcl_Interp *interp,
char *initialFile, char *initialDir,
FSRef *dirRef,
AEDescList *selectDescPtr,
- AEDesc *dirDescPtr);
+ AEDesc *dirDescPtr);
/*
* Have we initialized the file dialog subsystem
@@ -273,15 +273,15 @@ Tk_GetOpenFileObjCmd(
AEDescList selectDesc = {typeNull, NULL};
char *initialFile = NULL, *initialDir = NULL;
static CONST char *openOptionStrings[] = {
- "-defaultextension", "-filetypes",
- "-initialdir", "-initialfile",
+ "-defaultextension", "-filetypes",
+ "-initialdir", "-initialfile",
"-message", "-multiple",
- "-parent", "-title", NULL
+ "-parent", "-title", NULL
};
enum openOptions {
- OPEN_DEFAULT, OPEN_FILETYPES,
+ OPEN_DEFAULT, OPEN_FILETYPES,
OPEN_INITDIR, OPEN_INITFILE,
- OPEN_MESSAGE, OPEN_MULTIPLE,
+ OPEN_MESSAGE, OPEN_MULTIPLE,
OPEN_PARENT, OPEN_TITLE
};
@@ -289,14 +289,14 @@ Tk_GetOpenFileObjCmd(
InitFileDialogs();
}
- result = TCL_ERROR;
- parent = (Tk_Window) clientData;
+ result = TCL_ERROR;
+ parent = (Tk_Window) clientData;
multiple = false;
title = NULL;
- message = NULL;
+ message = NULL;
TkInitFileFilters(&ofd.fl);
-
+
ofd.curType = 0;
ofd.popupItem = OPEN_POPUP_ITEM;
ofd.usePopup = 1;
@@ -331,10 +331,14 @@ Tk_GetOpenFileObjCmd(
}
break;
case OPEN_INITDIR:
- initialDir = Tcl_GetStringFromObj(objv[i + 1], NULL);
+ initialDir = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
+ /* empty strings should be like no selection given */
+ if (choiceLen == 0) { initialDir = NULL; }
break;
case OPEN_INITFILE:
initialFile = Tcl_GetStringFromObj(objv[i + 1], NULL);
+ /* empty strings should be like no selection given */
+ if (choiceLen == 0) { initialFile = NULL; }
break;
case OPEN_MESSAGE:
choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
@@ -374,8 +378,7 @@ Tk_GetOpenFileObjCmd(
initialPtr = &initialDesc;
}
result = NavServicesGetFile(interp, &ofd, initialPtr,
- NULL, &selectDesc,
- title, message, multiple, OPEN_FILE);
+ NULL, &selectDesc, title, message, multiple, OPEN_FILE);
end:
TkFreeFileFilters(&ofd.fl);
@@ -434,11 +437,11 @@ Tk_GetSaveFileObjCmd(
if (!fileDlgInited) {
InitFileDialogs();
}
-
- result = TCL_ERROR;
- parent = (Tk_Window) clientData;
+
+ result = TCL_ERROR;
+ parent = (Tk_Window) clientData;
title = NULL;
- message = NULL;
+ message = NULL;
for (i = 1; i < objc; i += 2) {
char *choice;
@@ -462,15 +465,19 @@ Tk_GetSaveFileObjCmd(
/* Currently unimplemented - what would we do here anyway? */
break;
case SAVE_INITDIR:
- choice = Tcl_GetStringFromObj(objv[i + 1], NULL);
- if (HandleInitialDirectory(interp, NULL, choice, &dirRef,
- NULL, &initialDesc) != TCL_OK) {
- result = TCL_ERROR;
- goto end;
- }
+ choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
+ /* empty strings should be like no selection given */
+ if (choiceLen &&
+ HandleInitialDirectory(interp, NULL, choice, &dirRef,
+ NULL, &initialDesc) != TCL_OK) {
+ result = TCL_ERROR;
+ goto end;
+ }
break;
case SAVE_INITFILE:
- initialFile = Tcl_GetStringFromObj(objv[i + 1], NULL);
+ initialFile = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
+ /* empty strings should be like no selection given */
+ if (choiceLen == 0) { initialFile = NULL; }
break;
case SAVE_MESSAGE:
choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
@@ -492,7 +499,7 @@ Tk_GetSaveFileObjCmd(
break;
}
}
-
+
TkInitFileFilters(&ofd.fl);
ofd.usePopup = 0;
@@ -503,7 +510,7 @@ Tk_GetSaveFileObjCmd(
title, message, false, SAVE_FILE);
end:
-
+
AEDisposeDesc(&initialDesc);
if (title != NULL) {
CFRelease(title);
@@ -511,7 +518,7 @@ Tk_GetSaveFileObjCmd(
if (message != NULL) {
CFRelease(message);
}
-
+
return result;
}
@@ -549,14 +556,13 @@ Tk_ChooseDirectoryObjCmd(clientData, interp, objc, objv)
CFStringRef message, title;
OpenFileData ofd;
static CONST char *chooseOptionStrings[] = {
- "-initialdir", "-message", "-mustexist", "-parent", "-title", NULL
+ "-initialdir", "-message", "-mustexist", "-parent", "-title", NULL
};
enum chooseOptions {
- CHOOSE_INITDIR, CHOOSE_MESSAGE, CHOOSE_MUSTEXIST,
- CHOOSE_PARENT, CHOOSE_TITLE
+ CHOOSE_INITDIR, CHOOSE_MESSAGE, CHOOSE_MUSTEXIST,
+ CHOOSE_PARENT, CHOOSE_TITLE
};
-
-
+
if (!NavServicesAvailable()) {
return TCL_ERROR;
}
@@ -564,10 +570,10 @@ Tk_ChooseDirectoryObjCmd(clientData, interp, objc, objv)
if (!fileDlgInited) {
InitFileDialogs();
}
- result = TCL_ERROR;
- parent = (Tk_Window) clientData;
+ result = TCL_ERROR;
+ parent = (Tk_Window) clientData;
title = NULL;
- message = NULL;
+ message = NULL;
for (i = 1; i < objc; i += 2) {
char *choice;
@@ -586,9 +592,10 @@ Tk_ChooseDirectoryObjCmd(clientData, interp, objc, objv)
}
switch (index) {
case CHOOSE_INITDIR:
- choice = Tcl_GetStringFromObj(objv[i + 1], NULL);
- if (HandleInitialDirectory(interp, NULL, choice, &dirRef,
- NULL, &initialDesc) != TCL_OK) {
+ choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
+ if (choiceLen &&
+ HandleInitialDirectory(interp, NULL, choice, &dirRef,
+ NULL, &initialDesc) != TCL_OK) {
result = TCL_ERROR;
goto end;
}
@@ -613,11 +620,10 @@ Tk_ChooseDirectoryObjCmd(clientData, interp, objc, objv)
break;
}
}
-
+
TkInitFileFilters(&ofd.fl);
ofd.usePopup = 0;
-
if (initialDesc.descriptorType == typeFSRef) {
initialPtr = &initialDesc;
}
@@ -658,7 +664,7 @@ HandleInitialDirectory (
}
err = FSPathMakeRef((unsigned char*) dirName,
- dirRef, &isDirectory);
+ dirRef, &isDirectory);
if (err != noErr) {
Tcl_AppendResult(interp, "bad directory \"",