Icons in display dialog

Yeah - some of those older ones are definitely showing their age, Adam. Since most of the really scruffy ones are below about 10 KB, something like the following should do the trick (although you can adjust the size filter to taste):

to show_icons over k for t
	set p to (path to "csrv")'s POSIX path & "CoreTypes.bundle/Contents/Resources/"
	set l to list folder POSIX file p without invisibles
	set e to count l
	set q to true
	set b to "+"
	set m to 1
	repeat
		set f to l's item m
		set i to POSIX file (p & f)
		set s to ((size of (info for i)) + 500) div 1000
		if f ends with ".icns" and s > k then
			set d to f's text 1 thru -6 & return & s & " KB"
			if not gave up of (display dialog d buttons {"Cancel", "Pause"} default button 2 with icon i giving up after t) then ¬
				set b to button returned of (display dialog d buttons {"Cancel", "-", "+"} default button b with icon i)
			if q then set q to false
		end if
		set m to m + (b & 1)
		if m > e then
			if q then return beep
			set m to 1
		else if m < 1 then
			set m to e
		end if
	end repeat
end show_icons

show_icons over 10 for 1 (* over size (KB), for time (seconds) *)

Now that is really slick, Kai. Terse, but slick. Thanks

This is exactly what I’m trying to do! See thread http://bbs.applescript.net/viewtopic.php?id=16693
I can’t find where the iTunes icon is located, though…

Hi Slim,

The iTunes icon is here:

set f to “Macintosh HD:Applications:iTunes.app:Contents:Resources:iTunes.icns” as alias

on my computer. Jaguar’s ‘display dialog’ command can’t use icon references I think, so I can’t check if using this reference works.

As I mentioned in the other post, if you’re writing a script app, you could add a “cicn” resource to the app and use that icon.

Edited: hoping that I’m not going to get scoldings for mentioning an old fashioned method.

gl,

Just to confirm Kel’s advice, this works in Tiger: Edit: cleaned up path (see below)

display dialog "iTunes" with icon path to resource "iTunes.icns" in bundle (path to application "iTunes")

However, also in Tiger, a dialog displayed by an application (such as in Slim’s script, should automatically display that app’s Aqua icon for note/icon 1 (as Dominik mentioned earlier in this topic).

This variation of Slim’s script, for example, shows the iTunes logo in the dialog:

tell application "iTunes" to tell library playlist 1
	set shuffle to not shuffle
	display dialog "Shuffle O" & {"ff", "n"}'s item ((shuffle as integer) + 1) buttons "Sweet" default button 1 with icon 1
end tell

kai, why do you do POSIX file (POSIX path of **) and not just path to ** ?

It may have something to do with the fact that I’ve been up all night (5:30 AM here), working on a project for which the deadline is due in 3 hours time - and have still been trying to squeeze in the odd reply to this forum, Qwerty. Well spotted. :slight_smile:

Edit: On reflection (if I remember correctly), the direct reference didn’t work in an earlier version. But since it clearly does now, that simplifies things considerably. :slight_smile:

display dialog "Final collection." with icon path to resource "TheCheat.icns" in bundle POSIX file (POSIX path of (path to me))

I keep getting an error "Expected end of line, etc. but found ". at the first " mark of TheCheat.icns

Is the word resource a variable?

What am I doing wrong?

That compile-time error is possible with a broken line, PUNCH:

display dialog "Final collection." with icon path to 
resource "TheCheat.icns" in bundle (path to me)

I realise you’ve posted a single statement above - so there may be another problem involved. However, the term ‘resource’ should normally compile as a keyword, not a variable:

display dialog "Final collection." with icon path to resource "TheCheat.icns" in bundle (path to me)

Some icons:
http://interfacelift.com/icons-mac/index.php?sort=date

Some nice stuff there, Mark. :slight_smile:

Ok, I put just that line in a scriptwindow, and got this error:

A " can’t go after this identifier.

I’ve tried putting it in a Finder tell, and several other variations.

What am I doing wrong?

display dialog "Final collection." with icon path to resource "TheCheat.icns" in bundle (path to me)

Im pre-tiger so I think I need to utilise the “old fashioned way” but it may be a good resource to inject a theam or some personallity to the script interface.

Is your system pre-Tiger, PUNCH? The path to resource command was added in AppleScript 1.10 (Mac OS X version 10.4).

yeah, here at work, we’re still on Panther. I tested on a Tiger machine, and it worked great.

What can I do to make this work on Panther?

Try something like this instead, PUNCH (should work for both Tiger and pre-Tiger):

display dialog "Final collection." with icon POSIX file (POSIX path of (path to me) & "Contents/Resources/TheCheat.icns")

That didn’t work either.

I’ll explain what I’ve done.

I copied/pasted your line of code into a blank AS doc. Saved it as an app bundle, then I just double click the app. It displays the dialog, but doesn’t show the icon.

I then changed the name of my icon to applet.icns, and replaced the existing one in the resources folder. It DID change the icon of my app, but again, when I run the app, it displays the dialog, but no icon.

Thanx

I can’t test for this in Panther, PUNCH - but can I just check that you also changed the name of the icon in the script?

display dialog "Final collection." with icon POSIX file (POSIX path of (path to me) & "Contents/Resources/applet.icns")

If you’ve replaced the applet.icns file with another icon of the same name, this should now show the new icon, anyway:

display dialog "Final collection." with icon 1

(Using the path to an icon file is obviously more useful for displaying various different icons in dialogs.)

Insane.

Nothing worked. In fact, when I selected icon 1 it just gave me a generic finder looking icon. But hey, at least it displayed an icon at all eh?

Thnx

Checking into this in a little more detail, PUNCH, the release notes for AppleScript 1.10 (Mac OS X version 10.4) say:

This suggests that the ability to display alternative icons may have only been introduced in Tiger. So, for the moment, it looks like you’re stuck with the 3 standard icon options: stop (0), note (1) & caution (2). (It used to be possible to display an alternative icon by adding a new ‘cicn’ resource to an app - but things have changed a little since those days.)

This at least explains why your attempts didn’t alert us to a problem. :confused: