Permalink
Browse files

freightelementview

  • Loading branch information...
1 parent 2677064 commit 1c3d34bede864279afcc92516cb89c672245bb57 andrea@VEGETA committed Nov 3, 2009
Showing with 37 additions and 4 deletions.
  1. +1 −1 Rakefile
  2. +32 −0 lib/freightrain/freight_element_view.rb
  3. +4 −3 lib/freightrain/rubygnome_extensions/gtk_layout.rb
View
@@ -9,7 +9,7 @@ require 'rake/testtask'
spec = Gem::Specification.new do |s|
s.name = 'freightrain'
- s.version = '0.1.10'
+ s.version = '0.1.11'
s.has_rdoc = false
s.summary = 'ruby desktop development made easy'
s.description = s.summary
@@ -0,0 +1,32 @@
+
+module Freightrain
+
+ class FreightElementView < FreightView
+
+ signal :selected
+
+ def value
+ return @value
+ end
+
+ def value=(val)
+ @value = val
+ end
+
+ def control
+ return toplevel
+ end
+
+ def set_ui_selection(bool)
+ @signals.values.each { |s| s.stifle }
+ selected(bool)
+ @signals.values.each { |s| s.unleash }
+ end
+
+ def selected(bool)
+ raise "selected is not overridden. You should override the selected method on your #{self.class.name} control"
+ end
+
+
+ end
+end
@@ -7,10 +7,11 @@ def initialize(layout, element_class, signals)
@layout = layout
@element_class = element_class
@signals = signals
+ selected_callback = @signals[:selected]
@signals[:selected] = lambda { |value| @layout.elements.each do |item|
- item.selected = (item.value == value)
- end
- @signals[:selected].call(value) if @signals[:selected]
+ item.set_ui_selection(item.value == value)
+ end
+ selected_callback.call(value) if selected_callback
}
end

0 comments on commit 1c3d34b

Please sign in to comment.