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
@@ -8,84 +8,84 @@
|
|
8
8
|
class SongListView < VR::ListView
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
AUDIO_ICON = Gdk::Pixbuf.new(File.dirname(__FILE__) + "/audio-x-generic.png")
|
12
12
|
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
def initialize
|
15
|
+
@cols = {}
|
16
|
+
@cols[:pix] = {:pix => Gdk::Pixbuf, :song => String } #two renderers in this column
|
17
|
+
@cols[:date] = VR::CalendarCol # DateTime
|
18
|
+
@cols[:artist] = String
|
19
|
+
@cols[:first_name] = String
|
20
|
+
@cols[:last_name] = String
|
21
|
+
@cols[:popular] = VR::ProgressCol
|
22
|
+
@cols[:buy] = VR::ComboCol
|
23
|
+
@cols[:quantity] = VR::SpinCol
|
24
|
+
@cols[:price] = VR::CurrencyCol
|
25
|
+
@cols[:check] = TrueClass
|
26
|
+
super(@cols)
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
#
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
28
|
+
col_sort_column_id(:artist => id(:last_name), :song => id(:song), :first_name=> id(:first_name))
|
29
|
+
col_sort_column_id(:last_name => id(:last_name), :popular => id(:popular))
|
30
|
+
col_sort_column_id(:last_name => id(:last_name), :popular => id(:popular), :buy=> id(:buy))
|
31
|
+
col_sort_column_id(:check => id(:check), :date => id(:date))
|
32
|
+
col_sort_column_id(:price => id(:price), :check => id(:check), :date => id(:date))
|
33
|
+
col_sort_column_id(:quantity => id(:quantity))
|
34
|
+
col_title(:first_name => "First", :last_name => "Last", :check => "Ok", :quantity => "Qty")
|
35
|
+
ren_width(:popular => 80, :check=> 20, :buy => 80, :quantity=>90)
|
36
|
+
# ren_attr(:price, :edit_inline => true)
|
37
|
+
ren_editable(true)
|
38
|
+
|
39
|
+
# this block executes after ARTIST is edited ("edited" event).
|
40
|
+
renderer(:artist).edited_callback = Proc.new { | model_col, iter |
|
41
|
+
names = iter[id(:artist)].split
|
42
|
+
iter[id(:first_name)] = names[0]
|
43
|
+
iter[id(:last_name)] = names[1]
|
44
|
+
}
|
45
|
+
|
46
|
+
# this block must evaluate to true to allow updating.
|
47
|
+
renderer(:artist).validate_block = Proc.new { |text, model_col, iter, view|
|
48
|
+
if text.split.size == 2 # insist on two names
|
49
|
+
true
|
50
|
+
else
|
51
|
+
alert("You must enter two names.", :parent => self)
|
52
|
+
false
|
53
|
+
end
|
54
|
+
}
|
55
|
+
refresh()
|
56
|
+
self.visible = true
|
57
|
+
end
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
59
|
+
# this just loads the data into the model
|
60
|
+
def refresh()
|
61
|
+
data = get_data() # returns array of songs
|
62
|
+
(0..6).each do |i|
|
63
|
+
row = model.append # add_row()
|
64
|
+
row[id(:pix)] = AUDIO_ICON
|
65
|
+
row[id(:first_name)] = data[i][0]
|
66
|
+
row[id(:last_name)] = data[i][1]
|
67
|
+
row[id(:artist)] = row[id(:first_name)] + " " + row[id(:last_name)]
|
68
|
+
row[id(:song)] = data[i][2]
|
69
|
+
row[id(:quantity)] = VR::SpinCol.new(0,0,100,1) # Gtk::Adjustment.new(0,0,100,1,0,0) #
|
70
|
+
row[id(:price)] = VR::CurrencyCol.new(2.99)
|
71
|
+
row[id(:popular)] = data[i][3]
|
72
|
+
row[id(:buy)] = VR::ComboCol.new("Buy", "Buy", "Rent", "Listen") # all rows use the same combobox
|
73
|
+
row[id(:check)] = false
|
74
|
+
row[id(:date)] = VR::CalendarCol.new(data[i][4], :format => "%d %b %Y ", :hide_time=>true, :hide_date => false)
|
75
|
+
end
|
76
76
|
|
77
|
-
|
77
|
+
end
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
79
|
+
def get_data
|
80
|
+
rows = []
|
81
|
+
rows << ["Iggy", "Pop", "I Wanna Be Your Dog", 88, DateTime.new(1981,11,21)]
|
82
|
+
rows << ["Joe", "Cocker", "You Are So Beautiful", 91, DateTime.new(1973,12,7)]
|
83
|
+
rows << ["Elvis", "Costello", "Pump it Up", 77, DateTime.new(1982, 5, 5)]
|
84
|
+
rows << ["Paul", "McCartney", "Silly Love Songs", 69, DateTime.new(1979,7,13)]
|
85
|
+
rows << ["Dorothy", "Moore", "Misty Blue", 97, DateTime.new(1981, 1, 14)]
|
86
|
+
rows << ["Rod", "Stewart", "Hot Legs", 54, DateTime.new(1982, 9, 27)]
|
87
|
+
rows << ["Lionel", "Richie", "Three Times a Lady", 84, DateTime.new(1978, 1, 3)]
|
88
|
+
end
|
89
89
|
|
90
90
|
end
|
91
91
|
|
@@ -1,68 +1,68 @@
|
|
1
1
|
|
2
2
|
class SongListViewGUI < SongListView
|
3
3
|
|
4
|
-
|
4
|
+
include GladeGUI
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def before_show
|
7
|
+
@builder["scrolledwindow1"].add(self)
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
def self__row_activated(*args)
|
11
|
+
return unless rows = selected_rows
|
12
|
+
row = rows[0]
|
13
|
+
alert "You selected\n#{row[:song]}\nby #{row[:artist]}"
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
def invisible__toggled(*args)
|
17
|
+
v = !@builder["invisible"].active?
|
18
|
+
col_visible(:last_name => v, :first_name => v )
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
def radio__toggled(*args)
|
22
|
+
ren_radio(:check => @builder["radio"].active?)
|
23
|
+
each_row { |r| r[:check] = false }
|
24
|
+
repaint
|
25
|
+
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
def background__toggled(*args)
|
28
|
+
val = @builder["background"].active? ? "yellow" : "white"
|
29
|
+
renderer(:pix).background = val
|
30
|
+
ren_attr(:song, :background => val) # same as set_background( :song => val)
|
31
|
+
repaint
|
32
|
+
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
def xalign__toggled(*args)
|
35
|
+
val = @builder["xalign"].active? ? 1 : 0
|
36
|
+
ren_xalign(:artist => val)
|
37
|
+
repaint
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
def bold__toggled(*args)
|
41
|
+
val = @builder["bold"].active? ? Pango::WEIGHT_BOLD : Pango::WEIGHT_NORMAL
|
42
|
+
ren_weight(:song => val) #number from 100 to 900, BOLD = 700
|
43
|
+
repaint
|
44
|
+
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
46
|
+
def center__toggled(*args)
|
47
|
+
val = @builder["center"].active? ? 0.5 : 0
|
48
|
+
col_alignment(:artist => val)
|
49
|
+
repaint
|
50
|
+
end
|
51
|
+
|
52
|
+
def editable__toggled(*args)
|
53
|
+
ren_editable(!@builder["editable"].active?)
|
54
|
+
end
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
def digits__toggled(*args)
|
57
|
+
val = @builder["digits"].active? ? 1 : 0
|
58
|
+
ren_digits(:quantity => val)
|
59
|
+
repaint
|
60
|
+
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
def repaint
|
63
|
+
@builder["scrolledwindow1"].hide
|
64
|
+
@builder["window1"].show_all
|
65
|
+
end
|
66
66
|
end
|
67
67
|
|
68
68
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
--- !ruby/object:VR_ENV
|
2
|
+
width: 1373
|
3
|
+
height: 665
|
4
|
+
panel_pos: 256
|
5
|
+
run_command_line: ruby main.rb
|
6
|
+
open_files:
|
7
|
+
- "/home/eric/vrp/vr3/examples/listview_objects/bin/ListViewObjectsGUI.rb"
|
8
|
+
- "/home/eric/vrp/vr3/examples/listview_objects/bin/ListViewObjects.rb"
|
9
|
+
- "/home/eric/vrp/vr3/examples/listview_objects/bin/DataObject.rb"
|
10
|
+
open_folders:
|
11
|
+
- "/home/eric/vrp/vr3/examples/listview_objects"
|
12
|
+
- "/home/eric/vrp/vr3/examples/listview_objects/bin"
|
13
|
+
- "/home/eric/vrp/vr3/examples/listview_objects/bin/glade"
|
14
|
+
current_file: "/home/eric/vrp/vr3/examples/listview_objects/bin/DataObject.rb"
|
15
|
+
rdoc_command_line: rdoc -x README
|
16
|
+
vr_yaml_file: ".vr_settings.yaml"
|
17
|
+
notebook_panel_position: 400
|
18
|
+
current_line: 3
|
19
|
+
settings_file_version: 1
|
@@ -5,49 +5,49 @@
|
|
5
5
|
|
6
6
|
class DataObject
|
7
7
|
|
8
|
-
|
8
|
+
include GladeGUI
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
def initialize(name, address, email, phone)
|
11
|
+
@name = name
|
12
|
+
@address = address
|
13
|
+
@email = email
|
14
|
+
@phone = phone
|
15
|
+
end
|
16
16
|
|
17
17
|
# In the glade form, there are buttons named buttonSave and buttonCancel.
|
18
18
|
# By using the naming convention <name>__clicked these methods will be called when the clicked even occurs.
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
def buttonSave__clicked(*args)
|
21
|
+
get_glade_variables()
|
22
|
+
@builder["window1"].destroy
|
23
|
+
end
|
24
24
|
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
def buttonCancel__clicked(*args)
|
27
|
+
@builder["window1"].destroy
|
28
|
+
end
|
29
29
|
|
30
30
|
|
31
31
|
#The to_s method defines how this object appears in the ListView.
|
32
32
|
#Think of it like an icon. It should be a short representation
|
33
33
|
#of the object. THen when the user clicks on it, they get the full object
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
def to_s
|
36
|
+
"#{@name} (#{@email})"
|
37
|
+
end
|
38
38
|
|
39
39
|
#The visual_attributes method defines the appearance of the object in the
|
40
40
|
#ListView. You can change the background to red for example to flag the object.
|
41
41
|
#Here the invalid emails will be shown with a yellow background. Try entering an invalid
|
42
42
|
#email, and you'll see it will turn yellow.
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
def visual_attributes()
|
45
|
+
{ :background => email_valid? ? "white" : "yellow" }
|
46
|
+
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
def email_valid?
|
49
|
+
@email =~ /\A[\w\._%-]+@[\w\.-]+\.[a-zA-Z]{2,4}\z/
|
50
|
+
end
|
51
51
|
|
52
52
|
|
53
53
|
end
|
@@ -3,35 +3,35 @@
|
|
3
3
|
|
4
4
|
class ListViewObjects < VR::ListView
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
6
|
+
def initialize()
|
7
|
+
|
8
|
+
#define column types, then call super()
|
9
|
+
@cols = {}
|
10
|
+
@cols[:join] = VR::CalendarCol
|
11
|
+
@cols[:name] = DataObject
|
12
|
+
@cols[:quote] = VR::TextCol
|
13
|
+
super(@cols)
|
14
|
+
col_title(:join => "Joined On", :name => "Name (email)", :quote => "Favorite Quote")
|
15
|
+
col_width(:join => 200, :name => 300)
|
16
|
+
populate_data()
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
def populate_data() # just populates model with random data
|
22
|
+
row = add_row()
|
23
|
+
row[:join] = VR::CalendarCol.new DateTime.new(2011, 1, 15, 7, 23, 0)
|
24
|
+
row[:name] = DataObject.new("Henry Johnson", "18458 S Beauford St.", "hohohoja@email.net", "154-453-8585")
|
25
|
+
row[:quote] = VR::TextCol.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.\n\n- Umberto Eco"
|
26
|
+
row = add_row()
|
27
|
+
row[:join] = VR::CalendarCol.new DateTime.new(1997, 7, 24, 3, 26, 0)
|
28
|
+
row[:name] = DataObject.new("Theo Alexander", "935 Medford Ln.", "noreply@gmail.com", "586-673-9474")
|
29
|
+
row[:quote] = VR::TextCol.new "The instinct of nearly all societies is to lock up anybody who is truly free. First, society begins by trying to beat you up. If this fails, they try to poison you. If this fails too, they finish by loading honors on your head.\n\n- Jean Cocteau (1889-1963)"
|
30
|
+
row = add_row()
|
31
|
+
row[:join] = VR::CalendarCol.new DateTime.new(1987, 5, 11, 6, 43, 0)
|
32
|
+
row[:name] = DataObject.new("Billy Vincent", "675 Telegraph Rd.", "jimmy@visualruby.net", "432-485-5863")
|
33
|
+
row[:quote] = VR::TextCol.new "There are two ways of constructing a software design; one way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.\n\n- C. A. R. Hoare"
|
34
|
+
end
|
35
35
|
|
36
36
|
|
37
37
|
end
|
@@ -3,23 +3,23 @@
|
|
3
3
|
|
4
4
|
class ListViewObjectsGUI < ListViewObjects
|
5
5
|
|
6
|
-
|
6
|
+
include GladeGUI
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
def before_show
|
9
|
+
@builder["scrolledwindow1"].add(self)
|
10
|
+
self.visible = true
|
11
|
+
# edited_callback is a method that is called after a cell has been edited. It is
|
12
|
+
# used to do housekeeping after the value of the cell has changed.
|
13
|
+
renderer(:quote).edited_callback = method(:self__cursor_changed)
|
14
|
+
end
|
15
15
|
|
16
16
|
# When the selection changes, the quote at the bottom of the page needs to be updated.
|
17
17
|
# Then the quote matches the selected record. Try it.
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
def self__cursor_changed(*args)
|
20
|
+
return unless row = selected_rows.first # iter = selection.selected
|
21
|
+
@builder["labelQuote"].label = row[:quote].text
|
22
|
+
end
|
23
23
|
|
24
24
|
|
25
25
|
end
|
@@ -1,38 +1,38 @@
|
|
1
1
|
|
2
2
|
class MainApp #(change name)
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
include GladeGUI
|
5
|
+
|
6
|
+
# make $ENV global object available everywhere
|
7
|
+
def before_show()
|
8
|
+
$ENV = VR::load_yaml(:class => SavableSettings, :file_name => "settings.yaml")
|
9
|
+
@builder[:window1].resize $ENV.width, $ENV.height
|
10
|
+
refresh()
|
11
|
+
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def refresh()
|
14
|
+
@builder[:text].text = $ENV.text
|
15
|
+
@builder[:window1].title = $ENV.title
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def buttonEdit__clicked(*a)
|
19
|
+
$ENV.show_glade(self)
|
20
|
+
refresh()
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
# delete_event signal occurs before the window actually closes
|
24
|
+
# It gives us time to save the height and width of the widow before
|
25
|
+
#closing it. Returns: true = don't close window, false = close window.
|
26
26
|
def window1__delete_event(*)
|
27
|
-
|
28
|
-
|
27
|
+
$ENV.width, $ENV.height = @builder[:window1].size()
|
28
|
+
VR::save_yaml($ENV)
|
29
29
|
return false #ok to close
|
30
|
-
|
30
|
+
end
|
31
31
|
|
32
|
-
|
32
|
+
def buttonCancel__clicked(*a)
|
33
33
|
window1__delete_event
|
34
|
-
|
35
|
-
|
34
|
+
@builder[:window1].destroy
|
35
|
+
end
|
36
36
|
|
37
37
|
end
|
38
38
|
|
@@ -1,39 +1,38 @@
|
|
1
1
|
|
2
2
|
class SavableSettings
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
4
|
+
include GladeGUI
|
5
|
+
|
6
|
+
attr_accessor :height, :width, :title, :text
|
7
|
+
|
8
|
+
def initialize()
|
9
|
+
defaults()
|
10
|
+
end
|
11
|
+
|
12
|
+
# defaults are set on new and loaded objects. You can add to this list
|
13
|
+
# and it will not cause errors. New variables will be added
|
14
|
+
# and loaded objects will function flawlessly. When you load a yaml
|
15
|
+
# file using VR::load_yaml, it will look for a method named "defaults"
|
16
|
+
# and execute it, so use the name "defaults, and it will automatically run.
|
17
|
+
|
18
|
+
def defaults()
|
19
|
+
@height ||= 200
|
20
|
+
@width ||= 350
|
21
|
+
@title ||= "Savable Settings Demo"
|
22
|
+
@text ||= "Try running this program multiple times.\n\n" +
|
21
23
|
"It will create a file named settings.yaml that stores " +
|
22
24
|
"the height, width, title, and text from this window, so the " +
|
23
25
|
"window will be restored to the same state as when you exited.\n\n " +
|
24
26
|
"If you want to reset the file to the defaults, just delete the settings.yaml file.\n\n" +
|
25
27
|
"You may need to click the 'Refresh' to see the settings.yaml file."
|
26
|
-
|
28
|
+
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
def buttonSave__clicked(*a)
|
31
|
+
get_glade_variables
|
32
|
+
VR::save_yaml(self)
|
33
|
+
@builder[:window1].destroy
|
34
|
+
end
|
33
35
|
|
34
|
-
def buttonCancel__clicked(*a)
|
35
|
-
@builder[:window1].destroy
|
36
|
-
end
|
37
36
|
|
38
37
|
end
|
39
38
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
--- !ruby/object:VR_ENV
|
2
|
+
width: 1366
|
3
|
+
height: 692
|
4
|
+
panel_pos: 490
|
5
|
+
run_command_line: ruby main.rb
|
6
|
+
open_files:
|
7
|
+
- "/home/eric/vrp/vr3/examples/simple_ruby_gui/bin/DataObjectGUI.rb"
|
8
|
+
- "/home/eric/vrp/vr3/examples/simple_ruby_gui/main.rb"
|
9
|
+
open_folders:
|
10
|
+
- "/home/eric/vrp/vr3/examples/simple_ruby_gui"
|
11
|
+
- "/home/eric/vrp/vr3/examples/simple_ruby_gui/bin"
|
12
|
+
- "/home/eric/vrp/vr3/examples/simple_ruby_gui/bin/glade"
|
13
|
+
current_file: "/home/eric/vrp/vr3/examples/simple_ruby_gui/main.rb"
|
14
|
+
rdoc_command_line: rdoc -x README
|
15
|
+
vr_yaml_file: ".vr_settings.yaml"
|
16
|
+
notebook_panel_position: 400
|
17
|
+
current_line: 13
|
18
|
+
settings_file_version: 1
|
19
|
+
builder: !ruby/object:Gtk::Builder {}
|
20
|
+
filename: ".vr_settings.yaml"
|