libui_paradise 0.2.49 → 0.4.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +405 -259
  3. data/bin/libui_message +7 -0
  4. data/doc/README.gen +356 -131
  5. data/doc/todo/todo.md +14 -5
  6. data/lib/libui_paradise/autoinclude.rb +2 -1
  7. data/lib/libui_paradise/base/base.rb +51 -62
  8. data/lib/libui_paradise/base_module/base_module.rb +1514 -0
  9. data/lib/libui_paradise/colours/colours.rb +14 -2
  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 +3 -5
  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 +139 -49
  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 +80 -43
  46. data/lib/libui_paradise/examples/simple/005_text_drawing_example.rb +11 -11
  47. data/lib/libui_paradise/examples/simple/007_control_gallery.rb +21 -14
  48. data/lib/libui_paradise/examples/simple/009_spectrum.rb +7 -1
  49. data/lib/libui_paradise/examples/simple/010_font_button.rb +31 -0
  50. data/lib/libui_paradise/examples/simple/011_simple_notepad.rb +24 -0
  51. data/lib/libui_paradise/examples/simple/012_table_example.rb +71 -0
  52. data/lib/libui_paradise/examples/simple/013_scrolling_pane_example.rb +28 -0
  53. data/lib/libui_paradise/examples/simple/014_simple_entry_example.rb +30 -0
  54. data/lib/libui_paradise/examples/simple/015_slider_example.rb +32 -0
  55. data/lib/libui_paradise/fiddle/{pointer.rb → fiddle.rb} +768 -615
  56. data/lib/libui_paradise/generic_window/generic_window.rb +1 -1
  57. data/lib/libui_paradise/images/README.md +5 -2
  58. data/lib/libui_paradise/libui_classes/button.rb +31 -0
  59. data/lib/libui_paradise/libui_classes/entry.rb +35 -0
  60. data/lib/libui_paradise/libui_classes/grid.rb +14 -23
  61. data/lib/libui_paradise/libui_classes/hbox.rb +39 -0
  62. data/lib/libui_paradise/libui_classes/libui_classes.rb +9 -1595
  63. data/lib/libui_paradise/libui_classes/msg_box.rb +121 -0
  64. data/lib/libui_paradise/libui_classes/msg_box_error.rb +41 -0
  65. data/lib/libui_paradise/libui_classes/slider.rb +28 -0
  66. data/lib/libui_paradise/libui_classes/spinbox.rb +48 -0
  67. data/lib/libui_paradise/libui_classes/vbox.rb +38 -0
  68. data/lib/libui_paradise/project/project.rb +6 -1
  69. data/lib/libui_paradise/prototype/prototype.rb +8 -10
  70. data/lib/libui_paradise/requires/require_the_libui_classes.rb +2 -2
  71. data/lib/libui_paradise/requires/require_the_libui_paradise_project.rb +5 -3
  72. data/lib/libui_paradise/toplevel_methods/add_to_the_registered_widgets.rb +70 -0
  73. data/lib/libui_paradise/toplevel_methods/hash_fiddle_pointer_widgets.rb +37 -0
  74. data/lib/libui_paradise/toplevel_methods/toplevel_counters.rb +83 -0
  75. data/lib/libui_paradise/toplevel_methods/toplevel_methods.rb +792 -0
  76. data/lib/libui_paradise/version/version.rb +2 -2
  77. data/lib/libui_paradise.rb +0 -0
  78. data/libui_paradise.gemspec +5 -4
  79. data/test/testing_generic_window.rb +2 -0
  80. metadata +35 -30
  81. data/doc/SNIPPETS.md +0 -94
  82. data/lib/libui_paradise/extensions/counters.rb +0 -58
  83. data/lib/libui_paradise/extensions/extensions.rb +0 -29
  84. data/lib/libui_paradise/extensions/hash_fiddle_pointer_widgets.rb +0 -150
  85. data/lib/libui_paradise/extensions/misc.rb +0 -754
  86. data/lib/libui_paradise/libui_classes/box.rb +0 -156
  87. data/lib/libui_paradise/toplevel_methods/misc.rb +0 -13
@@ -8,250 +8,99 @@
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
- # require 'libui_paradise/fiddle/pointer.rb'
14
+ # require 'libui_paradise/fiddle/fiddle.rb'
15
15
  # =========================================================================== #
16
16
  module Fiddle
17
17
 
18
18
  class Pointer # === Fiddle::Pointer
19
19
 
20
- require 'libui_paradise/extensions/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
- # === on_changed
24
- #
25
- # The idea for this method is to respond to on-changed events, in
26
- # particular on a spinbox. Currently it is enabled for a few
27
- # widgets, including :entry. This may be expanded at a later time
28
- # to add on-changed support for more widgets.
29
- #
30
- # For a combobox we may have to use this code:
31
- #
32
- # LibUI.combobox_on_selected
33
- # UI.spinbox_on_changed(self, spinbox_changed_callback, nil)
34
- # end
35
- #
36
- # Be sure to pass the proc object into the method, in a block.
37
- #
38
- # Usage examples:
39
- #
40
- # text_entry.on_changed { text_changed_callback }
41
- # slider.on_changed { slider_changed_callback }
42
- #
43
- # ========================================================================= #
44
- def on_changed(&block)
45
- current_widget = available_pointers?[self.object_id] # This will be an Array.
46
- _pointer = current_widget.first # Not used currently in this method.
47
- type = current_widget.last
48
- case type
49
- # ======================================================================= #
50
- # === :entry
51
- # ======================================================================= #
52
- when :entry
53
- LibUI.entry_on_changed(self, block.call, nil)
54
- # ======================================================================= #
55
- # === :multiline_entry
56
- # ======================================================================= #
57
- when :multiline_entry
58
- LibUI.multiline_entry_on_changed(self, block.call, nil)
59
- # ======================================================================= #
60
- # === :spinbox
61
- # ======================================================================= #
62
- when :spinbox
63
- LibUI.spinbox_on_changed(self, block.call, nil)
64
- # ======================================================================= #
65
- # === :slider
66
- #
67
- # This is for a slider bar.
68
- # ======================================================================= #
69
- when :slider
70
- LibUI.slider_on_changed(self, block.call, nil)
71
- # ======================================================================= #
72
- # === :colour_button
73
- # ======================================================================= #
74
- when :colour_button
75
- LibUI.color_button_on_changed(self, block.call, nil)
76
- # ======================================================================= #
77
- # === :combobox
78
- # ======================================================================= #
79
- when :combobox
80
- LibUI.combobox_on_selected(self, block.call, nil)
81
- else
82
- e 'Not registered type in .on_changed(): '+type.to_s
83
- end
84
- end
85
-
86
- # ========================================================================= #
87
- # === fraction=
88
- #
89
- # This is mostly a wrapper to reach ruby-gtk3 compatibility.
24
+ # === available_pointers?
90
25
  # ========================================================================= #
91
- def fraction=(i = '')
92
- i = i * 100
93
- set_value(i)
94
- end
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?
95
30
 
96
31
  # ========================================================================= #
97
- # === set_text
98
- #
99
- # This method can be used to set the text of a particular libui-widget,
100
- # in particular entries.
32
+ # === clear
101
33
  # ========================================================================= #
102
- def set_text(
103
- display_this_text = '', # This is the text that will be used.
104
- type = nil
34
+ def clear(
35
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
105
36
  )
37
+ _pointer = current_widget.first # Not used currently in this method.
38
+ type = current_widget.last
39
+
106
40
  object_id = self.object_id
107
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
108
- this_widget = hash[object_id].first
41
+ hash = hash_fiddle_pointer_widgets?
109
42
  if type.nil?
110
43
  type = hash[object_id].last # This should be :grid. But it is not used here.
111
44
  end
112
45
  case type
113
46
  # ======================================================================= #
114
- # === :new_progress_bar
115
- # ======================================================================= #
116
- when :new_progress_bar
117
- # This currently does nothing.
118
- # ======================================================================= #
119
47
  # === :multiline_entry
120
- #
121
- # This is a text-view widget actually.
122
48
  # ======================================================================= #
123
49
  when :multiline_entry
124
- LibUI.multiline_entry_set_text(
125
- this_widget,
126
- display_this_text.to_s
127
- )
128
- # ======================================================================= #
129
- # === :text
130
- # ======================================================================= #
131
- when :text,
132
- :label
133
- LibUI.label_set_text(
134
- this_widget,
135
- display_this_text.to_s
136
- )
137
- # ======================================================================= #
138
- # === :textview
139
- # ======================================================================= #
140
- when :textview
141
- LibUI.multiline_entry_set_text(
142
- this_widget,
143
- display_this_text.to_s
144
- )
145
- # ======================================================================= #
146
- # === :entry
147
- # ======================================================================= #
148
- when :entry
149
- LibUI.entry_set_text(
150
- this_widget,
151
- display_this_text.to_s
152
- )
50
+ ::LibUI.multiline_entry_set_text(self, '')
153
51
  # ======================================================================= #
154
- # === :search_entry
52
+ # === :combobox
155
53
  #
156
- # This is specifically for a search-entry.
54
+ # This currently does not work; it depends on libui-ng, which has not
55
+ # yet been added completely.
157
56
  # ======================================================================= #
158
- when :search_entry
159
- LibUI.entry_set_text(
160
- this_widget,
161
- display_this_text.to_s
162
- )
57
+ when :combobox
58
+ # LibUI.multiline_entry_set_text(
59
+ # this_widget,
60
+ # display_this_text.to_s
61
+ # )
163
62
  else
164
- puts 'Unhandled case in set_text(): '+
165
- type.to_s
63
+ puts "Unhandled case in clear(): "\
64
+ "#{type}"
166
65
  end
167
- end; alias set_content set_text # === set_content
66
+ end
168
67
 
169
68
  # ========================================================================= #
170
- # === text?
171
- #
172
- # This method queries the content of any widget that may contain text, in
173
- # particular entries such as a gtk-entry.
69
+ # === is_read_only
174
70
  # ========================================================================= #
175
- def text?(
176
- type = nil
71
+ def is_read_only(
72
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
177
73
  )
178
- object_id = self.object_id
179
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
180
- if type.nil?
181
- # ===================================================================== #
182
- # In this case we must determine the type in use.
183
- # ===================================================================== #
184
- if hash.has_key? object_id
185
- type = hash[object_id].last # The last entry contains the type.
186
- end
187
- end
74
+ _pointer = current_widget.first # Not used currently in this method.
75
+ type = current_widget.last
188
76
  case type
189
77
  # ======================================================================= #
190
- # === :new_progress_bar
191
- #
192
- # This is actually a progress-bar.
78
+ # === :entry
193
79
  # ======================================================================= #
194
- when :new_progress_bar,
195
- :progress_bar
196
- return LibUI.progress_bar_value(self).to_s
80
+ when :entry
81
+ ::LibUI.entry_set_read_only(self, 1)
197
82
  # ======================================================================= #
198
83
  # === :multiline_entry
199
- #
200
- # This is, I believe, synonymous to :textview.
201
- # ======================================================================= #
202
- when :multiline_entry,
203
- :textview
204
- return LibUI.multiline_entry_text(self).to_s
205
- # ======================================================================= #
206
- # === :combobox
207
84
  # ======================================================================= #
208
- when :combobox
209
- return LibUI.combobox_selected(self).to_s
210
- else # This is the "historic" default. May have to be removed one day.
211
- return LibUI.entry_text(self).to_s
85
+ when :multiline_entry
86
+ ::LibUI.multiline_entry_set_read_only(self, 1)
87
+ else
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
212
94
  end
213
- end; alias buffer? text? # === buffer?
214
- alias selected? text? # === selected?
215
- alias value? text? # === value?
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
216
97
 
217
98
  # ========================================================================= #
218
- # === set_value
219
- #
220
- # This method has initially been created to assign a value to a
221
- # spinbutton. That way the following API is made possible:
222
- #
223
- # spinbutton.set_value(42)
224
- #
99
+ # === new_row
225
100
  # ========================================================================= #
226
- def set_value(
227
- new_value
228
- )
229
- object_id = self.object_id
230
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
231
- this_widget = hash[object_id].first
232
- type = hash[object_id].last
233
- case type
234
- # ======================================================================= #
235
- # === :new_progress_bar
236
- #
237
- # This is actually a progress-bar.
238
- # ======================================================================= #
239
- when :new_progress_bar,
240
- :progress_bar
241
- LibUI.progress_bar_set_value(this_widget, new_value.to_i)
242
- # ======================================================================= #
243
- # === :spinbox
244
- # ======================================================================= #
245
- when :spinbox
246
- LibUI.spinbox_set_value(
247
- this_widget,
248
- new_value.to_i # Must be an Integer.
249
- )
250
- else
251
- e 'Not registered type: '+type.to_s
252
- end
253
- end; alias value= set_value # === value=
254
- alias start_position= set_value # === start_position=
101
+ def new_row
102
+ ::LibuiParadise.new_row
103
+ end
255
104
 
256
105
  # ========================================================================= #
257
106
  # === right (right tag)
@@ -264,7 +113,7 @@ class Pointer # === Fiddle::Pointer
264
113
  yspan = 1
265
114
  )
266
115
  object_id = self.object_id
267
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
116
+ hash = hash_fiddle_pointer_widgets?
268
117
  type = hash[object_id].last # The last entry contains the type.
269
118
  case left
270
119
  # ======================================================================= #
@@ -303,202 +152,225 @@ class Pointer # === Fiddle::Pointer
303
152
  valign: 0
304
153
  }
305
154
  )
306
- LibuiParadise.counter_left += 1
155
+ # ===================================================================== #
156
+ # And we must add a new row next:
157
+ # ===================================================================== #
158
+ LibuiParadise.new_row
307
159
  else
308
160
  end
309
161
  end
310
162
 
311
163
  # ========================================================================= #
312
- # === left (left tag)
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
+ #
313
172
  # ========================================================================= #
314
- def left(
315
- widget,
316
- left = LibuiParadise.counter_left?,
317
- top = LibuiParadise.counter_top?,
318
- xspan = 1,
319
- yspan = 1
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
320
183
  )
321
- object_id = self.object_id
322
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
323
- type = hash[object_id].last # The last entry contains the type.
324
- case left
325
184
  # ======================================================================= #
326
- # === :default
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
+ #
327
189
  # ======================================================================= #
328
- when :default
329
- left = LibuiParadise.counter_left?
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
330
196
  end
331
- case top
332
- # ======================================================================= #
333
- # === :default
334
- # ======================================================================= #
335
- when :default
336
- top = LibuiParadise.counter_top?
337
- end
338
- case type
339
- # ======================================================================= #
340
- # === :vbox
341
- # ======================================================================= #
342
- when :vbox
343
- add(widget)
344
197
  # ======================================================================= #
345
- # === :grid
198
+ # left, top, xspan, yspan, hexpand, halign, vexpand, valign
199
+ # 0, 0, 2, 1, 0, 0, 1, 0
346
200
  # ======================================================================= #
347
- when :grid
348
- hash_grid(
349
- widget,
350
- {
351
- left: left,
352
- top: top,
353
- xspan: xspan,
354
- yspan: yspan,
355
- hexpand: 0,
356
- halign: 0,
357
- vexpand: 0,
358
- valign: 0
359
- }
360
- )
361
- LibuiParadise.counter_left += 1
362
- else
363
- end
364
- end
365
-
366
- # ========================================================================= #
367
- # === new_row
368
- # ========================================================================= #
369
- def new_row
370
- LibuiParadise.counter_left = 0
371
- LibuiParadise.counter_top += 1
372
- end
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
373
214
 
374
215
  # ========================================================================= #
375
- # === hash_grid
376
- #
377
- # Usage example:
216
+ # === show_then_main_then_quit
378
217
  #
379
- # hash_grid(text('Yo6'), { left: 0, top: 3, xspan: 1, yspan: 1, hexpand: 0, halign: 0, vexpand: 0, valign: 0 })
218
+ # This method ultimately combines three other method calls, or even
219
+ # four, since as of December 2023.
380
220
  #
221
+ # The argument that this method accepts is the main window.
381
222
  # ========================================================================= #
382
- def hash_grid(
383
- pass_this_widget,
384
- hash = {}
223
+ def show_then_main_then_quit(
224
+ optional_widget = nil
385
225
  )
386
- array_to_be_passed = []
387
226
  # ======================================================================= #
388
- # === :left
227
+ # First handle non-nil arguments given.
389
228
  # ======================================================================= #
390
- if hash.has_key? :left
391
- array_to_be_passed << hash[:left]
392
- else
393
- array_to_be_passed << 0
394
- end
395
- # ======================================================================= #
396
- # === :top
397
- # ======================================================================= #
398
- if hash.has_key? :top
399
- array_to_be_passed << hash[:top]
400
- else
401
- array_to_be_passed << 0
229
+ if optional_widget
230
+ self << optional_widget
402
231
  end
403
- # ======================================================================= #
404
- # === :xspan
405
- # ======================================================================= #
406
- if hash.has_key? :xspan
407
- array_to_be_passed << hash[:xspan]
408
- else
409
- array_to_be_passed << 0
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
239
+
240
+ # ========================================================================= #
241
+ # === text?
242
+ #
243
+ # This method queries the content of any widget that may contain text, in
244
+ # particular entries such as a gtk-entry.
245
+ # ========================================================================= #
246
+ def text?(
247
+ type = nil
248
+ )
249
+ object_id = self.object_id
250
+ hash = hash_fiddle_pointer_widgets?
251
+ if type.nil?
252
+ # ===================================================================== #
253
+ # In this case we must determine the type in use.
254
+ # ===================================================================== #
255
+ if hash.has_key? object_id
256
+ type = hash[object_id].last # The last entry contains the type.
257
+ end
410
258
  end
259
+ case type
411
260
  # ======================================================================= #
412
- # === :yspan
261
+ # === :label
413
262
  # ======================================================================= #
414
- if hash.has_key? :yspan
415
- array_to_be_passed << hash[:yspan]
416
- else
417
- array_to_be_passed << 0
418
- end
263
+ when :label
264
+ return LibUI.label_text(self).to_s
419
265
  # ======================================================================= #
420
- # === :hexpand
266
+ # === :new_progress_bar
267
+ #
268
+ # This is actually a progress-bar.
421
269
  # ======================================================================= #
422
- if hash.has_key? :hexpand
423
- array_to_be_passed << hash[:hexpand]
424
- else
425
- array_to_be_passed << 0
426
- end
270
+ when :new_progress_bar,
271
+ :progress_bar
272
+ return LibUI.progress_bar_value(self).to_s
427
273
  # ======================================================================= #
428
- # === :halign
274
+ # === :multiline_entry
275
+ #
276
+ # This is, I believe, synonymous to :textview.
429
277
  # ======================================================================= #
430
- if hash.has_key? :halign
431
- array_to_be_passed << hash[:halign]
432
- else
433
- array_to_be_passed << 0
434
- end
278
+ when :multiline_entry,
279
+ :textview
280
+ return LibUI.multiline_entry_text(self).to_s
435
281
  # ======================================================================= #
436
- # === :vexpand
282
+ # === :combobox
437
283
  # ======================================================================= #
438
- if hash.has_key? :vexpand
439
- array_to_be_passed << hash[:vexpand]
440
- else
441
- array_to_be_passed << 0
284
+ when :combobox
285
+ return LibUI.combobox_selected(self).to_s
286
+ else # This is the "historic" default. May have to be removed one day.
287
+ return LibUI.entry_text(self).to_s
442
288
  end
289
+ end; alias buffer? text? # === buffer?
290
+ alias value? text? # === value?
291
+ alias selected? text? # === selected?
292
+
293
+ # ========================================================================= #
294
+ # === on_toggled
295
+ # ========================================================================= #
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
300
+ case type
443
301
  # ======================================================================= #
444
- # === :valign
302
+ # === :checkbox
445
303
  # ======================================================================= #
446
- if hash.has_key? :valign
447
- array_to_be_passed << hash[:valign]
304
+ when :checkbox
305
+ ::LibUI.checkbox_on_toggled(self, block.call, nil)
448
306
  else
449
- array_to_be_passed << 0
307
+ e 'Not yet added here: '+type.to_s
450
308
  end
451
- ui_grid_append(pass_this_widget, *array_to_be_passed)
452
- end; alias hash hash_grid # === hash
309
+ end
453
310
 
454
311
  # ========================================================================= #
455
- # === ui_grid_append
312
+ # === on_changed
456
313
  #
457
- # This method can be used to append onto a grid in LibUI.
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.
458
318
  #
459
- # Usage example:
319
+ # For a combobox we may have to use this code:
460
320
  #
461
- # grid.grid_append(text('Right'), 1, 0, 1, 1, 0, 0.5, 1, 0)
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 }
462
331
  #
463
332
  # ========================================================================= #
464
- def ui_grid_append(
465
- widget_to_append,
466
- left = 0,
467
- top = 0,
468
- xspan = 1,
469
- yspan = 1, #
470
- hexpand = 0, # A "boolean". 0 means false here.
471
- halign = 0,
472
- vexpand = 0, # A "boolean". 0 means false here.
473
- valign = 0
474
- )
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
475
338
  # ======================================================================= #
476
- # The signature in Go is:
477
- #
478
- # Append(child Control, left, top int, xspan, yspan int, hexpand bool, halign Align, vexpand bool, valign Align)
339
+ # === :entry
340
+ # ======================================================================= #
341
+ when :entry
342
+ ::LibUI.entry_on_changed(self, block.call, nil)
343
+ # ======================================================================= #
344
+ # === :multiline_entry
345
+ # ======================================================================= #
346
+ when :multiline_entry
347
+ ::LibUI.multiline_entry_on_changed(self, block.call, nil)
348
+ # ======================================================================= #
349
+ # === :spinbox
350
+ # ======================================================================= #
351
+ when :spinbox
352
+ ::LibUI.spinbox_on_changed(self, block.call, nil)
353
+ # ======================================================================= #
354
+ # === :slider
479
355
  #
356
+ # This is for a slider bar.
480
357
  # ======================================================================= #
481
- object_id = self.object_id
482
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
483
- this_widget = hash[object_id].first
484
- _type = hash[object_id].last # This should be :grid. But it is not used here.
358
+ when :slider
359
+ ::LibUI.slider_on_changed(self, block.call, nil)
485
360
  # ======================================================================= #
486
- # left, top, xspan, yspan, hexpand, halign, vexpand, valign
487
- # 0, 0, 2, 1, 0, 0, 1, 0
361
+ # === :colour_button
488
362
  # ======================================================================= #
489
- LibUI.grid_append(
490
- this_widget,
491
- widget_to_append,
492
- left,
493
- top,
494
- xspan,
495
- yspan,
496
- hexpand,
497
- halign,
498
- vexpand,
499
- valign
500
- )
501
- end; alias grid_append ui_grid_append # === grid_append
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)
370
+ else
371
+ e 'Not registered type in .on_changed(): '+type.to_s
372
+ end
373
+ end
502
374
 
503
375
  # ========================================================================= #
504
376
  # === append (append tag, add tag)
@@ -510,22 +382,44 @@ class Pointer # === Fiddle::Pointer
510
382
  padding_to_use = 1,
511
383
  *remaining_arguments
512
384
  )
385
+ if padding_to_use.is_a? Hash
386
+ padding_to_use = 1 # Hardcoded exception.
387
+ end
388
+ if padding_to_use > 1
389
+ padding_to_use = 1 # For now only a value of 1 seems to work.
390
+ end
513
391
  current_widget = available_pointers?[self.object_id] # This will be an Array.
514
392
  _pointer = current_widget.first # Not used currently in this method.
515
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
403
+ end
516
404
  case type
517
405
  # ======================================================================= #
518
406
  # === :grid
519
407
  #
520
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
+ #
521
415
  # ======================================================================= #
522
416
  when :grid
523
417
  LibUI.grid_append(
524
418
  self,
525
419
  this_widget.to_s,
526
420
  padding_to_use,
527
- remaining_arguments[0],
528
- remaining_arguments[1],
421
+ left_position,
422
+ top_position,
529
423
  remaining_arguments[2],
530
424
  remaining_arguments[3],
531
425
  remaining_arguments[4],
@@ -553,42 +447,197 @@ class Pointer # === Fiddle::Pointer
553
447
  when :window
554
448
  LibUI.window_set_child(self, this_widget)
555
449
  else # This is the default.
556
- LibUI.box_append(
450
+ ::LibUI.box_append(
557
451
  self, this_widget, padding_to_use
558
452
  )
559
453
  end
560
- end; alias add append # === add
561
- alias << append # === <<
454
+ end; alias add append # === add
455
+ alias << append # === <<
456
+ alias pack_start append # === pack_start
457
+
458
+ # ========================================================================= #
459
+ # === append_text_column
460
+ #
461
+ # This method is specifically used for libui-tables.
462
+ # ========================================================================= #
463
+ def append_text_column(
464
+ text,
465
+ a,
466
+ b = -1
467
+ )
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
472
+ # ======================================================================= #
473
+ # === :table
474
+ #
475
+ # This is the primary entry point for this method.
476
+ # ======================================================================= #
477
+ when :table
478
+ ::LibUI.table_append_text_column(self, text, a, b)
479
+ else
480
+ e 'Not registered type in .append_text_column(): '+type.to_s
481
+ end
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.
499
+ end
500
+ case type
501
+ # ======================================================================= #
502
+ # === :new_progress_bar
503
+ # ======================================================================= #
504
+ when :new_progress_bar
505
+ # This currently does nothing.
506
+ # ======================================================================= #
507
+ # === :multiline_entry
508
+ #
509
+ # This is a text-view widget actually.
510
+ # ======================================================================= #
511
+ when :multiline_entry
512
+ LibUI.multiline_entry_set_text(
513
+ this_widget,
514
+ display_this_text.to_s
515
+ )
516
+ # ======================================================================= #
517
+ # === :text
518
+ # ======================================================================= #
519
+ when :text,
520
+ :label
521
+ LibUI.label_set_text(
522
+ this_widget,
523
+ display_this_text.to_s
524
+ )
525
+ # ======================================================================= #
526
+ # === :textview
527
+ # ======================================================================= #
528
+ when :textview
529
+ LibUI.multiline_entry_set_text(
530
+ this_widget,
531
+ display_this_text.to_s
532
+ )
533
+ # ======================================================================= #
534
+ # === :entry
535
+ # ======================================================================= #
536
+ when :entry
537
+ LibUI.entry_set_text(
538
+ this_widget,
539
+ display_this_text.to_s
540
+ )
541
+ # ======================================================================= #
542
+ # === :search_entry
543
+ #
544
+ # This is specifically for a search-entry.
545
+ # ======================================================================= #
546
+ when :search_entry
547
+ LibUI.entry_set_text(
548
+ this_widget,
549
+ display_this_text.to_s
550
+ )
551
+ else
552
+ puts 'Unhandled case in set_text(): '+
553
+ type.to_s
554
+ end
555
+ end; alias set_content set_text # === set_content
556
+
557
+ # ========================================================================= #
558
+ # === group_maximal
559
+ # ========================================================================= #
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(
577
+ this_widget,
578
+ optional_padding = 0
579
+ )
580
+ add(this_widget, optional_padding)
581
+ end
582
+
583
+ # ========================================================================= #
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)
590
+ #
591
+ # ========================================================================= #
592
+ def set_value(
593
+ new_value
594
+ )
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
599
+ case type
600
+ # ======================================================================= #
601
+ # === :new_progress_bar
602
+ #
603
+ # This is actually a progress-bar.
604
+ # ======================================================================= #
605
+ when :new_progress_bar,
606
+ :progress_bar
607
+ ::LibUI.progress_bar_set_value(this_widget, new_value.to_i)
608
+ # ======================================================================= #
609
+ # === :spinbox
610
+ # ======================================================================= #
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=
562
621
 
563
622
  # ========================================================================= #
564
- # === clear
623
+ # === append_this_array
624
+ #
625
+ # This method only works for comboboxes.
565
626
  # ========================================================================= #
566
- def clear(
567
- current_widget = available_pointers?[self.object_id] # This will be an Array.
568
- )
569
- _pointer = current_widget.first # Not used currently in this method.
570
- type = current_widget.last
571
-
627
+ def append_this_array(array)
572
628
  object_id = self.object_id
573
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
574
- if type.nil?
575
- type = hash[object_id].last # This should be :grid. But it is not used here.
576
- end
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
577
632
  case type
578
633
  # ======================================================================= #
579
634
  # === :combobox
580
- #
581
- # This currently does not work; it depends on libui-ng, which has not
582
- # yet been added completely.
583
635
  # ======================================================================= #
584
636
  when :combobox
585
- # LibUI.multiline_entry_set_text(
586
- # this_widget,
587
- # display_this_text.to_s
588
- # )
589
- else
590
- puts 'Unhandled case in clear(): '+
591
- type.to_s
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.
592
641
  end
593
642
  end
594
643
 
@@ -599,7 +648,7 @@ class Pointer # === Fiddle::Pointer
599
648
  type = nil
600
649
  )
601
650
  object_id = self.object_id
602
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
651
+ hash = hash_fiddle_pointer_widgets?
603
652
  if type.nil?
604
653
  # ===================================================================== #
605
654
  # In this case we must determine the type in use.
@@ -619,66 +668,17 @@ class Pointer # === Fiddle::Pointer
619
668
  end
620
669
  end
621
670
 
622
- # ========================================================================= #
623
- # === is_read_only
624
- # ========================================================================= #
625
- def is_read_only(
626
- current_widget = available_pointers?[self.object_id] # This will be an Array.
627
- )
628
- _pointer = current_widget.first # Not used currently in this method.
629
- type = current_widget.last
630
- case type
631
- # ======================================================================= #
632
- # === :multiline_entry
633
- # ======================================================================= #
634
- when :multiline_entry
635
- LibUI.multiline_entry_set_read_only(self, 1)
636
- else
637
- pp caller()
638
- puts "#{type} (class #{type.class}) is not yet implemented in .padded=."
639
- end
640
- end
641
-
642
- # ========================================================================= #
643
- # === append_this_string
644
- #
645
- # This method can be used to append a String to an existing String.
646
- # ========================================================================= #
647
- def append_this_string(i)
648
- ::LibUI.attributed_string_append_unattributed(self, i)
649
- end
650
-
651
- # ========================================================================= #
652
- # === append_text_column
653
- #
654
- # This method is specifically used for libui-tables.
655
- # ========================================================================= #
656
- def append_text_column(text, a, b)
657
- object_id = self.object_id
658
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
659
- type = hash[object_id].last # The last entry contains the type.
660
- case type
661
- # ======================================================================= #
662
- # === :button
663
- # ======================================================================= #
664
- when :table
665
- LibUI.table_append_text_column(self, text, a, b)
666
- else
667
- e 'Not registered type in .append_text_column(): '+type.to_s
668
- end
669
- end
670
-
671
671
  # ========================================================================= #
672
672
  # === padded=
673
673
  #
674
674
  # Set a uniform padding via this method.
675
675
  # ========================================================================= #
676
676
  def padded=(
677
- pad_n_px = 25,
677
+ pad_n_px = 25, # How much to pad in n px. LibUI currently does not allow for that, though.
678
678
  type = nil
679
679
  )
680
680
  object_id = self.object_id
681
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
681
+ hash = hash_fiddle_pointer_widgets?
682
682
  if type.nil?
683
683
  # ===================================================================== #
684
684
  # In this case we must determine the type in use.
@@ -689,6 +689,11 @@ class Pointer # === Fiddle::Pointer
689
689
  end
690
690
  case type
691
691
  # ======================================================================= #
692
+ # === :window
693
+ # ======================================================================= #
694
+ when :window
695
+ LibUI.window_set_margined(self, 1)
696
+ # ======================================================================= #
692
697
  # === :grid
693
698
  # ======================================================================= #
694
699
  when :grid
@@ -719,139 +724,8 @@ class Pointer # === Fiddle::Pointer
719
724
  pp caller()
720
725
  puts "#{type} (class #{type.class}) is not yet implemented in .padded=."
721
726
  end
722
- end; alias set_padded padded= # === set_padded
723
-
724
- # ========================================================================= #
725
- # === disable (disable tag)
726
- # ========================================================================= #
727
- def disable(&block)
728
- object_id = self.object_id
729
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
730
- type = hash[object_id].last # The last entry contains the type.
731
- case type
732
- # ======================================================================= #
733
- # === :button
734
- # ======================================================================= #
735
- when :button
736
- LibUI.control_disable(self)
737
- else
738
- e 'Not registered type in .disable(): '+type.to_s
739
- end
740
- end
741
-
742
- # ========================================================================= #
743
- # === enable (enable tag)
744
- # ========================================================================= #
745
- def enable(&block)
746
- object_id = self.object_id
747
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
748
- type = hash[object_id].last # The last entry contains the type.
749
- case type
750
- # ======================================================================= #
751
- # === :button
752
- # ======================================================================= #
753
- when :button
754
- LibUI.control_enable(self)
755
- else
756
- e 'Not registered type in .enable(): '+type.to_s
757
- end
758
- end
759
-
760
- # ========================================================================= #
761
- # === populate
762
- # ========================================================================= #
763
- def populate(dataset)
764
- object_id = self.object_id
765
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
766
- type = hash[object_id].last
767
- case type
768
- # ======================================================================= #
769
- # === :combobox
770
- # ======================================================================= #
771
- when :combobox
772
- self.append_this_array(dataset)
773
- end
774
- end
775
-
776
- # ========================================================================= #
777
- # === is_padded
778
- # ========================================================================= #
779
- def is_padded
780
- set_padded(1)
781
- end
782
-
783
- # ========================================================================= #
784
- # === show_then_main_then_quit
785
- #
786
- # This method ultimately combines three other method calls.
787
- # ========================================================================= #
788
- def show_then_main_then_quit
789
- LibUI.control_show(self)
790
- main_then_quit
791
- end; alias elegant_exit show_then_main_then_quit # === elegant_exit
792
- alias complex_finalizer show_then_main_then_quit # === complex_finalizer
793
- alias intelligent_close_down show_then_main_then_quit # === intelligent_close_down
794
- alias intelligent_quit show_then_main_then_quit # === intelligent_quit
795
- alias intelligent_exit show_then_main_then_quit # === intelligent_exit
796
-
797
- # ========================================================================= #
798
- # === on_clicked
799
- #
800
- # This method is in general called on a button-widget.
801
- # ========================================================================= #
802
- def on_clicked(&block)
803
- LibUI.button_on_clicked(self, &block)
804
- end; alias on_click_event on_clicked # === on_click_event
805
-
806
- # ========================================================================= #
807
- # === available_pointers?
808
- # ========================================================================= #
809
- def available_pointers?
810
- LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
811
- end; alias main_hash? available_pointers? # === main_hash?
812
-
813
- # ========================================================================= #
814
- # === append_this_array
815
- # ========================================================================= #
816
- def append_this_array(array)
817
- object_id = self.object_id
818
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
819
- _this_widget = hash[object_id].first # This variable is currently not in use.
820
- type = hash[object_id].last
821
- case type
822
- # ======================================================================= #
823
- # === :combobox
824
- # ======================================================================= #
825
- when :combobox
826
- array.each {|this_entry|
827
- LibUI.combobox_append(self, this_entry)
828
- }
829
- LibUI.combobox_set_selected(self, 0) # The first one will be active too.
830
- end
831
- end
832
-
833
- # ========================================================================= #
834
- # === maximal
835
- # ========================================================================= #
836
- def maximal(this_widget, optional_padding = 1)
837
- add(this_widget, optional_padding)
838
- end
839
-
840
- # ========================================================================= #
841
- # === group_maximal
842
- # ========================================================================= #
843
- def group_maximal(*i)
844
- i.flatten.each {|entry|
845
- maximal(entry)
846
- }
847
- end
848
-
849
- # ========================================================================= #
850
- # === minimal
851
- # ========================================================================= #
852
- def minimal(this_widget, optional_padding = 0)
853
- add(this_widget, optional_padding)
854
- end
727
+ end; alias set_padded padded= # === set_padded
728
+ alias set_padding padded= # === set_padding
855
729
 
856
730
  # ========================================================================= #
857
731
  # === text
@@ -872,7 +746,7 @@ class Pointer # === Fiddle::Pointer
872
746
  )
873
747
  i = i.to_s # Let's ensure we have a String past this point.
874
748
  object_id = self.object_id
875
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
749
+ hash = hash_fiddle_pointer_widgets?
876
750
  _this_widget = hash[object_id].first # This variable is currently not in use.
877
751
  type = hash[object_id].last
878
752
  case type
@@ -886,18 +760,6 @@ class Pointer # === Fiddle::Pointer
886
760
  end
887
761
  end; alias add_text text # === text
888
762
 
889
- # ========================================================================= #
890
- # === add_hsep
891
- #
892
- # This method adds a horizontal separator.
893
- # ========================================================================= #
894
- def add_hsep
895
- object_id = self.object_id
896
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
897
- this_widget = hash[object_id].first
898
- this_widget.add(::LibuiParadise::Extensions.horizontal_separator, 0)
899
- end; alias add_horizontal_separator add_hsep # === add_horizontal_separator
900
-
901
763
  # ========================================================================= #
902
764
  # === active?
903
765
  # ========================================================================= #
@@ -910,7 +772,7 @@ class Pointer # === Fiddle::Pointer
910
772
  # === :checkbox
911
773
  # ======================================================================= #
912
774
  when :checkbox
913
- checked = (UI.checkbox_checked(pointer) == 1)
775
+ checked = (::LibUI.checkbox_checked(pointer) == 1)
914
776
  return (checked == true)
915
777
  # ======================================================================= #
916
778
  # === :entry
@@ -921,41 +783,114 @@ class Pointer # === Fiddle::Pointer
921
783
  e 'An entry can not be "active". Check the code - there may '\
922
784
  'an erroneous assumption if the method .active? is called.'
923
785
  end
924
- end; alias is_active? active? # === is_active?
786
+ end; alias is_active? active? # === is_active?
787
+
788
+ # ========================================================================= #
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
925
841
 
926
842
  # ========================================================================= #
927
- # === set_active
843
+ # === enable (enable tag)
928
844
  # ========================================================================= #
929
- def set_active
930
- current_widget = available_pointers?[self.object_id] # This will be an Array.
931
- pointer = current_widget.first
932
- 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.
933
849
  case type
934
850
  # ======================================================================= #
935
- # === :checkbox
851
+ # === :button
936
852
  # ======================================================================= #
937
- when :checkbox
938
- 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
939
857
  end
940
- end; alias is_active set_active # === is_active
941
- alias is_now_active set_active # === is_now_active
858
+ end
942
859
 
943
860
  # ========================================================================= #
944
- # === set_inactive
861
+ # === is_padded
945
862
  # ========================================================================= #
946
- def set_inactive
947
- current_widget = available_pointers?[self.object_id] # This will be an Array.
948
- pointer = current_widget.first
949
- 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
950
886
  case type
951
887
  # ======================================================================= #
952
- # === :checkbox
888
+ # === :combobox
953
889
  # ======================================================================= #
954
- when :checkbox
955
- LibUI.checkbox_set_checked(pointer, 0)
890
+ when :combobox
891
+ self.append_this_array(dataset)
956
892
  end
957
- end; alias is_inactive set_inactive # === is_inactive
958
- alias is_now_inactive set_inactive # === is_now_inactive
893
+ end
959
894
 
960
895
  # ========================================================================= #
961
896
  # === child
@@ -971,7 +906,7 @@ class Pointer # === Fiddle::Pointer
971
906
  # === show_the_controls
972
907
  # ========================================================================= #
973
908
  def show_the_controls
974
- LibUI.control_show(self)
909
+ ::LibUI.control_show(self)
975
910
  end; alias control_show show_the_controls # === control_show
976
911
 
977
912
  # ========================================================================= #
@@ -980,7 +915,7 @@ class Pointer # === Fiddle::Pointer
980
915
  # For now this only works on @main_window.
981
916
  # ========================================================================= #
982
917
  def is_margined(
983
- i = LibuiParadise::Extensions.main_window?
918
+ i = LibuiParadise.main_window?
984
919
  )
985
920
  id = self.object_id
986
921
  hash = main_hash?
@@ -992,7 +927,7 @@ class Pointer # === Fiddle::Pointer
992
927
  # === :window
993
928
  # ===================================================================== #
994
929
  when :window
995
- LibUI.window_set_margined(_.first, 1)
930
+ ::LibUI.window_set_margined(_.first, 1)
996
931
  else
997
932
  e 'The type '+type.to_s+' in is_margined() is currently not supported.'
998
933
  end
@@ -1009,6 +944,29 @@ class Pointer # === Fiddle::Pointer
1009
944
  end; alias uses_a_margin is_margined # === uses_a_margin
1010
945
  alias has_margin is_margined # === has_margin
1011
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
+
1012
970
  # ========================================================================= #
1013
971
  # === main_then_quit
1014
972
  #
@@ -1017,6 +975,7 @@ class Pointer # === Fiddle::Pointer
1017
975
  def main_then_quit
1018
976
  ::LibUI.main
1019
977
  ::LibUI.quit
978
+ #::LibUI.uninit # Trying this since as of November 2023. Nope, does not work.
1020
979
  end
1021
980
 
1022
981
  # ========================================================================= #
@@ -1033,15 +992,183 @@ class Pointer # === Fiddle::Pointer
1033
992
  }
1034
993
  end; alias simple_exit close_properly # === simple_exit
1035
994
  alias sane_exit close_properly # === sane_exit
1036
- alias should_quit close_properly # === should_quit
1037
995
  alias do_quit close_properly # === should_quit
996
+ alias should_quit close_properly # === should_quit
997
+
998
+ # ========================================================================= #
999
+ # === fraction=
1000
+ #
1001
+ # This method is mostly a wrapper to reach ruby-gtk3 compatibility.
1002
+ # ========================================================================= #
1003
+ def fraction=(i = '')
1004
+ i = i * 100
1005
+ set_value(i)
1006
+ end
1007
+
1008
+ # ========================================================================= #
1009
+ # === left (left tag)
1010
+ # ========================================================================= #
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
1062
+
1063
+ # ========================================================================= #
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 })
1069
+ #
1070
+ # ========================================================================= #
1071
+ def hash_grid(
1072
+ pass_this_widget,
1073
+ hash = {}
1074
+ )
1075
+ array_to_be_passed = []
1076
+ # ======================================================================= #
1077
+ # === :left
1078
+ # ======================================================================= #
1079
+ if hash.has_key? :left
1080
+ array_to_be_passed << hash[:left]
1081
+ else
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
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)
1150
+ end
1151
+
1152
+ # ========================================================================= #
1153
+ # === on_key_press_event
1154
+ # ========================================================================= #
1155
+ def on_key_press_event(&block)
1156
+ # e 'NOT YET IMPLEMENTED.'
1157
+ end
1158
+
1159
+ # ========================================================================= #
1160
+ # === on_button_press_event
1161
+ # ========================================================================= #
1162
+ def on_button_press_event(&block)
1163
+ # e 'NOT YET IMPLEMENTED'
1164
+ end
1038
1165
 
1039
1166
  # ========================================================================= #
1040
- # === Skeleton methods:
1167
+ # === Skeleton methods
1041
1168
  #
1042
- # A "skeleton" method is one that doesn't do anything right now. These
1043
- # were added to increase compatibility with the gtk_paradise gem in
1044
- # particular.
1169
+ # A "skeleton" method is one that doesn't do anything right now.
1170
+ # These were added to increase compatibility with the gtk_paradise
1171
+ # gem in particular.
1045
1172
  #
1046
1173
  # Some of these skeleton methods may become real methods one day,
1047
1174
  # depending on how sophisticated the libui code will be - but
@@ -1071,13 +1198,13 @@ class Pointer # === Fiddle::Pointer
1071
1198
  def reset_the_internal_variables; end
1072
1199
  def editable=(true_or_false = false); end
1073
1200
  def set_max_length(n = 100); end
1074
- def use_gtk_paradise_project_css_file; end
1075
1201
  def append_project_CSS_file; end
1076
1202
  def infer_the_size_automatically; end
1077
1203
  def set_column_spacing(i = 1); end
1078
1204
  def set_row_spacing(i = 1); end
1079
1205
  def css_class(i = ''); end
1080
1206
  def set_border_width(i = 2); end
1207
+ alias set_border_size set_border_width
1081
1208
  def set_colour(i = 'blue'); end
1082
1209
  def make_bold; end
1083
1210
  def set_name(i = ''); end
@@ -1092,6 +1219,7 @@ class Pointer # === Fiddle::Pointer
1092
1219
  def lightgreen; end
1093
1220
  def set_background_colour(i = ''); end
1094
1221
  def set_size_request(a = 42, b = 42); end
1222
+ def set_size(a = 42, b = 42); end
1095
1223
  def the_first_entry_is_active; end
1096
1224
  def clear_old_datapoints; end
1097
1225
  def width_height(a = 500, b = 500); end
@@ -1103,6 +1231,7 @@ class Pointer # === Fiddle::Pointer
1103
1231
  def enable_free_form_css; end
1104
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.
1105
1233
  def align_to_the_left; end
1234
+ def align_to_the_right; end
1106
1235
  def yellowish_background; end
1107
1236
  def on_enter; end
1108
1237
  def on_value_changed; end
@@ -1123,7 +1252,9 @@ class Pointer # === Fiddle::Pointer
1123
1252
  def font=(i = ''); end
1124
1253
  def set_activates_default(i = true); end
1125
1254
  def enable_events; end
1255
+ def enable_all_events; end
1126
1256
  def do_focus; end
1257
+ def set_homogeneous(i = true); end
1127
1258
  def border(i = '', *a); end
1128
1259
  def fancy_hint(i = ''); end
1129
1260
  def fancy_hints(i = ''); end
@@ -1135,24 +1266,46 @@ class Pointer # === Fiddle::Pointer
1135
1266
  def spacing1=(i = 2); end
1136
1267
  def spacing2=(i = 2); end
1137
1268
  def spacing=(i = 0); end
1269
+ def light_blue_background; end
1270
+ def hover(i = :hack_26) # Currently not in use.
1271
+ end
1272
+ def set_font_size(i = :hack_26) # Currently not in use.
1273
+ end
1274
+ def maximize # This should maximize the window. It does not yet work.
1275
+ end
1276
+ def use_gtk_paradise_project_css_file; end
1277
+ def on_hover_colour(i = '', &block); end
1138
1278
  def deselect; end
1139
1279
  # def fraction=(i = ''); end
1140
1280
  def return_all_entries
1141
1281
  []
1142
1282
  end
1143
-
1283
+ def drag_via_left_to_right(a, b)
1284
+ vbox(a, b)
1285
+ end
1286
+ def default_styling(i = '')
1287
+ end
1144
1288
  # ========================================================================= #
1145
- # === on_key_press_event
1289
+ # === This is currently not in use.
1146
1290
  # ========================================================================= #
1147
- def on_key_press_event(&block)
1148
- # e 'NOT YET IMPLEMENTED.'
1291
+ def padding=(i = 8)
1149
1292
  end
1150
1293
 
1151
1294
  # ========================================================================= #
1152
- # === on_button_press_event
1295
+ # === uniform_spacing
1153
1296
  # ========================================================================= #
1154
- def on_button_press_event(&block)
1155
- # e 'NOT YET IMPLEMENTED'
1297
+ def uniform_spacing(i = 8)
1156
1298
  end
1157
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
1158
1311
  end; end