Re: Where did the icon come from?
Re: Where did the icon come from?
- Subject: Re: Where did the icon come from?
- From: John Joyce <email@hidden>
- Date: Sat, 17 Jul 2010 01:18:35 -0500
You might be going about it wrong.
A user can, in Finder's Get Info window, set the application they prefer for all files of a given "type".
On my system I've set some text file types to always open in TextMate, for example.
TextMate the app provides custom file icons for all the file types it can save in.
After making this change in Finder's get info windows, all files of that type will have an icon that has been provided by TextMate and registered with a UTI.
At the end of the day, a user or another UTI more specific than yours may set the file icon regardless of what you want it to be.
On Jul 16, 2010, at 5:50 PM, Eric Gorr wrote:
>
> On Jul 16, 2010, at 6:31 PM, James Walker wrote:
>
>> On 7/16/2010 2:45 PM, Eric Gorr wrote:
>>> Thanks, but I wasn't specific enough.
>>>
>>> What I am looking for is something like this:
>>>
>>> $WhoProvidedIcon /Path/To/file.myex
>>>
>>> UTI: com.myapplication.document
>>> PLIST: /path/to/myapplication.app/Contents/Info.plist
>>> ICON: /path/to/myapplication.app/Contents/Resources/BaseDoc.icns
>>
>> Perhaps you could get some of this information by first using UTTypeCreateAllIdentifiersForTag to get the possible UTIs for the extension, and then passing each UTI to UTTypeCopyDeclaringBundleURL and UTTypeCopyDeclaration.
>
> Gotta love it when you learn about functions you were unaware of previously.
>
> I don't think I need UTTypeCreateAllIdentifiersForTag....NSWorkspace should give me the UTI for the file.
>
> So, This code is probably all I need:
>
> NSString* uti = [ws typeOfFile:@"/Users/egorr/Desktop/file.vwx" error:&error];
>
> NSLog( @"UTI: %@", uti );
> NSLog( @"UTI localized description: %@", [ws localizedDescriptionForType:uti] );
> NSLog( @"UTI error description: %@",[error localizedDescription] );
>
> NSURL* utiDeclarationURL = (NSURL*)UTTypeCopyDeclaringBundleURL( (CFStringRef)uti );
>
> NSLog( @"UTI declaration URL: %@", utiDeclarationURL );
>
> NSDictionary* utiDeclaration = (NSDictionary*)UTTypeCopyDeclaration( (CFStringRef)uti );
>
> NSLog( @"UTI declaration: %@", utiDeclaration );
>
> (Also gotta love the toll-free bridging...)
>
> Of course, I'll edit the obtaining the uti to take a path from the command line.
>
> Doesn't quite give me the path to the icon, but does get me to the application which the declaration came from for the UTI.
>
> As long as all of this matches what the OS will do, then I should be good to go for my situation.
>
> p.s. Yes, I know that the icon for a file may not be an icon at all, but an image provided by a Quick Look plugin...but in my case, I know that it is an icon and not something provided by a Quick Look plugin. But, it would be interesting if one could determine exactly where the image for the file was coming from. The code above won't do that.
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden