visualruby 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.vr_settings.yaml +27 -0
- data/bin/editor/VR_Document.rb +156 -156
- data/bin/editor/VR_TabSearch.rb +37 -37
- data/bin/editor/VR_Tabs.rb +82 -82
- data/bin/editor/VR_TextShell.rb +49 -52
- data/bin/editor/VR_TextViewCommon.rb +31 -31
- data/bin/main/GemTree.rb +14 -14
- data/bin/main/NewProjectGUI.rb +24 -24
- data/bin/main/OpenProject.rb +53 -53
- data/bin/main/ProjectChooserView.rb +31 -31
- data/bin/main/ProjectTree.rb +17 -17
- data/bin/main/RubygemsAPI.rb +73 -63
- data/bin/main/VR_ENV.rb +29 -29
- data/bin/main/VR_ENV_GLOBAL.rb +52 -52
- data/bin/main/VR_File_Tree.rb +88 -88
- data/bin/main/VR_Local_Gem_Tree.rb +53 -53
- data/bin/main/VR_Main.rb +240 -238
- data/bin/main/VR_Remote_Gem_Tree.rb +41 -41
- data/bin/main/glade/Splash.glade +19 -0
- data/bin/tools/VR_Tools.rb +72 -72
- data/examples/active_record/.vr_settings.yaml +50 -0
- data/examples/active_record/active_record.rb +2 -2
- data/examples/active_record/bin/ChoosePerson.rb +10 -10
- data/examples/active_record/bin/Person.rb +6 -6
- data/examples/active_record2/.vr_settings.yaml +23 -0
- data/examples/active_record2/bin/CompanyGUI.rb +42 -42
- data/examples/active_record2/bin/Employee.rb +13 -13
- data/examples/active_record2/bin/Employer.rb +5 -5
- data/examples/active_record2/bin/Paycheck.rb +5 -5
- data/examples/active_record2/main.rb +4 -4
- data/examples/alert_box/bin/AlertBoxDemo.rb +40 -50
- data/examples/alert_box/bin/glade/AlertBoxDemo.glade +14 -45
- data/examples/all_widgets/.vr_settings.yaml +18 -0
- data/examples/all_widgets/bin/AllWidgets.rb +19 -16
- data/examples/calculator/.vr_settings.yaml +18 -0
- data/examples/calculator/bin/Calculator.rb +22 -22
- data/examples/child_window/.vr_settings.yaml +21 -0
- data/examples/child_window/bin/ChildWindowDemo.rb +10 -10
- data/examples/child_window/bin/ModalWindow.rb +4 -4
- data/examples/child_window/bin/ModelessWindow.rb +4 -4
- data/examples/child_window/bin/MyChildClass.rb +10 -10
- data/examples/drag_drop/.vr_settings.yaml +16 -0
- data/examples/drag_drop/bin/DragDropDemo.rb +28 -28
- data/examples/filetreeview/.vr_settings.yaml +20 -0
- data/examples/filetreeview/bin/ProjectTree.rb +13 -23
- data/examples/filetreeview/bin/ProjectTreeGUI.rb +18 -17
- data/examples/listview/.vr_settings.yaml +19 -0
- data/examples/listview/bin/SongListView.rb +72 -72
- data/examples/listview/bin/SongListViewGUI.rb +52 -52
- data/examples/listview_objects/.vr_settings.yaml +19 -0
- data/examples/listview_objects/bin/DataObject.rb +23 -23
- data/examples/listview_objects/bin/ListViewObjects.rb +29 -29
- data/examples/listview_objects/bin/ListViewObjectsGUI.rb +12 -12
- data/examples/settings_file/bin/MainApp.rb +25 -25
- data/examples/settings_file/bin/SavableSettings.rb +25 -26
- data/examples/settings_file/settings.yaml +1 -1
- data/examples/simple_ruby_gui/.vr_settings.yaml +20 -0
- data/examples/simple_ruby_gui/bin/DataObjectGUI.rb +12 -12
- data/examples/treeview/.vr_settings.yaml +17 -0
- data/examples/treeview/bin/MyClass.rb +18 -17
- data/examples/treeview/bin/glade/MyClass.glade +61 -6
- data/skeleton/document/NewWindow.rb +8 -8
- data/skeleton/project/.vr_settings.yaml +15 -0
- data/skeleton/project/bin/MyClass.rb +7 -7
- data/vr +38 -41
- data/vrlib/doc/images/add.png +0 -0
- data/vrlib/doc/images/arrow_up.png +0 -0
- data/vrlib/doc/images/brick.png +0 -0
- data/vrlib/doc/images/brick_link.png +0 -0
- data/vrlib/doc/images/bug.png +0 -0
- data/vrlib/doc/images/bullet_black.png +0 -0
- data/vrlib/doc/images/bullet_toggle_minus.png +0 -0
- data/vrlib/doc/images/bullet_toggle_plus.png +0 -0
- data/vrlib/doc/images/date.png +0 -0
- data/vrlib/doc/images/delete.png +0 -0
- data/vrlib/doc/images/find.png +0 -0
- data/vrlib/doc/images/macFFBgHack.png +0 -0
- data/vrlib/doc/images/package.png +0 -0
- data/vrlib/doc/images/page_green.png +0 -0
- data/vrlib/doc/images/page_white_text.png +0 -0
- data/vrlib/doc/images/page_white_width.png +0 -0
- data/vrlib/doc/images/plugin.png +0 -0
- data/vrlib/doc/images/ruby.png +0 -0
- data/vrlib/doc/images/tag_blue.png +0 -0
- data/vrlib/doc/images/tag_green.png +0 -0
- data/vrlib/doc/images/transparent.png +0 -0
- data/vrlib/doc/images/wrench.png +0 -0
- data/vrlib/doc/images/wrench_orange.png +0 -0
- data/vrlib/doc/images/zoom.png +0 -0
- data/vrlib/lib/Alert.rb +98 -55
- data/vrlib/lib/DragDrop.rb +43 -43
- data/vrlib/lib/GladeGUI.rb +207 -207
- data/vrlib/lib/IconHash.rb +10 -10
- data/vrlib/lib/SavableClass.rb +38 -38
- data/vrlib/lib/SimpleComboBoxEntry.rb +3 -3
- data/vrlib/lib/treeview/FileTreeView.rb +71 -70
- data/vrlib/lib/treeview/IterMethods.rb +35 -35
- data/vrlib/lib/treeview/ListView.rb +25 -25
- data/vrlib/lib/treeview/TreeView.rb +15 -15
- data/vrlib/lib/treeview/ViewCommon.rb +134 -131
- data/vrlib/lib/treeview/columns/CalendarCol.rb +48 -48
- data/vrlib/lib/treeview/columns/CellRendererCombo.rb +26 -26
- data/vrlib/lib/treeview/columns/CellRendererDate.rb +25 -25
- data/vrlib/lib/treeview/columns/CellRendererObject.rb +37 -37
- data/vrlib/lib/treeview/columns/CellRendererPhone.rb +25 -25
- data/vrlib/lib/treeview/columns/CellRendererPixbuf.rb +8 -8
- data/vrlib/lib/treeview/columns/CellRendererProgress.rb +8 -8
- data/vrlib/lib/treeview/columns/CellRendererSpin.rb +17 -17
- data/vrlib/lib/treeview/columns/CellRendererText.rb +18 -18
- data/vrlib/lib/treeview/columns/CellRendererToggle.rb +25 -25
- data/vrlib/lib/treeview/columns/ComboCol.rb +12 -12
- data/vrlib/lib/treeview/columns/CurrencyCol.rb +13 -13
- data/vrlib/lib/treeview/columns/DateCol.rb +10 -10
- data/vrlib/lib/treeview/columns/ImageCol.rb +16 -16
- data/vrlib/lib/treeview/columns/SpinCol.rb +5 -5
- data/vrlib/lib/treeview/columns/TextCol.rb +24 -24
- data/vrlib/lib/treeview/columns/TreeViewColumn.rb +71 -76
- data/vrlib/rdoc_replace.yaml +36 -36
- metadata +43 -6
- data/Splash.rb +0 -40
@@ -113,47 +113,47 @@ module VR
|
|
113
113
|
|
114
114
|
attr_accessor :vr_renderer, :vr_column
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
116
|
+
def load_columns(cols) # :nodoc:
|
117
|
+
@vr_renderer = {}
|
118
|
+
@vr_column = {}
|
119
|
+
model_col = 0
|
120
|
+
cols.each_pair do | sym, type|
|
121
|
+
col = VR::TreeViewColumn.new(self, model_col, sym, type)
|
122
|
+
model_col = model_col + (type.class == Hash ? type.size : 1)
|
123
|
+
self.append_column(col)
|
124
|
+
end
|
125
|
+
turn_on_comboboxes()
|
126
|
+
@column_keys = flatten_hash(cols).keys
|
127
|
+
end
|
128
128
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
129
|
+
def method_missing(meth, *args) # :nodoc:
|
130
|
+
unless m = /^(ren_|col_)(.+)$/.match(meth.to_s)
|
131
|
+
super
|
132
|
+
return
|
133
|
+
end
|
134
|
+
if args.first.is_a? Hash
|
135
|
+
args.first.each_pair { |key, val| method(m[1] + "attr").call(key, m[2] => val) }
|
136
|
+
else
|
137
|
+
method(m[1] + "attr").call(m[2] => args.first)
|
138
|
+
end
|
139
139
|
end
|
140
140
|
|
141
141
|
# Sets properties on renderers (and columns) See VR::ViewCommon#col_attr for more.
|
142
142
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
143
|
+
def ren_attr(*args)
|
144
|
+
cols = args.select { |arg| !arg.is_a? Hash }
|
145
|
+
return unless hash = args.detect { |arg| arg.is_a? Hash }
|
146
|
+
cols = @column_keys if cols.empty?
|
147
|
+
cols.each do |c|
|
148
|
+
hash.each_pair do | key, val |
|
149
|
+
if renderer(c).respond_to?(key.to_s + "=")
|
150
|
+
renderer(c).send(key.to_s + '=', val)
|
151
|
+
elsif column(c).respond_to?(key.to_s + "=")
|
152
|
+
column(c).send(key.to_s + '=', val)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
157
|
|
158
158
|
# Sets properties on many columns at once. It can be called with many columns and many attributes.
|
159
159
|
# Also, if you don't specify any columns, it will set the properties on all of them. There are
|
@@ -176,20 +176,20 @@ attr_accessor :vr_renderer, :vr_column
|
|
176
176
|
# In the vast majority of cases, VR::ViewCommon#col_attr and VR::ViewCommon#ren_attr are interchangable.
|
177
177
|
|
178
178
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
179
|
+
def col_attr(*args)
|
180
|
+
cols = args.select { |arg| !arg.is_a? Hash }
|
181
|
+
return unless hash = args.detect { |arg| arg.is_a? Hash }
|
182
|
+
cols = @column_keys if cols.empty?
|
183
|
+
cols.each do |c|
|
184
|
+
hash.each_pair do | key, val |
|
185
|
+
if column(c).respond_to?(key.to_s + "=")
|
186
|
+
column(c).send(key.to_s + '=', val)
|
187
|
+
elsif renderer(c).respond_to?(key.to_s + "=")
|
188
|
+
renderer(c).send(key.to_s + '=', val)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
193
|
|
194
194
|
|
195
195
|
# Returns an array of rows that are selected in the VR::TreeView or VR::ListView.
|
@@ -198,54 +198,54 @@ attr_accessor :vr_renderer, :vr_column
|
|
198
198
|
# selection mode, it will return an array with one row. These rows are
|
199
199
|
# able to respond to column IDs. They are the same types of rows as returned by
|
200
200
|
# VR::ViewCommon#vr_row.
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
201
|
+
|
202
|
+
def selected_rows()
|
203
|
+
rows = []
|
204
|
+
selection.each do |model, path, iter|
|
205
|
+
rows << vr_row(iter)
|
206
|
+
end
|
207
|
+
rows
|
208
|
+
end
|
209
209
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
210
|
+
def delete_selected()
|
211
|
+
refs = []
|
212
|
+
selection.each do |mod, path, iter|
|
213
|
+
refs << Gtk::TreeRowReference.new(mod, path)
|
214
|
+
end
|
215
|
+
refs.each do |ref|
|
216
|
+
model.remove(model.get_iter(ref.path))
|
217
|
+
end
|
218
|
+
end
|
219
219
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
220
|
+
def turn_on_comboboxes() # :nodoc:
|
221
|
+
# detect if comboboxes are present:
|
222
|
+
found = false
|
223
|
+
self.each_renderer do |r|
|
224
|
+
if r.is_a? VR::CellRendererCombo
|
225
|
+
found = true
|
226
|
+
break
|
227
|
+
end
|
228
|
+
end
|
229
|
+
return unless found
|
230
|
+
self.signal_connect("cursor_changed") do |view|
|
231
|
+
next unless iter = view.selection.selected
|
232
|
+
view.each_renderer do |r|
|
233
|
+
r.set_model( iter[r.model_col] ) if r.is_a? VR::CellRendererCombo
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
237
|
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
238
|
+
def flatten_hash(hash) # :nodoc:
|
239
|
+
h = {}
|
240
|
+
hash.each do | k, v |
|
241
|
+
if v.class == Hash
|
242
|
+
v.each_pair { |key, val| h[key] = val }
|
243
|
+
else
|
244
|
+
h[k] = v
|
245
|
+
end
|
246
|
+
end
|
247
|
+
return h
|
248
|
+
end
|
249
249
|
|
250
250
|
# Enumerates each row in the model and returns an instance of GtkTreeIter.
|
251
251
|
# However, the iters returned have been converted into a "row" using VR::ViewCommon#vr_row
|
@@ -254,9 +254,12 @@ attr_accessor :vr_renderer, :vr_column
|
|
254
254
|
# @view.each_row { |row| puts row[:name] } # works!
|
255
255
|
#
|
256
256
|
|
257
|
-
|
258
|
-
|
259
|
-
|
257
|
+
def each_row
|
258
|
+
self.model.each do |mod, pth, itr|
|
259
|
+
iter = model.get_iter(pth) #bug?
|
260
|
+
yield vr_row(iter)
|
261
|
+
end
|
262
|
+
end
|
260
263
|
|
261
264
|
# Converts a normal GtkTreeIter to use VR's column IDs. You can use it like this:
|
262
265
|
#
|
@@ -264,17 +267,17 @@ attr_accessor :vr_renderer, :vr_column
|
|
264
267
|
# row[:name] = "Chester" # works!
|
265
268
|
|
266
269
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
270
|
+
def vr_row(iter)
|
271
|
+
unless iter.respond_to?(:id)
|
272
|
+
iter.extend(VR::IterMethods)
|
273
|
+
iter.column_keys = @column_keys
|
274
|
+
end
|
275
|
+
return iter
|
276
|
+
end
|
274
277
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
+
def get_iter(path)
|
279
|
+
vr_row(model.get_iter(path))
|
280
|
+
end
|
278
281
|
|
279
282
|
|
280
283
|
# Returns a VR::TreeViewColumn object for the column. You can pass this method either
|
@@ -290,17 +293,17 @@ attr_accessor :vr_renderer, :vr_column
|
|
290
293
|
# methods instead. See VR::ViewCommon for more.
|
291
294
|
|
292
295
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
296
|
+
def column(id)
|
297
|
+
@vr_column[id]
|
298
|
+
end
|
299
|
+
|
300
|
+
def each_renderer
|
301
|
+
self.columns.each do |c|
|
302
|
+
c.cells.each do |r|
|
303
|
+
yield r
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
304
307
|
|
305
308
|
#Returns the renderer for a given column ID.
|
306
309
|
#
|
@@ -334,16 +337,16 @@ attr_accessor :vr_renderer, :vr_column
|
|
334
337
|
#
|
335
338
|
#This is perfectly valid even though there are better ways of setting these properties in visualruby.
|
336
339
|
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
+
def renderer(sym)
|
341
|
+
@vr_renderer[sym]
|
342
|
+
end
|
340
343
|
|
341
|
-
#
|
342
|
-
#
|
343
|
-
#
|
344
|
-
#
|
345
|
-
#
|
346
|
-
#
|
344
|
+
# def renderer(id)
|
345
|
+
# each_renderer do |r|
|
346
|
+
# return r if r.model_col == id(id)
|
347
|
+
# end
|
348
|
+
# return nil
|
349
|
+
# end
|
347
350
|
|
348
351
|
# Returns the number of the given column ID. This is very useful when you're
|
349
352
|
# working with Gtk's methods because they require column numbers (not Column IDs)
|
@@ -362,9 +365,9 @@ attr_accessor :vr_renderer, :vr_column
|
|
362
365
|
# you also have the option of converting the whole iter to use column IDs (symbols)
|
363
366
|
# using VR::ViewCommon#vr_row.
|
364
367
|
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
+
def id(id)
|
369
|
+
return (id.is_a? Fixnum or id.is_a? Integer) ? id : @column_keys.index(id)
|
370
|
+
end
|
368
371
|
|
369
372
|
end
|
370
373
|
end
|
@@ -18,72 +18,72 @@ module VR
|
|
18
18
|
#
|
19
19
|
# See the example project, "listview_objects" for more.
|
20
20
|
|
21
|
-
|
21
|
+
class CalendarCol
|
22
22
|
|
23
|
-
|
23
|
+
include GladeGUI
|
24
24
|
|
25
|
-
|
25
|
+
attr_accessor :date, :date_format, :show_time, :show_calendar
|
26
26
|
#
|
27
27
|
# - datetime - Instance of DateTime class that holds the date value.
|
28
28
|
# - date_format - String that holds the Ruby date format. Default: "%d %b %Y %I:%M%p"
|
29
29
|
# - show_time - true/false If this is false, the time will not appear in the edit window.
|
30
30
|
# - show_calendar - true/false If this is false, Calendar will not appear. Only time will edit.
|
31
31
|
#
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
32
|
+
def initialize(datetime, flags = {}) #flags = :hide_date => true, hide_time => true, :format => "%d %b %Y %I:%M%p"
|
33
|
+
@format = flags[:format]
|
34
|
+
@format ||= flags[:hide_date] ? "%I:%M%p" : "%d %b %Y %I:%M%p"
|
35
|
+
@format ||= flags[:hide_time] ? "%d %b %Y" : @date_format
|
36
|
+
@hide_date = flags[:hide_date]
|
37
|
+
@hide_time = flags[:hide_time]
|
38
|
+
@show_calendar = show_calendar
|
39
|
+
@date = datetime
|
40
|
+
@hour = @date.strftime("%I").to_f
|
41
|
+
@minute = @date.min()
|
42
|
+
@am = (@date.hour < 12)
|
43
|
+
@pm = !@am
|
44
|
+
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
def show_glade(parent = nil)
|
47
|
+
super
|
48
|
+
@builder["hboxTime"].hide if @hide_time
|
49
|
+
@builder["date"].hide if @hide_date
|
50
|
+
end
|
51
51
|
|
52
52
|
# displays time according to the @date_format instance variable. If you want to
|
53
53
|
# change the appearance of this object, assign a new vale to @date_format.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
|
55
|
+
def to_s
|
56
|
+
@date.strftime(@format)
|
57
|
+
end
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
def am__toggled(*args) # :nodoc:
|
60
|
+
@builder["pm"].active = !@builder["am"].active?
|
61
|
+
end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
def pm__toggled(*args) # :nodoc:
|
64
|
+
@builder["am"].active = !@builder["pm"].active?
|
65
|
+
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
def buttonSave__clicked(*args) # :nodoc:
|
68
|
+
get_glade_variables()
|
69
|
+
m = @builder["am"].active? ? "AM" : "PM"
|
70
|
+
t = DateTime.strptime("#{@hour.to_i.to_s} #{@minute.to_i.to_s} #{m}", "%I %M %p")
|
71
|
+
@date = DateTime.new(@date.year, @date.month, @date.day, t.hour, t.min, 0)
|
72
|
+
@builder["window1"].destroy
|
73
|
+
end
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
def buttonCancel__clicked(*args) # :nodoc:
|
76
|
+
@builder["window1"].destroy
|
77
|
+
end
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
def <=>(calendar)
|
80
|
+
return @date <=> calendar.date
|
81
|
+
end
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
def value
|
84
|
+
@date
|
85
|
+
end
|
86
86
|
|
87
|
-
|
87
|
+
end
|
88
88
|
|
89
89
|
end
|
@@ -15,28 +15,28 @@ module VR
|
|
15
15
|
|
16
16
|
class CellRendererCombo < Gtk::CellRendererCombo
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
attr_accessor :edited_callback, :validate_block
|
19
|
+
attr_reader :model_col, :column, :model_sym
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
21
|
+
def initialize(model_col, column, view, model_sym) # :nodoc:
|
22
|
+
super()
|
23
|
+
@model_col = model_col
|
24
|
+
@column = column
|
25
|
+
@view = view
|
26
|
+
@model_sym = model_sym
|
27
|
+
@view.model.set_sort_func(@model_col) { |m,x,y| x[@model_col].selected <=> y[@model_col].selected }
|
28
|
+
@validate_block = Proc.new { |text, model_sym, row, view | true }
|
29
|
+
self.editable = true
|
30
|
+
self.has_entry = false
|
31
|
+
@edited_callback = nil
|
32
|
+
self.signal_connect('edited') do |ren, path, text| # iter for
|
33
|
+
iter = @view.model.get_iter(path)
|
34
|
+
if @validate_block.call(text, @model_sym, @view.vr_row(iter), @view)
|
35
|
+
iter[@model_col].selected = text
|
36
|
+
@edited_callback.call(@model_sym, @view.vr_row(iter)) if @edited_callback
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
40
|
|
41
41
|
# This sets the renderer's "editable" property to true, and makes it save
|
42
42
|
# the edited value to the model. When a user edits a row in the ListView
|
@@ -55,11 +55,11 @@ module VR
|
|
55
55
|
# is_editable = boolean
|
56
56
|
#
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
def set_model(vr_combo) # :nodoc:
|
59
|
+
self.model = Gtk::ListStore.new(String)
|
60
|
+
vr_combo.selections.each { |s| r = self.model.append ; r[0] = s }
|
61
|
+
self.text_column = 0
|
62
|
+
end
|
63
63
|
|
64
64
|
end
|
65
65
|
|
@@ -13,33 +13,33 @@ module VR
|
|
13
13
|
|
14
14
|
class CellRendererDate < Gtk::CellRendererText
|
15
15
|
|
16
|
-
|
16
|
+
attr_accessor :date_format, :edited_callback, :model_col, :column, :model_sym
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
18
|
+
def initialize(model_col, column, view, model_sym) # :nodoc:
|
19
|
+
super()
|
20
|
+
@model_col = model_col
|
21
|
+
@column = column
|
22
|
+
@view = view
|
23
|
+
@model_sym = model_sym
|
24
|
+
@view.model.set_sort_func(@model_col) { |m,x,y| x[@model_col] <=> y[@model_col] }
|
25
|
+
@date_format = "%m-%d-%Y"
|
26
|
+
@validate_block = Proc.new { |text, model_sym, row, view|
|
27
|
+
begin
|
28
|
+
Date.strptime(text, @date_format)
|
29
|
+
true
|
30
|
+
rescue
|
31
|
+
alert("Unrecognized date format: " + text)
|
32
|
+
false
|
33
|
+
end }
|
34
|
+
@edited_block = nil
|
35
35
|
self.signal_connect('edited') do |ren, path, text|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
next unless iter = @view.model.get_iter(path)
|
37
|
+
if @validate_block.call(text, @model_sym, @view.vr_row(iter), @view)
|
38
|
+
iter[@model_col] = DateTime.strptime(text, @date_format)
|
39
|
+
@edited_callback.call(@model_sym, @view.vr_row(iter)) if @edited_callback
|
40
|
+
end
|
41
41
|
end
|
42
|
-
|
43
|
-
|
42
|
+
end
|
43
|
+
end
|
44
44
|
|
45
45
|
end
|
@@ -13,45 +13,45 @@ module VR
|
|
13
13
|
|
14
14
|
class CellRendererObject < Gtk::CellRendererText
|
15
15
|
|
16
|
-
|
16
|
+
attr_accessor :model_col, :column, :edited_callback, :visual_attributes_method, :model_sym
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
18
|
+
def initialize(model_col, column, view, model_sym) # :nodoc:
|
19
|
+
super()
|
20
|
+
@model_col = model_col
|
21
|
+
@model_sym = model_sym
|
22
|
+
@view = view
|
23
|
+
@column = column
|
24
|
+
@edit = true
|
25
|
+
@edited_callback = nil
|
26
|
+
@visual_attributes_method = "visual_attributes"
|
27
|
+
@view.model.set_sort_func(@model_col) { |m,x,y| x[@model_col] <=> y[@model_col] }
|
28
|
+
@show_block = Proc.new { |obj| obj.show_glade() if obj.respond_to? "show_glade" }
|
29
|
+
@view.signal_connect("row_activated") do | view, path, col |
|
30
|
+
next if !@edit or !col.eql? @column
|
31
|
+
iter = @view.model.get_iter(path)
|
32
|
+
obj = iter[@model_col]
|
33
|
+
@show_block.call(obj)
|
34
|
+
block = @edited_callback ? @edited_callback.call(@model_sym, @view.vr_row(iter)) : true
|
35
|
+
@view.signal_emit_stop("row_activated") if block
|
36
|
+
end
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
39
|
+
alias :set_editable :editable=
|
40
|
+
def editable=(e)
|
41
|
+
@edit = e
|
42
|
+
end
|
43
|
+
|
44
|
+
def render_object(iter)
|
45
|
+
obj = iter[@view.id(@model_col)]
|
46
|
+
self.text = obj.respond_to?(:to_s) ? obj.to_s : "Define to_s!"
|
47
|
+
if obj.respond_to? @visual_attributes_method
|
48
|
+
return unless attrib = obj.send(@visual_attributes_method)
|
49
|
+
attrib.each_pair do | key, val |
|
50
|
+
self.send( key.to_s + "=", val)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
54
|
|
55
|
-
|
55
|
+
end
|
56
56
|
|
57
57
|
end
|