visualruby 3.0.12 → 3.0.13
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 +6 -6
- data/examples/alert_box/.vr_settings.yaml +5 -4
- data/examples/alert_box/main.rb +8 -0
- data/examples/listview/.vr_settings.yaml +5 -8
- data/examples/listview/bin/SongListView.rb +9 -9
- data/examples/listview/main.rb +1 -1
- data/examples/listview_objects/bin/ListViewObjects.rb +8 -8
- data/lib/Alert.rb +30 -21
- data/lib/GladeGUI.rb +17 -3
- data/lib/oinspect/MethodsListView.rb +11 -10
- data/lib/oinspect/ObjectInspectorGUI.rb +36 -20
- data/lib/oinspect/VariablesListView.rb +31 -30
- data/lib/oinspect/glade/ObjectInspectorGUI.glade +90 -12
- data/lib/treeview/FileTreeView.rb +23 -6
- data/lib/treeview/IterMethods.rb +66 -66
- data/lib/treeview/ListView.rb +5 -5
- data/lib/treeview/ViewCommon.rb +43 -23
- data/lib/treeview/columns/{TextCol.rb → BlobCol.rb} +6 -6
- data/lib/treeview/columns/CalendarCol.rb +23 -27
- data/lib/treeview/columns/CellRendererCombo.rb +1 -1
- data/lib/treeview/columns/CellRendererObject.rb +1 -1
- data/lib/treeview/columns/CellRendererProgress.rb +17 -17
- data/lib/treeview/columns/CellRendererSpin.rb +1 -1
- data/lib/treeview/columns/CellRendererText.rb +1 -1
- data/lib/treeview/columns/CellRendererToggle.rb +3 -3
- data/lib/treeview/columns/ComboCol.rb +1 -1
- data/lib/treeview/columns/CurrencyCol.rb +1 -1
- data/lib/treeview/columns/ImageCol.rb +1 -1
- data/lib/treeview/columns/ProgressCol.rb +4 -4
- data/lib/treeview/columns/SpinCol.rb +1 -1
- data/lib/treeview/columns/TreeViewColumn.rb +15 -20
- data/src/main/VR_File_Tree.rb +2 -3
- data/src/main/VR_Main.rb +12 -0
- data/src/main/glade/VR_Main.glade +14 -0
- metadata +3 -10
- data/lib/IconHash.rb +0 -18
- data/lib/SimpleComboBoxEntry.rb +0 -8
- data/lib/treeview/columns/CellRendererDate.rb +0 -45
- data/lib/treeview/columns/CellRendererPhone.rb +0 -45
- data/lib/treeview/columns/CellRendererPixbuf.rb +0 -16
- data/lib/treeview/columns/DateCol.rb +0 -20
- data/src/main/ProjectChooserView.rb +0 -40
@@ -13,7 +13,7 @@ module VR
|
|
13
13
|
|
14
14
|
# FileTreeView creates a TreeView of files with folders and icons.
|
15
15
|
# Often you should subclass this class for a particular use.
|
16
|
-
# @param [String]
|
16
|
+
# @param [String] root Root folder of the tree
|
17
17
|
# @param [String] icon_path Path to a folder where icons are stored. See VR::IconHash
|
18
18
|
# @param [String] glob Glob designating the files to be included. Google: "ruby glob" for more.
|
19
19
|
# @param [Proc] validate_block Block that limits files and folders to include. When block returns true file is includud. (false = excluded)
|
@@ -21,11 +21,12 @@ module VR
|
|
21
21
|
@root = File.expand_path(root)
|
22
22
|
@glob = glob
|
23
23
|
@validate_block = validate_block
|
24
|
-
super(:file => {:pix => Gdk::Pixbuf, :file_name => String}, :empty => TrueClass,
|
25
|
-
|
24
|
+
super(:file => {:pix => Gdk::Pixbuf, :file_name => String}, :empty => TrueClass,
|
25
|
+
:path => String, :sort_on => String)
|
26
|
+
col_visible( :path => false, :sort_on => false, :empty => false)
|
26
27
|
self.headers_visible = false
|
27
|
-
@icons = File.directory?(icon_path) ?
|
28
|
-
parse_signals()
|
28
|
+
@icons = File.directory?(icon_path) ? IconHash.new(icon_path) : nil
|
29
|
+
parse_signals() #fix this! Subclasses may call twice!
|
29
30
|
model.set_sort_column_id(id(:sort_on), :ascending )
|
30
31
|
self.set_enable_search(false)
|
31
32
|
refresh
|
@@ -128,10 +129,26 @@ module VR
|
|
128
129
|
def get_selected_path()
|
129
130
|
selection.selected ? selection.selected[id(:path)] : nil
|
130
131
|
end
|
132
|
+
|
133
|
+
class IconHash < Hash # :nodoc:
|
134
|
+
|
135
|
+
def initialize(path)
|
136
|
+
Dir.glob(path + "/*.png").each do |f|
|
137
|
+
ext = File.basename(f, ".png")
|
138
|
+
self[ext] = Gdk::Pixbuf.new(f)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def get_icon(file_name)
|
143
|
+
ext = File.extname(file_name).gsub(".", "")
|
144
|
+
self.has_key?(ext) ? self[ext] : self["unknown"]
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
131
148
|
|
132
149
|
end
|
133
150
|
|
134
|
-
|
151
|
+
|
135
152
|
|
136
153
|
|
137
154
|
end
|
data/lib/treeview/IterMethods.rb
CHANGED
@@ -1,82 +1,82 @@
|
|
1
1
|
|
2
|
-
module VR
|
2
|
+
module VR::ViewCommon
|
3
3
|
|
4
4
|
# The IterMethods module extends the GtkTreeIter class so it can work with
|
5
5
|
# visualruby's colum ID symbols as well as Gtk's column numbers.
|
6
6
|
#
|
7
7
|
|
8
|
-
module IterMethods
|
8
|
+
module IterMethods
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
attr_accessor :column_keys
|
11
|
+
@column_keys = nil
|
12
12
|
|
13
|
-
# The [] method returns the value from the specified column in the iter:
|
14
|
-
#
|
15
|
-
# val = iter[:name]
|
16
|
-
#
|
17
|
-
# - col_id -- Either a visualruby column ID symbol, as above, or an integer.
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
# The [] method returns the value from the specified column in the iter:
|
14
|
+
#
|
15
|
+
# val = iter[:name]
|
16
|
+
#
|
17
|
+
# - col_id -- Either a visualruby column ID symbol, as above, or an integer.
|
18
|
+
#
|
19
|
+
|
20
|
+
def [](col_id)
|
21
|
+
get_value(id(col_id))
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
def []=(col_id,val)
|
25
|
+
i = id(col_id)
|
26
|
+
set_value(i, val)
|
27
|
+
end
|
28
28
|
|
29
|
-
# The id() method translates visualruby's colum ID symbols into integers that
|
30
|
-
# GtkTreeIter can use:
|
31
|
-
#
|
32
|
-
# iter = model.append
|
33
|
-
# iter[id(:name)] = "Henry"
|
34
|
-
#
|
35
|
-
# Normally, its best to use VR's "rows" instead. They will already use the column ID symbols.
|
36
|
-
#
|
37
|
-
|
38
|
-
|
39
|
-
|
29
|
+
# The id() method translates visualruby's colum ID symbols into integers that
|
30
|
+
# GtkTreeIter can use:
|
31
|
+
#
|
32
|
+
# iter = model.append
|
33
|
+
# iter[id(:name)] = "Henry"
|
34
|
+
#
|
35
|
+
# Normally, its best to use VR's "rows" instead. They will already use the column ID symbols.
|
36
|
+
#
|
37
|
+
def id(col_id) # :nodoc:
|
38
|
+
return (col_id.is_a? Fixnum) ? col_id : @column_keys.index(col_id)
|
39
|
+
end
|
40
40
|
|
41
|
-
# This will load the values of any object into the iter. It will look at all the
|
42
|
-
# instance variables, methods, and ActiveRecord fields and match them to
|
43
|
-
# columns in a VR::ListView or VR::TreeView. For example, if your object
|
44
|
-
# has an instance variable, @name, this will fill in a column with the symbol :name.
|
45
|
-
#
|
46
|
-
# class MyClass
|
47
|
-
# @name = "Henry"
|
48
|
-
# end
|
49
|
-
#
|
50
|
-
# @view = VR::ListView.new(:name => String)
|
51
|
-
# my = MyClass.new
|
52
|
-
# row = @view.add_row()
|
53
|
-
# row.load_object(my) # assigns "Henry" to first cell
|
54
|
-
#
|
55
|
-
#
|
56
|
-
# -obj--any ruby object or object subclassed from ActiveRecord::Base.
|
57
|
-
#
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
41
|
+
# This will load the values of any object into the iter. It will look at all the
|
42
|
+
# instance variables, methods, and ActiveRecord fields and match them to
|
43
|
+
# columns in a VR::ListView or VR::TreeView. For example, if your object
|
44
|
+
# has an instance variable, @name, this will fill in a column with the symbol :name.
|
45
|
+
#
|
46
|
+
# class MyClass
|
47
|
+
# @name = "Henry"
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# @view = VR::ListView.new(:name => String)
|
51
|
+
# my = MyClass.new
|
52
|
+
# row = @view.add_row()
|
53
|
+
# row.load_object(my) # assigns "Henry" to first cell
|
54
|
+
#
|
55
|
+
#
|
56
|
+
# -obj--any ruby object or object subclassed from ActiveRecord::Base.
|
57
|
+
#
|
58
|
+
def load_object(obj)
|
59
|
+
class_sym = obj.class.name.to_sym
|
60
|
+
self[class_sym] = obj if @column_keys.include?(class_sym)
|
61
|
+
@column_keys.each do |k|
|
62
|
+
begin
|
63
|
+
self[k] = obj.send(k) if obj.respond_to?(k.to_s)
|
64
|
+
rescue
|
65
|
+
end
|
65
66
|
end
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
67
|
+
keys = @column_keys.inject([]) { |ar, e| ar << e.to_s }
|
68
|
+
matches = obj.attributes.keys & keys if obj.attributes.is_a? Hash
|
69
|
+
matches.each do |field|
|
70
|
+
begin
|
71
|
+
self[field.to_sym] = obj.attributes[field]
|
72
|
+
rescue
|
73
|
+
end
|
74
|
+
end
|
75
|
+
obj.instance_variables.each do |name|
|
76
|
+
self[name] = instance_variable_get(name) if @column_keys.include?(name)
|
73
77
|
end
|
74
|
-
end
|
75
|
-
obj.instance_variables.each do |name|
|
76
|
-
self[name] = instance_variable_get(name) if @column_keys.include?(name)
|
77
78
|
end
|
78
|
-
|
79
|
-
|
79
|
+
|
80
|
+
end
|
80
81
|
|
81
82
|
end
|
82
|
-
end
|
data/lib/treeview/ListView.rb
CHANGED
@@ -22,11 +22,11 @@ module VR
|
|
22
22
|
# * DateTime - Displays in a default date format(editable), edits like a String
|
23
23
|
# * TrueClass - Displays as a GtkCheckButton, click checkbox to edit
|
24
24
|
# * GdkPixbuf - Just an Image, uneditable
|
25
|
-
# * VR::CalendarCol - Displays in a default date format(editable), calendar window to edit.
|
26
|
-
# * VR::SpinCol - Displays as a number with default number of digits, edits like a GtkSpinButton
|
27
|
-
# * VR::ComboCol - Displays String, edits like a GtkComboBoxEntry
|
28
|
-
# * VR::ProgressCol - Displays a GtkProgressBar, uneditable
|
29
|
-
# * VR::
|
25
|
+
# * VR::Col::CalendarCol - Displays in a default date format(editable), calendar window to edit.
|
26
|
+
# * VR::Col::SpinCol - Displays as a number with default number of digits, edits like a GtkSpinButton
|
27
|
+
# * VR::Col::ComboCol - Displays String, edits like a GtkComboBoxEntry
|
28
|
+
# * VR::Col::ProgressCol - Displays a GtkProgressBar, uneditable
|
29
|
+
# * VR::Col::BlobCol - For long strings. Displays first 20 characters in view, edits with simple text editor.
|
30
30
|
#
|
31
31
|
# You can also add your own user-defined column types. See: {Adding Your Own Objects to ListView}[link:/site/ListView%20Tutorial.html#objects].
|
32
32
|
#
|
data/lib/treeview/ViewCommon.rb
CHANGED
@@ -111,16 +111,17 @@ module VR
|
|
111
111
|
|
112
112
|
module ViewCommon
|
113
113
|
|
114
|
-
attr_accessor :vr_renderer
|
114
|
+
attr_accessor :vr_renderer
|
115
115
|
|
116
116
|
def load_columns(cols) # :nodoc:
|
117
117
|
@vr_renderer = {}
|
118
|
-
@
|
118
|
+
@vr_cols = {}
|
119
119
|
model_col = 0
|
120
120
|
cols.each_pair do | sym, type|
|
121
|
-
col = VR::TreeViewColumn.new(self, model_col, sym, type)
|
121
|
+
col = VR::Col::TreeViewColumn.new(self, model_col, sym, type)
|
122
122
|
model_col = model_col + (type.class == Hash ? type.size : 1)
|
123
123
|
self.append_column(col)
|
124
|
+
@vr_cols[sym] = col
|
124
125
|
end
|
125
126
|
turn_on_comboboxes()
|
126
127
|
@column_keys = flatten_hash(cols).keys
|
@@ -167,7 +168,7 @@ attr_accessor :vr_renderer, :vr_column
|
|
167
168
|
# Also, if the column VR::TreeViewColumn object doesn't support the property, it will try to
|
168
169
|
# set the property on the renderer instead. In the above example, the col_attr() method tries to
|
169
170
|
# set teh "<b>background</b>" property of a VR:TreeViewColumn. However, that object doesn't
|
170
|
-
# support the "background" property, but the renderer for the column, VR::CellRendererText does.
|
171
|
+
# support the "background" property, but the renderer for the column, VR::Col::Ren::CellRendererText does.
|
171
172
|
# So it sets the renderer's property instead. So, in this example this line of code would do exactly the same
|
172
173
|
# thing:
|
173
174
|
#
|
@@ -185,13 +186,29 @@ attr_accessor :vr_renderer, :vr_column
|
|
185
186
|
if column(c).respond_to?(key.to_s + "=")
|
186
187
|
column(c).send(key.to_s + '=', val)
|
187
188
|
elsif renderer(c).respond_to?(key.to_s + "=")
|
188
|
-
|
189
|
+
renderer(c).send(key.to_s + '=', val)
|
189
190
|
end
|
190
191
|
end
|
191
192
|
end
|
192
193
|
end
|
193
194
|
|
194
195
|
|
196
|
+
# def col_attr(*args)
|
197
|
+
# cols = args.select { |arg| !arg.is_a? Hash }
|
198
|
+
# return unless hash = args.detect { |arg| arg.is_a? Hash }
|
199
|
+
# cols = @column_keys if cols.empty?
|
200
|
+
# cols.each do |c|
|
201
|
+
# hash.each_pair do | key, val |
|
202
|
+
# if column(c).respond_to?(key.to_s + "=")
|
203
|
+
# column(c).send(key.to_s + '=', val)
|
204
|
+
# elsif renderer(c).respond_to?(key.to_s + "=")
|
205
|
+
# renderer(c).send(key.to_s + '=', val)
|
206
|
+
# end
|
207
|
+
# end
|
208
|
+
# end
|
209
|
+
# end
|
210
|
+
#
|
211
|
+
|
195
212
|
# Returns an array of rows that are selected in the VR::TreeView or VR::ListView.
|
196
213
|
# If nothing is selected, it returns an empty array. If you've configured your
|
197
214
|
# listview to accept multiple selections, it will return all of them. In single
|
@@ -221,17 +238,20 @@ attr_accessor :vr_renderer, :vr_column
|
|
221
238
|
# detect if comboboxes are present:
|
222
239
|
found = false
|
223
240
|
self.each_renderer do |r|
|
224
|
-
if r.is_a? VR::CellRendererCombo
|
241
|
+
if r.is_a? VR::Col::Ren::CellRendererCombo
|
225
242
|
found = true
|
226
243
|
break
|
227
244
|
end
|
228
245
|
end
|
229
246
|
return unless found
|
230
247
|
self.signal_connect("cursor_changed") do |view|
|
231
|
-
next unless iter = view.selection.selected
|
232
|
-
|
233
|
-
|
248
|
+
next unless iter = view.selection.selected
|
249
|
+
@vr_renderer.each do |sym, ren|
|
250
|
+
ren.set_model iter[id(sym)] if ren.is_a? VR::Col::Ren::CellRendererCombo
|
234
251
|
end
|
252
|
+
# view.each_renderer do |r|
|
253
|
+
# r.set_model( iter[r.model_col] ) if r.is_a? VR::Col::Ren::CellRendererCombo
|
254
|
+
# end
|
235
255
|
end
|
236
256
|
end
|
237
257
|
|
@@ -269,7 +289,7 @@ attr_accessor :vr_renderer, :vr_column
|
|
269
289
|
|
270
290
|
def vr_row(iter)
|
271
291
|
unless iter.respond_to?(:id)
|
272
|
-
iter.extend(
|
292
|
+
iter.extend(IterMethods)
|
273
293
|
iter.column_keys = @column_keys
|
274
294
|
end
|
275
295
|
return iter
|
@@ -294,7 +314,7 @@ attr_accessor :vr_renderer, :vr_column
|
|
294
314
|
|
295
315
|
|
296
316
|
def column(id)
|
297
|
-
@
|
317
|
+
@vr_cols[id]
|
298
318
|
end
|
299
319
|
|
300
320
|
def each_renderer
|
@@ -314,22 +334,22 @@ attr_accessor :vr_renderer, :vr_column
|
|
314
334
|
#The VR::ListView class will
|
315
335
|
#automatically assign renderers to each column based on its type:
|
316
336
|
#
|
317
|
-
#String, Fixnum, Integer, Float => VR::CellRendererText
|
318
|
-
#TrueClass => VR::CellRendererToggle
|
319
|
-
#GdkPixbuf => VR::CellRendererPixbuf
|
320
|
-
#DateTime => VR::CellRendererDate
|
321
|
-
#VR::CalendarCol, VR::
|
322
|
-
#VR::SpinCol => VR::CellRendererSpin
|
323
|
-
#VR::ProgressCol => VR::CellRendererProgress
|
324
|
-
#VR::ComboCol => VR::CellRendererCombo
|
337
|
+
#String, Fixnum, Integer, Float => VR::Col::Ren::CellRendererText
|
338
|
+
#TrueClass => VR::Col::Ren::CellRendererToggle
|
339
|
+
#GdkPixbuf => VR::Col::Ren::CellRendererPixbuf
|
340
|
+
#DateTime => VR::Col::Ren::CellRendererDate
|
341
|
+
#VR::Col::CalendarCol, VR::Col::BlobCol => VR::Col::Ren::CellRendererObject
|
342
|
+
#VR::Col::SpinCol => VR::Col::Ren::CellRendererSpin
|
343
|
+
#VR::Col::ProgressCol => VR::Col::Ren::CellRendererProgress
|
344
|
+
#VR::Col::ComboCol => VR::Col::Ren::CellRendererCombo
|
325
345
|
#
|
326
346
|
#The renderer() method will return one of these renderers:
|
327
347
|
#
|
328
348
|
# ren = @view.renderer(:ok)
|
329
|
-
# puts ren.class.name # VR::CellRendererToggle (:ok column is a TrueClass)
|
330
|
-
# puts @view.renderer(:name).class.name # => VR::CellRendererText
|
349
|
+
# puts ren.class.name # VR::Col::Ren::CellRendererToggle (:ok column is a TrueClass)
|
350
|
+
# puts @view.renderer(:name).class.name # => VR::Col::Ren::CellRendererText
|
331
351
|
#
|
332
|
-
#All the types of renderers are subclasses of Gtk renderers. For example, VR::CellRendererText
|
352
|
+
#All the types of renderers are subclasses of Gtk renderers. For example, VR::Col::Ren::CellRendererText
|
333
353
|
#is a subclass of Gtk::CellRendererText. So, you can use these objects just as you would use a
|
334
354
|
#normal Gtk renderer:
|
335
355
|
#
|
@@ -353,7 +373,7 @@ attr_accessor :vr_renderer, :vr_column
|
|
353
373
|
# This method converts the column ID symbols from the VR::ListView#new constructor
|
354
374
|
# to Integers:
|
355
375
|
#
|
356
|
-
# @view = VR::ListView.new(:name => String, :date => VR::CalendarCol)
|
376
|
+
# @view = VR::ListView.new(:name => String, :date => VR::Col::CalendarCol)
|
357
377
|
#
|
358
378
|
# Later in code...
|
359
379
|
#
|
@@ -1,18 +1,18 @@
|
|
1
1
|
|
2
|
-
module VR
|
2
|
+
module VR::Col
|
3
3
|
|
4
|
-
# The
|
4
|
+
# The BlobCol class is a simple text editor for editing strings of data:
|
5
5
|
#
|
6
6
|
# http://visualruby.net/img/textcol.jpg
|
7
7
|
#
|
8
8
|
# It is a very useful class when you want to display and edit long strings
|
9
9
|
# of data in a VR::ListView. To create a coulmn of long strings in a VR::ListView,
|
10
|
-
# simply define the column type as VR::
|
10
|
+
# simply define the column type as VR::Col::BlobCol:
|
11
11
|
#
|
12
|
-
# @view = VR::ListView.new(:name => String, :quote => VR::
|
12
|
+
# @view = VR::ListView.new(:name => String, :quote => VR::Col::BlobCol)
|
13
13
|
# row = @view.add_row
|
14
14
|
# row[:name] = "Eric"
|
15
|
-
# row[:quote] = VR::
|
15
|
+
# row[:quote] = VR::Col::BlobCol.new("I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. - Umberto Eco) ")
|
16
16
|
#
|
17
17
|
# The above listview will only display the first 20 characters of the quote, so
|
18
18
|
# it won't destroy the appearance of the listview. When a user clicks on the
|
@@ -20,7 +20,7 @@ module VR
|
|
20
20
|
#
|
21
21
|
# See the example project, "listview_objects" for more.
|
22
22
|
|
23
|
-
class
|
23
|
+
class BlobCol
|
24
24
|
|
25
25
|
include GladeGUI
|
26
26
|
|
@@ -1,22 +1,22 @@
|
|
1
1
|
|
2
|
-
module VR
|
2
|
+
module VR::Col
|
3
3
|
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
4
|
+
# The CalendarCol class is a simple calendar window where you can edit
|
5
|
+
# the date:
|
6
|
+
#
|
7
|
+
# http://visualruby.net/img/calendar.jpg
|
8
|
+
#
|
9
|
+
# This class is very useful when you want to display and edit dates
|
10
|
+
# in a VR::ListView. You can define a column with the type VR::Col::CalendarCol
|
11
|
+
# and the column will display as a date, and when the user clicks on the
|
12
|
+
# date, a calendar window will appear so he/she can edit it:
|
13
|
+
#
|
14
|
+
# @view = VR::ListView.new(:name => String, :birthday => VR::Col::CalendarCol)
|
15
|
+
# row = @view.add_row
|
16
|
+
# row[:name] = "Eric"
|
17
|
+
# row[:birthday] = VR::Col::CalendarCol.new(DateTime.new(1966, 7, 14))
|
18
|
+
#
|
19
|
+
# See the example project, "listview_objects" for more.
|
20
20
|
|
21
21
|
class CalendarCol
|
22
22
|
|
@@ -49,22 +49,21 @@ module VR
|
|
49
49
|
@builder["date"].hide if @hide_date
|
50
50
|
end
|
51
51
|
|
52
|
-
#
|
53
|
-
# change the appearance of this object, assign a new vale to @date_format.
|
54
|
-
|
52
|
+
# Output shown in ListView according to the @date_format instance variable. If you want to
|
53
|
+
# change the appearance of this object, assign a new vale to @date_format.
|
55
54
|
def to_s
|
56
55
|
@date.strftime(@format)
|
57
56
|
end
|
58
57
|
|
59
|
-
def am__toggled(*args)
|
58
|
+
def am__toggled(*args)
|
60
59
|
@builder["pm"].active = !@builder["am"].active?
|
61
60
|
end
|
62
61
|
|
63
|
-
def pm__toggled(*args)
|
62
|
+
def pm__toggled(*args)
|
64
63
|
@builder["am"].active = !@builder["pm"].active?
|
65
64
|
end
|
66
65
|
|
67
|
-
def buttonSave__clicked(*args)
|
66
|
+
def buttonSave__clicked(*args)
|
68
67
|
get_glade_variables()
|
69
68
|
m = @builder["am"].active? ? "AM" : "PM"
|
70
69
|
t = DateTime.strptime("#{@hour.to_i.to_s} #{@minute.to_i.to_s} #{m}", "%I %M %p")
|
@@ -72,10 +71,7 @@ module VR
|
|
72
71
|
@builder["window1"].destroy
|
73
72
|
end
|
74
73
|
|
75
|
-
|
76
|
-
@builder["window1"].destroy
|
77
|
-
end
|
78
|
-
|
74
|
+
# Used for sorting in ListView
|
79
75
|
def <=>(calendar)
|
80
76
|
return @date <=> calendar.date
|
81
77
|
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
module VR
|
2
|
-
|
3
|
-
class CellRendererProgress < Gtk::CellRendererProgress # :nodoc:
|
4
|
-
|
5
|
-
attr_reader :model_col, :column, :model_sym
|
6
|
-
|
7
|
-
def initialize(model_col, column, view, model_sym)
|
8
|
-
super()
|
9
|
-
@model_col = model_col
|
10
|
-
@model_sym = model_sym
|
11
|
-
@column = column
|
12
|
-
@view = view
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
1
|
+
#module VR
|
2
|
+
#
|
3
|
+
# class CellRendererProgress < Gtk::CellRendererProgress # :nodoc:
|
4
|
+
#
|
5
|
+
# attr_reader :model_col, :column, :model_sym
|
6
|
+
#
|
7
|
+
# def initialize(model_col, column, view, model_sym)
|
8
|
+
# super()
|
9
|
+
# @model_col = model_col
|
10
|
+
# @model_sym = model_sym
|
11
|
+
# @column = column
|
12
|
+
# @view = view
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
#end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module VR
|
1
|
+
module VR::Col::Ren
|
2
2
|
|
3
3
|
#
|
4
4
|
# This renderer has a slightly different validate_block than the others. Its validate_block will be called with three
|
@@ -8,7 +8,7 @@ module VR
|
|
8
8
|
# (row[:name].length < 3)
|
9
9
|
# }
|
10
10
|
#
|
11
|
-
# Also, you can use the VR::CellRendererToggle#edited= method to allow editing.
|
11
|
+
# Also, you can use the VR::Col::Ren::CellRendererToggle#edited= method to allow editing.
|
12
12
|
#
|
13
13
|
|
14
14
|
class CellRendererToggle < Gtk::CellRendererToggle
|
@@ -29,7 +29,7 @@ module VR
|
|
29
29
|
next unless iter = @view.model.get_iter(path)
|
30
30
|
if @validate_block.call(@model_sym, @view.vr_row(iter), @view)
|
31
31
|
iter[model_col] = !iter[model_col]
|
32
|
-
|
32
|
+
@edited_callback.call(@model_col, iter) if @edited_callback
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
module VR
|
1
|
+
module VR::Col
|
2
2
|
|
3
3
|
# This class is simply a wrapper for an Integer. It signals VR::Listview's
|
4
4
|
# and VR::Treeviews constructor to make this column a progressbar using
|
5
|
-
# VR::CellRendererProgress. For example, whwn you create a VR::ListView,
|
5
|
+
# VR::Col::Ren::CellRendererProgress. For example, whwn you create a VR::ListView,
|
6
6
|
# you can pass VR::Progress as a column type:
|
7
7
|
#
|
8
|
-
# @view = VR::ListView.new(String, VR::
|
8
|
+
# @view = VR::ListView.new(name: String, prog: VR::Col::ProgressCol, pix: Gdk::Pixbif)
|
9
9
|
#
|
10
10
|
# This makes model_col #1 a progress bar. When you set the value of the column,
|
11
11
|
# provide an integer value from 0 to 100:
|
12
12
|
#
|
13
|
-
# @view.add_row("
|
13
|
+
# @view.add_row("Jerry", 65, @pixbuf)
|
14
14
|
#
|
15
15
|
#
|
16
16
|
|