Permalink
Browse files

changeable regions

  • Loading branch information...
1 parent ecdf106 commit a00988d37a52198ec582e7b3f27999b0825da673 andrea@VEGETA committed Nov 20, 2009
View
@@ -9,7 +9,7 @@ require 'rake/testtask'
spec = Gem::Specification.new do |s|
s.name = 'freightrain'
- s.version = '0.4.3'
+ s.version = '0.4.4'
s.has_rdoc = false
s.summary = 'ruby desktop development made easy'
s.description = s.summary
@@ -11,6 +11,7 @@ def initialize(widget)
end
def plug_in(region_widget)
+ @widget.remove(@widget.children.first)
@widget << region_widget
end
@@ -18,6 +18,8 @@ def self.wrap_container(widget)
end
def toplevel
+ p self.class.name
+ p "#{self.class.name} toplevel is nil" if !@builder.toplevel
return @builder.toplevel
end
@@ -4,7 +4,8 @@ module Freightrain
class FreightRegion
def initialize(name, options)
- @viewmodel = Freightrain[(name.to_s + "_view_model").to_sym]
+ viewmodel_name = options[:viewmodel] || name
+ @viewmodel = Freightrain[(viewmodel_name.to_s + "_view_model").to_sym]
@container = name.to_s + "_region"
end
@@ -17,6 +18,15 @@ def on_show(view)
view.class.wrap_container(container).plug_in(@viewmodel.show)
end
+ def change(viewmodel, view)
+ new_viewmodel = Freightrain[(viewmodel.to_s + "_view_model").to_sym]
+ if new_viewmodel != @viewmodel
+ @viewmodel = new_viewmodel
+ container = view.send(@container)
+ view.class.wrap_container(container).plug_in(@viewmodel.show)
+ end
+ end
+
end
end

0 comments on commit a00988d

Please sign in to comment.