[futurebasic] Re: [FB] Re: Custom Icon, re-Do

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2004 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Tue, 22 Jun 2004 21:26:28 -0400
If I save the image file to a folder, and then save over it again,  the 
icon is correct when I open the folder, it is only when on the Desktop 
that this is a problem...that the old still shows no matter what I've 
tried (until after a restart). I wonder if I need to do that old trick 
to bump folder mod date thing or something for the desktop folder?

?

rc

On Tuesday, June 22, 2004, at 07:42  PM, Robert Covington wrote:

>
> On Tuesday, June 22, 2004, at 11:27  AM, Ken Shmidheiser wrote:
>
>> Robert,
>>
>> I hope I understand what you need. As I understand it, you need need 
>> to add a preview icon to a picture file that is immediately updated 
>> by the Finder. I have attached some demo code that does that. Perhaps 
>> you can explore the resultant file for clues to make your code work.
>>
>> Quite some time ago, with kind guidance from Robert Purves, I put 
>> together a  private project that I called "Big Sipper" that explored 
>> the little-known sips (scriptable image processing system) included 
>> with OS X. You can call sips commands from the Terminal or with 
>> AppleScript. Here is the URL for more info:
>>
>> http://www.apple.com/applescript/imageevents/
>>
>> Among the things sips does very well is add preview icons that are 
>> immediately updated by the Finder to many types of graphic files. It 
>> can do a host of other image manipulation including: flipping, 
>> resizing, getting comprehensive graphic file information, padding, 
>> and on and on. From the Terminal, the sips one-liner to add a preview 
>> icon to a file is simply:
>
> That's interesting, if that simple, but I have a Classic need too. 
> Question: does it add not only the picture preview, but also the 
> 'icns', and also icl8 and icn# families too?
>
> If so, I might can use that. My replace engine is already working, and 
> I just need the Fnder to update the darned icon. If you restart, it's 
> there correctly. I tried a flushvol, no change. And I'd prefer to stay 
> in the condom of OS X Mac than go naked with Unix, as you don't know 
> where a kernel has been these days.
>
> I can write over a file and turn off the custom icon flag, it all 
> works to update, at least if you click on the file...no more custom 
> icon. But if I replace the icns inside and all the other (I've 
> verified it is all correct), the Finder still shows no matter what 
> I've done, the icns image of the prior as the custom icon on the 
> desktop. The preview is fine.
>
> This is  holding me up from making another $50 for a month's work. :)
>
> "Big Sipper" , nice pun.
>
> rc
>
>>
>> sips --addIcon [ file path here ]
>>
>> Example, to add a preview icon to a jpeg file named "test.jpg" on 
>> your Desktop, you would enter:
>>
>> sips --addIcon ~/Desktop/test.jpg"
>>
>> One minor annoyance with sips is that it must be fed POSIX-complaint 
>> file palhs-- they can't contain ASCII high-bit characters, and 
>> certain characters such as spaces must be properly escaped.
>>
>> This might provide a basis for exploration for you. If you or others 
>> are interested, perhaps I can brush off Big Sipper and post the code 
>> here. I was able to write quite a few sips functions that performed 
>> very well and if I can get some time, I'll post a few more to provide 
>> some ideas of implementing sips in FB^3.
>>
>> Ken
>>
>> /*
>>
>> Add Preview Icon to Graphic File
>>
>>     Demo of the Unix and AppleScript
>>     sips (scriptable image processing system)
>>
>>     By Ken Shmidheiser
>>     Somerset, KY
>>
>>     June 22, 2004
>>
>> */
>>
>> Include "Subs AppleScript.Incl"
>>
>> local fn AddPreviewIcon$( unixPath as str255 )
>> '~'1
>> dim as str255 commandStr, tempStr
>>
>> commandStr = "sips --addIcon " + unixPath
>>
>> open "Unix", 2, commandStr
>> do : line input# 2, tempStr
>> tempStr += tempStr
>> until eof (2) : close  2
>>
>> end fn = tempStr
>>
>>
>> clear local mode
>> local fn GetPOSIXFilePath$( optionalFileType as str15 )
>> '~'1
>> dim as OSErr   err
>> dim as long    j, k
>> dim as Str255  path, esc, tmp
>> dim as str63   cmdStr
>>
>> long if optionalFileType[0] = 4
>> cmdStr  = "set the_app to "
>> cmdStr += "(choose file of type {"""
>> cmdStr += optionalFileType + """}) as string"
>> xelse
>> cmdStr = "set the_app to (choose file) as string"
>> end if
>>
>> route _toAppleScript
>> print cmdStr
>> print "return POSIX path of the_app"
>> route _toScreen
>>
>> err = usr AppleScriptRun( path )
>> // Exit on user cancel
>> if ( err != _noErr ) then path = "" : exit fn
>> // Remove enclosing double quotes generated by AppleScript
>> path = mid$( path, 2, path[0] - 2 )
>>
>> // Escape special Unix characters
>> esc = " ^$*+?[()|{\~" : k = 1
>> while ( k <= esc[0] )
>> tmp = mid$( esc, k, 1 )
>> j = instr( 1, path, tmp )
>> while ( j )
>> path = left$( path, j - 1 ) + "\" + mid$( path, j )
>> j = instr( j + 2, path, tmp )
>> wend
>> k++
>> wend
>>
>> end fn = path
>>
>> window 1
>>
>> dim as str255 unixPath
>>
>> // unixPath = fn GetPOSIXFilePath$( "jpg" )
>> unixPath = fn GetPOSIXFilePath$( "" )
>>
>> fn AddPreviewIcon$( unixPath )
>>
>> print "Preview icon added to: " + unixPath
>>
>> include "Subs Quick Event Loop.Incl"
>>
>> --
>>
>
> --
>