Recent

Author Topic: Hoe to get the application icon for a specific extension  (Read 13859 times)

havezet

  • New Member
  • *
  • Posts: 26
Hoe to get the application icon for a specific extension
« on: November 06, 2010, 10:29:09 am »
I need to extract the os icon for a specific file extension, for instance the icon of the Preview.app for a JPG (as is registered on a default osx installation). I need this icon in a TBitmap.

Does anyone know where to get started?

Thank you

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Hoe to get the application icon for a specific extension
« Reply #1 on: November 06, 2010, 03:03:27 pm »
jpeg.icns and many others are in /Applications/Preview.app/Contents/Resources.

These icon files are associated with Preview via its Info.plist file.

Thanks.

-Phil



havezet

  • New Member
  • *
  • Posts: 26
Re: Hoe to get the application icon for a specific extension
« Reply #2 on: November 07, 2010, 06:14:08 am »
Thank you Phil, so where I should find the icon. But how would I know in which app folder I should check? Is there a way to query the OS for the application(s) that are associated with an extension? Or should I query every .app folder for the plist file individually to check if it is associated with a specific extension (hope not).

Thanks

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Hoe to get the application icon for a specific extension
« Reply #3 on: November 07, 2010, 07:15:07 pm »
I'm afraid I don't understand what you're trying to do. Or why.

Thanks.

-Phil

Mando

  • Full Member
  • ***
  • Posts: 181
Re: Hoe to get the application icon for a specific extension
« Reply #4 on: November 08, 2010, 12:00:45 am »
Hello,

try this
http://forum.lazarus.freepascal.org/index.php?topic=2140.0

I use it, and works...

regards

havezet

  • New Member
  • *
  • Posts: 26
Re: Hoe to get the application icon for a specific extension
« Reply #5 on: November 08, 2010, 06:05:55 am »
@mando; that is exactly what I need but while I haven't tried it on the Mac platform, looking at the code it appears to be Windows only.

@Phil; I'll try to explain. I read the folder contents of a random folder which can contain every possible file/extension. Now I need to display the icon of the associated application for every listed file (like Finder does too).

Hert

Mando

  • Full Member
  • ***
  • Posts: 181
Re: Hoe to get the application icon for a specific extension
« Reply #6 on: November 08, 2010, 08:50:11 am »
That's right. The code is for windows only. (at least I've only tested on windows). I did not know you wanted it to Mac, Sorry.

I hope you have luck in your search.

Regards.

jhvhs

  • New Member
  • *
  • Posts: 18
Re: Hoe to get the application icon for a specific extension
« Reply #7 on: November 12, 2010, 08:22:59 pm »
Hi,

On a mac things are absolutely different. The default icon is not assigned by file extension, it is assigned via the UTI (Uniform Type Identifier). Thus, several, say, Excel 2004 spreadsheet files might have different icons, and different default launching programs, and the file extension doesn't mean a thing - it might be some nonsense or it might be absent (really absent - not hidden).
Quote
One of the primary design goals of UTIs was to eliminate the ambiguities and problems associated with inferring a file's content from its MIME type, filename extension, or type or creator code1
More information can be found at http://developer.apple.com/macosx/uniformtypeidentifiers.html
Thus, custom code should be developed for the purpose of getting an icon for a filetype on MacOSX, because it uses unique technologies not available on other systems.
A sample Objective-C program that gets an icon for a UTI (not the file extension) can be found at
http://files.macscripter.net/joy/files/uticon.m

Hope this helps.

1 - In MacOS Classic, the type of the file was determined by the application that has created it, and file extensions were absolutely meaningless. These days, file extesions are used by the system to assign a UTI to files of non-Mac origin.

Dibo

  • Hero Member
  • *****
  • Posts: 1057
Re: Hoe to get the application icon for a specific extension
« Reply #8 on: December 19, 2010, 02:19:57 pm »
So we know how to get extensions icons on windows and macos, but does anyone know how to get on linux?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12645
  • FPC developer.
Re: Hoe to get the application icon for a specific extension
« Reply #9 on: December 19, 2010, 10:29:56 pm »
So we know how to get extensions icons on windows and macos, but does anyone know how to get on linux?

Linux has no standarized GUI. There is KDE and Gnome, but there are others (XFCE,Windowmaker and other -step variants) too

Dibo

  • Hero Member
  • *****
  • Posts: 1057
Re: Hoe to get the application icon for a specific extension
« Reply #10 on: December 20, 2010, 03:09:03 am »
Ehh, I think you have right. I always thought that is only GTK/QT responsibility but this is GNOME, KDE etc. Fool me some task in mantis (about TShelListView with native extension icons, assigned to Lazarus Team Programmer). This can be done with compiler defines but to much work

 

TinyPortal © 2005-2018