freightrain 0.5.13 → 0.5.14
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/extensions/gtk/binding_base.rb +17 -0
- data/lib/extensions/gtk/gtk_bootstrapper.rb +3 -0
- data/lib/extensions/gtk/interface_builder.rb +7 -5
- data/lib/extensions/gtk/widgets/gtk_statusicon.rb +28 -0
- data/lib/extensions/gtk/widgets/gtk_widget.rb +1 -13
- data/lib/freightrain/binding/freight_binding.rb +3 -3
- data/lib/freightrain/freight_view.rb +1 -1
- metadata +4 -2
data/Rakefile
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
module BindingBase
|
3
|
+
|
4
|
+
def bind(binding_options)
|
5
|
+
@bindings ||= {}
|
6
|
+
binding = FreightBinding.new(self, binding_options)
|
7
|
+
#TODO: send out warning on override?
|
8
|
+
@bindings[binding_options[:property]] = binding
|
9
|
+
return binding
|
10
|
+
end
|
11
|
+
|
12
|
+
def bindings
|
13
|
+
@bindings ||= {}
|
14
|
+
return @bindings.values
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
|
2
2
|
#TODO: use require all
|
3
|
+
#TODO: use File.join for god's sake!
|
3
4
|
|
4
5
|
require 'libglade2'
|
6
|
+
require File.dirname(__FILE__) + "/binding_base.rb"
|
5
7
|
require File.dirname(__FILE__) + "/widgets/gtk_image.rb"
|
6
8
|
require File.dirname(__FILE__) + "/widgets/gtk_toggle_button.rb"
|
7
9
|
require File.dirname(__FILE__) + "/widgets/gtk_toggle_tool_button.rb"
|
@@ -11,6 +13,7 @@ require File.dirname(__FILE__) + "/widgets/gtk_calendar.rb"
|
|
11
13
|
require File.dirname(__FILE__) + "/widgets/gtk_treeview.rb"
|
12
14
|
require File.dirname(__FILE__) + "/widgets/gtk_treeviewcolumn.rb"
|
13
15
|
require File.dirname(__FILE__) + "/widgets/gtk_layout.rb"
|
16
|
+
require File.dirname(__FILE__) + "/widgets/gtk_statusicon.rb"
|
14
17
|
require File.dirname(__FILE__) + "/interface_builder.rb"
|
15
18
|
require File.dirname(__FILE__) + "/dialog_helper.rb"
|
16
19
|
|
@@ -15,14 +15,16 @@ module Freightrain
|
|
15
15
|
|
16
16
|
def create_objects_from_file(file_name)
|
17
17
|
@builder.add_from_file(get_glade_file(file_name))
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
if @builder.objects.first.respond_to? :toplevel
|
19
|
+
@control = @builder.objects.first.toplevel
|
20
|
+
end
|
21
|
+
return @builder.objects.select do |obj|
|
22
|
+
obj.respond_to? :name
|
23
|
+
end
|
22
24
|
end
|
23
25
|
|
24
26
|
def create_object_accessors(widgets, view)
|
25
|
-
widgets.each do |widget|
|
27
|
+
widgets.select { |widget| widget.respond_to? :name }.each do |widget|
|
26
28
|
name = widget.name
|
27
29
|
view.instance_eval "def #{name}; @widgets.select { |w| w.name == '#{name}' }.first ;end;"
|
28
30
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
module Gtk
|
3
|
+
|
4
|
+
class StatusIcon
|
5
|
+
include BindingBase
|
6
|
+
|
7
|
+
#Gtk::StatusIcon is NOT a Gtk::Widget, but a more basic
|
8
|
+
#GLib::Object. That implies that statusicons do not have
|
9
|
+
#a 'name' method, which is necessary for a lot of stuff
|
10
|
+
#in freightrain, such as method accessor creation and
|
11
|
+
#binding. Since, in most other aspect, statusicons behave
|
12
|
+
#very likely other widgets, i decided to hard patch the problem
|
13
|
+
#as follows.
|
14
|
+
#This means that ALL the Gtk::StatusIcon you define will
|
15
|
+
#be called 'status_icon', regardless of the name you define
|
16
|
+
#in Glade. If, for some weird reason, you need to use TWO
|
17
|
+
#statusicons inside the same view, you can either fix
|
18
|
+
#this yourself (and send me a patch :-) ) or contact me.
|
19
|
+
def name
|
20
|
+
return "status_icon"
|
21
|
+
end
|
22
|
+
|
23
|
+
def icon_path=(path)
|
24
|
+
self.pixbuf = Gdk::Pixbuf.new(path)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -2,19 +2,7 @@
|
|
2
2
|
module Gtk
|
3
3
|
|
4
4
|
class Widget
|
5
|
-
|
6
|
-
def bind(binding_options)
|
7
|
-
@bindings ||= {}
|
8
|
-
binding = FreightBinding.new(self, binding_options)
|
9
|
-
#TODO: send out warning on override?
|
10
|
-
@bindings[binding_options[:property]] = binding
|
11
|
-
return binding
|
12
|
-
end
|
13
|
-
|
14
|
-
def bindings
|
15
|
-
@bindings ||= {}
|
16
|
-
return @bindings.values
|
17
|
-
end
|
5
|
+
include BindingBase
|
18
6
|
|
19
7
|
def color_from_rgb(string)
|
20
8
|
red = ((string[0..1].hex.to_i + 1) * 256) - 1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: freightrain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrea Dallera
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-21 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -58,10 +58,12 @@ files:
|
|
58
58
|
- lib/extensions/gtk/interface_builder.rb
|
59
59
|
- lib/extensions/gtk/dialog_helper.rb
|
60
60
|
- lib/extensions/gtk/gtk_bootstrapper.rb
|
61
|
+
- lib/extensions/gtk/binding_base.rb
|
61
62
|
- lib/extensions/gtk/widgets/gtk_layout.rb
|
62
63
|
- lib/extensions/gtk/widgets/gtk_image.rb
|
63
64
|
- lib/extensions/gtk/widgets/gtk_combo_box.rb
|
64
65
|
- lib/extensions/gtk/widgets/gtk_calendar.rb
|
66
|
+
- lib/extensions/gtk/widgets/gtk_statusicon.rb
|
65
67
|
- lib/extensions/gtk/widgets/gtk_treeview.rb
|
66
68
|
- lib/extensions/gtk/widgets/gtk_widget.rb
|
67
69
|
- lib/extensions/gtk/widgets/gtk_toggle_button.rb
|