summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macosx/tkMacOSXBitmap.c23
-rw-r--r--macosx/tkMacOSXColor.c26
-rw-r--r--macosx/tkMacOSXDialog.c50
-rw-r--r--macosx/tkMacOSXFileTypes.c112
-rw-r--r--macosx/tkMacOSXFileTypes.h144
-rw-r--r--macosx/tkMacOSXImage.c2
-rw-r--r--macosx/tkMacOSXPrivate.h8
-rw-r--r--macosx/tkMacOSXWm.c3
-rw-r--r--unix/Makefile.in25
-rwxr-xr-xunix/configure3
-rw-r--r--unix/configure.ac3
11 files changed, 353 insertions, 46 deletions
diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c
index abf0211..bbf053b 100644
--- a/macosx/tkMacOSXBitmap.c
+++ b/macosx/tkMacOSXBitmap.c
@@ -13,6 +13,7 @@
#include "tkMacOSXPrivate.h"
#include "tkMacOSXConstants.h"
+
/*
* This structure holds information about native bitmaps.
*/
@@ -174,9 +175,8 @@ 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;
@@ -253,7 +253,6 @@ TkpGetNativeAppBitmap(
NSString *string;
NSImage *image = nil;
NSSize size = { .width = builtInIconSize, .height = builtInIconSize };
-
if (iconBitmapTable.buckets &&
(hPtr = Tcl_FindHashEntry(&iconBitmapTable, name))) {
OSType type;
@@ -268,12 +267,12 @@ TkpGetNativeAppBitmap(
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:
@@ -312,11 +311,15 @@ TkpGetNativeAppBitmap(
*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));
}
}
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c
index 4732ddb..3c7d59e 100644
--- a/macosx/tkMacOSXColor.c
+++ b/macosx/tkMacOSXColor.c
@@ -31,6 +31,7 @@ static SystemColorDatum **systemColorIndex;
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};
@@ -389,6 +390,7 @@ SetCGColorComponents(
if (entry->type == HIBrush) {
OSStatus err = ChkErr(HIThemeBrushCreateCGColor, entry->value, c);
+ [pool drain];
return err == noErr;
}
GetRGBA(entry, pixel, rgba);
@@ -428,7 +430,7 @@ TkMacOSXInDarkMode(Tk_Window tkwin)
if (view) {
name = [[view effectiveAppearance] name];
} else {
- name = [[NSAppearance currentAppearance] name];
+ name = [[NSApp effectiveAppearance] name];
}
return (name == NSAppearanceNameDarkAqua);
}
@@ -595,7 +597,6 @@ TkpGetColor(
if (!initialized) {
initialized = YES;
- (void)[NSColorSpace sRGBColorSpace];
initColorTable();
}
if (tkwin) {
@@ -623,19 +624,30 @@ TkpGetColor(
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);
}
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index 4c1566b..b8ae204 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -3,10 +3,11 @@
*
* Contains the Mac implementation of the common dialog boxes.
*
- * Copyright © 1996-1997 Sun Microsystems, Inc.
- * Copyright © 2001-2009 Apple Inc.
- * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright © 2017 Christian Gollwitzer.
+ * Copyright (c) 1996-1997 Sun Microsystems, Inc.
+ * Copyright (c) 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * 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.
@@ -26,6 +27,30 @@
#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<UTType *> *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.
*/
@@ -302,11 +327,11 @@ getFileURL(
* 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];
}
@@ -319,11 +344,11 @@ getFileURL(
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];
}
@@ -803,9 +828,9 @@ Tk_GetOpenFileObjCmd(
[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];
@@ -1076,7 +1101,8 @@ Tk_GetSaveFileObjCmd(
[savepanel setAccessoryView:accessoryView];
- [savepanel setAllowedFileTypes:[filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex]];
+ setAllowedFileTypes(savepanel,
+ [filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex]);
[savepanel setAllowsOtherFileTypes:filterInfo.allowedExtensionsAllowAll];
} else if (defaultType) {
/*
@@ -1088,7 +1114,7 @@ Tk_GetSaveFileObjCmd(
NSMutableArray *AllowedFileTypes = [NSMutableArray array];
[AllowedFileTypes addObject:defaultType];
- [savepanel setAllowedFileTypes:AllowedFileTypes];
+ setAllowedFileTypes(savepanel, AllowedFileTypes);
[savepanel setAllowsOtherFileTypes:YES];
}
diff --git a/macosx/tkMacOSXFileTypes.c b/macosx/tkMacOSXFileTypes.c
new file mode 100644
index 0000000..c89328d
--- /dev/null
+++ b/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 <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
+#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:
+ */
diff --git a/macosx/tkMacOSXFileTypes.h b/macosx/tkMacOSXFileTypes.h
new file mode 100644
index 0000000..b5de54f
--- /dev/null
+++ b/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 {
+ const char *ostype;
+ const 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}
+};
diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c
index c3dc4ed..450ee65 100644
--- a/macosx/tkMacOSXImage.c
+++ b/macosx/tkMacOSXImage.c
@@ -1260,7 +1260,7 @@ TkNSImageConfigureMaster(
newImage = [[NSWorkspace sharedWorkspace] iconForFile:source];
break;
case FILETYPE_SOURCE:
- newImage = [[NSWorkspace sharedWorkspace] iconForFileType:source];
+ newImage = TkMacOSXIconForFileType(source);
break;
default:
newImage = NULL;
diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h
index 9e90a5c..d3be27d 100644
--- a/macosx/tkMacOSXPrivate.h
+++ b/macosx/tkMacOSXPrivate.h
@@ -30,6 +30,9 @@
#undef Cursor
#import <Cocoa/Cocoa.h>
#import <QuartzCore/QuartzCore.h>
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
+#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
+#endif
#ifndef NO_CARBON_H
#import <Carbon/Carbon.h>
#endif
@@ -304,8 +307,9 @@ MODULE_SCOPE void Ttk_MacOSXInit(void);
MODULE_SCOPE unsigned long TkMacOSXClearPixel(void);
MODULE_SCOPE int MacSystrayInit(Tcl_Interp *);
MODULE_SCOPE int MacPrint_Init(Tcl_Interp *);
-
-
+MODULE_SCOPE NSString* TkMacOSXOSTypeToUTI(OSType ostype);
+MODULE_SCOPE NSImage* TkMacOSXIconForFileType(NSString *filetype);
+
#pragma mark Private Objective-C Classes
#define VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index fcfe247..e26a240 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -2669,7 +2669,7 @@ WmIconphotoCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Image tk_icon;
- int width, height, isDefault = 0;
+ int width, height;
NSImage *newIcon = NULL;
if (objc < 4) {
@@ -2683,7 +2683,6 @@ WmIconphotoCmd(
*/
if (strcmp(Tcl_GetString(objv[3]), "-default") == 0) {
- isDefault = 1;
if (objc == 4) {
Tcl_WrongNumArgs(interp, 2, objv,
"window ?-default? image1 ?image2 ...?");
diff --git a/unix/Makefile.in b/unix/Makefile.in
index ba8dd29..9969c54 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -399,16 +399,14 @@ X11_OBJS = tkUnix.o tkUnix3d.o tkUnixButton.o tkUnixColor.o tkUnixConfig.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 tkMacOSXPrint.o tkMacOSXRegion.o \
- tkMacOSXScrlbr.o tkMacOSXSend.o \
- tkMacOSXServices.o tkMacOSXSubwindows.o tkMacOSXWindowEvent.o \
- tkMacOSXWm.o tkMacOSXXStubs.o tkMacOSXSysTray.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 tkMacOSXPrint.o tkMacOSXRegion.o \
+ tkMacOSXScrlbr.o tkMacOSXSend.o tkMacOSXServices.o \
+ tkMacOSXSubwindows.o tkMacOSXSysTray.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
@@ -527,8 +525,8 @@ AQUA_SRCS = \
$(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 \
@@ -1397,6 +1395,9 @@ tkMacOSXEntry.o: $(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
diff --git a/unix/configure b/unix/configure
index 6b96ef4..7eeeaa7 100755
--- a/unix/configure
+++ b/unix/configure
@@ -7640,6 +7640,9 @@ printf "%s\n" "#define MAC_OSX_TK 1" >>confdefs.h
if test -d /System/Library/Frameworks/UserNotifications.framework; then
LIBS="$LIBS -framework UserNotifications"
fi
+ if test -d "/System/Library/Frameworks/UniformTypeIdentifiers.framework"; then
+ LIBS="$LIBS -framework UniformTypeIdentifiers"
+ fi
EXTRA_CC_SWITCHES='-x objective-c'
TK_WINDOWINGSYSTEM=AQUA
if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then
diff --git a/unix/configure.ac b/unix/configure.ac
index cce5c29..93b3226 100644
--- a/unix/configure.ac
+++ b/unix/configure.ac
@@ -288,6 +288,9 @@ if test $tk_aqua = yes; then
if test -d /System/Library/Frameworks/UserNotifications.framework; then
LIBS="$LIBS -framework UserNotifications"
fi
+ if test -d "/System/Library/Frameworks/UniformTypeIdentifiers.framework"; then
+ LIBS="$LIBS -framework UniformTypeIdentifiers"
+ fi
EXTRA_CC_SWITCHES='-x objective-c'
TK_WINDOWINGSYSTEM=AQUA
if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then