[macruby-changes] [334] MacRuby/trunk/lib

source_changes at macosforge.org source_changes at macosforge.org
Tue Jul 8 20:15:18 PDT 2008


Revision: 334
          http://trac.macosforge.org/projects/ruby/changeset/334
Author:   rich at infoether.com
Date:     2008-07-08 20:15:18 -0700 (Tue, 08 Jul 2008)
Log Message:
-----------
move application to its own mapping and implement the ability to handle the block

Modified Paths:
--------------
    MacRuby/trunk/lib/hotcocoa/mapper.rb
    MacRuby/trunk/lib/hotcocoa/mappings/color.rb
    MacRuby/trunk/lib/hotcocoa.rb

Added Paths:
-----------
    MacRuby/trunk/lib/hotcocoa/mappings/application.rb

Modified: MacRuby/trunk/lib/hotcocoa/mapper.rb
===================================================================
--- MacRuby/trunk/lib/hotcocoa/mapper.rb	2008-07-08 22:34:46 UTC (rev 333)
+++ MacRuby/trunk/lib/hotcocoa/mapper.rb	2008-07-09 03:15:18 UTC (rev 334)
@@ -30,7 +30,13 @@
         if default_empty_rect_used
           control.sizeToFit if control.respondsToSelector(:sizeToFit) == 1
         end
-        control_block.call(control) if control_block
+        if control_block
+          if inst.respond_to?(:handle_block)
+            inst.handle_block(control, &control_block)
+          else
+            control_block.call(control)
+          end
+        end
         control
       end
     end

Added: MacRuby/trunk/lib/hotcocoa/mappings/application.rb
===================================================================
--- MacRuby/trunk/lib/hotcocoa/mappings/application.rb	                        (rev 0)
+++ MacRuby/trunk/lib/hotcocoa/mappings/application.rb	2008-07-09 03:15:18 UTC (rev 334)
@@ -0,0 +1,24 @@
+HotCocoa::Mappings.map :application => :NSApplication do
+  
+  def alloc_with_options(options)
+    NSApplication.sharedApplication
+  end
+  
+  def handle_block(application, &block)
+    block.call(application)
+    application.run
+  end
+  
+  custom_methods do
+    
+    def name=(name)
+      @name = name
+    end
+    
+    def name
+      @name
+    end
+    
+  end
+  
+end
\ No newline at end of file

Modified: MacRuby/trunk/lib/hotcocoa/mappings/color.rb
===================================================================
--- MacRuby/trunk/lib/hotcocoa/mappings/color.rb	2008-07-08 22:34:46 UTC (rev 333)
+++ MacRuby/trunk/lib/hotcocoa/mappings/color.rb	2008-07-09 03:15:18 UTC (rev 334)
@@ -17,7 +17,7 @@
       else
         return NSColor.colorWithDeviceRed red, green:green, blue:blue, alpha:alpha
       end
-    elsif [:red, :green, :blue].all? { |s| options.has_key?(s) }
+    elsif (options.keys & [:red, :green, :blue]).size == 3
       alpha = (options.delete(:alpha) or 1.0)
       return NSColor.colorWithCalibratedRed options.delete(:red), green:options.delete(:green), blue:options.delete(:blue), alpha:alpha
     else

Modified: MacRuby/trunk/lib/hotcocoa.rb
===================================================================
--- MacRuby/trunk/lib/hotcocoa.rb	2008-07-08 22:34:46 UTC (rev 333)
+++ MacRuby/trunk/lib/hotcocoa.rb	2008-07-09 03:15:18 UTC (rev 334)
@@ -2,15 +2,6 @@
 
 module HotCocoa
   
-  def application(&block)
-    app = NSApplication.sharedApplication
-    if block
-      block.call(app)
-      app.run
-    end
-    app
-  end
-  
   Views = {}
   
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080708/5257600c/attachment-0001.html 


More information about the macruby-changes mailing list