From: Kevin W. <kw...@co...> - 2007-03-08 16:15:13
|
I'm revisiting an earlier interest in getting Tk to display Mac-native icons under Aqua. Tk had this capability under Classic, but it is currently broken. My current method to display Mac-native icons is to use an external command-line tool to retrieve the icon, then convert it to a PNG via the sips tool. I would prefer to have a method to get icon data in the same manner as other Carbon applications, via IconServices; given a file path, Carbon would display the correct icon/image data in Tk. Because I'm not an expert with C, my question is whether this could be accomplished by patching tkMacOSXBitmap.c, or whether I would need to delve much deeper into defining a new image format or doing some conversion of icon data at the C level to display in Tk. Looking at tkMacOSXBitmap.c, it appears to make at least some use of IconServices (the function "GetIcon" is defined in IconServices). However, it focuses mainly on old-style resource files (and uses QuickDraw calls--aren't these deprecated?). The modern API for obtaining icon data is GetIconRef and related functions. Is there any way to add this API to the tkMacOSXBitmap.c file? The alternative approach I've envisioned involves creating a new image format for Tk that could read data from GetIconRef, or alternatively, doing some conversion of IconRef to a bitmap format that Tk can recognize, via CoreGraphics or CoreImage. But creating a new image format for Tk is out of my depth, and I have not found any method to convert IconRef's into a standard image format, at least in Carbon. (There are some methods that go the other way, i.e. convert a PNG to an IconRef or something similar.) Any advice is appreciated. -- Kevin Walzer Code by Kevin http://www.codebykevin.com |