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 f964d78..ab85052 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>
* README: update to patchlevel 8.4.6
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index 8da90f6..25883ce 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 2003/02/25 16:09:23 das Exp $
+ * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.4.2.1 2004/02/14 01:08:28 wolfsuit Exp $
*/
#include <Carbon/Carbon.h>
@@ -70,7 +70,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,
@@ -254,7 +254,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;
@@ -280,8 +280,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);
@@ -293,7 +293,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) {
@@ -327,10 +326,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)
@@ -349,10 +346,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;
}
}
@@ -374,6 +369,12 @@ Tk_GetOpenFileObjCmd(
TkFreeFileFilters(&ofd.fl);
AEDisposeDesc(&initialDesc);
AEDisposeDesc(&selectDesc);
+ if (title != NULL) {
+ CFRelease(title);
+ }
+ if (message != NULL) {
+ CFRelease(message);
+ }
return result;
}
@@ -407,7 +408,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",
@@ -425,8 +426,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;
@@ -473,10 +474,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);
@@ -488,10 +487,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;
}
}
@@ -508,6 +505,12 @@ Tk_GetSaveFileObjCmd(
end:
AEDisposeDesc(&initialDesc);
+ if (title != NULL) {
+ CFRelease(title);
+ }
+ if (message != NULL) {
+ CFRelease(message);
+ }
return result;
}
@@ -543,8 +546,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
@@ -564,8 +566,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;
@@ -593,10 +595,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);
@@ -608,10 +608,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;
}
}
@@ -628,6 +626,12 @@ Tk_ChooseDirectoryObjCmd(clientData, interp, objc, objv)
end:
AEDisposeDesc(&initialDesc);
+ if (title != NULL) {
+ CFRelease(title);
+ }
+ if (message != NULL) {
+ CFRelease(message);
+ }
return result;
}
@@ -720,8 +724,8 @@ NavServicesGetFile(
AEDesc *initialDescPtr,
unsigned char *initialFile,
AEDescList *selectDescPtr,
- StringPtr title,
- StringPtr message,
+ CFStringRef title,
+ CFStringRef message,
int multiple,
int isOpen)
{
@@ -785,22 +789,14 @@ NavServicesGetFile(
diagOptions.optionFlags += kNavSupportPackages;
diagOptions.clientName = CFStringCreateWithCString(NULL, "Wish", encoding);
- if (message == NULL) {
- 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) {
- 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 2180bf9..eec9c77 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.6.2.2 2003/08/12 08:49:39 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.6.2.3 2004/02/14 01:08:28 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 aa00e3a..6973213 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.7.2.1 2003/09/26 16:19:52 cc_benny Exp $
+ * RCS: @(#) $Id: tkMacOSXWm.c,v 1.7.2.2 2004/02/14 01:08:29 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);
+ }
}