Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > getting an icon for a filetype/creatorcode

getting an icon for a filetype/creatorcode
Thread Tools
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Jan 1, 2002, 12:53 PM
 
Hi,

I'm writing an app that deals with filetypes:



the problem comes when I want to get an icon that represents a filetype and creatorcode couplet.

Cocoa doesn't *seem* to have this ability, the closest I have found is the NSWorkspace Class.

NSWorkspace has a iconForFiletype: method that I have used successfully to get an icon for an extension-type. The same method can take a filetype, but that's not really what I need as I need to specify the creator code as well. (a document with a filetype 'HTML' will have a different icon depending on the creatorcode)

So I assume that I'll have to use carbon to do this. The File Manager seemed to have the answer in the PBDTGetIconSync function, but when I tried to use this I found that you must pass the size of icon you require, by way of a constant. The largest of these is defined as:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>kLarge8BitIconSize

Large <font color = blue>8</font>-bit color icon. Corresponding resource type: 'icl8'.</font>[/code]

That's not really what I want, I would like a mac os X style massive icon.

So obviously this isn't the way to go about it either!

What is the correct way? Does anyone know?

Thanks
     
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Jan 1, 2002, 11:44 PM
 
See LaunchServices.h, which contains the same APIs the Finder is said to use for discovering information about file/app binding and icons.

It's not Carbon per se, but some folk might still hate it because it's not Objective-C. Gasp.
Rick Roe
icons.cx | weblog
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Jan 2, 2002, 08:23 AM
 
Thanks Rick,

I have already used LaunchServices' LSGetApplicationForInfo to get the name of the app that handles an extension (and therefore that app's icon.)

However LS seems to require a reference (either FSRef or CFURL) to an instance of a filetype - whereas I am working with the concept of a filetype (I need to get the icon, even if no file of this kind exists on the filesystem.)

My current thinking is to create a temporary file with the attributes I require, get the info I require, then delete the file.

This seems rather ugly to me, but I can't find any other way of getting info for for a filetype/creatorcode couplet.

does anyone have any better ideas?

Digs.

[ 01-02-2002: Message edited by: Diggory Laycock ]
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:26 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2