visualruby 1.0.19 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/Splash.rb +40 -0
  3. data/bin/editor/VR_Document.rb +81 -74
  4. data/bin/editor/VR_TabSearch.rb +5 -7
  5. data/bin/editor/VR_Tabs.rb +57 -36
  6. data/bin/editor/VR_TextShell.rb +12 -34
  7. data/bin/editor/VR_TextViewCommon.rb +9 -28
  8. data/bin/main/NewProjectGUI.rb +14 -13
  9. data/bin/main/OpenProject.rb +69 -0
  10. data/bin/main/ProjectChooserView.rb +3 -2
  11. data/bin/main/ProjectTree.rb +25 -0
  12. data/bin/main/RubygemsAPI.rb +15 -11
  13. data/bin/main/VR_ENV.rb +38 -60
  14. data/bin/main/VR_ENV_GLOBAL.rb +45 -44
  15. data/bin/main/VR_File_Tree.rb +29 -21
  16. data/bin/main/VR_Local_Gem_Tree.rb +4 -19
  17. data/bin/main/VR_Main.rb +128 -144
  18. data/bin/main/VR_Remote_Gem_Tree.rb +6 -19
  19. data/bin/main/glade/NewProjectGUI.glade +94 -98
  20. data/bin/main/glade/OpenProject.glade +259 -0
  21. data/bin/main/glade/RubygemsAPI.glade +98 -62
  22. data/bin/main/glade/VR_ENV.glade +46 -55
  23. data/bin/main/glade/VR_ENV_GLOBAL.glade +251 -180
  24. data/bin/main/glade/VR_File_Tree.glade +25 -16
  25. data/bin/main/glade/VR_Local_Gem_Tree.glade +16 -8
  26. data/bin/main/glade/VR_Main.glade +410 -449
  27. data/bin/main/glade/VR_Remote_Gem_Tree.glade +33 -31
  28. data/bin/tools/VR_Tools.rb +60 -46
  29. data/{visualruby_examples → examples}/active_record/active_record.rb +16 -10
  30. data/{visualruby_examples → examples}/active_record/bin/ChoosePerson.rb +7 -0
  31. data/examples/active_record/bin/Person.rb +21 -0
  32. data/examples/active_record/bin/glade/ChoosePerson.glade +89 -0
  33. data/examples/active_record/bin/glade/Person.glade +197 -0
  34. data/{visualruby_examples → examples}/active_record/db/development.sqlite3 +0 -0
  35. data/{visualruby_examples → examples}/active_record2/bin/CompanyGUI.rb +7 -7
  36. data/{visualruby_examples → examples}/active_record2/bin/Employee.rb +0 -0
  37. data/{visualruby_examples → examples}/active_record2/bin/Employer.rb +0 -0
  38. data/{visualruby_examples → examples}/active_record2/bin/Paycheck.rb +0 -0
  39. data/examples/active_record2/bin/glade/CompanyGUI.glade +149 -0
  40. data/examples/active_record2/bin/glade/Employee.glade +126 -0
  41. data/{visualruby_examples → examples}/active_record2/bin/glade/Employer.glade +0 -0
  42. data/{visualruby_examples → examples}/active_record2/bin/glade/Paycheck.glade +0 -0
  43. data/{visualruby_examples → examples}/active_record2/db/development.sqlite3 +0 -0
  44. data/{visualruby_examples → examples}/active_record2/main.rb +15 -9
  45. data/examples/alert_box/bin/AlertBoxDemo.rb +80 -0
  46. data/examples/alert_box/bin/glade/AlertBoxDemo.glade +234 -0
  47. data/examples/alert_box/main.rb +12 -0
  48. data/{visualruby_examples → examples}/all_widgets/bin/AllWidgets.rb +18 -10
  49. data/{visualruby_examples → examples}/all_widgets/bin/glade/AllWidgets.glade +52 -16
  50. data/{visualruby_examples → examples}/all_widgets/bin/splash.png +0 -0
  51. data/examples/all_widgets/main.rb +12 -0
  52. data/{visualruby_examples → examples}/calculator/bin/Calculator.rb +23 -22
  53. data/{visualruby_examples → examples}/calculator/bin/glade/Calculator.glade +81 -51
  54. data/examples/calculator/main.rb +13 -0
  55. data/examples/child_window/bin/ChildWindowDemo.rb +52 -0
  56. data/examples/child_window/bin/ModalWindow.rb +9 -0
  57. data/examples/child_window/bin/ModelessWindow.rb +9 -0
  58. data/examples/child_window/bin/MyChildClass.rb +21 -0
  59. data/examples/child_window/bin/glade/ChildWindowDemo.glade +87 -0
  60. data/examples/child_window/bin/glade/ModalWindow.glade +61 -0
  61. data/examples/child_window/bin/glade/ModelessWindow.glade +61 -0
  62. data/{visualruby_examples → examples}/child_window/bin/glade/MyChildClass.glade +14 -12
  63. data/examples/child_window/main.rb +12 -0
  64. data/{visualruby_examples → examples}/drag_drop/bin/DragDropDemo.rb +9 -10
  65. data/examples/drag_drop/bin/glade/DragDropDemo.glade +161 -0
  66. data/{visualruby_examples → examples}/drag_drop/img/folder.png +0 -0
  67. data/{visualruby_examples → examples}/drag_drop/img/glade.png +0 -0
  68. data/{visualruby_examples → examples}/drag_drop/img/gtk-edit.png +0 -0
  69. data/{visualruby_examples → examples}/drag_drop/img/obj.png +0 -0
  70. data/{visualruby_examples → examples}/drag_drop/img/png.png +0 -0
  71. data/{visualruby_examples → examples}/drag_drop/img/rb.png +0 -0
  72. data/{visualruby_examples → examples}/drag_drop/img/ruby.png +0 -0
  73. data/{visualruby_examples → examples}/drag_drop/img/unknown.png +0 -0
  74. data/examples/drag_drop/main.rb +11 -0
  75. data/examples/filetreeview/bin/ProjectTree.rb +32 -0
  76. data/examples/filetreeview/bin/ProjectTreeGUI.rb +28 -0
  77. data/examples/filetreeview/bin/glade/ProjectTreeGUI.glade +156 -0
  78. data/examples/filetreeview/main.rb +13 -0
  79. data/{visualruby_examples → examples}/listview/bin/SongListView.rb +24 -20
  80. data/{visualruby_examples → examples}/listview/bin/SongListViewGUI.rb +12 -11
  81. data/{visualruby_examples → examples}/listview/bin/audio-x-generic.png +0 -0
  82. data/examples/listview/bin/glade/SongListViewGUI.glade +195 -0
  83. data/examples/listview/main.rb +10 -0
  84. data/examples/listview_objects/bin/DataObject.rb +53 -0
  85. data/{visualruby_examples → examples}/listview_objects/bin/ListViewObjects.rb +7 -4
  86. data/examples/listview_objects/bin/ListViewObjectsGUI.rb +26 -0
  87. data/examples/listview_objects/bin/glade/DataObject.glade +196 -0
  88. data/examples/listview_objects/bin/glade/ListViewObjectsGUI.glade +87 -0
  89. data/examples/listview_objects/main.rb +12 -0
  90. data/examples/settings_file/bin/MainApp.rb +38 -0
  91. data/examples/settings_file/bin/SavableSettings.rb +39 -0
  92. data/examples/settings_file/bin/glade/MainApp.glade +87 -0
  93. data/examples/settings_file/bin/glade/SavableSettings.glade +162 -0
  94. data/examples/settings_file/main.rb +14 -0
  95. data/examples/settings_file/settings.yaml +15 -0
  96. data/examples/simple_ruby_gui/bin/DataObjectGUI.rb +21 -0
  97. data/examples/simple_ruby_gui/bin/glade/DataObjectGUI.glade +195 -0
  98. data/examples/simple_ruby_gui/main.rb +16 -0
  99. data/{visualruby_examples → examples}/treeview/bin/MyClass.rb +1 -5
  100. data/examples/treeview/bin/glade/MyClass.glade +24 -0
  101. data/examples/treeview/main.rb +13 -0
  102. data/skeleton/document/New.glade +3 -4
  103. data/skeleton/document/NewWindow.rb +1 -1
  104. data/skeleton/project/bin/MyClass.rb +2 -2
  105. data/skeleton/project/bin/glade/MyClass.glade +12 -26
  106. data/skeleton/project/main.rb +4 -8
  107. data/vr +41 -37
  108. data/vrlib/lib/Alert.rb +67 -0
  109. data/vrlib/lib/DragDrop.rb +90 -0
  110. data/vrlib/lib/GladeGUI.rb +433 -0
  111. data/vrlib/lib/IconHash.rb +18 -0
  112. data/vrlib/lib/SavableClass.rb +56 -0
  113. data/vrlib/lib/SimpleComboBoxEntry.rb +8 -0
  114. data/vrlib/lib/glade/Alert.glade +119 -0
  115. data/vrlib/lib/treeview/FileTreeView.rb +113 -0
  116. data/vrlib/lib/treeview/IterMethods.rb +82 -0
  117. data/vrlib/lib/treeview/ListView.rb +85 -0
  118. data/vrlib/lib/treeview/TreeView.rb +43 -0
  119. data/vrlib/lib/treeview/ViewCommon.rb +370 -0
  120. data/vrlib/lib/treeview/columns/CalendarCol.rb +89 -0
  121. data/vrlib/lib/treeview/columns/CellRendererCombo.rb +66 -0
  122. data/vrlib/lib/treeview/columns/CellRendererDate.rb +45 -0
  123. data/vrlib/lib/treeview/columns/CellRendererObject.rb +57 -0
  124. data/vrlib/lib/treeview/columns/CellRendererPhone.rb +45 -0
  125. data/vrlib/lib/treeview/columns/CellRendererPixbuf.rb +16 -0
  126. data/vrlib/lib/treeview/columns/CellRendererProgress.rb +17 -0
  127. data/vrlib/lib/treeview/columns/CellRendererSpin.rb +37 -0
  128. data/vrlib/lib/treeview/columns/CellRendererText.rb +38 -0
  129. data/vrlib/lib/treeview/columns/CellRendererToggle.rb +47 -0
  130. data/vrlib/lib/treeview/columns/ComboCol.rb +43 -0
  131. data/vrlib/lib/treeview/columns/CurrencyCol.rb +23 -0
  132. data/vrlib/lib/treeview/columns/DateCol.rb +20 -0
  133. data/vrlib/lib/treeview/columns/ImageCol.rb +27 -0
  134. data/vrlib/lib/treeview/columns/ProgressCol.rb +27 -0
  135. data/vrlib/lib/treeview/columns/SpinCol.rb +11 -0
  136. data/vrlib/lib/treeview/columns/TextCol.rb +65 -0
  137. data/vrlib/lib/treeview/columns/TreeViewColumn.rb +93 -0
  138. data/{bin/main/glade/ProjectChooserGUI.glade → vrlib/lib/treeview/columns/glade/CalendarCol.glade} +71 -63
  139. data/{bin/main/glade/Splash.glade → vrlib/lib/treeview/columns/glade/ImageCol.glade} +5 -6
  140. data/vrlib/lib/treeview/columns/glade/TextCol.glade +82 -0
  141. data/vrlib/rdoc_replace.yaml +77 -0
  142. data/vrlib/vrlib.rb +7 -0
  143. metadata +163 -136
  144. data/bin/editor/glade/VR_Document.glade +0 -160
  145. data/bin/main/ProjectChooserGUI.rb +0 -41
  146. data/bin/main/Splash.rb +0 -22
  147. data/visualruby_examples/active_record/.vr_settings.yaml +0 -47
  148. data/visualruby_examples/active_record/bin/Person.rb +0 -13
  149. data/visualruby_examples/active_record/bin/glade/ChoosePerson.glade +0 -61
  150. data/visualruby_examples/active_record/bin/glade/Person.glade +0 -148
  151. data/visualruby_examples/active_record2/.vr_settings.yaml +0 -16
  152. data/visualruby_examples/active_record2/bin/glade/CompanyGUI.glade +0 -167
  153. data/visualruby_examples/active_record2/bin/glade/Employee.glade +0 -123
  154. data/visualruby_examples/all_widgets/.vr_settings.yaml +0 -13
  155. data/visualruby_examples/all_widgets/main.rb +0 -14
  156. data/visualruby_examples/calculator/.vr_settings.yaml +0 -11
  157. data/visualruby_examples/calculator/main.rb +0 -13
  158. data/visualruby_examples/child_window/.vr_settings.yaml +0 -16
  159. data/visualruby_examples/child_window/bin/ChildWindowDemo.rb +0 -39
  160. data/visualruby_examples/child_window/bin/MyChildClass.rb +0 -40
  161. data/visualruby_examples/child_window/bin/glade/ChildWindowDemo.glade +0 -101
  162. data/visualruby_examples/child_window/main.rb +0 -13
  163. data/visualruby_examples/drag_drop/.vr_settings.yaml +0 -12
  164. data/visualruby_examples/drag_drop/bin/glade/DragDropDemo.glade +0 -143
  165. data/visualruby_examples/drag_drop/main.rb +0 -14
  166. data/visualruby_examples/listview/.vr_settings.yaml +0 -12
  167. data/visualruby_examples/listview/bin/glade/SongListViewGUI.glade +0 -220
  168. data/visualruby_examples/listview/main.rb +0 -19
  169. data/visualruby_examples/listview_objects/.vr_settings.yaml +0 -16
  170. data/visualruby_examples/listview_objects/bin/DataObject.rb +0 -32
  171. data/visualruby_examples/listview_objects/bin/DataObjectGUI.rb +0 -41
  172. data/visualruby_examples/listview_objects/bin/ListViewObjectsGUI.rb +0 -18
  173. data/visualruby_examples/listview_objects/bin/glade/DataObject.glade +0 -198
  174. data/visualruby_examples/listview_objects/bin/glade/ListViewObjectsGUI.glade +0 -102
  175. data/visualruby_examples/listview_objects/main.rb +0 -13
  176. data/visualruby_examples/simple_ruby_gui/.vr_settings.yaml +0 -16
  177. data/visualruby_examples/simple_ruby_gui/bin/DataObjectGUI.rb +0 -20
  178. data/visualruby_examples/simple_ruby_gui/bin/glade/DataObjectGUI.glade +0 -163
  179. data/visualruby_examples/simple_ruby_gui/main.rb +0 -16
  180. data/visualruby_examples/treeview/.vr_settings.yaml +0 -12
  181. data/visualruby_examples/treeview/bin/glade/MyClass.glade +0 -48
  182. data/visualruby_examples/treeview/main.rb +0 -14
@@ -0,0 +1,234 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Generated with glade 3.16.1 -->
3
+ <interface>
4
+ <requires lib="gtk+" version="3.0"/>
5
+ <object class="GtkWindow" id="window1">
6
+ <property name="visible">True</property>
7
+ <property name="can_focus">False</property>
8
+ <property name="title" translatable="yes">Alert Box Demo</property>
9
+ <property name="modal">True</property>
10
+ <property name="window_position">center-always</property>
11
+ <property name="default_width">300</property>
12
+ <property name="default_height">200</property>
13
+ <child>
14
+ <object class="GtkBox" id="box1">
15
+ <property name="visible">True</property>
16
+ <property name="can_focus">False</property>
17
+ <property name="orientation">vertical</property>
18
+ <child>
19
+ <object class="GtkLabel" id="label5">
20
+ <property name="visible">True</property>
21
+ <property name="can_focus">False</property>
22
+ <property name="margin_top">20</property>
23
+ <property name="label" translatable="yes">&lt;big&gt;Alert Box Examples&lt;/big&gt;</property>
24
+ <property name="use_markup">True</property>
25
+ </object>
26
+ <packing>
27
+ <property name="expand">False</property>
28
+ <property name="fill">True</property>
29
+ <property name="position">0</property>
30
+ </packing>
31
+ </child>
32
+ <child>
33
+ <object class="GtkGrid" id="grid1">
34
+ <property name="visible">True</property>
35
+ <property name="can_focus">False</property>
36
+ <property name="margin_left">20</property>
37
+ <property name="margin_right">20</property>
38
+ <property name="margin_top">20</property>
39
+ <property name="margin_bottom">20</property>
40
+ <property name="row_spacing">22</property>
41
+ <property name="column_spacing">15</property>
42
+ <child>
43
+ <object class="GtkLabel" id="label1">
44
+ <property name="visible">True</property>
45
+ <property name="can_focus">False</property>
46
+ <property name="xalign">0</property>
47
+ <property name="label" translatable="yes">&lt;big&gt; Simple Alert Box Example&lt;/big&gt;
48
+ This just shows a message on the screen. Its very useful for alerts and debugging.</property>
49
+ <property name="use_markup">True</property>
50
+ </object>
51
+ <packing>
52
+ <property name="left_attach">0</property>
53
+ <property name="top_attach">0</property>
54
+ <property name="width">1</property>
55
+ <property name="height">1</property>
56
+ </packing>
57
+ </child>
58
+ <child>
59
+ <object class="GtkButton" id="buttonSimple">
60
+ <property name="label" translatable="yes">Try</property>
61
+ <property name="visible">True</property>
62
+ <property name="can_focus">True</property>
63
+ <property name="receives_default">True</property>
64
+ <property name="valign">start</property>
65
+ </object>
66
+ <packing>
67
+ <property name="left_attach">1</property>
68
+ <property name="top_attach">0</property>
69
+ <property name="width">1</property>
70
+ <property name="height">1</property>
71
+ </packing>
72
+ </child>
73
+ <child>
74
+ <object class="GtkLabel" id="label4">
75
+ <property name="visible">True</property>
76
+ <property name="can_focus">False</property>
77
+ <property name="xalign">0</property>
78
+ <property name="label" translatable="yes">&lt;big&gt;Ask Any Question&lt;/big&gt;
79
+ Change the text on the buttons to ask anything</property>
80
+ <property name="use_markup">True</property>
81
+ </object>
82
+ <packing>
83
+ <property name="left_attach">0</property>
84
+ <property name="top_attach">4</property>
85
+ <property name="width">1</property>
86
+ <property name="height">1</property>
87
+ </packing>
88
+ </child>
89
+ <child>
90
+ <object class="GtkButton" id="buttonQuestion">
91
+ <property name="label" translatable="yes">Try</property>
92
+ <property name="visible">True</property>
93
+ <property name="can_focus">True</property>
94
+ <property name="receives_default">True</property>
95
+ <property name="valign">start</property>
96
+ </object>
97
+ <packing>
98
+ <property name="left_attach">1</property>
99
+ <property name="top_attach">4</property>
100
+ <property name="width">1</property>
101
+ <property name="height">1</property>
102
+ </packing>
103
+ </child>
104
+ <child>
105
+ <object class="GtkLabel" id="label3">
106
+ <property name="visible">True</property>
107
+ <property name="can_focus">False</property>
108
+ <property name="xalign">0</property>
109
+ <property name="label" translatable="yes">&lt;big&gt;Request Input Example&lt;/big&gt;
110
+ This example shows how you can ask the user to enter text into a textbox.</property>
111
+ <property name="use_markup">True</property>
112
+ </object>
113
+ <packing>
114
+ <property name="left_attach">0</property>
115
+ <property name="top_attach">3</property>
116
+ <property name="width">1</property>
117
+ <property name="height">1</property>
118
+ </packing>
119
+ </child>
120
+ <child>
121
+ <object class="GtkButton" id="buttonInput">
122
+ <property name="label" translatable="yes">Try</property>
123
+ <property name="visible">True</property>
124
+ <property name="can_focus">True</property>
125
+ <property name="receives_default">True</property>
126
+ <property name="valign">start</property>
127
+ </object>
128
+ <packing>
129
+ <property name="left_attach">1</property>
130
+ <property name="top_attach">3</property>
131
+ <property name="width">1</property>
132
+ <property name="height">1</property>
133
+ </packing>
134
+ </child>
135
+ <child>
136
+ <object class="GtkLabel" id="label2">
137
+ <property name="visible">True</property>
138
+ <property name="can_focus">False</property>
139
+ <property name="xalign">0</property>
140
+ <property name="label" translatable="yes">&lt;big&gt;Yes/No Example&lt;/big&gt;
141
+ Ask the user a yes/no question by changing the text on the buttons.</property>
142
+ <property name="use_markup">True</property>
143
+ </object>
144
+ <packing>
145
+ <property name="left_attach">0</property>
146
+ <property name="top_attach">2</property>
147
+ <property name="width">1</property>
148
+ <property name="height">1</property>
149
+ </packing>
150
+ </child>
151
+ <child>
152
+ <object class="GtkButton" id="buttonYesNo">
153
+ <property name="label" translatable="yes">Try</property>
154
+ <property name="visible">True</property>
155
+ <property name="can_focus">True</property>
156
+ <property name="receives_default">True</property>
157
+ <property name="valign">start</property>
158
+ </object>
159
+ <packing>
160
+ <property name="left_attach">1</property>
161
+ <property name="top_attach">2</property>
162
+ <property name="width">1</property>
163
+ <property name="height">1</property>
164
+ </packing>
165
+ </child>
166
+ <child>
167
+ <object class="GtkLabel" id="label6">
168
+ <property name="visible">True</property>
169
+ <property name="can_focus">False</property>
170
+ <property name="xalign">0</property>
171
+ <property name="label" translatable="yes">&lt;big&gt;Simple Input Box Example&lt;/big&gt;
172
+ This just prompts the user for input in one line of code.</property>
173
+ <property name="use_markup">True</property>
174
+ </object>
175
+ <packing>
176
+ <property name="left_attach">0</property>
177
+ <property name="top_attach">1</property>
178
+ <property name="width">1</property>
179
+ <property name="height">1</property>
180
+ </packing>
181
+ </child>
182
+ <child>
183
+ <object class="GtkButton" id="buttonSimpleInput">
184
+ <property name="label" translatable="yes">Try</property>
185
+ <property name="visible">True</property>
186
+ <property name="can_focus">True</property>
187
+ <property name="receives_default">True</property>
188
+ <property name="valign">start</property>
189
+ </object>
190
+ <packing>
191
+ <property name="left_attach">1</property>
192
+ <property name="top_attach">1</property>
193
+ <property name="width">1</property>
194
+ <property name="height">1</property>
195
+ </packing>
196
+ </child>
197
+ </object>
198
+ <packing>
199
+ <property name="expand">False</property>
200
+ <property name="fill">True</property>
201
+ <property name="position">1</property>
202
+ </packing>
203
+ </child>
204
+ <child>
205
+ <object class="GtkButtonBox" id="buttonbox2">
206
+ <property name="visible">True</property>
207
+ <property name="can_focus">False</property>
208
+ <property name="margin_right">20</property>
209
+ <property name="layout_style">end</property>
210
+ <child>
211
+ <object class="GtkButton" id="buttonQuit">
212
+ <property name="label" translatable="yes">Quit</property>
213
+ <property name="visible">True</property>
214
+ <property name="can_focus">True</property>
215
+ <property name="receives_default">True</property>
216
+ <property name="margin_bottom">20</property>
217
+ </object>
218
+ <packing>
219
+ <property name="expand">True</property>
220
+ <property name="fill">True</property>
221
+ <property name="position">0</property>
222
+ </packing>
223
+ </child>
224
+ </object>
225
+ <packing>
226
+ <property name="expand">False</property>
227
+ <property name="fill">True</property>
228
+ <property name="position">2</property>
229
+ </packing>
230
+ </child>
231
+ </object>
232
+ </child>
233
+ </object>
234
+ </interface>
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # ignore -- this is for development, same as require 'vrlib'
4
+ require File.exists?("./../../vrlib/vrlib.rb") ? "./../../vrlib/vrlib.rb" : "vrlib"
5
+
6
+ # from require_all gem:
7
+ require_rel 'bin/'
8
+
9
+
10
+
11
+ AlertBoxDemo.new.show_glade()
12
+
@@ -1,9 +1,19 @@
1
1
  ##
2
2
  # This file shows all the widget types that auto-fill when you
3
- # call set_glade variables(). You can use any type of
4
- # widget in your programs, but you'll need to populate
5
- # them yourself using the @builder for your class. An example
6
- # of using the @builder to populate a widget is in the code
3
+ # call the show_glade() method. This provides a great shortcut
4
+ # for assigning initial values to widgets in your forms.
5
+ #
6
+ # So when you might normally write:
7
+ #
8
+ # @builder["window1"].title = "All Widgets"
9
+ #
10
+ # with GladeGui, you can write:
11
+ #
12
+ # @window1 = "All Widgets"
13
+ #
14
+ # them yourself using @builder["widget_name"].property= statement
15
+ #
16
+ # An example of using the @builder to populate a widget is in the code
7
17
  # below: The checkbutton is populated automatically with
8
18
  # the value "true," but the label of the checkbutton needs
9
19
  # to be set in glade, or here in your code. This line set the
@@ -16,13 +26,13 @@
16
26
  # Note: you must add an "adjustment" object to the spinbutton in glade
17
27
  # to make it work.
18
28
  #
19
-
29
+ #
20
30
  class AllWidgets
21
31
 
22
32
  include GladeGUI
23
33
 
24
- def show()
25
- load_glade(__FILE__) #loads file, glade/MyClass.glade into @builder
34
+ def window1__show(*args)
35
+ @window1 = "Showing All Widgets"
26
36
  @label1 = "I'm a Label"
27
37
  @checkbutton1 = true
28
38
  @builder["checkbutton1"].label = "I'm a Check Button" #this could be set in glade
@@ -33,9 +43,7 @@ class AllWidgets
33
43
  @textview1 = "I'm a Textview"
34
44
  @spinbutton1 = 10.5
35
45
  @fontbutton1 = "Courier 10"
36
- @calendar1 = DateTime.new(2011, 5, 14)
37
- set_glade_variables() #populates glade controls with insance variables (i.e. Myclass.label1)
38
- show_window()
46
+ @calendar1 = DateTime.new(2011, 5, 14)
39
47
  end
40
48
 
41
49
 
@@ -1,25 +1,37 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Generated with glade 3.16.1 -->
2
3
  <interface>
3
- <requires lib="gtk+" version="2.16"/>
4
- <!-- interface-naming-policy project-wide -->
4
+ <requires lib="gtk+" version="3.0"/>
5
+ <object class="GtkAdjustment" id="adjustment1">
6
+ <property name="upper">100</property>
7
+ <property name="step_increment">0.10000000000000001</property>
8
+ </object>
5
9
  <object class="GtkWindow" id="window1">
6
- <property name="visible">True</property>
7
- <property name="window_position">center-always</property>
8
- <signal name="destroy" handler="destroy_window"/>
10
+ <property name="can_focus">False</property>
9
11
  <child>
10
- <object class="GtkHBox" id="hbox1">
12
+ <object class="GtkBox" id="box1">
11
13
  <property name="visible">True</property>
14
+ <property name="can_focus">False</property>
15
+ <property name="margin_left">20</property>
16
+ <property name="margin_right">20</property>
17
+ <property name="margin_top">20</property>
18
+ <property name="margin_bottom">20</property>
12
19
  <child>
13
- <object class="GtkVBox" id="vbox2">
20
+ <object class="GtkBox" id="box2">
14
21
  <property name="visible">True</property>
15
- <property name="spacing">10</property>
22
+ <property name="can_focus">False</property>
23
+ <property name="orientation">vertical</property>
24
+ <property name="spacing">12</property>
16
25
  <child>
17
26
  <object class="GtkImage" id="image1">
18
27
  <property name="width_request">330</property>
19
28
  <property name="height_request">200</property>
20
29
  <property name="visible">True</property>
30
+ <property name="can_focus">False</property>
21
31
  </object>
22
32
  <packing>
33
+ <property name="expand">True</property>
34
+ <property name="fill">True</property>
23
35
  <property name="padding">10</property>
24
36
  <property name="position">0</property>
25
37
  </packing>
@@ -27,9 +39,12 @@
27
39
  <child>
28
40
  <object class="GtkLabel" id="label1">
29
41
  <property name="visible">True</property>
42
+ <property name="can_focus">False</property>
30
43
  <property name="label" translatable="yes">label</property>
31
44
  </object>
32
45
  <packing>
46
+ <property name="expand">True</property>
47
+ <property name="fill">True</property>
33
48
  <property name="position">1</property>
34
49
  </packing>
35
50
  </child>
@@ -39,9 +54,12 @@
39
54
  <property name="visible">True</property>
40
55
  <property name="can_focus">True</property>
41
56
  <property name="receives_default">False</property>
57
+ <property name="xalign">0.5</property>
42
58
  <property name="draw_indicator">True</property>
43
59
  </object>
44
60
  <packing>
61
+ <property name="expand">True</property>
62
+ <property name="fill">True</property>
45
63
  <property name="position">2</property>
46
64
  </packing>
47
65
  </child>
@@ -56,6 +74,8 @@
56
74
  <property name="numeric">True</property>
57
75
  </object>
58
76
  <packing>
77
+ <property name="expand">True</property>
78
+ <property name="fill">True</property>
59
79
  <property name="padding">10</property>
60
80
  <property name="position">3</property>
61
81
  </packing>
@@ -71,6 +91,8 @@
71
91
  <property name="uri">http://glade.gnome.org</property>
72
92
  </object>
73
93
  <packing>
94
+ <property name="expand">True</property>
95
+ <property name="fill">True</property>
74
96
  <property name="position">4</property>
75
97
  </packing>
76
98
  </child>
@@ -81,29 +103,38 @@
81
103
  <property name="invisible_char">•</property>
82
104
  </object>
83
105
  <packing>
106
+ <property name="expand">True</property>
107
+ <property name="fill">True</property>
84
108
  <property name="position">5</property>
85
109
  </packing>
86
110
  </child>
87
111
  <child>
88
112
  <object class="GtkProgressBar" id="progressbar1">
89
113
  <property name="visible">True</property>
114
+ <property name="can_focus">False</property>
90
115
  <property name="fraction">0.080000000000000002</property>
91
116
  <property name="text" translatable="yes">I'm a progressbar</property>
92
117
  </object>
93
118
  <packing>
119
+ <property name="expand">True</property>
120
+ <property name="fill">True</property>
94
121
  <property name="padding">10</property>
95
122
  <property name="position">6</property>
96
123
  </packing>
97
124
  </child>
98
125
  </object>
99
126
  <packing>
100
- <property name="padding">10</property>
127
+ <property name="expand">False</property>
128
+ <property name="fill">True</property>
101
129
  <property name="position">0</property>
102
130
  </packing>
103
131
  </child>
104
132
  <child>
105
- <object class="GtkVBox" id="vbox1">
133
+ <object class="GtkBox" id="box3">
106
134
  <property name="visible">True</property>
135
+ <property name="can_focus">False</property>
136
+ <property name="orientation">vertical</property>
137
+ <property name="spacing">12</property>
107
138
  <child>
108
139
  <object class="GtkCalendar" id="calendar1">
109
140
  <property name="visible">True</property>
@@ -120,13 +151,17 @@
120
151
  </packing>
121
152
  </child>
122
153
  <child>
123
- <object class="GtkHButtonBox" id="hbuttonbox1">
154
+ <object class="GtkButtonBox" id="buttonbox1">
124
155
  <property name="visible">True</property>
156
+ <property name="can_focus">False</property>
157
+ <property name="orientation">vertical</property>
158
+ <property name="layout_style">start</property>
125
159
  <child>
126
160
  <object class="GtkFontButton" id="fontbutton1">
127
161
  <property name="visible">True</property>
128
162
  <property name="can_focus">True</property>
129
163
  <property name="receives_default">True</property>
164
+ <property name="font">Sans 12</property>
130
165
  </object>
131
166
  <packing>
132
167
  <property name="expand">False</property>
@@ -136,6 +171,8 @@
136
171
  </child>
137
172
  </object>
138
173
  <packing>
174
+ <property name="expand">False</property>
175
+ <property name="fill">True</property>
139
176
  <property name="position">1</property>
140
177
  </packing>
141
178
  </child>
@@ -146,21 +183,20 @@
146
183
  <property name="can_focus">True</property>
147
184
  </object>
148
185
  <packing>
186
+ <property name="expand">True</property>
187
+ <property name="fill">True</property>
149
188
  <property name="padding">10</property>
150
189
  <property name="position">2</property>
151
190
  </packing>
152
191
  </child>
153
192
  </object>
154
193
  <packing>
155
- <property name="padding">10</property>
194
+ <property name="expand">False</property>
195
+ <property name="fill">True</property>
156
196
  <property name="position">1</property>
157
197
  </packing>
158
198
  </child>
159
199
  </object>
160
200
  </child>
161
201
  </object>
162
- <object class="GtkAdjustment" id="adjustment1">
163
- <property name="upper">100</property>
164
- <property name="step_increment">0.10000000000000001</property>
165
- </object>
166
202
  </interface>
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/ruby
2
+
3
+
4
+ # ignore -- this is for development, same as require 'vrlib'
5
+ require File.exists?("./../../vrlib/vrlib.rb") ? "./../../vrlib/vrlib.rb" : "vrlib"
6
+
7
+ # from require_all gem:
8
+ require_rel 'bin/'
9
+
10
+
11
+ AllWidgets.new.show_glade()
12
+
@@ -1,8 +1,5 @@
1
1
  ##
2
- # This class is a GUI for a calculator. The show() method
3
- # loads the Calculator.glade file using the line:
4
- #
5
- # load_glade(__FILE__)
2
+ # This class is a GUI for a calculator.
6
3
  #
7
4
  # The instance variable, @builder is a reference to the
8
5
  # Gtk::Builder object. @builder["window1"] is a reference to
@@ -13,51 +10,55 @@
13
10
  #
14
11
  # In glade, you'll see that the names of the keys are:
15
12
  #
16
- # Calculator.keys[0]
17
- # Calculator.keys[1] ...etc.
18
- #
19
- # This corresponds to the array @keys. Visual Ruby's library
20
- # will automatically load the values of the array into the
21
- # glade form using this line:
13
+ # button[0]
14
+ # button[1] ...etc.
22
15
  #
23
- # set_glade_variables(self)
24
- #
25
- # This line causes GladeGUI to search all the instance variables
26
- # and fill-in widgets that match the vaiable names.
16
+ # This corresponds to the array @button. Visual Ruby's GladeGUI interface
17
+ # will automatically load the values of the array into the form when the
18
+ # show_glade() method is called.
27
19
  #
28
20
 
21
+
29
22
  class Calculator
30
23
 
31
24
  include GladeGUI
32
25
 
33
26
  def before_show()
34
- @builder["window1"].title = "Calculator"
35
- @keys = [ 1, 2, 3, "C" ] +
27
+ @window1 = "Calculator" #sets window1's title to "Calculator"
28
+ @button = [ 1, 2, 3, "C" ] +
36
29
  [ 4, 5, 6, "+" ] +
37
30
  [ 7, 8, 9, "-" ] +
38
31
  [ 0, ".","/","=" ]
39
32
  end
40
33
 
41
- # This method is called when a key is clicked. It follows
34
+ # This method is called when any key is clicked. It follows
42
35
  # this naming convention: <glade_name>__<signal_name>. (Separator is
43
- # two underscores. This tells GladeGUI to connect all the
36
+ # two underscores.) This tells GladeGUI to connect all the
44
37
  # "clicked" signals to this method. It matches the glade
45
- # names "keys", "keys[x]" or "Calculator.keys[x]" to this method
38
+ # names "button", "button[x]" or "Calculator.button[x]" to this method
46
39
  # automatically for all the buttons. Look at the names
47
40
  # of the keys in glade by right clicking on Calculator.rb
41
+ #
42
+ # This is very useful because you don't need to write a handler for
43
+ # each button!
48
44
 
49
- def keys__clicked(button)
45
+
46
+ def button__clicked(button)
50
47
  case button.label
51
- when "C" then @builder["display"].text = ""
48
+ when "C" then
49
+ @builder["display"].text = ""
52
50
  when "=" then
53
51
  begin # this doesn't catch all errors
54
52
  @builder["display"].text = eval(@builder["display"].text).to_s
55
53
  rescue
56
54
  @builder["display"].text = "error"
57
55
  end
58
- else @builder["display"].text = @builder["display"].text + button.label
56
+ else
57
+ @builder["display"].text = @builder["display"].text + button.label
59
58
  end
60
59
  end
61
60
 
61
+
62
+
62
63
  end
63
64