libui_paradise 0.3.9 → 0.4.13

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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +176 -155
  3. data/bin/libui_message +1 -1
  4. data/doc/README.gen +175 -85
  5. data/doc/todo/todo.md +9 -5
  6. data/lib/libui_paradise/autoinclude.rb +2 -1
  7. data/lib/libui_paradise/base/base.rb +17 -67
  8. data/lib/libui_paradise/base_module/base_module.rb +1514 -0
  9. data/lib/libui_paradise/colours/colours.rb +4 -4
  10. data/lib/libui_paradise/domain_specific_language/README.md +6 -0
  11. data/lib/libui_paradise/examples/complex/002_tabs_example.rb +1 -2
  12. data/lib/libui_paradise/examples/complex/003_open_file_button_example.rb +1 -1
  13. data/lib/libui_paradise/examples/complex/006_coloured_boxes_example.rb +2 -2
  14. data/lib/libui_paradise/examples/complex/007_slider_example.rb +10 -4
  15. data/lib/libui_paradise/examples/complex/008_radio_button_example.rb +2 -2
  16. data/lib/libui_paradise/examples/complex/009_separator_example.rb +2 -2
  17. data/lib/libui_paradise/examples/complex/010_table_example.rb +5 -9
  18. data/lib/libui_paradise/examples/complex/011_two_buttons_showing_how_to_enable_and_disable_them.rb +2 -1
  19. data/lib/libui_paradise/examples/complex/012_password_entry_example.rb +1 -1
  20. data/lib/libui_paradise/examples/complex/013_form_example.rb +1 -1
  21. data/lib/libui_paradise/examples/complex/014_text_example.rb +1 -1
  22. data/lib/libui_paradise/examples/complex/015_text_view_example.rb +4 -4
  23. data/lib/libui_paradise/examples/complex/016_grid_example.rb +20 -11
  24. data/lib/libui_paradise/examples/complex/017_unicode_text_example.rb +2 -2
  25. data/lib/libui_paradise/examples/complex/018_spinbutton_example.rb +1 -1
  26. data/lib/libui_paradise/examples/complex/019_combo_box_example.rb +1 -1
  27. data/lib/libui_paradise/examples/complex/020_checkbox_example.rb +5 -5
  28. data/lib/libui_paradise/examples/complex/021_font_example.rb +4 -3
  29. data/lib/libui_paradise/examples/complex/022_simple_notepad_example.rb +3 -3
  30. data/lib/libui_paradise/examples/complex/023_msg_box_error.rb +5 -5
  31. data/lib/libui_paradise/examples/complex/024_parse_config_file_example.rb +2 -2
  32. data/lib/libui_paradise/examples/complex/025_colour_button.rb +1 -1
  33. data/lib/libui_paradise/examples/complex/026_basic_table_image.rb +5 -8
  34. data/lib/libui_paradise/examples/complex/027_basic_button_example.rb +3 -3
  35. data/lib/libui_paradise/examples/complex/028_try_for_automatic_button_press_event_after_a_delay.rb +4 -5
  36. data/lib/libui_paradise/examples/complex/029_progressbar_example.rb +4 -5
  37. data/lib/libui_paradise/examples/complex/030_entry_responds_to_comment_as_synonymous_to_the_enter_key_pressed_example.rb +5 -6
  38. data/lib/libui_paradise/examples/complex/031_notification_functionality_example.rb +3 -2
  39. data/lib/libui_paradise/examples/complex/032_simple_window_example.rb +2 -1
  40. data/lib/libui_paradise/examples/complex/033_daemonize_and_exit_after_delay_example.rb +3 -2
  41. data/lib/libui_paradise/examples/complex/034_bold_text_example.rb +115 -0
  42. data/lib/libui_paradise/examples/complex/035_parse_into_table_example.rb +109 -0
  43. data/lib/libui_paradise/examples/simple/001_open_file_example.rb +1 -1
  44. data/lib/libui_paradise/examples/simple/002_histogram_example.rb +6 -6
  45. data/lib/libui_paradise/examples/simple/003_fancy_text_example.rb +63 -35
  46. data/lib/libui_paradise/examples/simple/005_text_drawing_example.rb +3 -3
  47. data/lib/libui_paradise/examples/simple/007_control_gallery.rb +2 -1
  48. data/lib/libui_paradise/examples/simple/009_spectrum.rb +7 -1
  49. data/lib/libui_paradise/examples/simple/012_table_example.rb +5 -5
  50. data/lib/libui_paradise/examples/simple/013_scrolling_pane_example.rb +28 -0
  51. data/lib/libui_paradise/examples/simple/014_simple_entry_example.rb +30 -0
  52. data/lib/libui_paradise/examples/simple/015_slider_example.rb +32 -0
  53. data/lib/libui_paradise/fiddle/fiddle.rb +771 -636
  54. data/lib/libui_paradise/libui_classes/button.rb +31 -0
  55. data/lib/libui_paradise/libui_classes/entry.rb +35 -0
  56. data/lib/libui_paradise/libui_classes/grid.rb +14 -26
  57. data/lib/libui_paradise/libui_classes/hbox.rb +39 -0
  58. data/lib/libui_paradise/libui_classes/libui_classes.rb +9 -1630
  59. data/lib/libui_paradise/libui_classes/msg_box.rb +121 -0
  60. data/lib/libui_paradise/libui_classes/msg_box_error.rb +41 -0
  61. data/lib/libui_paradise/libui_classes/slider.rb +28 -0
  62. data/lib/libui_paradise/libui_classes/spinbox.rb +48 -0
  63. data/lib/libui_paradise/libui_classes/vbox.rb +38 -0
  64. data/lib/libui_paradise/project/project.rb +2 -1
  65. data/lib/libui_paradise/prototype/prototype.rb +8 -8
  66. data/lib/libui_paradise/requires/require_the_libui_classes.rb +2 -2
  67. data/lib/libui_paradise/requires/require_the_libui_paradise_project.rb +4 -2
  68. data/lib/libui_paradise/toplevel_methods/add_to_the_registered_widgets.rb +70 -0
  69. data/lib/libui_paradise/toplevel_methods/hash_fiddle_pointer_widgets.rb +37 -0
  70. data/lib/libui_paradise/{extensions → toplevel_methods}/toplevel_counters.rb +26 -1
  71. data/lib/libui_paradise/toplevel_methods/toplevel_methods.rb +792 -0
  72. data/lib/libui_paradise/version/version.rb +2 -2
  73. data/test/testing_generic_window.rb +2 -0
  74. metadata +22 -8
  75. data/doc/SNIPPETS.md +0 -65
  76. data/lib/libui_paradise/extensions/extensions.rb +0 -979
  77. data/lib/libui_paradise/libui_classes/box.rb +0 -157
@@ -8,8 +8,8 @@
8
8
  # really not recommended to do this.
9
9
  #
10
10
  # A cleaner solution would be to modify just in-place, such as via
11
- # refinements, but I don't quite like the syntax of refinements,
12
- # so I opted for the simpler toplevel modification instead.
11
+ # refinements, but I don't quite like the syntax of refinements, so
12
+ # I opted for the simpler toplevel modification instead.
13
13
  # =========================================================================== #
14
14
  # require 'libui_paradise/fiddle/fiddle.rb'
15
15
  # =========================================================================== #
@@ -17,50 +17,60 @@ module Fiddle
17
17
 
18
18
  class Pointer # === Fiddle::Pointer
19
19
 
20
- require 'libui_paradise/extensions/toplevel_counters.rb'
20
+ require 'libui_paradise/toplevel_methods/hash_fiddle_pointer_widgets.rb'
21
+ require 'libui_paradise/toplevel_methods/toplevel_counters.rb'
21
22
 
22
23
  # ========================================================================= #
23
- # === enable (enable tag)
24
+ # === available_pointers?
24
25
  # ========================================================================= #
25
- def enable(&block)
26
+ def available_pointers?
27
+ ::LibuiParadise.hash_fiddle_pointer_widgets?
28
+ end; alias main_hash? available_pointers? # === main_hash?
29
+ alias hash_fiddle_pointer_widgets? available_pointers? # === hash_fiddle_pointer_widgets?
30
+
31
+ # ========================================================================= #
32
+ # === clear
33
+ # ========================================================================= #
34
+ def clear(
35
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
36
+ )
37
+ _pointer = current_widget.first # Not used currently in this method.
38
+ type = current_widget.last
39
+
26
40
  object_id = self.object_id
27
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
28
- type = hash[object_id].last # The last entry contains the type.
41
+ hash = hash_fiddle_pointer_widgets?
42
+ if type.nil?
43
+ type = hash[object_id].last # This should be :grid. But it is not used here.
44
+ end
29
45
  case type
30
46
  # ======================================================================= #
31
- # === :button
47
+ # === :multiline_entry
32
48
  # ======================================================================= #
33
- when :button
34
- LibUI.control_enable(self)
49
+ when :multiline_entry
50
+ ::LibUI.multiline_entry_set_text(self, '')
51
+ # ======================================================================= #
52
+ # === :combobox
53
+ #
54
+ # This currently does not work; it depends on libui-ng, which has not
55
+ # yet been added completely.
56
+ # ======================================================================= #
57
+ when :combobox
58
+ # LibUI.multiline_entry_set_text(
59
+ # this_widget,
60
+ # display_this_text.to_s
61
+ # )
35
62
  else
36
- e 'Not registered type in .enable(): '+type.to_s
63
+ puts "Unhandled case in clear(): "\
64
+ "#{type}"
37
65
  end
38
66
  end
39
67
 
40
68
  # ========================================================================= #
41
- # === on_changed
42
- #
43
- # The idea for this method is to respond to on-changed events, in
44
- # particular on a spinbox. Currently it is enabled for a few
45
- # widgets, including :entry. This may be expanded at a later time
46
- # to add on-changed support for more widgets.
47
- #
48
- # For a combobox we may have to use this code:
49
- #
50
- # LibUI.combobox_on_selected
51
- # UI.spinbox_on_changed(self, spinbox_changed_callback, nil)
52
- # end
53
- #
54
- # Be sure to pass the proc object into the method, in a block.
55
- #
56
- # Usage examples:
57
- #
58
- # text_entry.on_changed { text_changed_callback }
59
- # slider.on_changed { slider_changed_callback }
60
- #
69
+ # === is_read_only
61
70
  # ========================================================================= #
62
- def on_changed(&block)
63
- current_widget = available_pointers?[self.object_id] # This will be an Array.
71
+ def is_read_only(
72
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
73
+ )
64
74
  _pointer = current_widget.first # Not used currently in this method.
65
75
  type = current_widget.last
66
76
  case type
@@ -68,121 +78,164 @@ class Pointer # === Fiddle::Pointer
68
78
  # === :entry
69
79
  # ======================================================================= #
70
80
  when :entry
71
- LibUI.entry_on_changed(self, block.call, nil)
81
+ ::LibUI.entry_set_read_only(self, 1)
72
82
  # ======================================================================= #
73
83
  # === :multiline_entry
74
84
  # ======================================================================= #
75
85
  when :multiline_entry
76
- LibUI.multiline_entry_on_changed(self, block.call, nil)
77
- # ======================================================================= #
78
- # === :spinbox
79
- # ======================================================================= #
80
- when :spinbox
81
- LibUI.spinbox_on_changed(self, block.call, nil)
82
- # ======================================================================= #
83
- # === :slider
84
- #
85
- # This is for a slider bar.
86
- # ======================================================================= #
87
- when :slider
88
- LibUI.slider_on_changed(self, block.call, nil)
89
- # ======================================================================= #
90
- # === :colour_button
91
- # ======================================================================= #
92
- when :colour_button
93
- LibUI.color_button_on_changed(self, block.call, nil)
94
- # ======================================================================= #
95
- # === :combobox
96
- # ======================================================================= #
97
- when :combobox
98
- LibUI.combobox_on_selected(self, block.call, nil)
86
+ ::LibUI.multiline_entry_set_read_only(self, 1)
99
87
  else
100
- e 'Not registered type in .on_changed(): '+type.to_s
88
+ pp 'The caller in is_read_only() will be shown next:'
89
+ puts
90
+ pp caller()
91
+ puts
92
+ puts "#{type} (class #{type.class}) is not yet implemented in .padded=."
93
+ puts
101
94
  end
102
- end
95
+ end; alias readonly is_read_only # === readonly
96
+ alias the_user_may_not_modify_this_entry is_read_only # === the_user_may_not_modify_this_entry
103
97
 
104
98
  # ========================================================================= #
105
- # === fraction=
106
- #
107
- # This is mostly a wrapper to reach ruby-gtk3 compatibility.
99
+ # === new_row
108
100
  # ========================================================================= #
109
- def fraction=(i = '')
110
- i = i * 100
111
- set_value(i)
101
+ def new_row
102
+ ::LibuiParadise.new_row
112
103
  end
113
104
 
114
105
  # ========================================================================= #
115
- # === set_text
116
- #
117
- # This method can be used to set the text of a particular libui-widget,
118
- # in particular entries.
106
+ # === right (right tag)
119
107
  # ========================================================================= #
120
- def set_text(
121
- display_this_text = '', # This is the text that will be used.
122
- type = nil
108
+ def right(
109
+ widget,
110
+ left = LibuiParadise.counter_left?,
111
+ top = LibuiParadise.counter_top?,
112
+ xspan = 1,
113
+ yspan = 1
123
114
  )
124
115
  object_id = self.object_id
125
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
126
- this_widget = hash[object_id].first
127
- if type.nil?
128
- type = hash[object_id].last # This should be :grid. But it is not used here.
116
+ hash = hash_fiddle_pointer_widgets?
117
+ type = hash[object_id].last # The last entry contains the type.
118
+ case left
119
+ # ======================================================================= #
120
+ # === :default
121
+ # ======================================================================= #
122
+ when :default
123
+ left = LibuiParadise.counter_left?
129
124
  end
130
- case type
125
+ case top
131
126
  # ======================================================================= #
132
- # === :new_progress_bar
127
+ # === :default
133
128
  # ======================================================================= #
134
- when :new_progress_bar
135
- # This currently does nothing.
129
+ when :default
130
+ top = LibuiParadise.counter_top?
131
+ end
132
+ case type
136
133
  # ======================================================================= #
137
- # === :multiline_entry
138
- #
139
- # This is a text-view widget actually.
134
+ # === :vbox
140
135
  # ======================================================================= #
141
- when :multiline_entry
142
- LibUI.multiline_entry_set_text(
143
- this_widget,
144
- display_this_text.to_s
145
- )
136
+ when :vbox
137
+ add(widget)
146
138
  # ======================================================================= #
147
- # === :text
139
+ # === :grid
148
140
  # ======================================================================= #
149
- when :text,
150
- :label
151
- LibUI.label_set_text(
152
- this_widget,
153
- display_this_text.to_s
141
+ when :grid
142
+ hash_grid(
143
+ widget,
144
+ {
145
+ left: left,
146
+ top: top,
147
+ xspan: xspan,
148
+ yspan: yspan,
149
+ hexpand: 0,
150
+ halign: 0,
151
+ vexpand: 0,
152
+ valign: 0
153
+ }
154
154
  )
155
+ # ===================================================================== #
156
+ # And we must add a new row next:
157
+ # ===================================================================== #
158
+ LibuiParadise.new_row
159
+ else
160
+ end
161
+ end
162
+
163
+ # ========================================================================= #
164
+ # === ui_grid_append
165
+ #
166
+ # This method can be used to append onto a grid in LibUI.
167
+ #
168
+ # Usage example:
169
+ #
170
+ # grid.grid_append(text('Right'), 1, 0, 1, 1, 0, 0.5, 1, 0)
171
+ #
172
+ # ========================================================================= #
173
+ def ui_grid_append(
174
+ widget_to_append,
175
+ left = LibuiParadise.left_counter?,
176
+ top = LibuiParadise.top_counter?,
177
+ xspan = 1,
178
+ yspan = 1, #
179
+ hexpand = 0, # A "boolean". 0 means false here.
180
+ halign = 0,
181
+ vexpand = 0, # A "boolean". 0 means false here, 1 means true, and thus "do expand".
182
+ valign = 0
183
+ )
155
184
  # ======================================================================= #
156
- # === :textview
185
+ # The signature in Go is:
186
+ #
187
+ # Append(child Control, left, top int, xspan, yspan int, hexpand bool, halign Align, vexpand bool, valign Align)
188
+ #
157
189
  # ======================================================================= #
158
- when :textview
159
- LibUI.multiline_entry_set_text(
160
- this_widget,
161
- display_this_text.to_s
162
- )
190
+ object_id = self.object_id
191
+ hash = hash_fiddle_pointer_widgets?
192
+ this_widget = hash[object_id].first
193
+ _type = hash[object_id].last # This should be :grid. But it is not used here.
194
+ if (left == LibuiParadise.left_counter?)
195
+ LibuiParadise.increment_the_left_counter
196
+ end
163
197
  # ======================================================================= #
164
- # === :entry
198
+ # left, top, xspan, yspan, hexpand, halign, vexpand, valign
199
+ # 0, 0, 2, 1, 0, 0, 1, 0
165
200
  # ======================================================================= #
166
- when :entry
167
- LibUI.entry_set_text(
168
- this_widget,
169
- display_this_text.to_s
170
- )
201
+ LibUI.grid_append(
202
+ this_widget,
203
+ widget_to_append, # This is the widget that will be added (appended) onto the grid-widget.
204
+ left,
205
+ top,
206
+ xspan,
207
+ yspan,
208
+ hexpand,
209
+ halign,
210
+ vexpand,
211
+ valign
212
+ )
213
+ end; alias grid_append ui_grid_append # === grid_append
214
+
215
+ # ========================================================================= #
216
+ # === show_then_main_then_quit
217
+ #
218
+ # This method ultimately combines three other method calls, or even
219
+ # four, since as of December 2023.
220
+ #
221
+ # The argument that this method accepts is the main window.
222
+ # ========================================================================= #
223
+ def show_then_main_then_quit(
224
+ optional_widget = nil
225
+ )
171
226
  # ======================================================================= #
172
- # === :search_entry
173
- #
174
- # This is specifically for a search-entry.
227
+ # First handle non-nil arguments given.
175
228
  # ======================================================================= #
176
- when :search_entry
177
- LibUI.entry_set_text(
178
- this_widget,
179
- display_this_text.to_s
180
- )
181
- else
182
- puts 'Unhandled case in set_text(): '+
183
- type.to_s
229
+ if optional_widget
230
+ self << optional_widget
184
231
  end
185
- end; alias set_content set_text # === set_content
232
+ ::LibUI.control_show(self)
233
+ main_then_quit
234
+ end; alias elegant_exit show_then_main_then_quit # === elegant_exit
235
+ alias complex_finalizer show_then_main_then_quit # === complex_finalizer
236
+ alias intelligent_close_down show_then_main_then_quit # === intelligent_close_down
237
+ alias intelligent_quit show_then_main_then_quit # === intelligent_quit
238
+ alias intelligent_exit show_then_main_then_quit # === intelligent_exit
186
239
 
187
240
  # ========================================================================= #
188
241
  # === text?
@@ -194,7 +247,7 @@ class Pointer # === Fiddle::Pointer
194
247
  type = nil
195
248
  )
196
249
  object_id = self.object_id
197
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
250
+ hash = hash_fiddle_pointer_widgets?
198
251
  if type.nil?
199
252
  # ===================================================================== #
200
253
  # In this case we must determine the type in use.
@@ -205,6 +258,11 @@ class Pointer # === Fiddle::Pointer
205
258
  end
206
259
  case type
207
260
  # ======================================================================= #
261
+ # === :label
262
+ # ======================================================================= #
263
+ when :label
264
+ return LibUI.label_text(self).to_s
265
+ # ======================================================================= #
208
266
  # === :new_progress_bar
209
267
  #
210
268
  # This is actually a progress-bar.
@@ -229,384 +287,384 @@ class Pointer # === Fiddle::Pointer
229
287
  return LibUI.entry_text(self).to_s
230
288
  end
231
289
  end; alias buffer? text? # === buffer?
232
- alias selected? text? # === selected?
233
290
  alias value? text? # === value?
291
+ alias selected? text? # === selected?
234
292
 
235
293
  # ========================================================================= #
236
- # === set_value
237
- #
238
- # This method has initially been created to assign a value to a
239
- # spinbutton. That way the following API is made possible:
240
- #
241
- # spinbutton.set_value(42)
242
- #
294
+ # === on_toggled
243
295
  # ========================================================================= #
244
- def set_value(
245
- new_value
246
- )
247
- object_id = self.object_id
248
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
249
- this_widget = hash[object_id].first
250
- type = hash[object_id].last
296
+ def on_toggled(&block)
297
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
298
+ _pointer = current_widget.first # Not used currently in this method.
299
+ type = current_widget.last
251
300
  case type
252
301
  # ======================================================================= #
253
- # === :new_progress_bar
254
- #
255
- # This is actually a progress-bar.
256
- # ======================================================================= #
257
- when :new_progress_bar,
258
- :progress_bar
259
- LibUI.progress_bar_set_value(this_widget, new_value.to_i)
260
- # ======================================================================= #
261
- # === :spinbox
302
+ # === :checkbox
262
303
  # ======================================================================= #
263
- when :spinbox
264
- LibUI.spinbox_set_value(
265
- this_widget,
266
- new_value.to_i # Must be an Integer.
267
- )
304
+ when :checkbox
305
+ ::LibUI.checkbox_on_toggled(self, block.call, nil)
268
306
  else
269
- e 'Not registered type: '+type.to_s
307
+ e 'Not yet added here: '+type.to_s
270
308
  end
271
- end; alias value= set_value # === value=
272
- alias start_position= set_value # === start_position=
309
+ end
273
310
 
274
311
  # ========================================================================= #
275
- # === left (left tag)
312
+ # === on_changed
313
+ #
314
+ # The idea for this method is to respond to on-changed events, in
315
+ # particular on a spinbox. Currently it is enabled for a few
316
+ # widgets, including :entry. This may be expanded at a later time
317
+ # to add on-changed support for more widgets.
318
+ #
319
+ # For a combobox we may have to use this code:
320
+ #
321
+ # LibUI.combobox_on_selected
322
+ # UI.spinbox_on_changed(self, spinbox_changed_callback, nil)
323
+ # end
324
+ #
325
+ # Be sure to pass the proc object into the method, in a block.
326
+ #
327
+ # Usage examples:
328
+ #
329
+ # text_entry.on_changed { text_changed_callback }
330
+ # slider.on_changed { slider_changed_callback }
331
+ #
276
332
  # ========================================================================= #
277
- def left(
278
- widget,
279
- left = LibuiParadise.counter_left?,
280
- top = LibuiParadise.counter_top?,
281
- xspan = 1,
282
- yspan = 1
283
- )
284
- object_id = self.object_id
285
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
286
- type = hash[object_id].last # The last entry contains the type.
287
- case left
333
+ def on_changed(&block)
334
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
335
+ _pointer = current_widget.first # Not used currently in this method.
336
+ type = current_widget.last
337
+ case type
288
338
  # ======================================================================= #
289
- # === :default
339
+ # === :entry
290
340
  # ======================================================================= #
291
- when :default
292
- left = LibuiParadise.counter_left?
293
- end
294
- case top
341
+ when :entry
342
+ ::LibUI.entry_on_changed(self, block.call, nil)
295
343
  # ======================================================================= #
296
- # === :default
344
+ # === :multiline_entry
297
345
  # ======================================================================= #
298
- when :default
299
- top = LibuiParadise.counter_top?
300
- end
301
- case type
346
+ when :multiline_entry
347
+ ::LibUI.multiline_entry_on_changed(self, block.call, nil)
302
348
  # ======================================================================= #
303
- # === :vbox
349
+ # === :spinbox
304
350
  # ======================================================================= #
305
- when :vbox
306
- add(widget)
351
+ when :spinbox
352
+ ::LibUI.spinbox_on_changed(self, block.call, nil)
307
353
  # ======================================================================= #
308
- # === :grid
354
+ # === :slider
355
+ #
356
+ # This is for a slider bar.
309
357
  # ======================================================================= #
310
- when :grid
311
- hash_grid(
312
- widget,
313
- {
314
- left: left,
315
- top: top,
316
- xspan: xspan,
317
- yspan: yspan,
318
- hexpand: 0,
319
- halign: 0,
320
- vexpand: 0,
321
- valign: 0
322
- }
323
- )
324
- LibuiParadise.counter_left += 1
358
+ when :slider
359
+ ::LibUI.slider_on_changed(self, block.call, nil)
360
+ # ======================================================================= #
361
+ # === :colour_button
362
+ # ======================================================================= #
363
+ when :colour_button
364
+ ::LibUI.color_button_on_changed(self, block.call, nil)
365
+ # ======================================================================= #
366
+ # === :combobox
367
+ # ======================================================================= #
368
+ when :combobox
369
+ ::LibUI.combobox_on_selected(self, block.call, nil)
325
370
  else
371
+ e 'Not registered type in .on_changed(): '+type.to_s
326
372
  end
327
373
  end
328
374
 
329
375
  # ========================================================================= #
330
- # === right (right tag)
376
+ # === append (append tag, add tag)
377
+ #
378
+ # This is simply a wrapper over LibUI.box_append().
331
379
  # ========================================================================= #
332
- def right(
333
- widget,
334
- left = LibuiParadise.counter_left?,
335
- top = LibuiParadise.counter_top?,
336
- xspan = 1,
337
- yspan = 1
380
+ def append(
381
+ this_widget,
382
+ padding_to_use = 1,
383
+ *remaining_arguments
338
384
  )
339
- object_id = self.object_id
340
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
341
- type = hash[object_id].last # The last entry contains the type.
342
- case left
343
- # ======================================================================= #
344
- # === :default
345
- # ======================================================================= #
346
- when :default
347
- left = LibuiParadise.counter_left?
385
+ if padding_to_use.is_a? Hash
386
+ padding_to_use = 1 # Hardcoded exception.
348
387
  end
349
- case top
350
- # ======================================================================= #
351
- # === :default
352
- # ======================================================================= #
353
- when :default
354
- top = LibuiParadise.counter_top?
388
+ if padding_to_use > 1
389
+ padding_to_use = 1 # For now only a value of 1 seems to work.
390
+ end
391
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
392
+ _pointer = current_widget.first # Not used currently in this method.
393
+ type = current_widget.last
394
+ left_position = LibuiParadise.counter_left?
395
+ top_position = LibuiParadise.counter_top?
396
+ if remaining_arguments[1]
397
+ top_position = remaining_arguments[1]
398
+ end
399
+ if remaining_arguments[0]
400
+ left_position = remaining_arguments[0]
401
+ else
402
+ LibuiParadise.increment_counter_left
355
403
  end
356
404
  case type
357
405
  # ======================================================================= #
358
- # === :vbox
359
- # ======================================================================= #
360
- when :vbox
361
- add(widget)
362
- # ======================================================================= #
363
406
  # === :grid
407
+ #
408
+ # This entry-point is specifically for a ui-grid element.
409
+ #
410
+ # The positional arguments stand for:
411
+ #
412
+ # gtk-widget, left, top, xspan, yspan, hexpand, halign, vexpand, valign
413
+ # grid_append(grid, entry1, 0, 0, 2, 1, 0, 0, 1, 0)
414
+ #
364
415
  # ======================================================================= #
365
416
  when :grid
366
- hash_grid(
367
- widget,
368
- {
369
- left: left,
370
- top: top,
371
- xspan: xspan,
372
- yspan: yspan,
373
- hexpand: 0,
374
- halign: 0,
375
- vexpand: 0,
376
- valign: 0
377
- }
417
+ LibUI.grid_append(
418
+ self,
419
+ this_widget.to_s,
420
+ padding_to_use,
421
+ left_position,
422
+ top_position,
423
+ remaining_arguments[2],
424
+ remaining_arguments[3],
425
+ remaining_arguments[4],
426
+ remaining_arguments[5],
427
+ remaining_arguments[6]
428
+ )
429
+ # ======================================================================= #
430
+ # === :tab
431
+ #
432
+ # This is specifically for the notebook-tab. In this case the argument
433
+ # names do not make a lot of sense. For instance, this_widget is
434
+ # actually the text-title for the tab, and padding_to_use is the
435
+ # actual widget that will be embedded. Because this is, however had,
436
+ # the "minor use case", compared to the subsequent "else" clause, I
437
+ # will keep the name as-is. The comment here should be kept, in order
438
+ # to explain this peculiar oddity though.
439
+ # ======================================================================= #
440
+ when :tab
441
+ LibUI.tab_append(self, this_widget.to_s, padding_to_use)
442
+ # ======================================================================= #
443
+ # === :window
444
+ #
445
+ # Add support for the toplevel window here, as of September 2021.
446
+ # ======================================================================= #
447
+ when :window
448
+ LibUI.window_set_child(self, this_widget)
449
+ else # This is the default.
450
+ ::LibUI.box_append(
451
+ self, this_widget, padding_to_use
378
452
  )
379
- LibuiParadise.counter_left += 1
380
- else
381
453
  end
382
- end
454
+ end; alias add append # === add
455
+ alias << append # === <<
456
+ alias pack_start append # === pack_start
383
457
 
384
458
  # ========================================================================= #
385
- # === new_row
386
- # ========================================================================= #
387
- def new_row
388
- LibuiParadise.counter_left = 0
389
- LibuiParadise.counter_top += 1
390
- end
391
-
392
- # ========================================================================= #
393
- # === hash_grid
394
- #
395
- # Usage example:
396
- #
397
- # hash_grid(text('Yo6'), { left: 0, top: 3, xspan: 1, yspan: 1, hexpand: 0, halign: 0, vexpand: 0, valign: 0 })
459
+ # === append_text_column
398
460
  #
461
+ # This method is specifically used for libui-tables.
399
462
  # ========================================================================= #
400
- def hash_grid(
401
- pass_this_widget,
402
- hash = {}
463
+ def append_text_column(
464
+ text,
465
+ a,
466
+ b = -1
403
467
  )
404
- array_to_be_passed = []
468
+ object_id = self.object_id
469
+ hash = hash_fiddle_pointer_widgets?
470
+ type = hash[object_id].last # The last entry contains the type.
471
+ case type
405
472
  # ======================================================================= #
406
- # === :left
473
+ # === :table
474
+ #
475
+ # This is the primary entry point for this method.
407
476
  # ======================================================================= #
408
- if hash.has_key? :left
409
- array_to_be_passed << hash[:left]
477
+ when :table
478
+ ::LibUI.table_append_text_column(self, text, a, b)
410
479
  else
411
- array_to_be_passed << 0
480
+ e 'Not registered type in .append_text_column(): '+type.to_s
412
481
  end
413
- # ======================================================================= #
414
- # === :top
415
- # ======================================================================= #
416
- if hash.has_key? :top
417
- array_to_be_passed << hash[:top]
418
- else
419
- array_to_be_passed << 0
482
+ end
483
+
484
+ # ========================================================================= #
485
+ # === set_text
486
+ #
487
+ # This method can be used to set the text of a particular libui-widget,
488
+ # in particular entries.
489
+ # ========================================================================= #
490
+ def set_text(
491
+ display_this_text = '', # This is the text that will be used.
492
+ type = nil
493
+ )
494
+ object_id = self.object_id
495
+ hash = hash_fiddle_pointer_widgets?
496
+ this_widget = hash[object_id].first
497
+ if type.nil?
498
+ type = hash[object_id].last # This should be :grid. But it is not used here.
420
499
  end
500
+ case type
421
501
  # ======================================================================= #
422
- # === :xspan
502
+ # === :new_progress_bar
423
503
  # ======================================================================= #
424
- if hash.has_key? :xspan
425
- array_to_be_passed << hash[:xspan]
426
- else
427
- array_to_be_passed << 0
428
- end
504
+ when :new_progress_bar
505
+ # This currently does nothing.
429
506
  # ======================================================================= #
430
- # === :yspan
507
+ # === :multiline_entry
508
+ #
509
+ # This is a text-view widget actually.
431
510
  # ======================================================================= #
432
- if hash.has_key? :yspan
433
- array_to_be_passed << hash[:yspan]
434
- else
435
- array_to_be_passed << 0
436
- end
511
+ when :multiline_entry
512
+ LibUI.multiline_entry_set_text(
513
+ this_widget,
514
+ display_this_text.to_s
515
+ )
437
516
  # ======================================================================= #
438
- # === :hexpand
517
+ # === :text
439
518
  # ======================================================================= #
440
- if hash.has_key? :hexpand
441
- array_to_be_passed << hash[:hexpand]
442
- else
443
- array_to_be_passed << 0
444
- end
519
+ when :text,
520
+ :label
521
+ LibUI.label_set_text(
522
+ this_widget,
523
+ display_this_text.to_s
524
+ )
445
525
  # ======================================================================= #
446
- # === :halign
526
+ # === :textview
447
527
  # ======================================================================= #
448
- if hash.has_key? :halign
449
- array_to_be_passed << hash[:halign]
450
- else
451
- array_to_be_passed << 0
452
- end
528
+ when :textview
529
+ LibUI.multiline_entry_set_text(
530
+ this_widget,
531
+ display_this_text.to_s
532
+ )
453
533
  # ======================================================================= #
454
- # === :vexpand
534
+ # === :entry
455
535
  # ======================================================================= #
456
- if hash.has_key? :vexpand
457
- array_to_be_passed << hash[:vexpand]
458
- else
459
- array_to_be_passed << 0
460
- end
536
+ when :entry
537
+ LibUI.entry_set_text(
538
+ this_widget,
539
+ display_this_text.to_s
540
+ )
461
541
  # ======================================================================= #
462
- # === :valign
542
+ # === :search_entry
543
+ #
544
+ # This is specifically for a search-entry.
463
545
  # ======================================================================= #
464
- if hash.has_key? :valign
465
- array_to_be_passed << hash[:valign]
546
+ when :search_entry
547
+ LibUI.entry_set_text(
548
+ this_widget,
549
+ display_this_text.to_s
550
+ )
466
551
  else
467
- array_to_be_passed << 0
552
+ puts 'Unhandled case in set_text(): '+
553
+ type.to_s
468
554
  end
469
- ui_grid_append(pass_this_widget, *array_to_be_passed)
470
- end; alias hash hash_grid # === hash
555
+ end; alias set_content set_text # === set_content
471
556
 
472
557
  # ========================================================================= #
473
- # === ui_grid_append
474
- #
475
- # This method can be used to append onto a grid in LibUI.
476
- #
477
- # Usage example:
478
- #
479
- # grid.grid_append(text('Right'), 1, 0, 1, 1, 0, 0.5, 1, 0)
480
- #
558
+ # === group_maximal
481
559
  # ========================================================================= #
482
- def ui_grid_append(
483
- widget_to_append,
484
- left = 0,
485
- top = 0,
486
- xspan = 1,
487
- yspan = 1, #
488
- hexpand = 0, # A "boolean". 0 means false here.
489
- halign = 0,
490
- vexpand = 0, # A "boolean". 0 means false here.
491
- valign = 0
492
- )
493
- # ======================================================================= #
494
- # The signature in Go is:
495
- #
496
- # Append(child Control, left, top int, xspan, yspan int, hexpand bool, halign Align, vexpand bool, valign Align)
497
- #
498
- # ======================================================================= #
499
- object_id = self.object_id
500
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
501
- this_widget = hash[object_id].first
502
- _type = hash[object_id].last # This should be :grid. But it is not used here.
503
- # ======================================================================= #
504
- # left, top, xspan, yspan, hexpand, halign, vexpand, valign
505
- # 0, 0, 2, 1, 0, 0, 1, 0
506
- # ======================================================================= #
507
- LibUI.grid_append(
560
+ def group_maximal(*i)
561
+ i.flatten.each {|entry|
562
+ maximal(entry)
563
+ }
564
+ end
565
+
566
+ # ========================================================================= #
567
+ # === maximal
568
+ # ========================================================================= #
569
+ def maximal(this_widget, optional_padding = 1)
570
+ add(this_widget, optional_padding)
571
+ end
572
+
573
+ # ========================================================================= #
574
+ # === minimal
575
+ # ========================================================================= #
576
+ def minimal(
508
577
  this_widget,
509
- widget_to_append,
510
- left,
511
- top,
512
- xspan,
513
- yspan,
514
- hexpand,
515
- halign,
516
- vexpand,
517
- valign
578
+ optional_padding = 0
518
579
  )
519
- end; alias grid_append ui_grid_append # === grid_append
580
+ add(this_widget, optional_padding)
581
+ end
520
582
 
521
583
  # ========================================================================= #
522
- # === append (append tag, add tag)
584
+ # === set_value
585
+ #
586
+ # This method has initially been created to assign a value to a
587
+ # spinbutton. That way the following API is made possible:
588
+ #
589
+ # spinbutton.set_value(42)
523
590
  #
524
- # This is simply a wrapper over LibUI.box_append().
525
591
  # ========================================================================= #
526
- def append(
527
- this_widget,
528
- padding_to_use = 1,
529
- *remaining_arguments
592
+ def set_value(
593
+ new_value
530
594
  )
531
- current_widget = available_pointers?[self.object_id] # This will be an Array.
532
- _pointer = current_widget.first # Not used currently in this method.
533
- type = current_widget.last
595
+ object_id = self.object_id
596
+ hash = hash_fiddle_pointer_widgets?
597
+ this_widget = hash[object_id].first
598
+ type = hash[object_id].last
534
599
  case type
535
600
  # ======================================================================= #
536
- # === :grid
601
+ # === :new_progress_bar
537
602
  #
538
- # This entry-point is specifically for a ui-grid element.
603
+ # This is actually a progress-bar.
539
604
  # ======================================================================= #
540
- when :grid
541
- LibUI.grid_append(
542
- self,
543
- this_widget.to_s,
544
- padding_to_use,
545
- remaining_arguments[0],
546
- remaining_arguments[1],
547
- remaining_arguments[2],
548
- remaining_arguments[3],
549
- remaining_arguments[4],
550
- remaining_arguments[5],
551
- remaining_arguments[6]
552
- )
605
+ when :new_progress_bar,
606
+ :progress_bar
607
+ ::LibUI.progress_bar_set_value(this_widget, new_value.to_i)
553
608
  # ======================================================================= #
554
- # === :tab
555
- #
556
- # This is specifically for the notebook-tab. In this case the argument
557
- # names do not make a lot of sense. For instance, this_widget is
558
- # actually the text-title for the tab, and padding_to_use is the
559
- # actual widget that will be embedded. Because this is, however had,
560
- # the "minor use case", compared to the subsequent "else" clause, I
561
- # will keep the name as-is. The comment here should be kept, in order
562
- # to explain this peculiar oddity though.
609
+ # === :spinbox
563
610
  # ======================================================================= #
564
- when :tab
565
- LibUI.tab_append(self, this_widget.to_s, padding_to_use)
611
+ when :spinbox
612
+ ::LibUI.spinbox_set_value(
613
+ this_widget,
614
+ new_value.to_i # Must be an Integer.
615
+ )
616
+ else
617
+ e 'Not registered type: '+type.to_s
618
+ end
619
+ end; alias value= set_value # === value=
620
+ alias start_position= set_value # === start_position=
621
+
622
+ # ========================================================================= #
623
+ # === append_this_array
624
+ #
625
+ # This method only works for comboboxes.
626
+ # ========================================================================= #
627
+ def append_this_array(array)
628
+ object_id = self.object_id
629
+ hash = hash_fiddle_pointer_widgets?
630
+ _this_widget = hash[object_id].first # This variable is currently not in use.
631
+ type = hash[object_id].last
632
+ case type
566
633
  # ======================================================================= #
567
- # === :window
568
- #
569
- # Add support for the toplevel window here, as of September 2021.
634
+ # === :combobox
570
635
  # ======================================================================= #
571
- when :window
572
- LibUI.window_set_child(self, this_widget)
573
- else # This is the default.
574
- LibUI.box_append(
575
- self, this_widget, padding_to_use
576
- )
636
+ when :combobox
637
+ array.each {|this_entry|
638
+ LibUI.combobox_append(self, this_entry)
639
+ }
640
+ LibUI.combobox_set_selected(self, 0) # The first one will be active too.
577
641
  end
578
- end; alias add append # === add
579
- alias << append # === <<
642
+ end
580
643
 
581
644
  # ========================================================================= #
582
- # === clear
645
+ # === empty?
583
646
  # ========================================================================= #
584
- def clear(
585
- current_widget = available_pointers?[self.object_id] # This will be an Array.
647
+ def empty?(
648
+ type = nil
586
649
  )
587
- _pointer = current_widget.first # Not used currently in this method.
588
- type = current_widget.last
589
-
590
650
  object_id = self.object_id
591
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
651
+ hash = hash_fiddle_pointer_widgets?
592
652
  if type.nil?
593
- type = hash[object_id].last # This should be :grid. But it is not used here.
653
+ # ===================================================================== #
654
+ # In this case we must determine the type in use.
655
+ # ===================================================================== #
656
+ if hash.has_key? object_id
657
+ type = hash[object_id].last # The last entry contains the type.
658
+ end
594
659
  end
595
660
  case type
596
661
  # ======================================================================= #
597
- # === :combobox
598
- #
599
- # This currently does not work; it depends on libui-ng, which has not
600
- # yet been added completely.
662
+ # === :entry
601
663
  # ======================================================================= #
602
- when :combobox
603
- # LibUI.multiline_entry_set_text(
604
- # this_widget,
605
- # display_this_text.to_s
606
- # )
664
+ when :entry
665
+ self.text?.empty?
607
666
  else
608
- puts "Unhandled case in clear(): "\
609
- "#{type}"
667
+ return true
610
668
  end
611
669
  end
612
670
 
@@ -616,11 +674,11 @@ class Pointer # === Fiddle::Pointer
616
674
  # Set a uniform padding via this method.
617
675
  # ========================================================================= #
618
676
  def padded=(
619
- pad_n_px = 25,
677
+ pad_n_px = 25, # How much to pad in n px. LibUI currently does not allow for that, though.
620
678
  type = nil
621
679
  )
622
680
  object_id = self.object_id
623
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
681
+ hash = hash_fiddle_pointer_widgets?
624
682
  if type.nil?
625
683
  # ===================================================================== #
626
684
  # In this case we must determine the type in use.
@@ -631,6 +689,11 @@ class Pointer # === Fiddle::Pointer
631
689
  end
632
690
  case type
633
691
  # ======================================================================= #
692
+ # === :window
693
+ # ======================================================================= #
694
+ when :window
695
+ LibUI.window_set_margined(self, 1)
696
+ # ======================================================================= #
634
697
  # === :grid
635
698
  # ======================================================================= #
636
699
  when :grid
@@ -661,163 +724,8 @@ class Pointer # === Fiddle::Pointer
661
724
  pp caller()
662
725
  puts "#{type} (class #{type.class}) is not yet implemented in .padded=."
663
726
  end
664
- end; alias set_padded padded= # === set_padded
665
-
666
- # ========================================================================= #
667
- # === disable (disable tag)
668
- # ========================================================================= #
669
- def disable(&block)
670
- object_id = self.object_id
671
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
672
- type = hash[object_id].last # The last entry contains the type.
673
- case type
674
- # ======================================================================= #
675
- # === :button
676
- # ======================================================================= #
677
- when :button
678
- LibUI.control_disable(self)
679
- else
680
- e 'Not registered type in .disable(): '+type.to_s
681
- end
682
- end
683
-
684
- # ========================================================================= #
685
- # === populate
686
- # ========================================================================= #
687
- def populate(dataset)
688
- object_id = self.object_id
689
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
690
- type = hash[object_id].last
691
- case type
692
- # ======================================================================= #
693
- # === :combobox
694
- # ======================================================================= #
695
- when :combobox
696
- self.append_this_array(dataset)
697
- end
698
- end
699
-
700
- # ========================================================================= #
701
- # === is_padded
702
- # ========================================================================= #
703
- def is_padded
704
- set_padded(1)
705
- end
706
-
707
- # ========================================================================= #
708
- # === on_clicked
709
- #
710
- # This method is in general called on a button-widget.
711
- # ========================================================================= #
712
- def on_clicked(&block)
713
- LibUI.button_on_clicked(self, &block)
714
- end; alias on_click_event on_clicked # === on_click_event
715
-
716
- # ========================================================================= #
717
- # === available_pointers?
718
- # ========================================================================= #
719
- def available_pointers?
720
- LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
721
- end; alias main_hash? available_pointers? # === main_hash?
722
-
723
- # ========================================================================= #
724
- # === empty?
725
- # ========================================================================= #
726
- def empty?(
727
- type = nil
728
- )
729
- object_id = self.object_id
730
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
731
- if type.nil?
732
- # ===================================================================== #
733
- # In this case we must determine the type in use.
734
- # ===================================================================== #
735
- if hash.has_key? object_id
736
- type = hash[object_id].last # The last entry contains the type.
737
- end
738
- end
739
- case type
740
- # ======================================================================= #
741
- # === :entry
742
- # ======================================================================= #
743
- when :entry
744
- self.text?.empty?
745
- else
746
- return true
747
- end
748
- end
749
-
750
- # ========================================================================= #
751
- # === is_read_only
752
- # ========================================================================= #
753
- def is_read_only(
754
- current_widget = available_pointers?[self.object_id] # This will be an Array.
755
- )
756
- _pointer = current_widget.first # Not used currently in this method.
757
- type = current_widget.last
758
- case type
759
- # ======================================================================= #
760
- # === :multiline_entry
761
- # ======================================================================= #
762
- when :multiline_entry
763
- LibUI.multiline_entry_set_read_only(self, 1)
764
- else
765
- pp caller()
766
- puts "#{type} (class #{type.class}) is not yet implemented in .padded=."
767
- end
768
- end
769
-
770
- # ========================================================================= #
771
- # === append_this_string
772
- #
773
- # This method can be used to append a String to an existing String.
774
- # ========================================================================= #
775
- def append_this_string(i)
776
- ::LibUI.attributed_string_append_unattributed(self, i)
777
- end
778
-
779
- # ========================================================================= #
780
- # === append_this_array
781
- # ========================================================================= #
782
- def append_this_array(array)
783
- object_id = self.object_id
784
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
785
- _this_widget = hash[object_id].first # This variable is currently not in use.
786
- type = hash[object_id].last
787
- case type
788
- # ======================================================================= #
789
- # === :combobox
790
- # ======================================================================= #
791
- when :combobox
792
- array.each {|this_entry|
793
- LibUI.combobox_append(self, this_entry)
794
- }
795
- LibUI.combobox_set_selected(self, 0) # The first one will be active too.
796
- end
797
- end
798
-
799
- # ========================================================================= #
800
- # === maximal
801
- # ========================================================================= #
802
- def maximal(this_widget, optional_padding = 1)
803
- add(this_widget, optional_padding)
804
- end
805
-
806
- # ========================================================================= #
807
- # === group_maximal
808
- # ========================================================================= #
809
- def group_maximal(*i)
810
- i.flatten.each {|entry|
811
- maximal(entry)
812
- }
813
- end
814
-
815
- # ========================================================================= #
816
- # === minimal
817
- # ========================================================================= #
818
- def minimal(this_widget, optional_padding = 0)
819
- add(this_widget, optional_padding)
820
- end
727
+ end; alias set_padded padded= # === set_padded
728
+ alias set_padding padded= # === set_padding
821
729
 
822
730
  # ========================================================================= #
823
731
  # === text
@@ -838,7 +746,7 @@ class Pointer # === Fiddle::Pointer
838
746
  )
839
747
  i = i.to_s # Let's ensure we have a String past this point.
840
748
  object_id = self.object_id
841
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
749
+ hash = hash_fiddle_pointer_widgets?
842
750
  _this_widget = hash[object_id].first # This variable is currently not in use.
843
751
  type = hash[object_id].last
844
752
  case type
@@ -852,18 +760,6 @@ class Pointer # === Fiddle::Pointer
852
760
  end
853
761
  end; alias add_text text # === text
854
762
 
855
- # ========================================================================= #
856
- # === add_hsep
857
- #
858
- # This method adds a horizontal separator.
859
- # ========================================================================= #
860
- def add_hsep
861
- object_id = self.object_id
862
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
863
- this_widget = hash[object_id].first
864
- this_widget.add(::LibuiParadise::Extensions.horizontal_separator, 0)
865
- end; alias add_horizontal_separator add_hsep # === add_horizontal_separator
866
-
867
763
  # ========================================================================= #
868
764
  # === active?
869
765
  # ========================================================================= #
@@ -876,7 +772,7 @@ class Pointer # === Fiddle::Pointer
876
772
  # === :checkbox
877
773
  # ======================================================================= #
878
774
  when :checkbox
879
- checked = (UI.checkbox_checked(pointer) == 1)
775
+ checked = (::LibUI.checkbox_checked(pointer) == 1)
880
776
  return (checked == true)
881
777
  # ======================================================================= #
882
778
  # === :entry
@@ -890,38 +786,111 @@ class Pointer # === Fiddle::Pointer
890
786
  end; alias is_active? active? # === is_active?
891
787
 
892
788
  # ========================================================================= #
893
- # === set_active
789
+ # === set_active
790
+ # ========================================================================= #
791
+ def set_active
792
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
793
+ pointer = current_widget.first
794
+ type = current_widget.last
795
+ case type
796
+ # ======================================================================= #
797
+ # === :checkbox
798
+ # ======================================================================= #
799
+ when :checkbox
800
+ ::LibUI.checkbox_set_checked(pointer, 1)
801
+ end
802
+ end; alias is_active set_active # === is_active
803
+ alias is_now_active set_active # === is_now_active
804
+
805
+ # ========================================================================= #
806
+ # === set_inactive
807
+ #
808
+ # This method currently only works for libui-checkboxes.
809
+ # ========================================================================= #
810
+ def set_inactive
811
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
812
+ pointer = current_widget.first
813
+ type = current_widget.last
814
+ case type
815
+ # ======================================================================= #
816
+ # === :checkbox
817
+ # ======================================================================= #
818
+ when :checkbox
819
+ ::LibUI.checkbox_set_checked(pointer, 0)
820
+ end
821
+ end; alias is_inactive set_inactive # === is_inactive
822
+ alias is_now_inactive set_inactive # === is_now_inactive
823
+
824
+ # ========================================================================= #
825
+ # === disable (disable tag)
826
+ # ========================================================================= #
827
+ def disable(&block)
828
+ object_id = self.object_id
829
+ hash = hash_fiddle_pointer_widgets?
830
+ type = hash[object_id].last # The last entry contains the type.
831
+ case type
832
+ # ======================================================================= #
833
+ # === :button
834
+ # ======================================================================= #
835
+ when :button
836
+ LibUI.control_disable(self)
837
+ else
838
+ e 'Not registered type in .disable(): '+type.to_s
839
+ end
840
+ end
841
+
842
+ # ========================================================================= #
843
+ # === enable (enable tag)
894
844
  # ========================================================================= #
895
- def set_active
896
- current_widget = available_pointers?[self.object_id] # This will be an Array.
897
- pointer = current_widget.first
898
- type = current_widget.last
845
+ def enable(&block)
846
+ object_id = self.object_id
847
+ hash = hash_fiddle_pointer_widgets?
848
+ type = hash[object_id].last # The last entry contains the type.
899
849
  case type
900
850
  # ======================================================================= #
901
- # === :checkbox
851
+ # === :button
902
852
  # ======================================================================= #
903
- when :checkbox
904
- LibUI.checkbox_set_checked(pointer, 1)
853
+ when :button
854
+ LibUI.control_enable(self)
855
+ else
856
+ e 'Not registered type in .enable(): '+type.to_s
905
857
  end
906
- end; alias is_active set_active # === is_active
907
- alias is_now_active set_active # === is_now_active
858
+ end
908
859
 
909
860
  # ========================================================================= #
910
- # === set_inactive
861
+ # === is_padded
911
862
  # ========================================================================= #
912
- def set_inactive
913
- current_widget = available_pointers?[self.object_id] # This will be an Array.
914
- pointer = current_widget.first
915
- type = current_widget.last
863
+ def is_padded
864
+ set_padded(1)
865
+ end
866
+
867
+ # ========================================================================= #
868
+ # === on_clicked
869
+ #
870
+ # This method is in general called on a button-widget. It allows us
871
+ # to simulate the action associated with clicking on a button.
872
+ # ========================================================================= #
873
+ def on_clicked(&block)
874
+ ::LibUI.button_on_clicked(self, &block)
875
+ end; alias on_click_event on_clicked # === on_click_event
876
+
877
+ # ========================================================================= #
878
+ # === populate
879
+ #
880
+ # This method will (try to) populate a combobox in LibUI.
881
+ # ========================================================================= #
882
+ def populate(dataset)
883
+ object_id = self.object_id
884
+ hash = hash_fiddle_pointer_widgets?
885
+ type = hash[object_id].last
916
886
  case type
917
887
  # ======================================================================= #
918
- # === :checkbox
888
+ # === :combobox
919
889
  # ======================================================================= #
920
- when :checkbox
921
- LibUI.checkbox_set_checked(pointer, 0)
890
+ when :combobox
891
+ self.append_this_array(dataset)
922
892
  end
923
- end; alias is_inactive set_inactive # === is_inactive
924
- alias is_now_inactive set_inactive # === is_now_inactive
893
+ end
925
894
 
926
895
  # ========================================================================= #
927
896
  # === child
@@ -937,7 +906,7 @@ class Pointer # === Fiddle::Pointer
937
906
  # === show_the_controls
938
907
  # ========================================================================= #
939
908
  def show_the_controls
940
- LibUI.control_show(self)
909
+ ::LibUI.control_show(self)
941
910
  end; alias control_show show_the_controls # === control_show
942
911
 
943
912
  # ========================================================================= #
@@ -946,7 +915,7 @@ class Pointer # === Fiddle::Pointer
946
915
  # For now this only works on @main_window.
947
916
  # ========================================================================= #
948
917
  def is_margined(
949
- i = LibuiParadise::Extensions.main_window?
918
+ i = LibuiParadise.main_window?
950
919
  )
951
920
  id = self.object_id
952
921
  hash = main_hash?
@@ -958,7 +927,7 @@ class Pointer # === Fiddle::Pointer
958
927
  # === :window
959
928
  # ===================================================================== #
960
929
  when :window
961
- LibUI.window_set_margined(_.first, 1)
930
+ ::LibUI.window_set_margined(_.first, 1)
962
931
  else
963
932
  e 'The type '+type.to_s+' in is_margined() is currently not supported.'
964
933
  end
@@ -975,6 +944,40 @@ class Pointer # === Fiddle::Pointer
975
944
  end; alias uses_a_margin is_margined # === uses_a_margin
976
945
  alias has_margin is_margined # === has_margin
977
946
 
947
+ # ========================================================================= #
948
+ # === autotitle
949
+ # ========================================================================= #
950
+ def autotitle(
951
+ i = title?
952
+ )
953
+ if i and respond_to?(:set_title)
954
+ set_title(i)
955
+ end
956
+ end
957
+
958
+ # ========================================================================= #
959
+ # === add_hsep
960
+ #
961
+ # This method adds a horizontal separator.
962
+ # ========================================================================= #
963
+ def add_hsep
964
+ object_id = self.object_id
965
+ hash = hash_fiddle_pointer_widgets?
966
+ this_widget = hash[object_id].first
967
+ this_widget.add(::LibuiParadise.horizontal_separator, 0)
968
+ end; alias add_horizontal_separator add_hsep # === add_horizontal_separator
969
+
970
+ # ========================================================================= #
971
+ # === main_then_quit
972
+ #
973
+ # We use ::LibUI just in case to avoid any possible name-collisions.
974
+ # ========================================================================= #
975
+ def main_then_quit
976
+ ::LibUI.main
977
+ ::LibUI.quit
978
+ #::LibUI.uninit # Trying this since as of November 2023. Nope, does not work.
979
+ end
980
+
978
981
  # ========================================================================= #
979
982
  # === close_properly
980
983
  #
@@ -993,54 +996,157 @@ class Pointer # === Fiddle::Pointer
993
996
  alias should_quit close_properly # === should_quit
994
997
 
995
998
  # ========================================================================= #
996
- # === main_then_quit
999
+ # === fraction=
997
1000
  #
998
- # We use ::LibUI just in case to avoid any possible name-collisions.
1001
+ # This method is mostly a wrapper to reach ruby-gtk3 compatibility.
999
1002
  # ========================================================================= #
1000
- def main_then_quit
1001
- ::LibUI.main
1002
- ::LibUI.quit
1003
- #::LibUI.uninit # Trying this since as of November 2023. Nope, does not work.
1003
+ def fraction=(i = '')
1004
+ i = i * 100
1005
+ set_value(i)
1004
1006
  end
1005
1007
 
1006
1008
  # ========================================================================= #
1007
- # === show_then_main_then_quit
1008
- #
1009
- # This method ultimately combines three other method calls.
1009
+ # === left (left tag)
1010
1010
  # ========================================================================= #
1011
- def show_then_main_then_quit
1012
- ::LibUI.control_show(self)
1013
- main_then_quit
1014
- end; alias elegant_exit show_then_main_then_quit # === elegant_exit
1015
- alias complex_finalizer show_then_main_then_quit # === complex_finalizer
1016
- alias intelligent_close_down show_then_main_then_quit # === intelligent_close_down
1017
- alias intelligent_quit show_then_main_then_quit # === intelligent_quit
1018
- alias intelligent_exit show_then_main_then_quit # === intelligent_exit
1011
+ def left(
1012
+ widget,
1013
+ left = LibuiParadise.counter_left?,
1014
+ top = LibuiParadise.counter_top?,
1015
+ xspan = 1,
1016
+ yspan = 1
1017
+ )
1018
+ object_id = self.object_id
1019
+ hash = hash_fiddle_pointer_widgets?
1020
+ type = hash[object_id].last # The last entry contains the type.
1021
+ case left
1022
+ # ======================================================================= #
1023
+ # === :default
1024
+ # ======================================================================= #
1025
+ when :default
1026
+ left = LibuiParadise.counter_left?
1027
+ end
1028
+ case top
1029
+ # ======================================================================= #
1030
+ # === :default
1031
+ # ======================================================================= #
1032
+ when :default
1033
+ top = LibuiParadise.counter_top?
1034
+ end
1035
+ case type
1036
+ # ======================================================================= #
1037
+ # === :vbox
1038
+ # ======================================================================= #
1039
+ when :vbox
1040
+ add(widget)
1041
+ # ======================================================================= #
1042
+ # === :grid
1043
+ # ======================================================================= #
1044
+ when :grid
1045
+ hash_grid(
1046
+ widget,
1047
+ {
1048
+ left: left,
1049
+ top: top,
1050
+ xspan: xspan,
1051
+ yspan: yspan,
1052
+ hexpand: 0,
1053
+ halign: 0,
1054
+ vexpand: 0,
1055
+ valign: 0
1056
+ }
1057
+ )
1058
+ LibuiParadise.counter_left += 1
1059
+ else
1060
+ end
1061
+ end; alias middle left # === middle
1019
1062
 
1020
1063
  # ========================================================================= #
1021
- # === append_text_column
1064
+ # === hash_grid
1065
+ #
1066
+ # Usage example:
1067
+ #
1068
+ # hash_grid(text('Yo6'), { left: 0, top: 3, xspan: 1, yspan: 1, hexpand: 0, halign: 0, vexpand: 0, valign: 0 })
1022
1069
  #
1023
- # This method is specifically used for libui-tables.
1024
1070
  # ========================================================================= #
1025
- def append_text_column(
1026
- text,
1027
- a,
1028
- b = -1
1071
+ def hash_grid(
1072
+ pass_this_widget,
1073
+ hash = {}
1029
1074
  )
1030
- object_id = self.object_id
1031
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
1032
- type = hash[object_id].last # The last entry contains the type.
1033
- case type
1075
+ array_to_be_passed = []
1034
1076
  # ======================================================================= #
1035
- # === :table
1036
- #
1037
- # This is the primary entry point for this method.
1077
+ # === :left
1038
1078
  # ======================================================================= #
1039
- when :table
1040
- ::LibUI.table_append_text_column(self, text, a, b)
1079
+ if hash.has_key? :left
1080
+ array_to_be_passed << hash[:left]
1041
1081
  else
1042
- e 'Not registered type in .append_text_column(): '+type.to_s
1082
+ array_to_be_passed << 0
1083
+ end
1084
+ # ======================================================================= #
1085
+ # === :top
1086
+ # ======================================================================= #
1087
+ if hash.has_key? :top
1088
+ array_to_be_passed << hash[:top]
1089
+ else
1090
+ array_to_be_passed << 0
1091
+ end
1092
+ # ======================================================================= #
1093
+ # === :xspan
1094
+ # ======================================================================= #
1095
+ if hash.has_key? :xspan
1096
+ array_to_be_passed << hash[:xspan]
1097
+ else
1098
+ array_to_be_passed << 0
1099
+ end
1100
+ # ======================================================================= #
1101
+ # === :yspan
1102
+ # ======================================================================= #
1103
+ if hash.has_key? :yspan
1104
+ array_to_be_passed << hash[:yspan]
1105
+ else
1106
+ array_to_be_passed << 0
1107
+ end
1108
+ # ======================================================================= #
1109
+ # === :hexpand
1110
+ # ======================================================================= #
1111
+ if hash.has_key? :hexpand
1112
+ array_to_be_passed << hash[:hexpand]
1113
+ else
1114
+ array_to_be_passed << 0
1115
+ end
1116
+ # ======================================================================= #
1117
+ # === :halign
1118
+ # ======================================================================= #
1119
+ if hash.has_key? :halign
1120
+ array_to_be_passed << hash[:halign]
1121
+ else
1122
+ array_to_be_passed << 0
1123
+ end
1124
+ # ======================================================================= #
1125
+ # === :vexpand
1126
+ # ======================================================================= #
1127
+ if hash.has_key? :vexpand
1128
+ array_to_be_passed << hash[:vexpand]
1129
+ else
1130
+ array_to_be_passed << 0
1131
+ end
1132
+ # ======================================================================= #
1133
+ # === :valign
1134
+ # ======================================================================= #
1135
+ if hash.has_key? :valign
1136
+ array_to_be_passed << hash[:valign]
1137
+ else
1138
+ array_to_be_passed << 0
1043
1139
  end
1140
+ ui_grid_append(pass_this_widget, *array_to_be_passed)
1141
+ end; alias hash hash_grid # === hash
1142
+
1143
+ # ========================================================================= #
1144
+ # === append_this_string
1145
+ #
1146
+ # This method can be used to append a String to an existing String.
1147
+ # ========================================================================= #
1148
+ def append_this_string(i)
1149
+ ::LibUI.attributed_string_append_unattributed(self, i)
1044
1150
  end
1045
1151
 
1046
1152
  # ========================================================================= #
@@ -1098,6 +1204,7 @@ class Pointer # === Fiddle::Pointer
1098
1204
  def set_row_spacing(i = 1); end
1099
1205
  def css_class(i = ''); end
1100
1206
  def set_border_width(i = 2); end
1207
+ alias set_border_size set_border_width
1101
1208
  def set_colour(i = 'blue'); end
1102
1209
  def make_bold; end
1103
1210
  def set_name(i = ''); end
@@ -1112,6 +1219,7 @@ class Pointer # === Fiddle::Pointer
1112
1219
  def lightgreen; end
1113
1220
  def set_background_colour(i = ''); end
1114
1221
  def set_size_request(a = 42, b = 42); end
1222
+ def set_size(a = 42, b = 42); end
1115
1223
  def the_first_entry_is_active; end
1116
1224
  def clear_old_datapoints; end
1117
1225
  def width_height(a = 500, b = 500); end
@@ -1123,6 +1231,7 @@ class Pointer # === Fiddle::Pointer
1123
1231
  def enable_free_form_css; end
1124
1232
  def show_all; end # This one here may become a real method one day, but right now I don't know how to enable that.
1125
1233
  def align_to_the_left; end
1234
+ def align_to_the_right; end
1126
1235
  def yellowish_background; end
1127
1236
  def on_enter; end
1128
1237
  def on_value_changed; end
@@ -1143,7 +1252,9 @@ class Pointer # === Fiddle::Pointer
1143
1252
  def font=(i = ''); end
1144
1253
  def set_activates_default(i = true); end
1145
1254
  def enable_events; end
1255
+ def enable_all_events; end
1146
1256
  def do_focus; end
1257
+ def set_homogeneous(i = true); end
1147
1258
  def border(i = '', *a); end
1148
1259
  def fancy_hint(i = ''); end
1149
1260
  def fancy_hints(i = ''); end
@@ -1160,6 +1271,8 @@ class Pointer # === Fiddle::Pointer
1160
1271
  end
1161
1272
  def set_font_size(i = :hack_26) # Currently not in use.
1162
1273
  end
1274
+ def maximize # This should maximize the window. It does not yet work.
1275
+ end
1163
1276
  def use_gtk_paradise_project_css_file; end
1164
1277
  def on_hover_colour(i = '', &block); end
1165
1278
  def deselect; end
@@ -1172,5 +1285,27 @@ class Pointer # === Fiddle::Pointer
1172
1285
  end
1173
1286
  def default_styling(i = '')
1174
1287
  end
1288
+ # ========================================================================= #
1289
+ # === This is currently not in use.
1290
+ # ========================================================================= #
1291
+ def padding=(i = 8)
1292
+ end
1293
+
1294
+ # ========================================================================= #
1295
+ # === uniform_spacing
1296
+ # ========================================================================= #
1297
+ def uniform_spacing(i = 8)
1298
+ end
1175
1299
 
1300
+ def disable_user_input; end
1301
+ def disallow_resizing
1302
+ end
1303
+ def on_enter_key_pressed(&block)
1304
+ end
1305
+ def use_this_font(i = '')
1306
+ end
1307
+ def set_default_size(a = 680, b = 560)
1308
+ end
1309
+ def top_left
1310
+ end
1176
1311
  end; end