visualruby 3.0.2 → 3.0.3

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.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/.vr_settings.yaml +27 -0
  3. data/bin/editor/VR_Document.rb +156 -156
  4. data/bin/editor/VR_TabSearch.rb +37 -37
  5. data/bin/editor/VR_Tabs.rb +82 -82
  6. data/bin/editor/VR_TextShell.rb +49 -52
  7. data/bin/editor/VR_TextViewCommon.rb +31 -31
  8. data/bin/main/GemTree.rb +14 -14
  9. data/bin/main/NewProjectGUI.rb +24 -24
  10. data/bin/main/OpenProject.rb +53 -53
  11. data/bin/main/ProjectChooserView.rb +31 -31
  12. data/bin/main/ProjectTree.rb +17 -17
  13. data/bin/main/RubygemsAPI.rb +73 -63
  14. data/bin/main/VR_ENV.rb +29 -29
  15. data/bin/main/VR_ENV_GLOBAL.rb +52 -52
  16. data/bin/main/VR_File_Tree.rb +88 -88
  17. data/bin/main/VR_Local_Gem_Tree.rb +53 -53
  18. data/bin/main/VR_Main.rb +240 -238
  19. data/bin/main/VR_Remote_Gem_Tree.rb +41 -41
  20. data/bin/main/glade/Splash.glade +19 -0
  21. data/bin/tools/VR_Tools.rb +72 -72
  22. data/examples/active_record/.vr_settings.yaml +50 -0
  23. data/examples/active_record/active_record.rb +2 -2
  24. data/examples/active_record/bin/ChoosePerson.rb +10 -10
  25. data/examples/active_record/bin/Person.rb +6 -6
  26. data/examples/active_record2/.vr_settings.yaml +23 -0
  27. data/examples/active_record2/bin/CompanyGUI.rb +42 -42
  28. data/examples/active_record2/bin/Employee.rb +13 -13
  29. data/examples/active_record2/bin/Employer.rb +5 -5
  30. data/examples/active_record2/bin/Paycheck.rb +5 -5
  31. data/examples/active_record2/main.rb +4 -4
  32. data/examples/alert_box/bin/AlertBoxDemo.rb +40 -50
  33. data/examples/alert_box/bin/glade/AlertBoxDemo.glade +14 -45
  34. data/examples/all_widgets/.vr_settings.yaml +18 -0
  35. data/examples/all_widgets/bin/AllWidgets.rb +19 -16
  36. data/examples/calculator/.vr_settings.yaml +18 -0
  37. data/examples/calculator/bin/Calculator.rb +22 -22
  38. data/examples/child_window/.vr_settings.yaml +21 -0
  39. data/examples/child_window/bin/ChildWindowDemo.rb +10 -10
  40. data/examples/child_window/bin/ModalWindow.rb +4 -4
  41. data/examples/child_window/bin/ModelessWindow.rb +4 -4
  42. data/examples/child_window/bin/MyChildClass.rb +10 -10
  43. data/examples/drag_drop/.vr_settings.yaml +16 -0
  44. data/examples/drag_drop/bin/DragDropDemo.rb +28 -28
  45. data/examples/filetreeview/.vr_settings.yaml +20 -0
  46. data/examples/filetreeview/bin/ProjectTree.rb +13 -23
  47. data/examples/filetreeview/bin/ProjectTreeGUI.rb +18 -17
  48. data/examples/listview/.vr_settings.yaml +19 -0
  49. data/examples/listview/bin/SongListView.rb +72 -72
  50. data/examples/listview/bin/SongListViewGUI.rb +52 -52
  51. data/examples/listview_objects/.vr_settings.yaml +19 -0
  52. data/examples/listview_objects/bin/DataObject.rb +23 -23
  53. data/examples/listview_objects/bin/ListViewObjects.rb +29 -29
  54. data/examples/listview_objects/bin/ListViewObjectsGUI.rb +12 -12
  55. data/examples/settings_file/bin/MainApp.rb +25 -25
  56. data/examples/settings_file/bin/SavableSettings.rb +25 -26
  57. data/examples/settings_file/settings.yaml +1 -1
  58. data/examples/simple_ruby_gui/.vr_settings.yaml +20 -0
  59. data/examples/simple_ruby_gui/bin/DataObjectGUI.rb +12 -12
  60. data/examples/treeview/.vr_settings.yaml +17 -0
  61. data/examples/treeview/bin/MyClass.rb +18 -17
  62. data/examples/treeview/bin/glade/MyClass.glade +61 -6
  63. data/skeleton/document/NewWindow.rb +8 -8
  64. data/skeleton/project/.vr_settings.yaml +15 -0
  65. data/skeleton/project/bin/MyClass.rb +7 -7
  66. data/vr +38 -41
  67. data/vrlib/doc/images/add.png +0 -0
  68. data/vrlib/doc/images/arrow_up.png +0 -0
  69. data/vrlib/doc/images/brick.png +0 -0
  70. data/vrlib/doc/images/brick_link.png +0 -0
  71. data/vrlib/doc/images/bug.png +0 -0
  72. data/vrlib/doc/images/bullet_black.png +0 -0
  73. data/vrlib/doc/images/bullet_toggle_minus.png +0 -0
  74. data/vrlib/doc/images/bullet_toggle_plus.png +0 -0
  75. data/vrlib/doc/images/date.png +0 -0
  76. data/vrlib/doc/images/delete.png +0 -0
  77. data/vrlib/doc/images/find.png +0 -0
  78. data/vrlib/doc/images/macFFBgHack.png +0 -0
  79. data/vrlib/doc/images/package.png +0 -0
  80. data/vrlib/doc/images/page_green.png +0 -0
  81. data/vrlib/doc/images/page_white_text.png +0 -0
  82. data/vrlib/doc/images/page_white_width.png +0 -0
  83. data/vrlib/doc/images/plugin.png +0 -0
  84. data/vrlib/doc/images/ruby.png +0 -0
  85. data/vrlib/doc/images/tag_blue.png +0 -0
  86. data/vrlib/doc/images/tag_green.png +0 -0
  87. data/vrlib/doc/images/transparent.png +0 -0
  88. data/vrlib/doc/images/wrench.png +0 -0
  89. data/vrlib/doc/images/wrench_orange.png +0 -0
  90. data/vrlib/doc/images/zoom.png +0 -0
  91. data/vrlib/lib/Alert.rb +98 -55
  92. data/vrlib/lib/DragDrop.rb +43 -43
  93. data/vrlib/lib/GladeGUI.rb +207 -207
  94. data/vrlib/lib/IconHash.rb +10 -10
  95. data/vrlib/lib/SavableClass.rb +38 -38
  96. data/vrlib/lib/SimpleComboBoxEntry.rb +3 -3
  97. data/vrlib/lib/treeview/FileTreeView.rb +71 -70
  98. data/vrlib/lib/treeview/IterMethods.rb +35 -35
  99. data/vrlib/lib/treeview/ListView.rb +25 -25
  100. data/vrlib/lib/treeview/TreeView.rb +15 -15
  101. data/vrlib/lib/treeview/ViewCommon.rb +134 -131
  102. data/vrlib/lib/treeview/columns/CalendarCol.rb +48 -48
  103. data/vrlib/lib/treeview/columns/CellRendererCombo.rb +26 -26
  104. data/vrlib/lib/treeview/columns/CellRendererDate.rb +25 -25
  105. data/vrlib/lib/treeview/columns/CellRendererObject.rb +37 -37
  106. data/vrlib/lib/treeview/columns/CellRendererPhone.rb +25 -25
  107. data/vrlib/lib/treeview/columns/CellRendererPixbuf.rb +8 -8
  108. data/vrlib/lib/treeview/columns/CellRendererProgress.rb +8 -8
  109. data/vrlib/lib/treeview/columns/CellRendererSpin.rb +17 -17
  110. data/vrlib/lib/treeview/columns/CellRendererText.rb +18 -18
  111. data/vrlib/lib/treeview/columns/CellRendererToggle.rb +25 -25
  112. data/vrlib/lib/treeview/columns/ComboCol.rb +12 -12
  113. data/vrlib/lib/treeview/columns/CurrencyCol.rb +13 -13
  114. data/vrlib/lib/treeview/columns/DateCol.rb +10 -10
  115. data/vrlib/lib/treeview/columns/ImageCol.rb +16 -16
  116. data/vrlib/lib/treeview/columns/SpinCol.rb +5 -5
  117. data/vrlib/lib/treeview/columns/TextCol.rb +24 -24
  118. data/vrlib/lib/treeview/columns/TreeViewColumn.rb +71 -76
  119. data/vrlib/rdoc_replace.yaml +36 -36
  120. metadata +43 -6
  121. data/Splash.rb +0 -40
@@ -2,87 +2,87 @@
2
2
 
3
3
  module VR
4
4
 
5
- module Draggable
6
- def add_target_widget(widget)
7
- @target_widgets ||= []
8
- @target_widgets << widget
9
- ar = [[ self.object_id.to_s, :same_app, 12_345]]
5
+ module Draggable
6
+ def add_target_widget(widget)
7
+ @target_widgets ||= []
8
+ @target_widgets << widget
9
+ ar = [[ self.object_id.to_s, :same_app, 12_345]]
10
10
  drag_source_set(Gdk::ModifierType::BUTTON1_MASK |
11
11
  Gdk::ModifierType::BUTTON2_MASK,
12
12
  ar,
13
13
  Gdk::DragAction::COPY |
14
- Gdk::DragAction::MOVE)
15
- widget.extend(VR::Droppable) unless widget.is_a?(VR::Droppable)
16
- widget.add_source_widget(self)
17
- # if not self.respond_to?(:drag_begin)
18
- self.signal_connect("drag_begin") do |widget, context|
19
- @target_widgets.each { |widg| widg.dragged_widget = self }
20
- end
21
- # end
22
- end
14
+ Gdk::DragAction::MOVE)
15
+ widget.extend(VR::Droppable) unless widget.is_a?(VR::Droppable)
16
+ widget.add_source_widget(self)
17
+ # if not self.respond_to?(:drag_begin)
18
+ self.signal_connect("drag_begin") do |widget, context|
19
+ @target_widgets.each { |widg| widg.dragged_widget = self }
20
+ end
21
+ # end
22
+ end
23
23
  end
24
24
 
25
- module Droppable
25
+ module Droppable
26
26
 
27
- attr_accessor :dragged_widget, :source_widgets
27
+ attr_accessor :dragged_widget, :source_widgets
28
28
 
29
29
 
30
- @dragged_widget = nil
30
+ @dragged_widget = nil
31
31
 
32
- def add_source_widget(widget)
33
- @source_widgets ||= []
34
- @source_widgets << [widget.object_id.to_s, :same_app, 12_345]
32
+ def add_source_widget(widget)
33
+ @source_widgets ||= []
34
+ @source_widgets << [widget.object_id.to_s, :same_app, 12_345]
35
35
  drag_dest_set(Gtk::DestDefaults::MOTION |
36
36
  Gtk::DestDefaults::HIGHLIGHT,
37
37
  @source_widgets,
38
38
  Gdk::DragAction::COPY |
39
39
  Gdk::DragAction::MOVE)
40
- end
40
+ end
41
41
 
42
- end
42
+ end
43
43
  end
44
44
 
45
45
  # module DragDrop
46
46
  #
47
- # attr_accessor :dragged_widget, :drag_array
47
+ # attr_accessor :dragged_widget, :drag_array
48
48
  #
49
- # def drag_array(element = nil)
50
- # @dnd ||= []
51
- # @dnd.push(element) if not element.nil?
52
- # return @dnd
53
- # end
49
+ # def drag_array(element = nil)
50
+ # @dnd ||= []
51
+ # @dnd.push(element) if not element.nil?
52
+ # return @dnd
53
+ # end
54
54
  #
55
55
  #
56
- # def drag_to(target_widget) #Gdk::Window::BUTTON1_MASK)
56
+ # def drag_to(target_widget) #Gdk::Window::BUTTON1_MASK)
57
57
  #
58
- # @target_widgets ||= []
59
- # @target_widgets << target_widget
58
+ # @target_widgets ||= []
59
+ # @target_widgets << target_widget
60
60
  #
61
- ## @drag_array ||= []
62
- ## @drag_array <<
61
+ ## @drag_array ||= []
62
+ ## @drag_array <<
63
63
  #
64
- # ar = [[ self.object_id.to_s, :same_app, 12_345]]
64
+ # ar = [[ self.object_id.to_s, :same_app, 12_345]]
65
65
  # drag_source_set(Gdk::ModifierType::BUTTON1_MASK |
66
66
  # Gdk::ModifierType::BUTTON2_MASK,
67
67
  # ar,
68
68
  # Gdk::DragAction::COPY |
69
- # Gdk::DragAction::MOVE)
69
+ # Gdk::DragAction::MOVE)
70
70
  #
71
- # ar = target_widget.drag_array([ self.object_id.to_s, :same_app, 12_345])
71
+ # ar = target_widget.drag_array([ self.object_id.to_s, :same_app, 12_345])
72
72
  # target_widget.drag_dest_set(Gtk::DestDefaults::MOTION |
73
73
  # Gtk::DestDefaults::HIGHLIGHT,
74
74
  # ar,
75
75
  # Gdk::DragAction::COPY |
76
76
  # Gdk::DragAction::MOVE)
77
77
  #
78
- # if not @done
79
- # @done = true
80
- # self.signal_connect("drag_begin") do |widget, context|
81
- # @target_widgets.each { |widg| widg.dragged_widget = self }
82
- # end
83
- # end
78
+ # if not @done
79
+ # @done = true
80
+ # self.signal_connect("drag_begin") do |widget, context|
81
+ # @target_widgets.each { |widg| widg.dragged_widget = self }
82
+ # end
83
+ # end
84
84
  #
85
- # end
85
+ # end
86
86
  #
87
87
  # end
88
88
  #
@@ -54,7 +54,7 @@
54
54
  #
55
55
  # def before_show()
56
56
  # puts @builder.to_s # => Gtk::Builder
57
- # end
57
+ # end
58
58
  #
59
59
  # end
60
60
  #
@@ -90,7 +90,7 @@
90
90
 
91
91
  module GladeGUI
92
92
 
93
- attr_accessor :builder
93
+ attr_accessor :builder
94
94
 
95
95
  ##
96
96
  #
@@ -98,21 +98,21 @@ module GladeGUI
98
98
  # You may pass a reference to a widget object, or a String that gives the name of the
99
99
  # widget on your glade form. So, it functions the same as this statement:
100
100
  #
101
- # widget_source.drag_to(widget_target)
101
+ # widget_source.drag_to(widget_target)
102
102
  #
103
103
  # It also functions the same as this statement:
104
104
  #
105
- # @builder["widget_source"].drag_to(@builder["widget_target"])
105
+ # @builder["widget_source"].drag_to(@builder["widget_target"])
106
106
  #
107
107
  #
108
108
 
109
109
  def set_drag_drop(hash)
110
- hash.each do |key,val|
111
- src = key.is_a?(Gtk::Widget) ? key : @builder[key]
112
- target = @builder[val]
113
- src.extend(VR::Draggable) unless src.is_a?(VR::Draggable)
114
- src.add_target_widget(target)
115
- end
110
+ hash.each do |key,val|
111
+ src = key.is_a?(Gtk::Widget) ? key : @builder[key]
112
+ target = @builder[val]
113
+ src.extend(VR::Draggable) unless src.is_a?(VR::Draggable)
114
+ src.add_target_widget(target)
115
+ end
116
116
  end
117
117
 
118
118
 
@@ -124,7 +124,7 @@ end
124
124
  # You can get a reference to any of the widgets on the glade form by
125
125
  # using the @builder object:
126
126
  #
127
- # widget = @builder["name"]
127
+ # widget = @builder["name"]
128
128
  #
129
129
  # Normally, you should give your widgets names of instance variables: i.e. "MyClass.var"
130
130
  # so they can be autoloaded using the set_glade_all() method.
@@ -133,38 +133,38 @@ end
133
133
  # Then the child window will run simultaniously with the parent.
134
134
  #
135
135
 
136
- def load_glade()
137
- caller__FILE__ = my_class_file_path()
138
- file_name = File.split(caller__FILE__)[0] + '/glade/' + class_name(self) + ".glade"
139
- @builder = Gtk::Builder.new
140
- @builder << file_name
136
+ def load_glade()
137
+ caller__FILE__ = my_class_file_path()
138
+ file_name = File.split(caller__FILE__)[0] + '/glade/' + class_name(self) + ".glade"
139
+ @builder = Gtk::Builder.new
140
+ @builder << file_name
141
141
  @builder.connect_signals{ |handle| method(handle) }
142
- # parse_signals() should be called after before_show()
143
- end
144
-
145
- def class_name(obj) # :nodoc:
146
- /.*\b(\w+)$/.match(obj.class.name)[1]
147
- end
148
-
149
- def parse_signals() # :nodoc:
150
- meths = self.class.instance_methods()
151
- meths.each do |meth|
152
- meth = meth.to_s #bug fix ruby 1.9 gives stmbol
153
- glade_name, signal_name = *(meth.split("__"))
154
- next if (signal_name.to_s == "" or glade_name.to_s == "") #covers nil
155
- if @builder
156
- @builder.objects.each do |obj|
157
- next unless obj.respond_to?(:builder_name)
158
- if obj.builder_name == glade_name or obj.builder_name =~ /^(?:#{class_name(self)}\.|)#{glade_name}\[\d+\]$/ #arrays
159
- obj.signal_connect(signal_name) { |*args| method(meth.to_sym).call(*args) }
160
- end
161
- end
162
- end
163
- obj = glade_name == "self" ? self : self.instance_variable_get("@" + glade_name)
164
- obj ||= eval(glade_name) if respond_to?(glade_name) and method(glade_name.to_sym).arity == 0 # no arguments!
165
- obj.signal_connect(signal_name) { |*args| method(meth.to_sym).call(*args) } if obj.respond_to?("signal_connect")
166
- end
167
- end
142
+ # parse_signals() should be called after before_show()
143
+ end
144
+
145
+ def class_name(obj) # :nodoc:
146
+ /.*\b(\w+)$/.match(obj.class.name)[1]
147
+ end
148
+
149
+ def parse_signals() # :nodoc:
150
+ meths = self.class.instance_methods()
151
+ meths.each do |meth|
152
+ meth = meth.to_s #bug fix ruby 1.9 gives stmbol
153
+ glade_name, signal_name = *(meth.split("__"))
154
+ next if (signal_name.to_s == "" or glade_name.to_s == "") #covers nil
155
+ if @builder
156
+ @builder.objects.each do |obj|
157
+ next unless obj.respond_to?(:builder_name)
158
+ if obj.builder_name == glade_name or obj.builder_name =~ /^(?:#{class_name(self)}\.|)#{glade_name}\[\d+\]$/ #arrays
159
+ obj.signal_connect(signal_name) { |*args| method(meth.to_sym).call(*args) }
160
+ end
161
+ end
162
+ end
163
+ obj = glade_name == "self" ? self : self.instance_variable_get("@" + glade_name)
164
+ obj ||= eval(glade_name) if respond_to?(glade_name) and method(glade_name.to_sym).arity == 0 # no arguments!
165
+ obj.signal_connect(signal_name) { |*args| method(meth.to_sym).call(*args) } if obj.respond_to?("signal_connect")
166
+ end
167
+ end
168
168
 
169
169
  # This method is the most useful method to populate a glade form. It will
170
170
  # populate from active_record fields and instance variables. It will simply
@@ -175,11 +175,11 @@ end
175
175
  #
176
176
  # So, to set all the values of a form, simply call the set_glade_all() method instead.
177
177
 
178
- def set_glade_all(obj = self)
179
- set_glade_active_record(obj)
180
- set_glade_variables(obj)
181
- # set_glade_hash(obj) if obj.is_a?(Hash) #only needed for Hash subclass. needed?
182
- end
178
+ def set_glade_all(obj = self)
179
+ set_glade_active_record(obj)
180
+ set_glade_variables(obj)
181
+ # set_glade_hash(obj) if obj.is_a?(Hash) #only needed for Hash subclass. needed?
182
+ end
183
183
 
184
184
  # This method is the most useful method to retreive values from a glade form. It will
185
185
  # populate from active_record fields and instance variables. It will simply
@@ -190,22 +190,22 @@ end
190
190
  #
191
191
  # So, to retreive all the values of a form back into your ActiveRecord object and instance variables, simply call the set_glade_all() method instead.
192
192
 
193
- def get_glade_all(obj = self)
194
- get_glade_active_record(obj)
195
- get_glade_variables(obj)
196
- end
193
+ def get_glade_all(obj = self)
194
+ get_glade_active_record(obj)
195
+ get_glade_variables(obj)
196
+ end
197
197
 
198
198
  # Populates the glade form from the fields of an ActiveRecord object.
199
199
  # So instead of having to assign each widget a value:
200
200
  #
201
- # @builder["ARObject.name"].text = @name
202
- # @builder["ARObject.address"].text = @address
203
- # @builder["ARObject.email"].text = @eamil
204
- # @builder["ARObject.phone"].text = @phone
201
+ # @builder["ARObject.name"].text = @name
202
+ # @builder["ARObject.address"].text = @address
203
+ # @builder["ARObject.email"].text = @eamil
204
+ # @builder["ARObject.phone"].text = @phone
205
205
  #
206
206
  # you can write one line of code:
207
207
  #
208
- # set_glade_active_record()
208
+ # set_glade_active_record()
209
209
  #
210
210
  # The optional parameter is seldom used because you usually want the
211
211
  # glade form to populate from the calling class. If you passed another object,
@@ -214,28 +214,28 @@ end
214
214
  # obj - type ActiveRecord::Base
215
215
  #
216
216
 
217
- def set_glade_active_record(obj = self)
218
- return if not defined? @attributes
219
- obj.attributes.each_pair { |key, val| fill_control(class_name(obj) + "." + key, val) }
220
- end
217
+ def set_glade_active_record(obj = self)
218
+ return if not defined? @attributes
219
+ obj.attributes.each_pair { |key, val| fill_control(class_name(obj) + "." + key, val) }
220
+ end
221
221
 
222
- def set_glade_hash(hash)
223
- return unless hash.is_a?(Hash)
224
- hash.each { |key,val| fill_control( key.to_s, val.to_s) }
225
- end
222
+ def set_glade_hash(hash)
223
+ return unless hash.is_a?(Hash)
224
+ hash.each { |key,val| fill_control( key.to_s, val.to_s) }
225
+ end
226
226
 
227
227
  #Populates the glade form from the instance variables of the class.
228
228
  #This works for Gtk:Button, Gtk::Entry, Gtk::Label and Gtk::Checkbutton.
229
229
  #So instead of having to assign each widget a value:
230
230
  #
231
- # @builder["DataObjectGUI.name"].text = @name
232
- # @builder["DataObjectGUI.address"].text = @address
233
- # @builder["DataObjectGUI.email"].text = @eamil
234
- # @builder["DataObjectGUI.phone"].text = @phone
231
+ # @builder["DataObjectGUI.name"].text = @name
232
+ # @builder["DataObjectGUI.address"].text = @address
233
+ # @builder["DataObjectGUI.email"].text = @eamil
234
+ # @builder["DataObjectGUI.phone"].text = @phone
235
235
  #
236
236
  #you can write one line of code:
237
237
  #
238
- # set_glade_variables()
238
+ # set_glade_variables()
239
239
  #
240
240
  #The optional parameter is seldom used because you usually want the
241
241
  #glade form to populate from the calling class. If you passed another object,
@@ -245,72 +245,72 @@ end
245
245
  #
246
246
 
247
247
 
248
-
249
- def set_glade_variables(obj = self)
250
- # set_glade_hash(obj) if obj.is_a?(Hash)
251
- obj.instance_variables.each do |name|
252
- name = name.to_s #ruby 1.9 passes symbol!
253
- v = obj.instance_variable_get(name)
254
- x = v.to_s
255
- if v.class == Array
256
- (0..v.size-1).each do |i|
257
- fill_control(class_name(obj) + "." + name.gsub("@", "") + "[" + i.to_s + "]", v[i] )
258
- end
259
- else
260
- fill_control(class_name(obj) + "." + name.gsub("@", ""), v)
261
- end
262
- end
263
- end
264
-
265
-
266
-
267
- def fill_control(glade_name, val) # :nodoc:
268
- control = @builder[glade_name]
269
- control_name = glade_name.split(".")[1]
270
- control ||= @builder[control_name] if control_name
271
- case control
272
- when Gtk::Window then control.title = val
273
- when Gtk::CheckButton then control.active = val
274
- when Gtk::TextView then control.buffer.text = val.to_s
275
- when Gtk::Entry then control.text = val.to_s
276
- when Gtk::FontButton then control.font_name = val.to_s
277
- when Gtk::LinkButton then control.uri = control.label = val.to_s
278
- when Gtk::Label, Gtk::Button then control.label = val.to_s
279
- when Gtk::Image then control.file = val.to_s
280
- when Gtk::SpinButton then control.value = val.to_f
281
- when Gtk::ProgressBar then control.fraction = val.to_f
282
- when Gtk::Calendar then control.select_month(val.month, val.year) ; control.select_day(val.day) ; control.mark_day(val.day)
283
- when Gtk::Adjustment then control.value = val.to_f
284
- when Gtk::ScrolledWindow, Gtk::Frame, Gtk::VBox, Gtk::HBox then control.add(val)
285
- end
286
- end
248
+
249
+ def set_glade_variables(obj = self)
250
+ # set_glade_hash(obj) if obj.is_a?(Hash)
251
+ obj.instance_variables.each do |name|
252
+ name = name.to_s #ruby 1.9 passes symbol!
253
+ v = obj.instance_variable_get(name)
254
+ x = v.to_s
255
+ if v.class == Array
256
+ (0..v.size-1).each do |i|
257
+ fill_control(class_name(obj) + "." + name.gsub("@", "") + "[" + i.to_s + "]", v[i] )
258
+ end
259
+ else
260
+ fill_control(class_name(obj) + "." + name.gsub("@", ""), v)
261
+ end
262
+ end
263
+ end
264
+
265
+
266
+
267
+ def fill_control(glade_name, val) # :nodoc:
268
+ control = @builder[glade_name]
269
+ control_name = glade_name.split(".")[1]
270
+ control ||= @builder[control_name] if control_name
271
+ case control
272
+ when Gtk::Window then control.title = val
273
+ when Gtk::CheckButton then control.active = val
274
+ when Gtk::TextView then control.buffer.text = val.to_s
275
+ when Gtk::Entry then control.text = val.to_s
276
+ when Gtk::FontButton then control.font_name = val.to_s
277
+ when Gtk::LinkButton then control.uri = control.label = val.to_s
278
+ when Gtk::Label, Gtk::Button then control.label = val.to_s
279
+ when Gtk::Image then control.file = val.to_s
280
+ when Gtk::SpinButton then control.value = val.to_f
281
+ when Gtk::ProgressBar then control.fraction = val.to_f
282
+ when Gtk::Calendar then control.select_month(val.month, val.year) ; control.select_day(val.day) ; control.mark_day(val.day)
283
+ when Gtk::Adjustment then control.value = val.to_f
284
+ when Gtk::ScrolledWindow, Gtk::Frame, Gtk::VBox, Gtk::HBox then control.add(val)
285
+ end
286
+ end
287
287
 
288
288
 
289
289
  #
290
- # def fill_control(glade_name, val) # :nodoc:
291
- # return unless glade_name and val
290
+ # def fill_control(glade_name, val) # :nodoc:
291
+ # return unless glade_name and val
292
292
  #puts glade_name + val.to_s
293
- # control = @builder[glade_name]
293
+ # control = @builder[glade_name]
294
294
  #puts control.class
295
- # control_name = glade_name.split(".")[1]
296
- # control ||= @builder[control_name] unless control_name.nil?
297
- # return if control.nil?
298
- # case control.class
299
- # when Gtk::Window then control.title = val
300
- # when Gtk::CheckButton then control.active = val
301
- # when Gtk::TextView then control.buffer.text = val.to_s
302
- # when Gtk::Entry then control.text = val.to_s
303
- # when Gtk::FontButton then control.font_name = val.to_s
304
- # when Gtk::LinkButton then control.uri = control.label = val.to_s
305
- # when Gtk::Label, Gtk::Button then control.label = val.to_s
306
- # when Gtk::Image then control.file = val.to_s
307
- # when Gtk::SpinButton then control.value = val.to_f
308
- # when Gtk::ProgressBar then control.fraction = val.to_f
309
- # when Gtk::Calendar then control.select_month(val.month, val.year) ; control.select_day(val.day) ; control.mark_day(val.day)
310
- # when Gtk::Adjustment then control.value = val.to_f
311
- # when Gtk::ScrolledWindow, Gtk::Frame, Gtk::Box then control.add(val)
312
- # end
313
- # end
295
+ # control_name = glade_name.split(".")[1]
296
+ # control ||= @builder[control_name] unless control_name.nil?
297
+ # return if control.nil?
298
+ # case control.class
299
+ # when Gtk::Window then control.title = val
300
+ # when Gtk::CheckButton then control.active = val
301
+ # when Gtk::TextView then control.buffer.text = val.to_s
302
+ # when Gtk::Entry then control.text = val.to_s
303
+ # when Gtk::FontButton then control.font_name = val.to_s
304
+ # when Gtk::LinkButton then control.uri = control.label = val.to_s
305
+ # when Gtk::Label, Gtk::Button then control.label = val.to_s
306
+ # when Gtk::Image then control.file = val.to_s
307
+ # when Gtk::SpinButton then control.value = val.to_f
308
+ # when Gtk::ProgressBar then control.fraction = val.to_f
309
+ # when Gtk::Calendar then control.select_month(val.month, val.year) ; control.select_day(val.day) ; control.mark_day(val.day)
310
+ # when Gtk::Adjustment then control.value = val.to_f
311
+ # when Gtk::ScrolledWindow, Gtk::Frame, Gtk::Box then control.add(val)
312
+ # end
313
+ # end
314
314
  #
315
315
  # Populates the instance variables from the glade form.
316
316
  # This works for Gtk:Button, Gtk::Entry, Gtk::Label and Gtk::Checkbutton.
@@ -332,58 +332,58 @@ end
332
332
  # obj - type Object
333
333
  #
334
334
 
335
- def get_glade_variables(obj = self)
336
- obj.instance_variables.each do |v|
337
- v = v.to_s #fix for ruby 1.9 giving symbols
338
- control = @builder[class_name(obj) + v.gsub("@", ".")]
339
- control ||= @builder[v.gsub("@", "")]
340
- case control
341
- when Gtk::CheckButton then obj.instance_variable_set(v, control.active?)
342
- when Gtk::Entry then obj.instance_variable_set(v, control.text)
343
- when Gtk::TextView then obj.instance_variable_set(v, control.buffer.text)
344
- when Gtk::FontButton then obj.instance_variable_set(v, control.font_name)
345
- when Gtk::Label, Gtk::Button then obj.instance_variable_set(v, control.label)
346
- when Gtk::SpinButton then obj.instance_variable_set(v, control.value)
347
- when Gtk::Image then obj.instance_variable_set(v, control.file)
348
- when Gtk::ProgressBar then obj.instance_variable_set(v, control.fraction)
349
- when Gtk::Calendar then obj.instance_variable_set(v, DateTime.new(*control.date))
350
- when Gtk::Adjustment then obj.instance_variable_set(v, control.value)
351
- end
352
- end
353
- end
354
-
355
-
356
- def get_glade_active_record(obj) # :nodoc:
357
- return if not defined? @attributes
358
- obj.attributes.each_pair do |key, val|
359
- control = @builder[class_name(obj) + "." + key]
360
- control ||= @builder[key]
361
- case control
362
- when Gtk::CheckButton then self.send("#{key}=", control.active?)
363
- when Gtk::Entry then self.send("#{key}=", control.text)
364
- when Gtk::TextView then self.send("#{key}=", control.buffer.text)
365
- when Gtk::FontButton then self.send("#{key}=", control.font_name)
366
- when Gtk::Label, Gtk::Button then self.send("#{key}=", control.label)
367
- when Gtk::SpinButton then self.send("#{key}=", control.value)
368
- when Gtk::Image then self.send("#{key}=", control.file)
369
- when Gtk::ProgressBar then self.send("#{key}=", control.fraction)
370
- when Gtk::Calendar then self.send("#{key}=", DateTime.new(*control.date))
371
- when Gtk::Adjustment then self.send("#{key}=", control.value)
372
- end
373
- end
374
- end
375
-
376
-
377
-
378
- def self.included(obj)
379
- temp = caller[0].split(":") #correct for windows C:\Users\george etc.
380
- caller_path_to_class_file, = temp[0].size == 1 ? temp[0] + ":" + temp[1] : temp[0]
381
- obj.class_eval do
382
- define_method :my_class_file_path do
383
- return caller_path_to_class_file
384
- end
385
- end
386
- end
335
+ def get_glade_variables(obj = self)
336
+ obj.instance_variables.each do |v|
337
+ v = v.to_s #fix for ruby 1.9 giving symbols
338
+ control = @builder[class_name(obj) + v.gsub("@", ".")]
339
+ control ||= @builder[v.gsub("@", "")]
340
+ case control
341
+ when Gtk::CheckButton then obj.instance_variable_set(v, control.active?)
342
+ when Gtk::Entry then obj.instance_variable_set(v, control.text)
343
+ when Gtk::TextView then obj.instance_variable_set(v, control.buffer.text)
344
+ when Gtk::FontButton then obj.instance_variable_set(v, control.font_name)
345
+ when Gtk::Label, Gtk::Button then obj.instance_variable_set(v, control.label)
346
+ when Gtk::SpinButton then obj.instance_variable_set(v, control.value)
347
+ when Gtk::Image then obj.instance_variable_set(v, control.file)
348
+ when Gtk::ProgressBar then obj.instance_variable_set(v, control.fraction)
349
+ when Gtk::Calendar then obj.instance_variable_set(v, DateTime.new(*control.date))
350
+ when Gtk::Adjustment then obj.instance_variable_set(v, control.value)
351
+ end
352
+ end
353
+ end
354
+
355
+
356
+ def get_glade_active_record(obj) # :nodoc:
357
+ return if not defined? @attributes
358
+ obj.attributes.each_pair do |key, val|
359
+ control = @builder[class_name(obj) + "." + key]
360
+ control ||= @builder[key]
361
+ case control
362
+ when Gtk::CheckButton then self.send("#{key}=", control.active?)
363
+ when Gtk::Entry then self.send("#{key}=", control.text)
364
+ when Gtk::TextView then self.send("#{key}=", control.buffer.text)
365
+ when Gtk::FontButton then self.send("#{key}=", control.font_name)
366
+ when Gtk::Label, Gtk::Button then self.send("#{key}=", control.label)
367
+ when Gtk::SpinButton then self.send("#{key}=", control.value)
368
+ when Gtk::Image then self.send("#{key}=", control.file)
369
+ when Gtk::ProgressBar then self.send("#{key}=", control.fraction)
370
+ when Gtk::Calendar then self.send("#{key}=", DateTime.new(*control.date))
371
+ when Gtk::Adjustment then self.send("#{key}=", control.value)
372
+ end
373
+ end
374
+ end
375
+
376
+
377
+
378
+ def self.included(obj)
379
+ temp = caller[0].split(":") #correct for windows C:\Users\george etc.
380
+ caller_path_to_class_file, = temp[0].size == 1 ? temp[0] + ":" + temp[1] : temp[0]
381
+ obj.class_eval do
382
+ define_method :my_class_file_path do
383
+ return caller_path_to_class_file
384
+ end
385
+ end
386
+ end
387
387
 
388
388
 
389
389
  #
@@ -392,41 +392,41 @@ end
392
392
  #Gtk.main.quit because visualruby automatically opens and closes all windows properly.
393
393
  #
394
394
  #
395
- def show_glade(parent = nil)
396
- load_glade()
397
- if parent then
398
- @builder[:window1].transient_for = parent.builder[:window1]
399
- # @builder[:window1].modal = true
400
- end
401
- before_show() if respond_to? :before_show
402
- parse_signals()
403
- set_glade_all()
404
- @builder[:window1].show #show_all can't hide widgets in before_show
405
- @top_level_window = Gtk.main_level == 0 ? true : false
406
- Gtk.main if @top_level_window or @builder[:window1].modal? #need new Gtk.main for blocking!
407
- end
395
+ def show_glade(parent = nil)
396
+ load_glade()
397
+ if parent then
398
+ @builder[:window1].transient_for = parent.builder[:window1]
399
+ # @builder[:window1].modal = true
400
+ end
401
+ before_show() if respond_to? :before_show
402
+ parse_signals()
403
+ set_glade_all()
404
+ @builder[:window1].show #show_all can't hide widgets in before_show
405
+ @top_level_window = Gtk.main_level == 0 ? true : false
406
+ Gtk.main if @top_level_window or @builder[:window1].modal? #need new Gtk.main for blocking!
407
+ end
408
408
 
409
409
 
410
410
 
411
411
 
412
- def window1__destroy(*args)
413
- Gtk.main_quit if @top_level_window or @builder["window1"].modal?
414
- end
412
+ def window1__destroy(*args)
413
+ Gtk.main_quit if @top_level_window or @builder["window1"].modal?
414
+ end
415
415
 
416
416
  def buttonCancel__clicked(*a)
417
417
  @builder[:window1].destroy
418
418
  end
419
419
 
420
420
 
421
- def active_record_valid?(show_errors = true)
422
- get_glade_all
423
- if not self.valid?
424
- alset(self.errors.full_messages.join("\n\n")) if show_errors
425
- self.reload
426
- return false
427
- end
428
- return true
429
- end
421
+ def active_record_valid?(show_errors = true)
422
+ get_glade_all
423
+ if not self.valid?
424
+ alset(self.errors.full_messages.join("\n\n")) if show_errors
425
+ self.reload
426
+ return false
427
+ end
428
+ return true
429
+ end
430
430
 
431
431
  end
432
432