summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--macosx/tkMacOSXDialog.c94
-rw-r--r--macosx/tkMacOSXMenu.c11
-rw-r--r--macosx/tkMacOSXWm.c30
4 files changed, 81 insertions, 70 deletions
diff --git a/ChangeLog b/ChangeLog
index 2bba247..f8a707e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2004-02-13 Jim Ingham <jingham@apple.com>
+
+ * tkMacOSXDialog.c (Tk_GetOpenFileObjCmd): Use CFStringRef for
+ title & message options, not pascal strings.
+ (Tk_GetSaveFileObjCmd): Ditto
+ (Tk_ChooseDirectoryObjCmd): Ditto
+ (NavServicesGetFile): Now that we get CFStrings, we don't need
+ to convert them here.
+
+ * tkMacOSXMenu.c (TkMacOSXDispatchMenuEvent): Cleanup, we don't
+ need to handle the Apple Menu picks any more, but the code didn't
+ reflect that.
+
+ * tkMacOSXWm.c (TkSetWMName): Use CFStrings for the Window Title
+ name, not Pascal strings.
+
2004-02-12 Jeff Hobbs <jeffh@ActiveState.com>
* win/tkWinDialog.c (ChooseDirectoryValidateProc): create a pidl
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;
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index 8005558..d914c4f 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.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: tkMacOSXMenu.c,v 1.10 2003/08/12 08:49:22 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.11 2004/02/14 01:26:49 wolfsuit Exp $
*/
#include "tkMacOSXInt.h"
#include "tkMenuButton.h"
@@ -1044,7 +1044,6 @@ ReconfigureIndividualMenu(
int count;
int index;
TkMenuEntry *mePtr;
- Str255 itemText;
int parentDisabled = 0;
for (mePtr = menuPtr->menuRefPtr->parentEntryPtr; mePtr != NULL;
@@ -2158,9 +2157,11 @@ TkMacOSXDispatchMenuEvent(
TkMenu *menuPtr = (TkMenu *) Tcl_GetHashValue(commandEntryPtr);
if ((currentAppleMenuID == menuID)
&& (index > menuPtr->numEntries + 1)) {
- Str255 itemText;
-
- GetMenuItemText(GetMenuHandle(menuID), index, itemText);
+ /*
+ * We don't need to do anything here, the standard
+ * Application event handler will open the built-in
+ * Apple menu item for us.
+ */
result = TCL_OK;
} else {
struct MenuCommandHandlerData *data
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index ff4b41e..0402e6a 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXWm.c,v 1.9 2004/01/13 02:06:01 davygrvy Exp $
+ * RCS: @(#) $Id: tkMacOSXWm.c,v 1.10 2004/02/14 01:26:49 wolfsuit Exp $
*/
#include <Carbon/Carbon.h>
@@ -4269,29 +4269,27 @@ TkSetWMName(
TkWindow *winPtr,
Tk_Uid titleUid)
{
- Str255 pTitle;
+ CFStringRef title;
WindowRef macWin;
- int destWrote;
if (Tk_IsEmbedded(winPtr)) {
return;
}
- Tcl_UtfToExternal(NULL, TkMacOSXCarbonEncoding, titleUid,
- strlen(titleUid), 0, NULL,
- (char *) &pTitle[1],
- 255, NULL, &destWrote, NULL); /* Internalize native */
- pTitle[0] = destWrote;
+
+ if (strlen(titleUid) > 0) {
+ title = CFStringCreateWithBytes(NULL, titleUid, strlen(titleUid),
+ kCFStringEncodingUTF8, false);
+ } else {
+ title = NULL;
+ }
macWin = GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window));
- /*
- * FIXME: Convert this to SetWindowTitleWithCFString, we should
- * use CFStrings and not pascal strings wherever they are supported,
- * since at some point there will be encodings that can't be supported
- * with the pascal string interfaces.
- */
-
- SetWTitle( macWin, pTitle);
+ SetWindowTitleWithCFString(macWin, title);
+
+ if (title != NULL) {
+ CFRelease(title);
+ }
}