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
data/vrlib/lib/IconHash.rb
CHANGED
@@ -2,17 +2,17 @@ module VR
|
|
2
2
|
|
3
3
|
class IconHash < Hash # :nodoc:
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
def initialize(path)
|
6
|
+
Dir.glob(path + "/*.png").each do |f|
|
7
|
+
ext = File.basename(f, ".png")
|
8
|
+
self[ext] = Gdk::Pixbuf.new(f)
|
9
|
+
end
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
def get_icon(file_name)
|
13
|
+
ext = File.extname(file_name).gsub(".", "")
|
14
|
+
self.has_key?(ext) ? self[ext] : self["unknown"]
|
15
|
+
end
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
data/vrlib/lib/SavableClass.rb
CHANGED
@@ -1,51 +1,51 @@
|
|
1
1
|
module VR
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
3
|
+
def self.load_yaml(flags)
|
4
|
+
me = nil
|
5
|
+
if File.file?(flags[:file_name])
|
6
|
+
me = YAML.load(File.open(flags[:file_name]).read)
|
7
|
+
elsif flags[:class]
|
8
|
+
me = flags[:class].new()
|
9
|
+
end
|
10
|
+
me.instance_variable_set(:@vr_yaml_file, flags[:file_name])
|
11
|
+
me.defaults() if me.respond_to?(:defaults)
|
12
|
+
VR::save_yaml(me)
|
13
|
+
return me
|
14
|
+
end
|
15
|
+
|
16
|
+
# todo create folders if don't exist
|
17
|
+
def self.save_yaml(obj, filename = nil)
|
18
|
+
filename ||= obj.instance_variable_get(:@vr_yaml_file)
|
19
|
+
data = YAML.dump(obj)
|
20
|
+
File.open(filename, "w") {|f| f.puts(data)}
|
21
|
+
end
|
22
22
|
|
23
23
|
end
|
24
24
|
|
25
25
|
#
|
26
26
|
#class VR::SavableClass
|
27
27
|
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
28
|
+
# def initialize(filename = nil)
|
29
|
+
# @filename = filename
|
30
|
+
# defaults
|
31
|
+
# end
|
32
32
|
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
33
|
+
# def self.load_yaml(filename)
|
34
|
+
# if File.file?(filename)
|
35
|
+
# me = YAML.load(File.open(filename).read)
|
36
|
+
# me.filename = filename
|
37
|
+
# me.defaults()
|
38
|
+
# return me
|
39
|
+
# else
|
40
|
+
# return nil
|
41
|
+
# end
|
42
|
+
# end
|
43
43
|
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
44
|
+
# def save_yaml(new_filename = nil)
|
45
|
+
# @filename = new_filename if new_filename
|
46
|
+
# data = YAML.dump(self)
|
47
|
+
# File.open(@filename, "w") {|f| f.puts(data)}
|
48
|
+
# end
|
49
49
|
#
|
50
50
|
#
|
51
51
|
#end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#This is for backwards compatibility. Before, there was an instance of
|
3
3
|
#SimpleComboBoxEntry in the VR_ENV_GLOBAL yaml file. Older projects try to
|
4
4
|
#load this instance.
|
5
|
-
module VR
|
6
|
-
|
7
|
-
|
5
|
+
module VR # :nodoc:
|
6
|
+
class SimpleComboBoxEntry
|
7
|
+
end
|
8
8
|
end
|
@@ -3,11 +3,11 @@ module VR
|
|
3
3
|
|
4
4
|
class FileTreeView < VR::TreeView # :nodoc:
|
5
5
|
|
6
|
-
|
6
|
+
include GladeGUI
|
7
7
|
|
8
|
-
|
8
|
+
attr_accessor :root, :glob, :test_block
|
9
9
|
|
10
|
-
|
10
|
+
def initialize(root = Dir.pwd, icon_path = nil, glob = "*")
|
11
11
|
@root = root
|
12
12
|
@glob = glob
|
13
13
|
super(:file => {:pix => Gdk::Pixbuf, :file_name => String}, :empty => TrueClass, :path => String, :modified_date => VR::DateCol, :sort_on => String)
|
@@ -16,94 +16,95 @@ module VR
|
|
16
16
|
@icons = File.directory?(icon_path) ? VR::IconHash.new(icon_path) : nil
|
17
17
|
parse_signals()
|
18
18
|
model.set_sort_column_id(id(:sort_on), :ascending )
|
19
|
-
|
19
|
+
self.set_enable_search(false)
|
20
20
|
refresh
|
21
|
-
|
22
|
-
end
|
21
|
+
self.visible = true # necessary!
|
22
|
+
end
|
23
23
|
|
24
24
|
# flags: :root => root path, :open_folders => array of paths to open
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
def refresh(flags={})
|
26
|
+
@root = flags[:root] if flags[:root]
|
27
|
+
open_folders = flags[:open_folders] ? flags[:open_folders] : get_open_folders()
|
28
|
+
model.clear
|
29
|
+
@root_iter = add_file(@root, nil)
|
30
|
+
open_folders([@root_iter[:path]])
|
31
|
+
# fill_folder(@root_iter)
|
32
|
+
# expand_row(@root_iter.path, false)
|
33
|
+
open_folders(open_folders)
|
33
34
|
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
def fill_folder(parent_iter)
|
37
|
+
model.remove(parent_iter.first_child) #remove dummy record
|
38
|
+
files = Dir.glob(File.join(parent_iter[id(:path)],@glob))
|
39
|
+
files = files.select &@test_block if @test_block
|
40
|
+
files.each do |fn|
|
41
|
+
add_file(fn, parent_iter)
|
42
|
+
end
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
def self__row_expanded(view, iter, path)
|
46
|
+
iter = model.get_iter(path) #bug fix
|
47
|
+
fill_folder(iter) if iter[id(:empty)]
|
48
|
+
expand_row(iter.path, false)
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
51
|
+
def expand_or_collapse_folder()
|
52
|
+
return unless row = selected_rows.first
|
53
|
+
if row_expanded?(row.path)
|
54
|
+
collapse_row(row.path)
|
55
|
+
else
|
56
|
+
self__row_expanded(self, row, row.path)
|
57
|
+
end
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
def get_open_folders()
|
61
|
+
expanded = []
|
62
|
+
map_expanded_rows {|view, path| expanded << model.get_iter(path)[id(:path)] }
|
63
|
+
return expanded
|
64
|
+
end
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
66
|
+
def open_folders(folder_paths)
|
67
|
+
model.each do |model, path, iter|
|
68
|
+
if folder_paths.include?(iter[id(:path)])
|
69
|
+
expand_row(path, false)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
72
73
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
def add_file(filename, parent = @root_iter)
|
75
|
+
my_path = File.dirname(filename)
|
76
|
+
model.each do |model, path, iter|
|
77
|
+
return if iter[id(:path)] == filename # duplicate
|
78
|
+
parent = iter if iter[id(:path)] == my_path
|
79
|
+
end
|
79
80
|
fn = filename.gsub("\\", "/")
|
80
81
|
parent[id(:empty)] = false unless parent.nil?
|
81
82
|
child = add_row(parent)
|
82
|
-
child[:pix] = @icons.get_icon(File.directory?(fn) ? "x.folder" : fn)
|
83
|
+
child[:pix] = @icons.get_icon(File.directory?(fn) ? "x.folder" : fn) if @icons
|
83
84
|
child[:file_name] = File.basename(fn)
|
84
85
|
child[:path] = fn
|
85
86
|
if File.directory?(fn)
|
86
|
-
|
87
|
-
|
88
|
-
|
87
|
+
child[:sort_on] = "0" + child[:file_name]
|
88
|
+
child[:empty] = true
|
89
|
+
add_row(child) # dummy record so expander appears
|
89
90
|
else
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
91
|
+
child[id(:sort_on)] = "1" + child[id(:file_name)]
|
92
|
+
end
|
93
|
+
return child
|
94
|
+
end
|
94
95
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
def set_show_expanders(expand)
|
97
|
+
self.show_expanders = expand
|
98
|
+
self.level_indentation = expand ? 0 : 12
|
99
|
+
end
|
99
100
|
|
100
|
-
|
101
|
-
|
102
|
-
|
101
|
+
def folder?(iter)
|
102
|
+
iter[id(:sort_on)][0,1] == "0"
|
103
|
+
end
|
103
104
|
|
104
|
-
|
105
|
+
def get_selected_path() (selection.selected ? selection.selected[id(:path)] : nil) end
|
105
106
|
|
106
|
-
end
|
107
|
+
end
|
107
108
|
|
108
109
|
|
109
110
|
|
@@ -7,8 +7,8 @@ module VR
|
|
7
7
|
|
8
8
|
module IterMethods
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
attr_accessor :column_keys
|
11
|
+
@column_keys = nil
|
12
12
|
|
13
13
|
# The [] method returns the value from the specified column in the iter:
|
14
14
|
#
|
@@ -16,15 +16,15 @@ module IterMethods
|
|
16
16
|
#
|
17
17
|
# - col_id -- Either a visualruby column ID symbol, as above, or an integer.
|
18
18
|
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
29
|
# The id() method translates visualruby's colum ID symbols into integers that
|
30
30
|
# GtkTreeIter can use:
|
@@ -34,9 +34,9 @@ module IterMethods
|
|
34
34
|
#
|
35
35
|
# Normally, its best to use VR's "rows" instead. They will already use the column ID symbols.
|
36
36
|
#
|
37
|
-
|
38
|
-
|
39
|
-
|
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
41
|
# This will load the values of any object into the iter. It will look at all the
|
42
42
|
# instance variables, methods, and ActiveRecord fields and match them to
|
@@ -55,28 +55,28 @@ module IterMethods
|
|
55
55
|
#
|
56
56
|
# -obj--any ruby object or object subclassed from ActiveRecord::Base.
|
57
57
|
#
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
66
|
+
end
|
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)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
80
|
|
81
81
|
end
|
82
82
|
end
|
@@ -3,7 +3,7 @@ module VR
|
|
3
3
|
|
4
4
|
class ListView < Gtk::TreeView
|
5
5
|
|
6
|
-
|
6
|
+
include ViewCommon
|
7
7
|
|
8
8
|
#The new() constructor takes a Hash that defines the columns as its only argument. The Hash defines
|
9
9
|
#symbols as the keys to give an ID to each column. The Hash also defines the type (class) of the column.
|
@@ -32,28 +32,28 @@ module VR
|
|
32
32
|
#
|
33
33
|
|
34
34
|
def initialize(cls)
|
35
|
-
|
35
|
+
super()
|
36
36
|
hash = flatten_hash(cls)
|
37
37
|
vals = hash.values
|
38
|
-
|
39
|
-
|
38
|
+
self.model = Gtk::ListStore.new(*vals)
|
39
|
+
load_columns(cls)
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
def add_active_record_rows(ar) # :nodoc:
|
43
|
+
ar.each do |obj|
|
44
|
+
row = add_row()
|
45
|
+
matches = obj.attributes.keys & @column_keys #intersection
|
46
|
+
matches.each { |field| row[field] = obj.attributes[field] }
|
47
|
+
end
|
48
|
+
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
def []( row ) # :nodoc:
|
51
|
+
model.get_iter(Gtk::TreePath.new("#{row}"))
|
52
|
+
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
def []( row, col ) # :nodoc:
|
55
|
+
model.get_iter(Gtk::TreePath.new("#{row}"))[col]
|
56
|
+
end
|
57
57
|
|
58
58
|
# This method will select a given row number. The row will be hilighted, and the
|
59
59
|
# GtkSelection object will point to that row. It uses the GtkTreeView#set_cursor
|
@@ -62,9 +62,9 @@ module VR
|
|
62
62
|
#- row_number: Integer (FixNum)
|
63
63
|
#
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
def select_row(row_number = 0)
|
66
|
+
set_cursor(Gtk::TreePath.new(row_number), nil, false)
|
67
|
+
end
|
68
68
|
|
69
69
|
#This will add a row to the data model, and fill-in the values from a Hash.
|
70
70
|
#This example would add a row to the model and set the name and email fields:
|
@@ -74,11 +74,11 @@ module VR
|
|
74
74
|
#
|
75
75
|
#- hash: A ruby Hash object with pairs of column ISs (symbols) and values.
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
77
|
+
def add_row(hash = {})
|
78
|
+
row = vr_row(model.append)
|
79
|
+
hash.each_pair { |key, val| row[key] = val }
|
80
|
+
return row
|
81
|
+
end
|
82
82
|
|
83
83
|
end
|
84
84
|
|
@@ -8,17 +8,17 @@ module VR
|
|
8
8
|
# Also, most of the useful methods for VR::TreeView are found in VR::ViewCommon.
|
9
9
|
# All the methods in VR::ViewCommon work on VR::TreeViews and VR::ListViews.
|
10
10
|
#
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
class TreeView < Gtk::TreeView
|
12
|
+
|
13
|
+
include ViewCommon
|
14
14
|
|
15
15
|
# See VR::ListView constructor. (exactly the same)
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
def initialize(cols)
|
18
|
+
super()
|
19
|
+
self.model = Gtk::TreeStore.new(*flatten_hash(cols).values)
|
20
|
+
load_columns(cols)
|
21
|
+
end
|
22
22
|
#
|
23
23
|
# Adds row to the model. This will return a "row" type iter that responds
|
24
24
|
# to column IDs (symbols). You need to provide a parent row (iter).
|
@@ -28,16 +28,16 @@ module VR
|
|
28
28
|
#
|
29
29
|
# @view.add_row(iter, :name => "Chester", :email => "chester@chesterizer.com")
|
30
30
|
#
|
31
|
-
#
|
31
|
+
#
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
def add_row(parent, hash = {})
|
36
|
+
row = vr_row(model.append(parent))
|
37
|
+
hash.each_pair { |key, val| row[key] = val }
|
38
|
+
return row
|
39
|
+
end
|
40
40
|
|
41
|
-
|
41
|
+
end
|
42
42
|
|
43
43
|
end
|