From: Satoshi N. <ps...@li...> - 2008-08-20 10:01:21
|
Growl Notifier 1.0.1 has been released. http://rubyforge.org/projects/growlnotifier/ http://growlnotifier.rubyforge.org/ Growl Notifier allows your application to post Growl notifications. It can then receive clicked and timed out notifications from Growl. Or you can give it a block, which will then be used as a clicked callback. It is an extraction and clean up of the Growl code from LimeChat. The option to pass procs is extracted from WebApp. LimeChat: http://github.com/psychs/limechat/tree/master WebApp: http://github.com/alloy/webapp-app/tree/master == Installation gem install growlnotifier == Requirements * Mac OS X 10.4 or 10.5 * Ruby 1.8 * RubyCocoa 0.13.1 == Example require 'rubygems' require 'growl' class GrowlController < OSX::NSObject HELLO_TYPE = 'Hello message received' def init if super_init @g = Growl::Notifier.sharedInstance @g.delegate = self @g.register('GrowlSample', [HELLO_TYPE]) @g.notify(HELLO_TYPE, 'Sticky', 'Hello world', :sticky => true, :click_context => Time.now.to_s ) @g.notify(HELLO_TYPE, 'Timed out', 'Hello world', :click_context => Time.now.to_s ) @count = 2 self end end def growlNotifierClicked_context(sender, context) puts "Clicked: #{context}" checkCount end def growlNotifierTimedOut_context(sender, context) puts "Timed out: #{context}" checkCount end def checkCount @count -= 1 OSX::NSApp.terminate(nil) if @count == 0 end end g = GrowlController.alloc.init OSX::NSApp.run -- Satoshi Nakagawa |