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.
- 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/bin/tools/VR_Tools.rb
CHANGED
|
@@ -6,29 +6,29 @@ module VR_Tools
|
|
|
6
6
|
end
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
def VR_Tools.popen(cmd)
|
|
10
|
+
begin
|
|
11
|
+
IO.popen(cmd)
|
|
12
|
+
rescue
|
|
13
|
+
alert("The following command couldn't run:\n\n<b>#{cmd}</b>\n\nCheck the path in Tools > Settings")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def VR_Tools.back_up()
|
|
20
|
-
|
|
20
|
+
path = File.join(ENV["HOME"], "visualruby_backup", Dir.pwd.gsub(ENV["HOME"], ""))
|
|
21
21
|
t = Time.now
|
|
22
22
|
out_dir = path + "/" + Dir.pwd.split("/").last + " Backup " + t.month().to_s + '-' + t.day().to_s + "-" + t.year().to_s + " at " + t.strftime('%I %M%p')
|
|
23
23
|
copy_recursively(Dir.pwd, out_dir)
|
|
24
|
-
|
|
24
|
+
alert "Files backed up to: \n\n" + path
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
def VR_Tools.copy_skeleton_project(path)
|
|
28
|
+
VR_Tools.copy_recursively(File.dirname(__FILE__) + "/../../skeleton/project", path)
|
|
29
|
+
end
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
def VR_Tools.copy_recursively(from, out_dir)
|
|
32
32
|
Find.find(from) do |path|
|
|
33
33
|
next if path == from
|
|
34
34
|
rel_path = path.gsub(from, "")
|
|
@@ -41,75 +41,75 @@ module VR_Tools
|
|
|
41
41
|
FileUtils.copy(path, out_dir + rel_path)
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
|
-
|
|
44
|
+
end
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
def self.create_gemspec()
|
|
47
|
+
main_file = $VR_ENV.run_command_line.split(" ")[1]
|
|
48
|
+
main_path = "."
|
|
49
|
+
bindir = "'.'" #( main_path == "bin") ? "'bin'" : "'#{main_path}', 'bin'"
|
|
50
|
+
libdir = "'.'" #(main_path == "lib") ? "'lib'" : "'#{main_path}', 'lib'"
|
|
51
|
+
str = <<END
|
|
52
52
|
Gem::Specification.new do |s|
|
|
53
53
|
s.name = "#{File.basename(Dir.pwd).downcase}" # i.e. visualruby. This name will show up in the gem list.
|
|
54
54
|
s.version = "0.0.1" # i.e. (major,non-backwards compatable).(backwards compatable).(bugfix)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
s.add_dependency "vrlib", ">= 0.0.1"
|
|
56
|
+
s.add_dependency "gtk2", ">= 0.0.1"
|
|
57
|
+
s.add_dependency "require_all", ">= 0.0.1"
|
|
58
|
+
s.has_rdoc = false
|
|
59
59
|
s.authors = ["Your Name"]
|
|
60
60
|
s.email = "you@yoursite.com" # optional
|
|
61
61
|
s.summary = "Short Description Here." # optional
|
|
62
62
|
s.homepage = "http://www.yoursite.org/" # optional
|
|
63
63
|
s.description = "Full description here" # optional
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
s.executables = ['#{main_file}'] # i.e. 'vr' (optional, blank if library project)
|
|
65
|
+
s.default_executable = '#{main_file}' # i.e. 'vr' (optional, blank if library project)
|
|
66
|
+
s.bindir = [#{bindir}] # optional, default = bin
|
|
67
|
+
s.require_paths = [#{libdir}] # optional, default = lib
|
|
68
|
+
s.files = Dir.glob(File.join("**", "*.{rb,glade}"))
|
|
69
|
+
s.rubyforge_project = "nowarning" # supress warning message
|
|
70
70
|
end
|
|
71
71
|
END
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
name = File.basename(Dir.pwd).downcase + ".gemspec"
|
|
73
|
+
if File.file?(name)
|
|
74
|
+
unless alert("Do you want to overwrite existing file?:\n<b>#{name}</b>?",
|
|
75
|
+
:headline => "File Already Exists", :button_yes => "Overwrite", :button_no => "Cancel", :width => 400)
|
|
76
|
+
return false
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
file_name = File.join(Dir.pwd,name)
|
|
80
|
+
File.open(file_name, "w") { |f| f.puts(str) }
|
|
81
|
+
return file_name
|
|
82
|
+
end
|
|
83
|
+
#
|
|
84
|
+
#this works on Dir.pwd that's maybe different from project
|
|
85
|
+
def VR_Tools.replace_html_in_docs()
|
|
86
|
+
return if not File.file? "rdoc_replace.yaml"
|
|
87
|
+
ar = YAML.load_file "rdoc_replace.yaml"
|
|
88
|
+
Dir.glob("#{Dir.pwd}/doc/**/*.html") do |f|
|
|
89
|
+
str = File.open(f).read
|
|
90
|
+
ar.each do |pair|
|
|
91
|
+
str.gsub!(pair[0], pair[1])
|
|
92
|
+
end
|
|
93
|
+
File.open(f, "w") { |file| file.puts(str) }
|
|
94
|
+
end
|
|
95
|
+
FileUtils.cp "#{Dir.pwd}/rdoc.css", "#{Dir.pwd}/doc/rdoc.css" if File.file?("#{Dir.pwd}/rdoc.css") and File.directory?("#{Dir.pwd}/doc")
|
|
82
96
|
end
|
|
83
|
-
#
|
|
84
|
-
#this works on Dir.pwd that's maybe different from project
|
|
85
|
-
def VR_Tools.replace_html_in_docs()
|
|
86
|
-
return if not File.file? "rdoc_replace.yaml"
|
|
87
|
-
ar = YAML.load_file "rdoc_replace.yaml"
|
|
88
|
-
Dir.glob("#{Dir.pwd}/doc/**/*.html") do |f|
|
|
89
|
-
str = File.open(f).read
|
|
90
|
-
ar.each do |pair|
|
|
91
|
-
str.gsub!(pair[0], pair[1])
|
|
92
|
-
end
|
|
93
|
-
File.open(f, "w") { |file| file.puts(str) }
|
|
94
|
-
end
|
|
95
|
-
FileUtils.cp "#{Dir.pwd}/rdoc.css", "#{Dir.pwd}/doc/rdoc.css" if File.file?("#{Dir.pwd}/rdoc.css") and File.directory?("#{Dir.pwd}/doc")
|
|
96
|
-
end
|
|
97
97
|
|
|
98
98
|
end
|
|
99
|
-
#
|
|
100
|
-
#
|
|
101
|
-
#
|
|
102
|
-
#
|
|
103
|
-
#
|
|
104
|
-
#
|
|
105
|
-
#
|
|
106
|
-
#
|
|
107
|
-
#
|
|
99
|
+
# def VR_Tools.sudo_command(command)
|
|
100
|
+
# @pass ||= ""
|
|
101
|
+
# if @pass.strip() == ""
|
|
102
|
+
# @pass = VR::Dialog.input_box("Enter System Password:")
|
|
103
|
+
# end
|
|
104
|
+
# result = command + "\n" + `echo #{@pass} | sudo -S #{command}`
|
|
105
|
+
# @pass = "" if result.include? "incorrect password"
|
|
106
|
+
# return result
|
|
107
|
+
# end
|
|
108
108
|
|
|
109
|
-
#
|
|
110
|
-
#
|
|
111
|
-
#
|
|
112
|
-
#
|
|
109
|
+
# def VR_Tools.create_desktop_launcher()
|
|
110
|
+
# command = "vr " + Dir.pwd
|
|
111
|
+
# name = File.basename(Dir.pwd) + " Project"
|
|
112
|
+
# str = <<END
|
|
113
113
|
#
|
|
114
114
|
##!/usr/bin/env xdg-open
|
|
115
115
|
#
|
|
@@ -126,10 +126,10 @@ end
|
|
|
126
126
|
#Icon=gnome-panel-launcher
|
|
127
127
|
#
|
|
128
128
|
#END
|
|
129
|
-
#
|
|
130
|
-
#
|
|
129
|
+
# return unless File.directory?(ENV["HOME"] + "/Desktop")
|
|
130
|
+
# fn = ENV["HOME"] + "/Desktop/" + name + ".desktop"
|
|
131
131
|
# File.open(fn,"w") { |f| f.puts(str) }
|
|
132
|
-
#
|
|
133
|
-
#
|
|
134
|
-
#
|
|
132
|
+
# File.chmod(0755, fn)
|
|
133
|
+
# alert("Created launcher:\n" + name + "\non your computer's desktop")
|
|
134
|
+
# end
|
|
135
135
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
--- !ruby/object:VR_ENV
|
|
2
|
+
vr_yaml_file: ".vr_settings.yaml"
|
|
3
|
+
width: 1139
|
|
4
|
+
height: 691
|
|
5
|
+
panel_pos: 453
|
|
6
|
+
notebook_panel_position: 400
|
|
7
|
+
run_command_line: ruby active_record.rb
|
|
8
|
+
open_files:
|
|
9
|
+
- "/home/eric/vrp/vr3/examples/active_record/bin/Person.rb"
|
|
10
|
+
- "/home/eric/vrp/vr3/examples/active_record/bin/ChoosePerson.rb"
|
|
11
|
+
- "/home/eric/vrp/vr3/examples/active_record/active_record.rb"
|
|
12
|
+
open_folders:
|
|
13
|
+
- "/home/eric/vrp/vr3/examples/active_record"
|
|
14
|
+
- "/home/eric/vrp/vr3/examples/active_record/bin"
|
|
15
|
+
- "/home/eric/vrp/vr3/examples/active_record/bin/glade"
|
|
16
|
+
current_file: "/home/eric/vrp/vr3/examples/active_record/active_record.rb"
|
|
17
|
+
current_line: 6
|
|
18
|
+
rdoc_command_line: rdoc -x README
|
|
19
|
+
builder: !ruby/object:Gtk::Builder {}
|
|
20
|
+
filename: ".vr_settings.yaml"
|
|
21
|
+
backup_path: "/home/eric"
|
|
22
|
+
browser: firefox
|
|
23
|
+
font_name: Monospace 10
|
|
24
|
+
glade_path: glade-gtk2
|
|
25
|
+
tab_spaces: 2
|
|
26
|
+
glade_box: !ruby/object:VR::SimpleComboBoxEntry {}
|
|
27
|
+
browser_box: !ruby/object:VR::SimpleComboBoxEntry {}
|
|
28
|
+
buttonChooseFolder: "..."
|
|
29
|
+
vbox1: !ruby/object:Gtk::VBox {}
|
|
30
|
+
label7: 'Editor Font:'
|
|
31
|
+
label3: 'Back-up Path:'
|
|
32
|
+
window1: !ruby/object:Gtk::Window {}
|
|
33
|
+
hbuttonbox1: !ruby/object:Gtk::HButtonBox {}
|
|
34
|
+
buttonCancel: Cancel
|
|
35
|
+
label8: 'RDoc Command Line: '
|
|
36
|
+
table1: !ruby/object:Gtk::Table {}
|
|
37
|
+
buttonTryBrowser: Try
|
|
38
|
+
buttonSave: Save
|
|
39
|
+
hboxBrowser: !ruby/object:Gtk::HBox {}
|
|
40
|
+
hboxGlade: !ruby/object:Gtk::HBox {}
|
|
41
|
+
label1: "<big><big><b>Visual Ruby Settings</b></big></big>"
|
|
42
|
+
label2: 'Browser Command Line:'
|
|
43
|
+
label4: 'Spaces for Each Tab in Editor:'
|
|
44
|
+
label5: 'Glade Command Line:'
|
|
45
|
+
label6: 'Command Line when "Run" is pressed:'
|
|
46
|
+
hbox1: !ruby/object:Gtk::HBox {}
|
|
47
|
+
hbox2: !ruby/object:Gtk::HBox {}
|
|
48
|
+
hbox3: !ruby/object:Gtk::HBox {}
|
|
49
|
+
hbox4: !ruby/object:Gtk::HBox {}
|
|
50
|
+
buttonTryGlade: Try
|
|
@@ -28,8 +28,8 @@ ChoosePerson.new.show_glade()
|
|
|
28
28
|
# create_table :people do |table|
|
|
29
29
|
# table.column :name, :string
|
|
30
30
|
# table.column :address, :string
|
|
31
|
-
#
|
|
32
|
-
#
|
|
31
|
+
# table.column :phone, :string
|
|
32
|
+
# table.column :email, :string
|
|
33
33
|
# end
|
|
34
34
|
#end
|
|
35
35
|
#
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
class ChoosePerson < VR::ListView
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
include GladeGUI
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
def initialize()
|
|
7
|
+
super(:person => Person) # Person class
|
|
8
|
+
end
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
def before_show()
|
|
11
|
+
@builder["scrolledwindow1"].add(self)
|
|
12
|
+
Person.all.each do |p|
|
|
13
|
+
row = add_row(:person => p)
|
|
14
|
+
end
|
|
15
15
|
self.show
|
|
16
|
-
|
|
16
|
+
end
|
|
17
17
|
|
|
18
18
|
def buttonShow__clicked(*a)
|
|
19
19
|
return unless row = selected_rows.first
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
class Person < ActiveRecord::Base
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
include GladeGUI
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
def before_show
|
|
6
6
|
@builder[:labelName].label = "<big>#{name}</big>"
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
set_glade_all() # updates entry boxes
|
|
8
|
+
end
|
|
9
9
|
|
|
10
10
|
# this is what shows in the listview
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
def to_s
|
|
12
|
+
"#{self.name} (#{self.email}) #{self.phone}"
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def buttonSave__clicked(*a)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
--- !ruby/object:VR_ENV
|
|
2
|
+
vr_yaml_file: ".vr_settings.yaml"
|
|
3
|
+
width: 1046
|
|
4
|
+
height: 718
|
|
5
|
+
panel_pos: 360
|
|
6
|
+
notebook_panel_position: 400
|
|
7
|
+
run_command_line: ruby main.rb
|
|
8
|
+
open_files:
|
|
9
|
+
- "/home/eric/vrp/vr3/examples/active_record2/main.rb"
|
|
10
|
+
- "/home/eric/vrp/vr3/examples/active_record2/bin/CompanyGUI.rb"
|
|
11
|
+
- "/home/eric/vrp/vr3/examples/active_record2/bin/Employer.rb"
|
|
12
|
+
- "/home/eric/vrp/vr3/examples/active_record2/bin/Employee.rb"
|
|
13
|
+
open_folders:
|
|
14
|
+
- "/home/eric/vrp/vr3/examples/active_record2"
|
|
15
|
+
- "/home/eric/vrp/vr3/examples/active_record2/bin"
|
|
16
|
+
- "/home/eric/vrp/vr3/examples/active_record2/bin/glade"
|
|
17
|
+
- "/home/eric/vrp/vr3/examples/active_record2/db"
|
|
18
|
+
current_file: "/home/eric/vrp/vr3/examples/active_record2/bin/Employee.rb"
|
|
19
|
+
current_line: 22
|
|
20
|
+
rdoc_command_line: rdoc -x README
|
|
21
|
+
builder: !ruby/object:Gtk::Builder {}
|
|
22
|
+
filename: ".vr_settings.yaml"
|
|
23
|
+
settings_file_version: 1
|
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
|
|
2
2
|
class CompanyGUI
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
include GladeGUI
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
#
|
|
11
|
-
|
|
7
|
+
def before_show()
|
|
8
|
+
@employer_view = VR::ListView.new(:employer => Employer, :address => String, :company_type => String)
|
|
9
|
+
@builder["scroll_employer"].add(@employer_view)
|
|
10
|
+
# @employer_view.selection.signal_connect("changed") { employer_view__changed }
|
|
11
|
+
@employer_view.col_width(:employer => 160, :address => 340, :company_type => 180)
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
##
|
|
16
|
-
|
|
13
|
+
@employee_view = VR::ListView.new(:employer => Employer, :employee => Employee, :address => String, :balance => String)
|
|
14
|
+
@builder["scroll_employee"].add(@employee_view)
|
|
15
|
+
## @employee_view.selection.signal_connect("changed") { employee_view__changed }
|
|
16
|
+
@employee_view.col_width(:employer => 160, :employee => 150, :address => 320)
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
@paycheck_view = VR::ListView.new(:employee => Employee, :date => DateTime, :description => String, :amt => Paycheck)
|
|
19
|
+
@builder["scroll_paycheck"].add(@paycheck_view)
|
|
20
|
+
@paycheck_view.col_width(:employee => 200, :date => 100, :description => 220, :amt => 100)
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
Employer.all.each do |e|
|
|
23
|
+
row = @employer_view.add_row
|
|
24
|
+
row[:employer] = e
|
|
25
|
+
row.load_object(e)
|
|
26
|
+
end
|
|
27
27
|
@builder[:window1].show_all
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
28
|
+
# @employer_view.select_row()
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def employer_view__cursor_changed(*a)
|
|
33
|
+
return unless row = @employer_view.selected_rows[0]
|
|
34
|
+
@employee_view.model.clear
|
|
35
|
+
Employee.where(:employer_id => row[:employer].id).each do |e|
|
|
36
|
+
row = @employee_view.add_row
|
|
37
|
+
row[:employee] = e
|
|
38
|
+
row.load_object(e)
|
|
39
|
+
end
|
|
40
|
+
# @employee_view.select_row(0)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def employee_view__cursor_changed(*a)
|
|
44
|
+
return unless row = @employee_view.selected_rows[0]
|
|
45
|
+
@paycheck_view.model.clear
|
|
46
|
+
Paycheck.where(:employee_id => row[:employee].id).each do |e|
|
|
47
|
+
row = @paycheck_view.add_row
|
|
48
|
+
row.load_object(e) #this loads employee object
|
|
49
|
+
row[:amt] = e
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
end
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
|
|
2
2
|
class Employee < ActiveRecord::Base
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
has_many :paychecks
|
|
4
|
+
belongs_to :employer
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
include GladeGUI
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
def visual_attributes
|
|
9
|
+
bal = balance().to_f
|
|
10
|
+
hash = { :text => name }
|
|
11
|
+
hash[:foreground] = (bal < 0) ? "white" : "black"
|
|
12
12
|
hash[:background] = (bal < 0) ? "red" : "white"
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
return hash
|
|
14
|
+
end
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
#
|
|
19
|
-
|
|
16
|
+
def balance()
|
|
17
|
+
Paycheck.sum(:amount, :conditions => "employee_id = #{id}").round(2).to_s
|
|
18
|
+
# Paycheck.find("employee_id = #{id}").calculate(:sum, :amount).round(2).to_s
|
|
19
|
+
end
|
|
20
20
|
|
|
21
21
|
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
class Employer < ActiveRecord::Base
|
|
3
|
-
|
|
3
|
+
has_many :employees
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
include GladeGUI
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
def to_s # this is what shows in the VR::ListView
|
|
8
|
+
name
|
|
9
|
+
end
|
|
10
10
|
|
|
11
11
|
end
|
|
@@ -29,18 +29,18 @@ CompanyGUI.new.show_glade()
|
|
|
29
29
|
# create_table :employers do |table|
|
|
30
30
|
# table.column :name, :string
|
|
31
31
|
# table.column :address, :string
|
|
32
|
-
#
|
|
32
|
+
# table.column :company_type, :string
|
|
33
33
|
# end
|
|
34
34
|
# create_table :employees do |table|
|
|
35
|
-
#
|
|
35
|
+
# table.column :employer_id, :integer
|
|
36
36
|
# table.column :name, :string
|
|
37
37
|
# table.column :address, :string
|
|
38
38
|
# end
|
|
39
39
|
# create_table :paychecks do |table|
|
|
40
|
-
#
|
|
40
|
+
# table.column :employee_id, :integer
|
|
41
41
|
# table.column :date, :date
|
|
42
42
|
# table.column :description, :string
|
|
43
|
-
#
|
|
43
|
+
# table.column :amount, :float
|
|
44
44
|
# end
|
|
45
45
|
#
|
|
46
46
|
#end
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
# If the flag :input_text is set, it will show a textbox. Then it will return
|
|
4
4
|
# the String value of the textbox, false or nil.
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
6
|
+
# Returns:
|
|
7
|
+
# true or String = :button_yes pressed
|
|
8
|
+
# false = :button_no pressed
|
|
9
|
+
# nil = "x" button closed window
|
|
10
10
|
#
|
|
11
11
|
#
|
|
12
12
|
# the flags for the alert() method are:
|
|
@@ -25,56 +25,46 @@
|
|
|
25
25
|
class AlertBoxDemo
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
include GladeGUI
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
def buttonSimple__clicked(*a)
|
|
31
|
+
alert "I'll be back"
|
|
32
|
+
end
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
#its best to include a parent so alert box always on top:
|
|
35
|
+
def buttonYesNo__clicked(*a)
|
|
36
|
+
if alert("Do you want to continue?", :button_yes => "Yes", :button_no => "No", :parent => self) #on top
|
|
37
|
+
alert "Ok we'll contine..." # not always on top
|
|
38
|
+
else
|
|
39
|
+
alert "Ok we'll abort!"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
# input boxes will return the string entered, false, or nil for "X" button:
|
|
44
|
+
def buttonInput__clicked(*a)
|
|
45
|
+
if answer = alert("Enter your full name:", :input_text => "Ralph",
|
|
46
|
+
:button_yes => "Go", :headline => "Enter Name")
|
|
47
|
+
alert "You entered:\n\n<b>" + answer + "</b>"
|
|
48
|
+
elsif answer == false
|
|
49
|
+
alert "You pressed the <b>Cancel</b> button"
|
|
50
|
+
elsif answer.nil?
|
|
51
|
+
alert "You pressed the <b>'X'</b> button"
|
|
52
|
+
else
|
|
53
|
+
# will never get here
|
|
54
|
+
end
|
|
55
|
+
end
|
|
41
56
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
# input boxes will return the string entered, false, or nil for "X" button:
|
|
54
|
-
def buttonInput__clicked(*a)
|
|
55
|
-
if answer = alert("Enter your full name:", :input_text => "Ralph",
|
|
56
|
-
:button_yes => "Go", :headline => "Enter Name")
|
|
57
|
-
alert "You entered:\n\n<b>" + answer + "</b>"
|
|
58
|
-
elsif answer == false
|
|
59
|
-
alert "You pressed the <b>Cancel</b> button"
|
|
60
|
-
elsif answer.nil?
|
|
61
|
-
alert "You pressed the <b>'X'</b> button"
|
|
62
|
-
else
|
|
63
|
-
alert "Error: Should return String (yes), false (no) or nil (quit button)"
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def buttonQuestion__clicked(*a)
|
|
68
|
-
if answer = alert("Your pants are on <b><u>fire</u></b>. What do you want to do?", :width => 500, :button_cancel => "Quit",
|
|
69
|
-
:button_yes => "Jump in Pool", :button_no => "Panic!", :title => "Pants on Fire", :headline => "Warning")
|
|
70
|
-
alert "Get going!"
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def buttonQuit__clicked(*a)
|
|
76
|
-
@builder[:window1].destroy
|
|
77
|
-
end
|
|
57
|
+
def buttonQuestion__clicked(*a)
|
|
58
|
+
if answer = alert("Your pants are on <b><u>fire</u></b>. What do you want to do?", :width => 500, :button_cancel => "Quit",
|
|
59
|
+
:button_yes => "Jump in Pool", :button_no => "Panic!",
|
|
60
|
+
:title => "Pants on Fire", :headline => "Warning")
|
|
61
|
+
alert "Get going!\n(alert() returned true)"
|
|
62
|
+
elsif answer == false # Panic
|
|
63
|
+
alert "Start Panicing!\n(alert() returned false)"
|
|
64
|
+
else
|
|
65
|
+
alert "Ok Avoid the question.\n(alert() returned nil)"
|
|
66
|
+
end
|
|
67
|
+
end
|
|
78
68
|
|
|
79
69
|
end
|
|
80
70
|
|