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
@@ -1,20 +1,20 @@
|
|
1
1
|
|
2
2
|
class DataObjectGUI
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
include GladeGUI
|
5
|
+
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
def initialize(name, address, phone, email)
|
8
|
+
@name = name
|
9
|
+
@address = address
|
10
|
+
@phone = phone
|
11
|
+
@email = email
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def buttonShow__clicked(*args)
|
15
|
+
get_glade_variables() #sets values of @name, @address etc. to values from glade form.
|
16
|
+
alert "Curent values:\n\n#{@name}\n#{@address}\n#{@email}\n#{@phone}\n"
|
17
|
+
end
|
18
18
|
|
19
19
|
|
20
20
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
--- !ruby/object:VR_ENV
|
2
|
+
width: 984
|
3
|
+
height: 711
|
4
|
+
panel_pos: 491
|
5
|
+
run_command_line: ruby main.rb
|
6
|
+
open_files:
|
7
|
+
- "/home/eric/vrp/vr3/examples/treeview/main.rb"
|
8
|
+
- "/home/eric/vrp/vr3/examples/treeview/bin/MyClass.rb"
|
9
|
+
open_folders:
|
10
|
+
- "/home/eric/vrp/vr3/examples/treeview"
|
11
|
+
- "/home/eric/vrp/vr3/examples/treeview/bin"
|
12
|
+
current_file: "/home/eric/vrp/vr3/examples/treeview/main.rb"
|
13
|
+
rdoc_command_line: rdoc -x README
|
14
|
+
vr_yaml_file: ".vr_settings.yaml"
|
15
|
+
notebook_panel_position: 400
|
16
|
+
current_line: 14
|
17
|
+
settings_file_version: 1
|
@@ -1,24 +1,25 @@
|
|
1
1
|
|
2
2
|
class MyClass #(change name)
|
3
3
|
|
4
|
-
|
4
|
+
include GladeGUI
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
6
|
+
def before_show()
|
7
|
+
@tree = VR::TreeView.new(:name => String, :age => Integer)
|
8
|
+
top = @tree.add_row(nil)
|
9
|
+
top[:name] = "Family"
|
10
|
+
eric = @tree.add_row(top, :name => "Eric", :age => 47)
|
11
|
+
joe = @tree.add_row(eric, :name => "Joe", :age => 15)
|
12
|
+
ann = @tree.add_row(eric, :name => "Ann", :age => 17)
|
13
|
+
pat = @tree.add_row(ann, :name => "Pat", :age => 2)
|
14
|
+
steve = @tree.add_row(top, :name => "Steve", :age => 51)
|
15
|
+
|
16
|
+
#alternate format
|
17
|
+
harvey = @tree.add_row(top)
|
18
|
+
harvey[:name] = "Harvey"
|
19
|
+
harvey[:age] = 60
|
20
|
+
@scrolledwindow1 = @tree #adds tree to the scrolledwindow
|
21
|
+
@tree.show
|
22
|
+
end
|
22
23
|
|
23
24
|
end
|
24
25
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!-- Generated with glade 3.
|
2
|
+
<!-- Generated with glade 3.16.1 -->
|
3
3
|
<interface>
|
4
4
|
<requires lib="gtk+" version="3.0"/>
|
5
5
|
<object class="GtkWindow" id="window1">
|
@@ -9,14 +9,69 @@
|
|
9
9
|
<property name="modal">True</property>
|
10
10
|
<property name="window_position">center</property>
|
11
11
|
<property name="default_width">300</property>
|
12
|
-
<property name="default_height">
|
12
|
+
<property name="default_height">300</property>
|
13
13
|
<child>
|
14
|
-
<object class="
|
14
|
+
<object class="GtkBox" id="box1">
|
15
15
|
<property name="visible">True</property>
|
16
|
-
<property name="can_focus">
|
17
|
-
<property name="
|
16
|
+
<property name="can_focus">False</property>
|
17
|
+
<property name="margin_left">20</property>
|
18
|
+
<property name="margin_right">20</property>
|
19
|
+
<property name="margin_top">20</property>
|
20
|
+
<property name="margin_bottom">20</property>
|
21
|
+
<property name="orientation">vertical</property>
|
22
|
+
<property name="spacing">10</property>
|
18
23
|
<child>
|
19
|
-
<
|
24
|
+
<object class="GtkLabel" id="label1">
|
25
|
+
<property name="visible">True</property>
|
26
|
+
<property name="can_focus">False</property>
|
27
|
+
<property name="label" translatable="yes"><big>TreeView Demo</big></property>
|
28
|
+
<property name="use_markup">True</property>
|
29
|
+
</object>
|
30
|
+
<packing>
|
31
|
+
<property name="expand">False</property>
|
32
|
+
<property name="fill">True</property>
|
33
|
+
<property name="position">0</property>
|
34
|
+
</packing>
|
35
|
+
</child>
|
36
|
+
<child>
|
37
|
+
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
38
|
+
<property name="visible">True</property>
|
39
|
+
<property name="can_focus">True</property>
|
40
|
+
<property name="shadow_type">in</property>
|
41
|
+
<child>
|
42
|
+
<placeholder/>
|
43
|
+
</child>
|
44
|
+
</object>
|
45
|
+
<packing>
|
46
|
+
<property name="expand">True</property>
|
47
|
+
<property name="fill">True</property>
|
48
|
+
<property name="position">1</property>
|
49
|
+
</packing>
|
50
|
+
</child>
|
51
|
+
<child>
|
52
|
+
<object class="GtkButtonBox" id="buttonbox1">
|
53
|
+
<property name="visible">True</property>
|
54
|
+
<property name="can_focus">False</property>
|
55
|
+
<property name="layout_style">end</property>
|
56
|
+
<child>
|
57
|
+
<object class="GtkButton" id="buttonCancel">
|
58
|
+
<property name="label" translatable="yes">Cancel</property>
|
59
|
+
<property name="visible">True</property>
|
60
|
+
<property name="can_focus">True</property>
|
61
|
+
<property name="receives_default">True</property>
|
62
|
+
</object>
|
63
|
+
<packing>
|
64
|
+
<property name="expand">False</property>
|
65
|
+
<property name="fill">True</property>
|
66
|
+
<property name="position">0</property>
|
67
|
+
</packing>
|
68
|
+
</child>
|
69
|
+
</object>
|
70
|
+
<packing>
|
71
|
+
<property name="expand">False</property>
|
72
|
+
<property name="fill">False</property>
|
73
|
+
<property name="position">2</property>
|
74
|
+
</packing>
|
20
75
|
</child>
|
21
76
|
</object>
|
22
77
|
</child>
|
@@ -1,15 +1,15 @@
|
|
1
1
|
|
2
2
|
class MyClass #(change name)
|
3
3
|
|
4
|
-
|
4
|
+
include GladeGUI
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
#code that runs immediately before the #show method of this class
|
7
|
+
def before_show()
|
8
|
+
@var1 = "Hello World"
|
9
|
+
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
def widget__clicked(*args)
|
12
|
+
#code that runs when widget named "widget" in glade is clicked.
|
13
|
+
end
|
14
14
|
|
15
15
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
--- !ruby/object:VR_ENV
|
2
|
+
browser: firefox
|
3
|
+
width: 800
|
4
|
+
height: 600
|
5
|
+
panel_pos: 360
|
6
|
+
backup_path: /home/eric
|
7
|
+
tab_spaces: 2
|
8
|
+
run_command_line: ruby main.rb
|
9
|
+
open_files:
|
10
|
+
- /home/eric/vrp/vrx/Untitled
|
11
|
+
open_folders: []
|
12
|
+
current_file: /home/eric/vrp/vrx/Untitled
|
13
|
+
glade_path: glade-3
|
14
|
+
font_name: Monospace 10
|
15
|
+
rdoc_command_line: rdoc -x README
|
@@ -1,15 +1,15 @@
|
|
1
1
|
|
2
2
|
class MyClass #(change name)
|
3
3
|
|
4
|
-
|
4
|
+
include GladeGUI
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def before_show()
|
7
|
+
@button1 = "Hello World"
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def button1__clicked(*args)
|
11
|
+
@builder["button1"].label = "Goodbye World"
|
12
|
+
end
|
13
13
|
|
14
14
|
end
|
15
15
|
|
data/vr
CHANGED
@@ -1,41 +1,38 @@
|
|
1
|
-
require "gtk3"
|
2
|
-
|
3
|
-
def load_everything
|
4
|
-
require "rubygems"
|
5
|
-
require "gtksourceview3"
|
6
|
-
require "yaml" #needed
|
7
|
-
require "net/http" #needed
|
8
|
-
require "net/https" #needed
|
9
|
-
require "find" #needed
|
10
|
-
require "fileutils" #needed
|
11
|
-
require "rubygems/installer"
|
12
|
-
require "rubygems/uninstaller"
|
13
|
-
require "rubygems/package"
|
14
|
-
require "rubygems/specification"
|
15
|
-
require "date"
|
16
|
-
|
17
|
-
require 'require_all'
|
18
|
-
|
19
|
-
require_rel 'vrlib/lib/'
|
20
|
-
require_rel 'bin/'
|
21
|
-
|
22
|
-
VR_Main.new(ARGV).show_glade()
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
Gtk.main
|
40
|
-
|
41
|
-
|
1
|
+
require "gtk3"
|
2
|
+
|
3
|
+
def load_everything
|
4
|
+
require "rubygems"
|
5
|
+
require "gtksourceview3"
|
6
|
+
require "yaml" #needed
|
7
|
+
require "net/http" #needed
|
8
|
+
require "net/https" #needed
|
9
|
+
require "find" #needed
|
10
|
+
require "fileutils" #needed
|
11
|
+
require "rubygems/installer"
|
12
|
+
require "rubygems/uninstaller"
|
13
|
+
require "rubygems/package"
|
14
|
+
require "rubygems/specification"
|
15
|
+
require "date"
|
16
|
+
|
17
|
+
require 'require_all'
|
18
|
+
|
19
|
+
require_rel 'vrlib/lib/'
|
20
|
+
require_rel 'bin/'
|
21
|
+
|
22
|
+
VR_Main.new(ARGV, @bldr).show_glade()
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
@bldr = Gtk::Builder.new
|
27
|
+
@bldr << File.join(File.dirname(__FILE__), "bin", "main", "glade", "Splash.glade")
|
28
|
+
@bldr[:image1].file = File.join(File.dirname(__FILE__), "img", "splash.png")
|
29
|
+
@bldr[:window1].show_all
|
30
|
+
|
31
|
+
|
32
|
+
GLib::Timeout.add(40) {
|
33
|
+
load_everything
|
34
|
+
}
|
35
|
+
|
36
|
+
Gtk.main
|
37
|
+
|
38
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/vrlib/lib/Alert.rb
CHANGED
@@ -1,66 +1,109 @@
|
|
1
1
|
|
2
2
|
module VR
|
3
3
|
|
4
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
#so it can be passed by reference
|
53
|
-
class DialogAnswer
|
54
|
-
attr_accessor :answer
|
4
|
+
class Alert # :nodoc:
|
5
|
+
|
6
|
+
attr_accessor :answer
|
7
|
+
|
8
|
+
include GladeGUI
|
9
|
+
|
10
|
+
def initialize(message, answer, flags = {})
|
11
|
+
@flags = flags
|
12
|
+
@answer = answer
|
13
|
+
@message = message
|
14
|
+
@p = nil
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def before_show
|
19
|
+
@flags[:title] = @flags[:title] ? @flags[:title] : @flags[:headline]
|
20
|
+
@builder[:window1].title = @flags[:title] if @flags[:title]
|
21
|
+
@builder[:window1].resize(@flags[:width],100) if @flags[:width].to_i > 100
|
22
|
+
@builder[:headline].show if @flags[:headline]
|
23
|
+
|
24
|
+
if text = @flags[:input_text]
|
25
|
+
@flags[:button_yes] ||= "Save"
|
26
|
+
@flags[:button_no] ||= "Cancel"
|
27
|
+
@builder[:input_text].show
|
28
|
+
end
|
29
|
+
|
30
|
+
@builder[:button_no].show if @flags[:button_no]
|
31
|
+
@builder[:button_cancel].show if @flags[:button_cancel]
|
32
|
+
set_glade_hash(@flags)
|
33
|
+
end
|
34
|
+
|
35
|
+
def button_yes__clicked(but)
|
36
|
+
@answer.answer = @flags[:input_text] ? @builder[:input_text].text : true
|
37
|
+
@builder[:window1].destroy
|
38
|
+
end
|
39
|
+
|
40
|
+
def button_no__clicked(but)
|
41
|
+
@answer.answer = false
|
42
|
+
@builder[:window1].destroy
|
43
|
+
end
|
44
|
+
|
45
|
+
def button_cancel__clicked(but) #answer stays nil
|
46
|
+
@builder[:window1].destroy
|
47
|
+
end
|
48
|
+
|
49
|
+
|
55
50
|
end
|
56
51
|
|
57
|
-
|
52
|
+
#so it can be passed by reference
|
53
|
+
class DialogAnswer # :nodoc:
|
54
|
+
attr_accessor :answer
|
55
|
+
end
|
58
56
|
|
57
|
+
end
|
59
58
|
|
59
|
+
# The alert method creates a pop-up alert in your program. It creates a modal
|
60
|
+
# window that halts execution of your code until the user closes it. Its great
|
61
|
+
# for displaying messages and debugging. It also has the option of displaying
|
62
|
+
# a text entry box for getting text input from the user. This small tool can save
|
63
|
+
# hundreds of lines of code in your programs. It can be used extesnively to
|
64
|
+
# display all types of messages and request all types of user input.
|
65
|
+
#
|
66
|
+
# There is an example project called "alert_box" in the home/visualruby/examples folder
|
67
|
+
# that shows several ways to use this versitle method.
|
68
|
+
#
|
69
|
+
# The alert box can disply 1, 2 or 3 buttons. The first button is denoted using the symbol: :button_yes
|
70
|
+
# button and is always displayed. You can add a :button_no button and a :button_cancel
|
71
|
+
# as well. The alert method will return a value based on the button pressed:
|
72
|
+
#
|
73
|
+
# Returns:
|
74
|
+
# true or String = :button_yes pressed (returns user input String when its a text entry box)
|
75
|
+
# false = :button_no pressed
|
76
|
+
# nil = :button_cancel pressed
|
77
|
+
# nil = "x" button closed window
|
78
|
+
#
|
79
|
+
# The first argument is a text message to display. It is the only required argument.
|
80
|
+
# If you just provide a text message, the message will pop-up with a button that says "Ok"
|
81
|
+
# that closes the window.
|
82
|
+
#
|
83
|
+
# The second, optional argument is a hash of flags that can configure the alert box to
|
84
|
+
# have much more functionality:
|
85
|
+
#
|
86
|
+
# :buton_yes = label for button that returns true (default: "Ok", "Save" when input_text is set))
|
87
|
+
# :button_no = label for button that returns false (default "Cancel" when input_text is set)
|
88
|
+
# :button_cancel = label for button that returns nil
|
89
|
+
# :input_text = default text for input box. Triggers appearance of input box.
|
90
|
+
# :width = with of window (used to make longer messages with wrapping look good.)
|
91
|
+
# :title = title of the window (appears in bar at top) Default = :headline
|
92
|
+
# :headline = large text that appears at the top.
|
93
|
+
# :parent = reference to parent window. Alert box will always be on top of this parent. Usually=self!
|
94
|
+
#
|
95
|
+
# ALL THESE FLAGS ARE OPTIONAL
|
96
|
+
#
|
97
|
+
# If you want to add these buttons, just set their values to whatever text you want them to
|
98
|
+
# display. For example, :button_no => "Abort Process" will cause the second button, to display
|
99
|
+
# "Abort Process" and if the user clicks it, the alert method will return false.
|
100
|
+
#
|
101
|
+
# There are many examples in the "alert_box" example project.
|
102
|
+
#
|
60
103
|
def alert(msg, flags = {})
|
61
|
-
|
62
|
-
|
63
|
-
|
104
|
+
@answer = VR::DialogAnswer.new()
|
105
|
+
VR::Alert.new(msg, @answer, flags).show_glade(flags[:parent])
|
106
|
+
return @answer.answer
|
64
107
|
end
|
65
108
|
|
66
109
|
|