freightrain 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ require 'rake/testtask'
9
9
 
10
10
  spec = Gem::Specification.new do |s|
11
11
  s.name = 'freightrain'
12
- s.version = '0.7.0'
12
+ s.version = '0.7.1'
13
13
  s.add_dependency('require_all', '>= 1.1.0')
14
14
  s.has_rdoc = false
15
15
  s.homepage = "http://github.com/bolthar/freightrain"
@@ -15,6 +15,11 @@ require File.join(File.dirname(__FILE__), "widgets/gtk_statusicon.rb")
15
15
  require File.join(File.dirname(__FILE__), "interface_builder.rb")
16
16
  require File.join(File.dirname(__FILE__), "dialog_helper.rb")
17
17
 
18
+ module Gtk
19
+
20
+
21
+ end
22
+
18
23
  module Freightrain
19
24
 
20
25
  module Toolkit
@@ -4,6 +4,11 @@ module Gtk
4
4
  class Widget
5
5
  include Freightrain::BindingBase
6
6
 
7
+ def defaults
8
+ @defaults = {} unless @defaults
9
+ return @defaults
10
+ end
11
+
7
12
  #made for easier compatibility (other toolkits use show/hide)
8
13
  def show
9
14
  self.visible = true
@@ -13,27 +18,37 @@ module Gtk
13
18
  self.visible = false
14
19
  end
15
20
 
16
- def color_from_rgb(rgb_array)
21
+ def name
22
+ return self.builder_name
23
+ end
24
+
25
+ def color_from_rgb(rgb_array)
26
+ return nil unless rgb_array.kind_of? Enumerable
17
27
  red = rgb_array[0] * 255
18
28
  green = rgb_array[1] * 255
19
29
  blue = rgb_array[2] * 255
20
30
  return Gdk::Color.new(red, green, blue)
21
31
  end
22
32
 
23
- def name
24
- return self.builder_name
33
+ def get_color(symbol_or_array)
34
+ if symbol_or_array.kind_of? Symbol
35
+ rgb_array = Color[symbol_or_array]
36
+ else
37
+ rgb_array = symbol_or_array
38
+ end
39
+ return color_from_rgb(rgb_array)
25
40
  end
26
41
 
27
42
  def background=(color)
28
- self.modify_bg(Gtk::STATE_NORMAL, color_from_rgb(color))
43
+ self.modify_bg(Gtk::STATE_NORMAL, get_color(color))
29
44
  end
30
45
 
31
46
  def foreground=(color)
32
- self.modify_fg(Gtk::STATE_NORMAL, color_from_rgb(color))
47
+ self.modify_fg(Gtk::STATE_NORMAL, get_color(color))
33
48
  end
34
49
 
35
50
  def base_background=(color)
36
- self.modify_base(Gtk::STATE_NORMAL, color_from_rgb(color))
51
+ self.modify_base(Gtk::STATE_NORMAL, get_color(color))
37
52
  end
38
53
 
39
54
  def plug_in(region_widget)
@@ -41,8 +56,6 @@ module Gtk
41
56
  self << region_widget
42
57
  end
43
58
 
44
-
45
59
  end
46
60
 
47
-
48
61
  end
@@ -22,9 +22,9 @@ module Freightrain
22
22
  @cache = value
23
23
  end
24
24
  rescue Exception => ex #TODO: logger...
25
- # p "#{@widget.name} - update"
26
- # p ex.message
27
- # p @path
25
+ p "#{@widget.name} - update"
26
+ p ex.message
27
+ p @path
28
28
  end
29
29
  end
30
30
 
@@ -0,0 +1,12 @@
1
+
2
+ class Color
3
+
4
+ @@colors = {}
5
+ @@colors[:red] = [255, 0, 0]
6
+ @@colors[:green] = [0, 255, 0]
7
+ @@colors[:blue] = [0, 0, 255]
8
+
9
+ def self.[](color_symbol)
10
+ return @@colors[color_symbol]
11
+ end
12
+ end
@@ -20,8 +20,9 @@ module Freightrain
20
20
  return @value
21
21
  end
22
22
 
23
- def on_selected
23
+ def on_selected
24
24
  fire :selected, @value
25
+ @view.update
25
26
  end
26
27
 
27
28
  def control
@@ -51,7 +51,7 @@ module Freightrain
51
51
  @widgets.select{ |widget| widget.is_a? LayoutWidget }.each do |widget|
52
52
  method_prefix = widget.name + "_on_"
53
53
  self.methods.select { |method_name| method_name =~ /#{method_prefix}/}.each do |method_name|
54
- signal_name = method_name.sub(method_prefix, "")
54
+ signal_name = method_name.to_s.sub(method_prefix, "")
55
55
  widget.add_signal_callback(signal_name.to_sym, method(method_name))
56
56
  end
57
57
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freightrain
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 0
10
- version: 0.7.0
9
+ - 1
10
+ version: 0.7.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrea Dallera
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-21 00:00:00 +02:00
18
+ date: 2010-11-02 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -107,6 +107,7 @@ files:
107
107
  - lib/freightrain/binding/binding_host.rb
108
108
  - lib/freightrain/signals/signal_host.rb
109
109
  - lib/freightrain/signals/freight_signal.rb
110
+ - lib/freightrain/color.rb
110
111
  - lib/freightrain/elements/freight_element_view.rb
111
112
  - lib/freightrain/elements/freight_element_view_model.rb
112
113
  - lib/freightrain/elements/layout_widget.rb