Index: macosx/tkMacOSXBitmap.c ================================================================== --- macosx/tkMacOSXBitmap.c +++ macosx/tkMacOSXBitmap.c @@ -11,10 +11,11 @@ * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXConstants.h" + /* * This structure holds information about native bitmaps. */ typedef struct { @@ -172,13 +173,12 @@ Pixmap TkpCreateNativeBitmap( Display *display, const void *source) /* Info about the icon to build. */ { - NSString *iconUTI = OSTYPE_TO_UTI(PTR2UINT(source)); - NSImage *iconImage = [[NSWorkspace sharedWorkspace] - iconForFileType: iconUTI]; + NSString *filetype = [NSString stringWithUTF8String:(char *)source]; + NSImage *iconImage = TkMacOSXIconForFileType(filetype); CGSize size = CGSizeMake(builtInIconSize, builtInIconSize); Pixmap pixmap = PixmapFromImage(display, iconImage, size); return pixmap; } @@ -251,11 +251,10 @@ Tcl_HashEntry *hPtr; Pixmap pixmap = None; NSString *string; NSImage *image = nil; NSSize size = { .width = builtInIconSize, .height = builtInIconSize }; - if (iconBitmapTable.buckets && (hPtr = Tcl_FindHashEntry(&iconBitmapTable, name))) { OSType type; IconBitmap *iconBitmap = (IconBitmap *)Tcl_GetHashValue(hPtr); name = NULL; @@ -266,16 +265,16 @@ stringByExpandingTildeInPath]; image = [[NSWorkspace sharedWorkspace] iconForFile:string]; break; case ICON_FILETYPE: string = [NSString stringWithUTF8String:iconBitmap->value]; - image = [[NSWorkspace sharedWorkspace] iconForFileType:string]; + image = TkMacOSXIconForFileType(string); break; case ICON_OSTYPE: if (OSTypeFromString(iconBitmap->value, &type) == TCL_OK) { - string = NSFileTypeForHFSTypeCode(type); - image = [[NSWorkspace sharedWorkspace] iconForFileType:string]; + string = [NSString stringWithUTF8String:iconBitmap->value]; + image = TkMacOSXIconForFileType(string); } break; case ICON_SYSTEMTYPE: name = iconBitmap->value; break; @@ -310,15 +309,19 @@ if (image) { *width = size.width; *height = size.height; pixmap = PixmapFromImage(display, image, NSSizeToCGSize(size)); } else if (name) { + /* + * As a last resort, try to interpret the name as an OSType. + * It would probably be better to just return None at this + * point. + */ OSType iconType; if (OSTypeFromString(name, &iconType) == TCL_OK) { - NSString *iconUTI = OSTYPE_TO_UTI(iconType); - NSImage *iconImage = [[NSWorkspace sharedWorkspace] - iconForFileType: iconUTI]; + NSString *iconUTI = TkMacOSXOSTypeToUTI(iconType); + NSImage *iconImage = TkMacOSXIconForFileType(iconUTI); pixmap = PixmapFromImage(display, iconImage, NSSizeToCGSize(size)); } } return pixmap; } Index: macosx/tkMacOSXColor.c ================================================================== --- macosx/tkMacOSXColor.c +++ macosx/tkMacOSXColor.c @@ -29,10 +29,11 @@ static SystemColorDatum **systemColorIndex; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 static NSAppearance *lightAqua = nil; static NSAppearance *darkAqua = nil; #endif + static NSColorSpace* sRGB = NULL; static const CGFloat WINDOWBACKGROUND[4] = {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0}; void initColorTable() @@ -415,10 +416,11 @@ NSAutoreleasePool *pool = [NSAutoreleasePool new]; if (entry->type == HIBrush) { OSStatus err = ChkErr(HIThemeBrushCreateCGColor, entry->value, c); + [pool drain]; return err == noErr; } GetRGBA(entry, pixel, rgba); *c = CGColorCreate(sRGB.CGColorSpace, rgba); [pool drain]; @@ -454,11 +456,11 @@ view = TkMacOSXGetNSViewForDrawable((Drawable)winPtr->privatePtr); } if (view) { name = [[view effectiveAppearance] name]; } else { - name = [[NSAppearance currentAppearance] name]; + name = [[NSApp effectiveAppearance] name]; } return (name == NSAppearanceNameDarkAqua); } #endif return false; @@ -628,15 +630,13 @@ TkColor *tkColPtr; XColor color; Colormap colormap = tkwin ? Tk_Colormap(tkwin) : noColormap; NSView *view = nil; static Bool initialized = NO; - static NSColorSpace* sRGB = nil; if (!initialized) { initialized = YES; - sRGB = [NSColorSpace sRGBColorSpace]; initColorTable(); } if (tkwin) { display = Tk_Display(tkwin); Drawable d = Tk_WindowId(tkwin); @@ -660,23 +660,34 @@ color.pixel = p.ulong; if (entry->type == semantic) { CGFloat rgba[4]; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 if (@available(macOS 10.14, *)) { - NSAppearance *savedAppearance = [NSAppearance currentAppearance]; - NSAppearance *windowAppearance = savedAppearance; + NSAppearance *windowAppearance; if (view) { windowAppearance = [view effectiveAppearance]; + } else { + windowAppearance = [NSApp effectiveAppearance]; } if ([windowAppearance name] == NSAppearanceNameDarkAqua) { colormap = darkColormap; } else { colormap = lightColormap; } - [NSAppearance setCurrentAppearance:windowAppearance]; - GetRGBA(entry, p.ulong, rgba); - [NSAppearance setCurrentAppearance:savedAppearance]; + if (@available(macOS 11.0, *)) { + CGFloat *rgbaPtr = rgba; + [windowAppearance performAsCurrentDrawingAppearance:^{ + GetRGBA(entry, p.ulong, rgbaPtr); + }]; + } else { +#if MAC_OS_X_VERSION_MIN_REQUIRED < 110000 + NSAppearance *savedAppearance = [NSAppearance currentAppearance]; + [NSAppearance setCurrentAppearance:windowAppearance]; + GetRGBA(entry, p.ulong, rgba); + [NSAppearance setCurrentAppearance:savedAppearance]; +#endif + } } else { GetRGBA(entry, p.ulong, rgba); } #else GetRGBA(entry, p.ulong, rgba); Index: macosx/tkMacOSXDialog.c ================================================================== --- macosx/tkMacOSXDialog.c +++ macosx/tkMacOSXDialog.c @@ -4,11 +4,12 @@ * Contains the Mac implementation of the common dialog boxes. * * Copyright (c) 1996-1997 Sun Microsystems, Inc. * Copyright (c) 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen - * Copyright (c) 2017 Christian Gollwitzer. + * Copyright (c) 2017 Christian Gollwitzer + * Copyright (c) 2022 Marc Culler * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -23,10 +24,34 @@ #define modalOK NSModalResponseOK #define modalCancel NSModalResponseCancel #endif // MAC_OS_X_VERSION_MIN_REQUIRED < 1090 #define modalOther -1 // indicates that the -command option was used. #define modalError -2 + +static void setAllowedFileTypes( + NSSavePanel *panel, + NSMutableArray *extensions) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000 +/* UTType exists in the SDK */ + if (@available(macOS 11.0, *)) { + NSMutableArray *allowedTypes = [NSMutableArray array]; + for (NSString *ext in extensions) { + UTType *uttype = [UTType typeWithFilenameExtension: ext]; + [allowedTypes addObject:uttype]; + } + [panel setAllowedContentTypes:allowedTypes]; + } else { +# if MAC_OS_X_VERSION_MIN_REQUIRED < 110000 +/* setAllowedFileTypes is not deprecated */ + [panel setAllowedFileTypes:extensions]; +#endif + } +#else + [panel setAllowedFileTypes:extensions]; +#endif +} /* * Vars for filtering in "open file" and "save file" dialogs. */ @@ -300,15 +325,15 @@ * the NSSavePanel, where it has the effect that it does not append an * extension. Setting the allowed file types to nil allows selecting * any file. */ - [openpanel setAllowedFileTypes:nil]; + setAllowedFileTypes(openpanel, nil); } else { NSMutableArray *allowedtypes = [filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex]; - [openpanel setAllowedFileTypes:allowedtypes]; + setAllowedFileTypes(openpanel, allowedtypes); [openpanel setAllowsOtherFileTypes:NO]; } filterInfo.userHasSelectedFilter = true; } @@ -317,15 +342,15 @@ NSPopUpButton *button = (NSPopUpButton *)sender; filterInfo.fileTypeIndex = [button indexOfSelectedItem]; if ([[filterInfo.fileTypeAllowsAll objectAtIndex:filterInfo.fileTypeIndex] boolValue]) { [savepanel setAllowsOtherFileTypes:YES]; - [savepanel setAllowedFileTypes:nil]; + setAllowedFileTypes(savepanel, nil); } else { NSMutableArray *allowedtypes = [filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex]; - [savepanel setAllowedFileTypes:allowedtypes]; + setAllowedFileTypes(savepanel, allowedtypes); [savepanel setAllowsOtherFileTypes:NO]; } filterInfo.userHasSelectedFilter = true; } @@ -801,13 +826,13 @@ * On OSX > 10.11, the options are not visible by default. Ergo * allow all file types [openpanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]]; */ - [openpanel setAllowedFileTypes:filterInfo.allowedExtensions]; + setAllowedFileTypes(openpanel, filterInfo.allowedExtensions); } else { - [openpanel setAllowedFileTypes:filterInfo.allowedExtensions]; + setAllowedFileTypes(openpanel, filterInfo.allowedExtensions); } if (filterInfo.allowedExtensionsAllowAll) { [openpanel setAllowsOtherFileTypes:YES]; } else { [openpanel setAllowsOtherFileTypes:NO]; @@ -1074,11 +1099,12 @@ [accessoryView addSubview:label]; [accessoryView addSubview:popupButton]; [savepanel setAccessoryView:accessoryView]; - [savepanel setAllowedFileTypes:[filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex]]; + setAllowedFileTypes(savepanel, + [filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex]); [savepanel setAllowsOtherFileTypes:filterInfo.allowedExtensionsAllowAll]; } else if (defaultType) { /* * If no filetypes are given, defaultextension is an alternative way to * specify the attached extension. Just propose this extension, but @@ -1086,11 +1112,11 @@ */ NSMutableArray *AllowedFileTypes = [NSMutableArray array]; [AllowedFileTypes addObject:defaultType]; - [savepanel setAllowedFileTypes:AllowedFileTypes]; + setAllowedFileTypes(savepanel, AllowedFileTypes); [savepanel setAllowsOtherFileTypes:YES]; } [savepanel setCanSelectHiddenExtension:YES]; [savepanel setExtensionHidden:NO]; ADDED macosx/tkMacOSXFileTypes.c Index: macosx/tkMacOSXFileTypes.c ================================================================== --- /dev/null +++ macosx/tkMacOSXFileTypes.c @@ -0,0 +1,112 @@ +/* +There are situations where a graphical user interface needs to know the file +type (i.e. data format) of a file. The two main ones are when generating an +icon to represent a file, and when filtering the choice of files in a file +open or save dialog. + +Early Macintosh systems used OSTypes as identifiers for file types. An OSType +is a FourCC datatype - four bytes which can be packed into a 32 bit integer. In +the HFS filesystem they were included in the file metadata. The metadata also +included another OSType (the Creator Code) which identified the application +which created the file. + +In OSX 10.4 the Uniform Type Identifier was introduced as an alternative way to +describe file types. These are strings (NSStrings, actually) in a reverse DNS +format, such as "com.apple.application-bundle". Apple provided a tool for +converting OSType codes to Uniform Type Identifiers, which they deprecated in +macOS 12.0 after introducing the UTType class in macOS 11.0. An instance of the +UTType class has properties which give the Uniform Type Identifier as well as +the preferred file name extension for a given file type. + +This module provides tools for working with file types which are meant to abstract +the many variants that Apple has used over the years, and which can be used +without generating deprecation warnings. +*/ + +#include "tkMacOSXPrivate.h" +#include "tkMacOSXFileTypes.h" +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000 +#import +#endif + +#define CHARS_TO_OSTYPE(string) (OSType) string[0] << 24 | \ + (OSType) string[1] << 16 | \ + (OSType) string[2] << 8 | \ + (OSType) string[3] + +static BOOL initialized = false; +static Tcl_HashTable ostype2identifier; +static void initOSTypeTable(void) { + int newPtr; + Tcl_HashEntry *hPtr; + const IdentifierForOSType *entry; + Tcl_InitHashTable(&ostype2identifier, TCL_ONE_WORD_KEYS); + for (entry = OSTypeDB; entry->ostype != NULL; entry++) { + const char *key = INT2PTR(CHARS_TO_OSTYPE(entry->ostype)); + hPtr = Tcl_CreateHashEntry(&ostype2identifier, key, &newPtr); + if (newPtr) { + Tcl_SetHashValue(hPtr, entry->identifier); + } + } + initialized = true; +} + +MODULE_SCOPE NSString *TkMacOSXOSTypeToUTI(OSType ostype) { + if (!initialized) { + initOSTypeTable(); + } + Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&ostype2identifier, INT2PTR(ostype)); + if (hPtr) { + char *UTI = Tcl_GetHashValue(hPtr); + return [[NSString alloc] initWithCString:UTI + encoding:NSASCIIStringEncoding]; + } + return nil; +} + +/* + * The NSWorkspace method iconForFileType, which was deprecated in macOS 12.0, would + * accept an NSString which could be an encoding of an OSType, or a file extension, + * or a Uniform Type Idenfier. This function can serve as a replacement. + */ + +MODULE_SCOPE NSImage *TkMacOSXIconForFileType(NSString *filetype) { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 + if (!initialized) { + initOSTypeTable(); + } + if (@available(macOS 11.0, *)) { + UTType *uttype = [UTType typeWithIdentifier: filetype]; + if (![uttype isDeclared]) { + uttype = [UTType typeWithFilenameExtension: filetype]; + } + if (![uttype isDeclared] && [filetype length] == 4) { + OSType ostype = CHARS_TO_OSTYPE(filetype.UTF8String); + NSString *UTI = TkMacOSXOSTypeToUTI(ostype); + uttype = [UTType typeWithIdentifier:UTI]; + } + if (![uttype isDeclared]) { + return nil; + } + return [[NSWorkspace sharedWorkspace] iconForContentType:uttype]; + } else { +/* Despite Apple's claims, @available does not prevent deprecation warnings. */ +# if MAC_OS_X_VERSION_MIN_REQUIRED < 110000 + return [[NSWorkspace sharedWorkspace] iconForFileType:filetype]; +#else + return nil; /* Never executed. */ +#endif + } +#else /* @available is not available. */ + return [[NSWorkspace sharedWorkspace] iconForFileType:filetype]; +#endif +} + +/* + * Local Variables: + * mode: objc + * c-basic-offset: 4 + * fill-column: 79 + * coding: utf-8 + * End: + */ ADDED macosx/tkMacOSXFileTypes.h Index: macosx/tkMacOSXFileTypes.h ================================================================== --- /dev/null +++ macosx/tkMacOSXFileTypes.h @@ -0,0 +1,144 @@ +/* +Apple never published a database of OSType codes for File Types. However, +a database of known OSType codes representing Creators and File Types used on +Apple systems prior to 2003 is available at: + + http://www.lacikam.co.il/tcdb/download/TCDBdata.zip + +Among the 12034 distinct OSType codes for File Types that are listed in the TCDB +database, there are 121 for which the UTTypeCreatePreferredIdentifierForTag +function (deprecated in macOS 12.0) was able to generate a Uniform Type +Identifier on macOS 12.5.1. The mapping from those OSTypes to Uniform Type +identifiers is given by the following array, in which OSTypes are represented as +strings of length 4. +*/ + +typedef struct { + char *ostype; + char *identifier; +} IdentifierForOSType; + +static const IdentifierForOSType OSTypeDB[] = { + {".SGI", "com.sgi.sgi-image"}, + {".WAV", "com.microsoft.waveform-audio"}, + {"8BPS", "com.adobe.photoshop-image"}, + {"ABPR", "com.apple.addressbook.person"}, + {"AIFC", "public.aifc-audio"}, + {"AIFF", "public.aiff-audio"}, + {"APPC", "com.apple.deprecated-application-file"}, + {"APPD", "com.apple.deprecated-application-file"}, + {"APPL", "com.apple.application-bundle"}, + {"ASF_", "com.microsoft.advanced-systems-format"}, + {"ASX_", "com.microsoft.advanced-stream-redirector"}, + {"BMP ", "com.microsoft.bmp"}, + {"BMPf", "com.microsoft.bmp"}, + {"BNDL", "com.apple.generic-bundle"}, + {"DDim", "com.apple.disk-image-raw"}, + {"DICM", "org.nema.dicom"}, + {"DOTM", "org.openxmlformats.wordprocessingml.template.macro-enabled"}, + {"EM3F", "com.apple.logic-song"}, + {"EPSF", "com.adobe.encapsulated-postscript"}, + {"FFIL", "com.apple.font-suitcase"}, + {"FLI ", "public.flc-animation"}, + {"FNDR", "com.apple.legacy.finder-icon"}, + {"GIFf", "com.compuserve.gif"}, + {"HTML", "public.html"}, + {"JPEG", "public.jpeg"}, + {"LWFN", "com.adobe.postscript-lwfn-font"}, + {"MP3 ", "public.mp3"}, + {"MP3!", "public.mp3"}, + {"MP3U", "com.apple.tv.m3u-playlist"}, + {"MPEG", "public.mpeg"}, + {"MPG ", "public.mpeg"}, + {"MPG2", "com.apple.music.mp2"}, + {"MPG3", "public.mp3"}, + {"Midi", "public.midi-audio"}, + {"MooV", "com.apple.quicktime-movie"}, + {"Mp3 ", "public.mp3"}, + {"PAT ", "org.gimp.pat"}, + {"PDF ", "com.adobe.pdf"}, + {"PICT", "com.apple.pict"}, + {"PNGf", "public.png"}, + {"PNRA", "com.real.realaudio"}, + {"PNRM", "com.real.realmedia"}, + {"PNTG", "com.apple.macpaint-image"}, + {"PPOT", "com.microsoft.powerpoint.pot"}, + {"PPSS", "com.microsoft.powerpoint.pps"}, + {"RTF ", "public.rtf"}, + {"SDP ", "public.sdp"}, + {"SIT5", "com.stuffit.archive.sit"}, + {"SLD8", "com.microsoft.powerpoint.ppt"}, + {"Sd2f", "com.digidesign.sd2-audio"}, + {"TEXT", "com.apple.traditional-mac-plain-text"}, + {"TIFF", "public.tiff"}, + {"TPIC", "com.truevision.tga-image"}, + {"ULAW", "public.ulaw-audio"}, + {"VfW ", "public.avi"}, + {"W8BN", "com.microsoft.word.doc"}, + {"W8TN", "com.microsoft.word.dot"}, + {"WAVE", "com.microsoft.waveform-audio"}, + {"XLA5", "com.microsoft.excel.xla"}, + {"XLS8", "com.microsoft.excel.xls"}, + {"XLW8", "com.microsoft.excel.xlw"}, + {"alis", "com.apple.alias-record"}, + {"appe", "com.apple.deprecated-application-file"}, + {"cdev", "com.apple.deprecated-application-file"}, + {"clpp", "com.apple.finder.pictclipping"}, + {"clps", "com.apple.finder.sound-clipping"}, + {"clpt", "com.apple.finder.textclipping"}, + {"clpu", "com.apple.finder.clipping"}, + {"ctrl", "com.apple.legacy.finder-icon"}, + {"dfil", "com.apple.deprecated-application-file"}, + {"dict", "com.apple.document-type.dictionary"}, + {"disk", "public.volume"}, + {"docs", "com.apple.documents-folder"}, + {"dvc!", "public.dv-movie"}, + {"ffil", "com.apple.font-suitcase"}, + {"flpy", "com.apple.storage-removable"}, + {"fold", "public.folder"}, + {"font", "com.apple.legacy.finder-icon"}, + {"grup", "com.apple.user-group"}, + {"hdrv", "com.apple.disk-image-raw"}, + {"hdsk", "com.apple.storage-internal"}, + {"help", "com.apple.help-document"}, + {"hkdb", "com.apple.itunes.db"}, + {"hvpl", "com.apple.music.visual"}, + {"ilaf", "com.apple.afp-internet-location"}, + {"ilfi", "com.apple.file-internet-location"}, + {"ilft", "com.apple.ftp-internet-location"}, + {"ilge", "com.apple.generic-internet-location"}, + {"ilht", "com.apple.web-internet-location"}, + {"ilma", "com.apple.mail-internet-location"}, + {"ilnw", "com.apple.news-internet-location"}, + {"macD", "com.apple.legacy.finder-icon"}, + {"mp3!", "public.mp3"}, + {"mpg3", "public.mp3"}, + {"note", "com.apple.alert-note"}, + {"osas", "com.apple.applescript.script"}, + {"plug", "com.apple.plugin"}, + {"pref", "com.apple.legacy.finder-icon"}, + {"prfb", "com.apple.icon-overlay.private-folder-badge"}, + {"prof", "com.apple.colorsync-profile"}, + {"qtif", "com.apple.quicktime-image"}, + {"sLS8", "com.microsoft.excel.xlt"}, + {"sM3F", "com.apple.logic-song"}, + {"sbBF", "com.apple.finder.burn-folder"}, + {"scrp", "com.apple.legacy.finder-icon"}, + {"sdoc", "com.apple.generic-stationery"}, + {"sfnt", "com.apple.font-suitcase"}, + {"shlb", "com.apple.legacy.finder-icon"}, + {"srvr", "com.apple.file-server"}, + {"svg ", "public.svg-image"}, + {"svgz", "public.svg-image"}, + {"tDoc", "com.apple.documents-folder"}, + {"tfil", "com.apple.font-suitcase"}, + {"trsh", "com.apple.trash-empty"}, + {"ttcf", "public.truetype-collection-font"}, + {"ttro", "com.apple.traditional-mac-plain-text"}, + {"txtn", "com.apple.txn.text-multimedia-data"}, + {"url ", "public.url"}, + {"user", "com.apple.user"}, + {"utxt", "public.utf16-plain-text"}, + {"vCrd", "public.vcard"}, + {NULL, NULL} +}; Index: macosx/tkMacOSXPrivate.h ================================================================== --- macosx/tkMacOSXPrivate.h +++ macosx/tkMacOSXPrivate.h @@ -26,10 +26,13 @@ #define TextStyle MacTextStyle #import #import #import +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000 +#import +#endif #ifndef NO_CARBON_H #import #endif #undef TextStyle #import /* for sel_isEqual() */ @@ -292,11 +295,13 @@ MODULE_SCOPE void TkMacOSXWinNSBounds(TkWindow *winPtr, NSView *view, NSRect *bounds); MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin); MODULE_SCOPE void TkMacOSXDrawAllViews(ClientData clientData); MODULE_SCOPE unsigned long TkMacOSXClearPixel(void); - +MODULE_SCOPE NSString* TkMacOSXOSTypeToUTI(OSType ostype); +MODULE_SCOPE NSImage* TkMacOSXIconForFileType(NSString *filetype); + #pragma mark Private Objective-C Classes #define VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) enum { tkMainMenu = 1, tkApplicationMenu, tkWindowsMenu, tkHelpMenu}; Index: macosx/tkMacOSXWm.c ================================================================== --- macosx/tkMacOSXWm.c +++ macosx/tkMacOSXWm.c @@ -2594,11 +2594,11 @@ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Image tk_icon; - int width, height, isDefault = 0; + int width, height; NSImage *newIcon = NULL; if (objc < 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?-default? image1 ?image2 ...?"); @@ -2608,11 +2608,10 @@ /* * Parse args. */ if (strcmp(Tcl_GetString(objv[3]), "-default") == 0) { - isDefault = 1; if (objc == 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?-default? image1 ?image2 ...?"); return TCL_ERROR; } Index: unix/Makefile.in ================================================================== --- unix/Makefile.in +++ unix/Makefile.in @@ -394,19 +394,18 @@ tkUnixSend.o tkUnixWm.o tkUnixXId.o AQUA_OBJS = tkMacOSXBitmap.o tkMacOSXButton.o tkMacOSXClipboard.o \ tkMacOSXColor.o tkMacOSXConfig.o tkMacOSXCursor.o tkMacOSXDebug.o \ tkMacOSXDialog.o tkMacOSXDraw.o tkMacOSXEmbed.o tkMacOSXEntry.o \ - tkMacOSXEvent.o tkMacOSXFont.o tkMacOSXHLEvents.o tkMacOSXImage.o \ - tkMacOSXInit.o tkMacOSXKeyboard.o tkMacOSXKeyEvent.o \ - tkMacOSXMenu.o \ - tkMacOSXMenubutton.o tkMacOSXMenus.o tkMacOSXMouseEvent.o \ - tkMacOSXNotify.o tkMacOSXRegion.o tkMacOSXScrlbr.o tkMacOSXSend.o \ - tkMacOSXServices.o tkMacOSXSubwindows.o tkMacOSXWindowEvent.o \ - tkMacOSXWm.o tkMacOSXXStubs.o \ - tkFileFilter.o tkMacWinMenu.o tkPointer.o tkUnix3d.o tkUnixScale.o \ - xcolors.o xdraw.o xgc.o ximage.o xutil.o \ + tkMacOSXEvent.o tkMacOSXFileTypes.o tkMacOSXFont.o tkMacOSXHLEvents.o \ + tkMacOSXImage.o tkMacOSXInit.o tkMacOSXKeyboard.o tkMacOSXKeyEvent.o \ + tkMacOSXMenu.o tkMacOSXMenubutton.o tkMacOSXMenus.o \ + tkMacOSXMouseEvent.o tkMacOSXNotify.o tkMacOSXRegion.o \ + tkMacOSXScrlbr.o tkMacOSXSend.o tkMacOSXServices.o \ + tkMacOSXSubwindows.o tkMacOSXWindowEvent.o tkMacOSXWm.o \ + tkMacOSXXStubs.o tkFileFilter.o tkMacWinMenu.o tkPointer.o tkUnix3d.o \ + tkUnixScale.o xcolors.o xdraw.o xgc.o ximage.o xutil.o \ ttkMacOSXTheme.o AQUA_TKTEST_OBJS = tkMacOSXTest.o OBJS = $(GENERIC_OBJS) $(WIDG_OBJS) $(CANV_OBJS) $(IMAGE_OBJS) $(TEXT_OBJS) \ @@ -519,12 +518,12 @@ $(MAC_OSX_DIR)/tkMacOSXClipboard.c $(MAC_OSX_DIR)/tkMacOSXColor.c \ $(MAC_OSX_DIR)/tkMacOSXConfig.c $(MAC_OSX_DIR)/tkMacOSXCursor.c \ $(MAC_OSX_DIR)/tkMacOSXDebug.c $(MAC_OSX_DIR)/tkMacOSXDialog.c \ $(MAC_OSX_DIR)/tkMacOSXDraw.c $(MAC_OSX_DIR)/tkMacOSXEmbed.c \ $(MAC_OSX_DIR)/tkMacOSXEntry.c $(MAC_OSX_DIR)/tkMacOSXEvent.c \ - $(MAC_OSX_DIR)/tkMacOSXFont.c $(MAC_OSX_DIR)/tkMacOSXHLEvents.c \ - $(MAC_OSX_DIR)/tkMacOSXImage.c \ + $(MAC_OSX_DIR)/tkMacOSXFont.c $(MAC_OSX_DIR)/tkMacOSXFileTypes.c\ + $(MAC_OSX_DIR)/tkMacOSXHLEvents.c $(MAC_OSX_DIR)/tkMacOSXImage.c \ $(MAC_OSX_DIR)/tkMacOSXInit.c $(MAC_OSX_DIR)/tkMacOSXKeyboard.c \ $(MAC_OSX_DIR)/tkMacOSXKeyEvent.c \ $(MAC_OSX_DIR)/tkMacOSXMenu.c \ $(MAC_OSX_DIR)/tkMacOSXMenubutton.c $(MAC_OSX_DIR)/tkMacOSXMenus.c \ $(MAC_OSX_DIR)/tkMacOSXMouseEvent.c $(MAC_OSX_DIR)/tkMacOSXNotify.c \ @@ -1273,10 +1272,13 @@ $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXEntry.c tkMacOSXEvent.o: $(MAC_OSX_DIR)/tkMacOSXEvent.c $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXEvent.c +tkMacOSXFileTypes.o: $(MAC_OSX_DIR)/tkMacOSXFileTypes.c + $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXFileTypes.c + tkMacOSXFont.o: $(MAC_OSX_DIR)/tkMacOSXFont.c $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXFont.c tkMacOSXHLEvents.o: $(MAC_OSX_DIR)/tkMacOSXHLEvents.c $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXHLEvents.c Index: unix/configure ================================================================== --- unix/configure +++ unix/configure @@ -9435,10 +9435,13 @@ cat >>confdefs.h <<\_ACEOF #define MAC_OSX_TK 1 _ACEOF LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit -framework QuartzCore" + if test -d "/System/Library/Frameworks/UniformTypeIdentifiers.framework"; then + LIBS="$LIBS -framework UniformTypeIdentifiers" + fi EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c' TK_WINDOWINGSYSTEM=AQUA if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then cat >>confdefs.h <<\_ACEOF Index: unix/configure.in ================================================================== --- unix/configure.in +++ unix/configure.in @@ -350,10 +350,13 @@ fi if test $tk_aqua = yes; then AC_DEFINE(MAC_OSX_TK, 1, [Are we building TkAqua?]) LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit -framework QuartzCore" + if test -d "/System/Library/Frameworks/UniformTypeIdentifiers.framework"; then + LIBS="$LIBS -framework UniformTypeIdentifiers" + fi EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c' TK_WINDOWINGSYSTEM=AQUA if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then AC_DEFINE(TK_MAC_DEBUG, 1, [Are TkAqua debug messages enabled?]) fi