[macruby-changes] [631] MacRuby/trunk/sample-macruby/Scripts/growl
source_changes at macosforge.org
source_changes at macosforge.org
Fri Sep 26 21:43:26 PDT 2008
Revision: 631
http://trac.macosforge.org/projects/ruby/changeset/631
Author: lsansonetti at apple.com
Date: 2008-09-26 21:43:26 -0700 (Fri, 26 Sep 2008)
Log Message:
-----------
adding delegation
Modified Paths:
--------------
MacRuby/trunk/sample-macruby/Scripts/growl/hotcocoa_growl.rb
MacRuby/trunk/sample-macruby/Scripts/growl/hotcocoa_sample.rb
Modified: MacRuby/trunk/sample-macruby/Scripts/growl/hotcocoa_growl.rb
===================================================================
--- MacRuby/trunk/sample-macruby/Scripts/growl/hotcocoa_growl.rb 2008-09-27 01:06:35 UTC (rev 630)
+++ MacRuby/trunk/sample-macruby/Scripts/growl/hotcocoa_growl.rb 2008-09-27 04:43:26 UTC (rev 631)
@@ -2,6 +2,8 @@
class Growl
include HotCocoa
+
+ attr_accessor :delegate
GROWL_IS_READY = 'Lend Me Some Sugar; I Am Your Neighbor!'
GROWL_NOTIFICATION_CLICKED = 'GrowlClicked!'
@@ -55,13 +57,17 @@
end
on_notification(:distributed => true, :named => "#{@app_name}-#{pid}-#{GROWL_NOTIFICATION_CLICKED}") do |n|
- puts '@@@ on clicked'
- puts n.userInfo[GROWL_CLICKED_CONTEXT_KEY][:user_click_context]
+ if @delegate and @delegate.respond_to?('growlNotifierClicked:context:')
+ ctx = n.userInfo[GROWL_CLICKED_CONTEXT_KEY][:user_click_context]
+ @delegate.growlNotifierClicked(self, context:ctx)
+ end
end
on_notification(:distributed => true, :named => "#{@app_name}-#{pid}-#{GROWL_NOTIFICATION_TIMED_OUT}") do |n|
- puts '@@@ on timed out'
- puts n.userInfo[GROWL_CLICKED_CONTEXT_KEY][:user_click_context]
+ if @delegate and @delegate.respond_to?('growlNotifierTimedOut:context:')
+ ctx = n.userInfo[GROWL_CLICKED_CONTEXT_KEY][:user_click_context]
+ @delegate.growlNotifierTimedOut(self, context:ctx)
+ end
end
dic = {
Modified: MacRuby/trunk/sample-macruby/Scripts/growl/hotcocoa_sample.rb
===================================================================
--- MacRuby/trunk/sample-macruby/Scripts/growl/hotcocoa_sample.rb 2008-09-27 01:06:35 UTC (rev 630)
+++ MacRuby/trunk/sample-macruby/Scripts/growl/hotcocoa_sample.rb 2008-09-27 04:43:26 UTC (rev 631)
@@ -6,6 +6,7 @@
def init
if super
@g = Growl.alloc.init
+ @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)
@@ -14,12 +15,12 @@
end
end
- def growlNotifierClicked_context(sender, context)
+ def growlNotifierClicked(sender, context:context)
puts "Clicked: #{context}"
checkCount
end
- def growlNotifierTimedOut_context(sender, context)
+ def growlNotifierTimedOut(sender, context:context)
puts "Timed out: #{context}"
checkCount
end
@@ -30,5 +31,5 @@
end
end
-g = GrowlController.alloc.init
+g = GrowlController.new
NSApp.run
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080926/c2bf38dd/attachment.html
More information about the macruby-changes
mailing list