[comp.sys.mac.programmer] Custom Icons

gary@sun.mcs.clarkson.edu (Gary Levin) (09/13/89)

I am trying to create a custom icon for my application.  I have
created the ICN#, FREF, BNDL with ResEdit and the new icon comes up
fine.  Now I find that I need to edit the new icon.  I can change it
with ResEdit, but nothing I seem to do will persuade the desktop to
use the new representation.  I've even used ResEdit to look at the
application, and it has the new icon in it.  "Using the Macintosh
Toolbox" from SYBEX says that option-apple-double click on finder
forces it to use the new icon, but that doesn't seem to work for me.
I am on a Mac II with Finder 6.1, System 6.0.2, Multifinder 6.0.1.
Suggestions?  
--
Gary Levin/Dept of Math & CS/Clarkson Univ/Potsdam, NY 13676/(315) 268-2384
BitNet: gary@clutx   Internet: gary@clutx.clarkson.edu

earleh@eleazar.dartmouth.edu (Earle R. Horton) (09/13/89)

In article <GARY.89Sep12161013@sun.clarkson.edu> gary@sun.mcs.clarkson.edu
	(Gary Levin) writes:
>I am trying to create a custom icon for my application.  I have
>created the ICN#, FREF, BNDL with ResEdit and the new icon comes up
>fine.  Now I find that I need to edit the new icon...

This is one of the classic Macintosh programming gotchas!  The most
straightforward, brute force approach to this problem is to delete the
Desktop file on the disk where the application resides, and then let
the Finder build a new one.

Earle R. Horton

pvh@Apple.COM (Pete Helme) (09/13/89)

Sometimes it helps to copy your app with the new icon to a blank floppy, 
rebuild the floppy's desktop with the command-option trick and then copy
the application back to your main hard disk.  But only on Tuesdays.

Pete Helme
MacDTS 

kk@mcnc.org (Krzysztof Kozminski) (09/13/89)

In article <15541@dartvax.Dartmouth.EDU> earleh@eleazar.dartmouth.edu
	(Earle R. Horton) writes:
>In article <GARY.89Sep12161013@sun.clarkson.edu> gary@sun.mcs.clarkson.edu
>	(Gary Levin) writes:
>>I am trying to create a custom icon for my application.  I have
>>created the ICN#, FREF, BNDL with ResEdit and the new icon comes up
>>fine.  Now I find that I need to edit the new icon...
>
>This is one of the classic Macintosh programming gotchas!  The most
>straightforward, brute force approach to this problem is to delete the
>Desktop file on the disk where the application resides, and then let
>the Finder build a new one.

I'm not sure if this is that great idea, especially on hard disks - sloooow,
and I lost once a disk when doing a desktop rebuild from Finder with 
option-command combination (or is it normal for Finder to take >2 hrs to
rebuild the desktop on HD-20 :-?). The simplest solution to Gary's problem
that I know of is to:

     - copy your application to another disk
     - copy it back

If I remember correctly, Finder updates the Desktop file whenever you copy
applications. Perhaps even option-drag-to-another-folder will do the job.

KK
-- 
Kris Kozminski   kk@mcnc.org
"The party was a masquerade; the guests were all wearing their faces."

rang@cs.wisc.edu (Anton Rang) (09/13/89)

In article <1373@speedy.mcnc.org> kk@mcnc.org (Krzysztof Kozminski) writes:
  [ lots of ideas about how to force icons to be changed in the Desktop ]

Hmm.  I thought this was common knowledge, but maybe not.  Doesn't it
always work to do the following?

  1.  Update the ICN# resource in the application.
  2.  Make sure the Bundle bit is set.
  3.  Turn off the Inited bit.         <-- the important part

At least with System 3.X through 6.0.3, this has always worked for me.
I don't use MultiFinder much when I'm programming, though (not enough
memory).  Does anybody else do this?  Does it ever fail?
  (As far as I can tell, turning off "Inited" tells the Finder it's a
file that hasn't been processed yet, so the desktop gets updated.)
   
+----------------------------------+------------------+
| Anton Rang (grad student)        | "VMS Forever!"   |
| University of Wisconsin--Madison | rang@cs.wisc.edu |
+----------------------------------+------------------+

jdarcy@multimax.encore.com (Jeff "green monster" d'Arcy) (09/13/89)

Your desktop file needs to be updated before the new icon will appear.  One
way to do this, as many have suggested, is to rebuild the desktop.  Another
way (probably not kosher but I do it anyway) is to use ResEdit.  Find the
old icon in the desktop file, remember its ID, and then replace it with the
new one, being careful to set the ID to what it was in the desktop rather
than what it was in the application.

Jeff d'Arcy		jdarcy@encore.com		(508) 460-0500
    Encore has provided the medium, but the message remains my own

stores@unix.SRI.COM (Matt Mora) (09/13/89)

In article <RANG.89Sep13085719@derby.cs.wisc.edu> rang@cs.wisc.edu (Anton Rang) writes:
>In article <1373@speedy.mcnc.org> kk@mcnc.org (Krzysztof Kozminski) writes:
>  [ lots of ideas about how to force icons to be changed in the Desktop ]
>
>Hmm.  I thought this was common knowledge, but maybe not.  Doesn't it
>always work to do the following?
>
>  1.  Update the ICN# resource in the application.
>  2.  Make sure the Bundle bit is set.
>  3.  Turn off the Inited bit.         <-- the important part

Sorry, Close  but no cigar.  You forgot one step.

   4. Open the desktop file and look for your application's signature.
      select it and clear it from the desktop file. 
      Save your changes.

I just tried your steps and the finder used the old icon.

I guess the finder sees your application, gets its sig, and checks to see if
it is in the desktop file, if so it  uses the icon in the desktop file.
If the desktop file doesn't contain your app's sig, then it looks for it
in your app's resource fork and marks it as "inited".


Just a theory :-) who knows what the hell the finder does!






-- 
___________________________________________________________
Matthew Mora
SRI International                       stores@unix.sri.com
___________________________________________________________

mnkonar@manyjars.SRC.Honeywell.COM (Murat N. Konar) (09/13/89)

In article <1373@speedy.mcnc.org> kk@mcnc.org.UUCP (Krzysztof Kozminski) writes:
[The subject is how to get the Finder to display a modified or new application
icon]
>If I remember correctly, Finder updates the Desktop file whenever you copy
>applications. Perhaps even option-drag-to-another-folder will do the job.

If I remember correctly, the Finder does a desktop file to desktop file
copy of all the info related to the application (this includes the icon).
However, if it takes too long to re-build your hard disk's desktop file,
you can copy the application to a floppy, re-build it's desktop file, and
then copy the application back.  Hmmm. Now that I think about it though, even
this may not be enough.  Try it though.

____________________________________________________________________
Have a day. :^|
Murat N. Konar        Honeywell Systems & Research Center, Camden, MN
mnkonar@SRC.honeywell.com (internet) {umn-cs,ems,bthpyd}!srcsip!mnkonar(UUCP)

gary@sun.mcs.clarkson.edu (Gary Levin) (09/14/89)

Thanks to all who responded to my request.
In article <GARY.89Sep12161013@sun.clarkson.edu> (Gary Levin) writes:

gary>I am trying to create a custom icon for my application.  I have
gary>created the ICN#, FREF, BNDL with ResEdit and the new icon comes up
gary>fine.  Now I find that I need to edit the new icon.  I can change it
gary>with ResEdit, but nothing I seem to do will persuade the desktop to
gary>use the new representation.  I've even used ResEdit to look at the
gary>application, and it has the new icon in it.

The suggestions were:
(1) Copy to a blank disk.
(2) Move to another folder.
(3) Get info for file (in ResEdit) and set Bundle, unset Inited.
(4) Modify the desktop file.
(5) Rebuild the desktop with option-clover Restart.

Only (5) worked.  One person warned against this, but I tried it
anyway.  On a 60 Meg partition, it only took 1.5 mins.  It claims to
have run out of memory in the finder, so perhaps some files lost their
special image.  

I would have tried (4), except I have no idea where to find the
desktop file, nor how to modify it.

Again, thanks.

--
Gary Levin/Dept of Math & CS/Clarkson Univ/Potsdam, NY 13676/(315) 268-2384
BitNet: gary@clutx   Internet: gary@clutx.clarkson.edu