Permalink
Browse files

regions stub

  • Loading branch information...
1 parent 33e9118 commit 28231c08e2dbd956f5c2a6f1edf5b2d7d5071372 andrea@VEGETA committed Nov 5, 2009
Showing with 39 additions and 1 deletion.
  1. +1 −1 Rakefile
  2. +18 −0 lib/freightrain/freight_region.rb
  3. +7 −0 lib/freightrain/freight_view_model.rb
  4. +13 −0 lib/freightrain/region_host.rb
View
@@ -9,7 +9,7 @@ require 'rake/testtask'
spec = Gem::Specification.new do |s|
s.name = 'freightrain'
- s.version = '0.1.13'
+ s.version = '0.2.1'
s.has_rdoc = false
s.summary = 'ruby desktop development made easy'
s.description = s.summary
@@ -0,0 +1,18 @@
+
+module Freightrain
+ ù
+ class FreightRegion
+
+ def initialize(name, options)
+ @container = name.to_s + "_region"
+ @viewmodel_class = Freightrain[(name + "_view_model").to_sym]
+ end
+
+ def on_show(view)
+ @viewmodel = @viewmodel_class.new
+ view.send(@container) << @viewmodel.show
+ end
+
+ end
+
+end
@@ -10,17 +10,24 @@ def self.service(name)
@services << name.to_sym
end
+ def self.region(name, options)
+ @regions ||= {}
+ @regions[:name] = options
+ end
+
def initialize()
@view = Freightrain[self.class.name.sub("Model","").to_convention_sym]
@view.signals.each do |key,signal|
signal.connect(method("on_" + key.to_s)) if self.respond_to? "on_" + key.to_s
end
@view.data_source = self
get_services
+ build_regions
end
def show
@view.toplevel.visible = true
+ return @view.toplevel
end
def hide
@@ -0,0 +1,13 @@
+
+module RegionHost
+
+ def build_regions
+ regions = self.class.instance_variable_get(:@regions)
+ regions ||= []
+ regions.each do |name, options|
+ @regions[name] = FreightRegion.new(name, options)
+ end
+ end
+
+
+end

0 comments on commit 28231c0

Please sign in to comment.