diff options
Diffstat (limited to 'macosx/tkMacOSXDialog.c')
-rw-r--r-- | macosx/tkMacOSXDialog.c | 94 |
1 files changed, 45 insertions, 49 deletions
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index eb77843..f917fdc 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.6 2003/10/23 23:55:17 wolfsuit Exp $ + * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.7 2004/02/14 01:26:49 wolfsuit Exp $ */ #include <Carbon/Carbon.h> @@ -82,7 +82,7 @@ static void InitFileDialogs(); static int NavServicesGetFile(Tcl_Interp *interp, OpenFileData *ofd, AEDesc *initialDescPtr, unsigned char *initialFile, AEDescList *selectDescPtr, - StringPtr title, StringPtr message, int multiple, int isOpen); + CFStringRef title, CFStringRef message, int multiple, int isOpen); static int HandleInitialDirectory (Tcl_Interp *interp, char *initialFile, char *initialDir, FSRef *dirRef, @@ -266,7 +266,7 @@ Tk_GetOpenFileObjCmd( int i, result, multiple; OpenFileData ofd; Tk_Window parent; - Str255 message, title; + CFStringRef message, title; AEDesc initialDesc = {typeNull, NULL}; FSRef dirRef; AEDesc *initialPtr = NULL; @@ -292,8 +292,8 @@ Tk_GetOpenFileObjCmd( result = TCL_ERROR; parent = (Tk_Window) clientData; multiple = false; - title[0] = 0; - message[0] = 0; + title = NULL; + message = NULL; TkInitFileFilters(&ofd.fl); @@ -305,7 +305,6 @@ Tk_GetOpenFileObjCmd( char *choice; int index, choiceLen; char *string; - int srcRead, dstWrote; if (Tcl_GetIndexFromObj(interp, objv[i], openOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { @@ -339,10 +338,8 @@ Tk_GetOpenFileObjCmd( break; case OPEN_MESSAGE: choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); - Tcl_UtfToExternal(NULL, TkMacOSXCarbonEncoding, choice, choiceLen, - 0, NULL, StrBody(message), 255, - &srcRead, &dstWrote, NULL); - message[0] = dstWrote; + message = CFStringCreateWithBytes(NULL, choice, choiceLen, + kCFStringEncodingUTF8, false); break; case OPEN_MULTIPLE: if (Tcl_GetBooleanFromObj(interp, objv[i + 1], &multiple) @@ -361,10 +358,8 @@ Tk_GetOpenFileObjCmd( break; case OPEN_TITLE: choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); - Tcl_UtfToExternal(NULL, TkMacOSXCarbonEncoding, choice, choiceLen, - 0, NULL, StrBody(title), 255, - &srcRead, &dstWrote, NULL); - title[0] = dstWrote; + title = CFStringCreateWithBytes(NULL, choice, choiceLen, + kCFStringEncodingUTF8, false); break; } } @@ -386,6 +381,12 @@ Tk_GetOpenFileObjCmd( TkFreeFileFilters(&ofd.fl); AEDisposeDesc(&initialDesc); AEDisposeDesc(&selectDesc); + if (title != NULL) { + CFRelease(title); + } + if (message != NULL) { + CFRelease(message); + } return result; } @@ -419,7 +420,7 @@ Tk_GetSaveFileObjCmd( AEDesc initialDesc = {typeNull, NULL}; AEDesc *initialPtr = NULL; FSRef dirRef; - Str255 title, message; + CFStringRef title, message; OpenFileData ofd; static CONST char *saveOptionStrings[] = { "-defaultextension", "-filetypes", "-initialdir", "-initialfile", @@ -437,8 +438,8 @@ Tk_GetSaveFileObjCmd( result = TCL_ERROR; parent = (Tk_Window) clientData; StrLength(initialFile) = 0; - title[0] = 0; - message[0] = 0; + title = NULL; + message = NULL; for (i = 1; i < objc; i += 2) { char *choice; @@ -485,10 +486,8 @@ Tk_GetSaveFileObjCmd( break; case SAVE_MESSAGE: choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); - Tcl_UtfToExternal(NULL, TkMacOSXCarbonEncoding, choice, choiceLen, - 0, NULL, StrBody(message), 255, - &srcRead, &dstWrote, NULL); - StrLength(message) = (unsigned char) dstWrote; + message = CFStringCreateWithBytes(NULL, choice, choiceLen, + kCFStringEncodingUTF8, false); break; case SAVE_PARENT: choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); @@ -500,10 +499,8 @@ Tk_GetSaveFileObjCmd( break; case SAVE_TITLE: choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); - Tcl_UtfToExternal(NULL, TkMacOSXCarbonEncoding, choice, choiceLen, - 0, NULL, StrBody(title), 255, - &srcRead, &dstWrote, NULL); - StrLength(title) = (unsigned char) dstWrote; + title = CFStringCreateWithBytes(NULL, choice, choiceLen, + kCFStringEncodingUTF8, false); break; } } @@ -520,6 +517,12 @@ Tk_GetSaveFileObjCmd( end: AEDisposeDesc(&initialDesc); + if (title != NULL) { + CFRelease(title); + } + if (message != NULL) { + CFRelease(message); + } return result; } @@ -555,8 +558,7 @@ Tk_ChooseDirectoryObjCmd(clientData, interp, objc, objv) AEDesc initialDesc = {typeNull, NULL}; AEDesc *initialPtr = NULL; FSRef dirRef; - Str255 message, title; - int srcRead, dstWrote; + CFStringRef message, title; OpenFileData ofd; static CONST char *chooseOptionStrings[] = { "-initialdir", "-message", "-mustexist", "-parent", "-title", NULL @@ -576,8 +578,8 @@ Tk_ChooseDirectoryObjCmd(clientData, interp, objc, objv) } result = TCL_ERROR; parent = (Tk_Window) clientData; - title[0] = 0; - message[0] = 0; + title = NULL; + message = NULL; for (i = 1; i < objc; i += 2) { char *choice; @@ -605,10 +607,8 @@ Tk_ChooseDirectoryObjCmd(clientData, interp, objc, objv) break; case CHOOSE_MESSAGE: choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); - Tcl_UtfToExternal(NULL, TkMacOSXCarbonEncoding, choice, choiceLen, - 0, NULL, StrBody(message), 255, - &srcRead, &dstWrote, NULL); - StrLength(message) = (unsigned char) dstWrote; + message = CFStringCreateWithBytes(NULL, choice, choiceLen, + kCFStringEncodingUTF8, false); break; case CHOOSE_PARENT: choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); @@ -620,10 +620,8 @@ Tk_ChooseDirectoryObjCmd(clientData, interp, objc, objv) break; case CHOOSE_TITLE: choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); - Tcl_UtfToExternal(NULL, TkMacOSXCarbonEncoding, choice, choiceLen, - 0, NULL, StrBody(title), 255, - &srcRead, &dstWrote, NULL); - StrLength(title) = (unsigned char) dstWrote; + title = CFStringCreateWithBytes(NULL, choice, choiceLen, + kCFStringEncodingUTF8, false); break; } } @@ -640,6 +638,12 @@ Tk_ChooseDirectoryObjCmd(clientData, interp, objc, objv) end: AEDisposeDesc(&initialDesc); + if (title != NULL) { + CFRelease(title); + } + if (message != NULL) { + CFRelease(message); + } return result; } @@ -732,8 +736,8 @@ NavServicesGetFile( AEDesc *initialDescPtr, unsigned char *initialFile, AEDescList *selectDescPtr, - StringPtr title, - StringPtr message, + CFStringRef title, + CFStringRef message, int multiple, int isOpen) { @@ -797,22 +801,14 @@ NavServicesGetFile( diagOptions.optionFlags += kNavSupportPackages; diagOptions.clientName = CFStringCreateWithCString(NULL, "Wish", encoding); - if (message == NULL || message[0] == 0) { - diagOptions.message = NULL; - } else { - diagOptions.message = CFStringCreateWithPascalString(NULL, message, encoding); - } + diagOptions.message = message; + diagOptions.windowTitle = title; if ((initialFile != NULL) && (initialFile[0] != 0)) { diagOptions.saveFileName = CFStringCreateWithPascalString(NULL, initialFile, encoding); } else { diagOptions.saveFileName = NULL; } - if (title == NULL || title[0] == '\0') { - diagOptions.windowTitle = NULL; - } else { - diagOptions.windowTitle = CFStringCreateWithPascalString(NULL, title, encoding); - } diagOptions.actionButtonLabel = NULL; diagOptions.cancelButtonLabel = NULL; |