Skip to content

Commit

Permalink
Added a sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
psychs committed Jul 31, 2008
1 parent b0df874 commit 04d67ca
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions samples/growl_sample.rb
@@ -0,0 +1,36 @@
require 'osx/cocoa'
require File.expand_path('../../lib/growl', __FILE__)

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 growlNotifier_notificationClicked(sender, context)
puts "Clicked: #{context}"
checkCount
end

def growlNotifier_notificationTimedOut(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

0 comments on commit 04d67ca

Please sign in to comment.