setting the icon of a project

Need help with a script? This is the place to discuss how to get your code running!

setting the icon of a project

Postby Stephane Leys on Tue Sep 01, 2009 5:13 am

How do I set the icon of a project by script ?
I thought that creating an icns resource with ID = -16455 was enough. This indeed works for changing the icon once it has been set in the info wd of the Finder but not for setting the icon for the first time. Obviously, there is something else to do to inform the Finder of using this icon in the resource instead of the generic icon for this type of file. But I don't know what. AS, Shell ?

S.
User avatar
Stephane Leys
 
Posts: 607
Joined: Sun Jul 06, 2008 11:03 am

Re: setting the icon of a project

Postby marksch on Wed Sep 02, 2009 9:48 am

Hi Stephane,

What exactly do you mean by "icon of a project"? Do you want to change the icon of standalone, or the icon of a stack, or are you referring of an icon in the interface that I am not aware of?

If you are talking about standalones, you can set the icon in the standalone builder.

Best regards,

Mark
Economy-x-Talk is always looking for new projects. Contact me for a quote.

Make your URL's short with http://qurl.tk

MacBook (Intel, 2.16Ghz, 2GB memory) | Mac OS X 10.5.8
User avatar
marksch
 
Posts: 60
Joined: Fri Aug 22, 2008 4:51 am

Re: setting the icon of a project

Postby Stephane Leys on Thu Sep 03, 2009 1:10 am

marksch wrote:What exactly do you mean by "icon of a project"? Do you want to change the icon of standalone, or the icon of a stack, or are you referring of an icon in the interface that I am not aware of?

The word "stack" belongs to HC terminology. The files produced by SC are named "project". So, I'm talking about the icns used by the Finder to show this file.
I'm talking about doing this by script.
The technique consists in putting an icns resource with ID -16455 into the resource fork of the project (appeared in OS 7 , I think).
But this is not sufficient. One also needs to set a flag in the file data of the Finder to tell it that this file is using another icon than the generic icon for this type of file. This is what I don't know how to do.
The Finder is setting this flag when pasting an icon into the info window of the file. Then, changing the ID -16455 resource is understood by the Finder. But I wish to do it on a project using the generic icon without having to go to the Finder and open the info window.
marksch wrote:If you are talking about standalones, you can set the icon in the standalone builder.

The SAM is using the "modern" method i.e. putting a .icns file into the Contents:Resources: folder of the bundle app. But projects are not bundle folders and thus require using the "old" technique.
Unless there is yet another technique that I don't know.

S.
User avatar
Stephane Leys
 
Posts: 607
Joined: Sun Jul 06, 2008 11:03 am

Re: setting the icon of a project

Postby supercardus on Thu Sep 03, 2009 7:42 am

You would "think" there would be a simple AppleScriptable property to set the custom icon flag of files and folders (and I bet there is) but I am not aware of it. But, you should be able to set this flag using SetFile from the shell function. Something like:

Code: Select all
SetFile -a C <filePath>
User avatar
supercardus
Site Admin
 
Posts: 533
Joined: Sat Jul 05, 2008 1:37 pm
Location: Northern Sierra Nevada

Re: setting the icon of a project

Postby Stephane Leys on Fri Sep 04, 2009 12:53 am

supercardus wrote:
Code: Select all
SetFile -a C <filePath>

Thanks Scott, I'll explore this lead.

S.
User avatar
Stephane Leys
 
Posts: 607
Joined: Sun Jul 06, 2008 11:03 am


Return to Scripting in SuperTalk

Who is online

Users browsing this forum: No registered users and 0 guests

cron