1require 'osx/cocoa' 2require 'growl' 3include OSX 4 5class GrowlController 6 MESSAGE_KIND = 'message' 7 CLICKED_KIND = 'clicked' 8 9 def initialize 10 # Register this application to Growl. 11 @growl = Growl::Notifier.alloc.initWithDelegate(self) 12 @growl.start(:GrowlClientDemo, [MESSAGE_KIND, CLICKED_KIND]) 13 end 14 15 def show_message 16 # Send a notification to Growl. 17 @growl.notify(MESSAGE_KIND, 'RubyCocoa Growl Client', 'click this!', 'you can write some tags here', true) 18 end 19 20 def growl_onClicked(sender, context) 21 # Send a notification with a hash form. 22 @growl.notifyWith( 23 :type => CLICKED_KIND, 24 :title => 'Clicked', 25 :desc => context, 26 :sticky => false, 27 :priority => 0 28 ) 29 exit! 30 end 31end 32 33if $0 == __FILE__ 34 controller = GrowlController.new 35 controller.show_message 36 NSApplication.sharedApplication 37 NSApp.run 38end 39