clickable notifications with applescript

The Growl forums have moved to Google Groups, this forum is read only.
Locked
ahmettaha
Harmless
Posts: 15
Joined: Thu Nov 30, 2006 10:58 am

clickable notifications with applescript

Post by ahmettaha »

How do I create clickable notifications with applescript? I couldnt find it anywhere. I would like it to go to a web page.

Thanks
User avatar
bgannin
Growl Team
Posts: 1817
Joined: Thu Dec 02, 2004 8:11 am
Location: ..here
Contact:

Post by bgannin »

In looking at the bindings for AppleScript it doesn't appear that they currently support the clickability of notifications and such you should file a Trac ticket to remind us that this functionality is needed.
Try my software!

#define ADIUMX pimp //by me
#define QUESTION ((2b) || (!2b))
Have you hugged a programmer today?
ahmettaha
Harmless
Posts: 15
Joined: Thu Nov 30, 2006 10:58 am

Post by ahmettaha »

how do I do that. I cant see create new ticket on that link
User avatar
bgannin
Growl Team
Posts: 1817
Joined: Thu Dec 02, 2004 8:11 am
Location: ..here
Contact:

Post by bgannin »

Apparently Growl's Trac isn't open like Adium's, my apologies. I'll make a ticket momentarily. If you could, please post desired syntax/terminology for the changes and these will be included in the ticket as well.
Try my software!

#define ADIUMX pimp //by me
#define QUESTION ((2b) || (!2b))
Have you hugged a programmer today?
User avatar
bgannin
Growl Team
Posts: 1817
Joined: Thu Dec 02, 2004 8:11 am
Location: ..here
Contact:

Post by bgannin »

Try my software!

#define ADIUMX pimp //by me
#define QUESTION ((2b) || (!2b))
Have you hugged a programmer today?
ahmettaha
Harmless
Posts: 15
Joined: Thu Nov 30, 2006 10:58 am

Post by ahmettaha »

it would be cool if this gets implemented. I just created a widget for google apps for your domain mailboxes, and I use growl for notifications, and it would be nice to be able to go to the message when clicked on the notification
User avatar
nanovivid
Frappa
Posts: 137
Joined: Fri Dec 03, 2004 10:13 pm

Post by nanovivid »

See also http://trac.growl.info/ticket/255

ingmarstein said it didn't look to be possible for technical reasons. :(
User avatar
bgannin
Growl Team
Posts: 1817
Joined: Thu Dec 02, 2004 8:11 am
Location: ..here
Contact:

Post by bgannin »

nanovivid wrote:See also http://trac.growl.info/ticket/255

ingmarstein said it didn't look to be possible for technical reasons. :(
Good catch, I was foolish enough not to search and that's what I get :)
Try my software!

#define ADIUMX pimp //by me
#define QUESTION ((2b) || (!2b))
Have you hugged a programmer today?
DeltaTee
Latté
Posts: 71
Joined: Sun Jun 05, 2005 7:58 pm
Contact:

Post by DeltaTee »

If GrowlHelperApp was able to return a tag as a reference to a notification (and then accept that tag again), I don't think this would be impossible with code similar to:

Code: Select all

tell application "GrowlHelperApp" to set theTag to (display notification "...")

repeat with x from 1 to 100 
  delay 0.1 
  tell application "GrowlHelperApp" to set theStatus to (get status of notification theTag)

  if theStatus = "Clicked" then 
    -- do stuff 
  else if theStatus = "Closed" then 
    exit repeat 
  end 
end repeat
It just requires a tag to be able to preserve state.[/code]
Wooden Brain Concepts
Latté
Posts: 50
Joined: Wed Dec 27, 2006 2:37 am

Documentation

Post by Wooden Brain Concepts »

Can you point to some documentation on clickable notifications? I use AppleScript too but there might be a way to get distributed notifications in AS Studio projects at least. It involves using a bit of C code in a studio project and having the project respond to an invisible button (on clicked).
Wooden Brain Concepts
Latté
Posts: 50
Joined: Wed Dec 27, 2006 2:37 am

Re: clickable notifications with applescript

Post by Wooden Brain Concepts »

OK guys... revisiting this topic.

I tried to find a way to fudge this one but so far have been unsuccessful. I really believe this should be possible in AppleScript Studio by defining some C sources and connecting them to buttons on the interface. The idea is to use C code to click an invisible button and set the title of the button to the result string.

I was able to do something like this to get distributed notifications from iTunes, with some help from jobu:
http://bbs.macscripter.net/viewtopic.php?id=19608

A method he suggested in an email was to set the title of the connected button to the notification string, something like this (but obviously for Growl not for iTunes):

Code: Select all

-(void)handleGrowlNotification:(NSNotification *)aNotification {
	//NSLog(@"Handle Notification Growl");
	//NSLog(@"The whole userInfo dictionary:");
	//NSLog([[aNotification userInfo] description]);
	NSString *playerState = [[aNotification userInfo] objectForKey:@"Player State"];
	playerState = ((playerState) ? playerState : @"Unknown");
	[asActionButton setTitle:playerState];
	[asActionButton performClick:nil];
}
In other words, the:

Code: Select all

- (void) growlNotificationWasClicked:(id)clickContext;
in the growl framework would click this invisible button and pass the clickContext to the title of the Action button. then it can be handled with the on clicked handler.

unfortunately i just don't know enough C to write this.

the other problem I see is the appelscript dictionary does not support the clickContext parameter. There would have to be some way to send this parameter.

so ideally you could use applescript to display notifications, but only the "growlNotificationWasClicked" event would get handled in C and passed to this button.

Can anyone put this all together?

Failing this, if anyone could provide a really simple XCODE project with the growl framework built in that actually sends notifications and responds to clicks, I might be able to piece it together from that. but with just the commented framework in the SDK that's not enough for me to go on.
Wooden Brain Concepts
Latté
Posts: 50
Joined: Wed Dec 27, 2006 2:37 am

Re: clickable notifications with applescript

Post by Wooden Brain Concepts »

OK...

I got it sussed out.

Turns out the biggest stumbling block was this piddling issue of image sizes for high resolution images. For that sordid history see:

http://forums.cocoaforge.com/viewtopic.php?f=6&t=16005

This is the resulting sample project:

http://www.woodenbrain.com/sw/betas/WBC_ASS_Growler.zip

WBC ASS Growler is made available as a demonstration of a method of how to post clickable notifications to Growl with AppleScript Studio.

It creates a custom c class, which actually posts the notifications and receives call backs from the click context.

In its current version, you can pass a string click context to this "GrowlObserver" class. If the click context is a URL beginning with "http://" the class will receive the callback and open the link in the default browser.

If it is anything else, it will pass the click context back to the alternate title of a button (usually invisible in the GUI) and click it. You can then handle that click.

======

This sample project is provides a courtesy to the community. Please feel free to use with credit.
If open source, comments are fine for credit, otherwise about box or similar. Please include link to http://www.woodenbrain.com.
Locked