• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Get Preferred Application Icon URL for a given file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get Preferred Application Icon URL for a given file


  • Subject: Re: Get Preferred Application Icon URL for a given file
  • From: glenn andreas <email@hidden>
  • Date: Sun, 11 Nov 2007 09:47:07 -0600


On Nov 11, 2007, at 9:23 AM, JanakiRam wrote:

Hi All,
I've a specific requirement to get preferred application Icon for a
file.


I've gone thru the Cocoa API and found that NSWorkspace is able to
get the icon as NSImage but i need to get icon URL , so that my Webkit HTML
Page img tag -- can show that image.

You assume such a thing is possible, but there are several problems:

1) For classic or CFM style apps, the icon could still be part of the resource fork for the application. There is thus only a URL for the file, not the specific icon within that file.

2) For other apps, the icons (at different sizes) are stored in an .icns file in the thing. I don't believe that WebKit is able to display an icns file (since, among other things, it would have to pick which size you really wanted, which could easily end up with blocky images or blurry ones).

3) Assuming that LaunchServices keeps each icon as a separate file (i.e. with a one to one mapping between icon and URL) in some internal cache is either wrong or subject to change, undocumented, unsupported, etc... You can't even assume LaunchServices even keeps a cache of icons like the old desktop database did under Classic.



I feel this should be possible may be using some other API or lower
level API's.


Can any one provide some pointers to solve this problem.

The best thing to do is to provide a custom "file-icon" protocol (or "pseudo-CGI" magic URL) that you implement in your program which fetches the icon at an appropriate size, and then returns the PNG or TIFF representation. See NSURLProtocol (or the various "load request" related delegate methods for WebViews). This approach is definitely doable, though...




Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next generation of fractal art




_______________________________________________

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


  • Follow-Ups:
    • Re: Get Preferred Application Icon URL for a given file
      • From: JanakiRam <email@hidden>
References: 
 >Get Preferred Application Icon URL for a given file (From: JanakiRam <email@hidden>)

  • Prev by Date: Removing Application-Created Items
  • Next by Date: Re: Get Preferred Application Icon URL for a given file
  • Previous by thread: Get Preferred Application Icon URL for a given file
  • Next by thread: Re: Get Preferred Application Icon URL for a given file
  • Index(es):
    • Date
    • Thread