gtk_paradise 0.9.120 → 0.11.19

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gtk_paradise might be problematic. Click here for more details.

Files changed (492) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4521 -2997
  3. data/bin/genity +26 -0
  4. data/bin/gtk_editor +7 -0
  5. data/doc/README.gen +4484 -2975
  6. data/doc/todo/TODO_FOR_THE_GTK_PARADISE_PROJECT.md +281 -218
  7. data/doc/todo/recurring_todo_tasks.md +4 -3
  8. data/gtk_paradise.gemspec +28 -17
  9. data/lib/gtk_paradise/app/app.rb +77 -45
  10. data/lib/gtk_paradise/app/{app_module.rb → app_module/app_module.rb} +1064 -899
  11. data/lib/gtk_paradise/base_module/base_module.rb +7043 -33
  12. data/lib/gtk_paradise/base_module/class_methods/class_methods.rb +0 -0
  13. data/lib/gtk_paradise/base_module/css.rb +200 -268
  14. data/lib/gtk_paradise/base_module/experimental.rb +119 -0
  15. data/lib/gtk_paradise/base_module/html_support.rb +40 -15
  16. data/lib/gtk_paradise/base_module/these_methods_work_for_gtk3_and_gtk4.rb +155 -0
  17. data/lib/gtk_paradise/base_module_and_app_module/base_module_and_app_module.rb +1 -1
  18. data/lib/gtk_paradise/colours/colour_palette/material_design.rb +239 -0
  19. data/lib/gtk_paradise/colours/gtk_colour_constants.rb +8 -2
  20. data/lib/gtk_paradise/colours/parse.rb +8 -1
  21. data/lib/gtk_paradise/commandline/commandline.rb +20 -19
  22. data/lib/gtk_paradise/constants/constants.rb +227 -7
  23. data/lib/gtk_paradise/css_files/borders.css +81 -0
  24. data/lib/gtk_paradise/css_files/colours.css +329 -328
  25. data/lib/gtk_paradise/css_files/css_accordion.css +6 -2
  26. data/lib/gtk_paradise/css_files/hover_effects.css +588 -0
  27. data/lib/gtk_paradise/css_files/project.css +153 -189
  28. data/lib/gtk_paradise/drawing/README.md +3 -0
  29. data/lib/gtk_paradise/drawing/drawing.rb +68 -0
  30. data/lib/gtk_paradise/{base_module/colours.rb → drawing/event.rb} +37 -45
  31. data/lib/gtk_paradise/drawing/star.rb +96 -0
  32. data/lib/gtk_paradise/drawing/tool.rb +268 -0
  33. data/lib/gtk_paradise/drawing/turtle.rb +138 -0
  34. data/lib/gtk_paradise/emojis/emojis.rb +14 -13
  35. data/lib/gtk_paradise/examples/advanced/001_5x5_grid_example.rb +35 -50
  36. data/lib/gtk_paradise/examples/advanced/002_advanced_drag_and_drop_example.rb +21 -13
  37. data/lib/gtk_paradise/examples/advanced/003_html_like_support.rb +4 -25
  38. data/lib/gtk_paradise/examples/advanced/004_on_hover_example_on_gtk_entry.rb +4 -4
  39. data/lib/gtk_paradise/examples/advanced/005_csv_example.rb +6 -2
  40. data/lib/gtk_paradise/examples/advanced/007_label_responding_to_events_example.rb +1 -10
  41. data/lib/gtk_paradise/examples/advanced/008_options_example.rb +6 -3
  42. data/lib/gtk_paradise/examples/advanced/009_key_events.rb +1 -1
  43. data/lib/gtk_paradise/examples/advanced/010_extensive_text_view_example.rb +18 -17
  44. data/lib/gtk_paradise/examples/advanced/011_moving_blocks_example.rb +3 -3
  45. data/lib/gtk_paradise/examples/advanced/012_cell_data_sorting_example.rb +3 -4
  46. data/lib/gtk_paradise/examples/advanced/013_advanced_css_example.rb +86 -49
  47. data/lib/gtk_paradise/examples/advanced/014_popup_example.rb +9 -9
  48. data/lib/gtk_paradise/examples/advanced/015_advanced_button_example.rb +7 -19
  49. data/lib/gtk_paradise/examples/advanced/017_lean_CSS_example.rb +10 -13
  50. data/lib/gtk_paradise/examples/advanced/018_coloured_text_example.rb +7 -13
  51. data/lib/gtk_paradise/examples/advanced/019_gtk_entry_showing_the_cursor_position.rb +1 -1
  52. data/lib/gtk_paradise/examples/advanced/020_scale_this_image.rb +1 -10
  53. data/lib/gtk_paradise/examples/advanced/021_scroll_events_on_gtk_entry.rb +4 -0
  54. data/lib/gtk_paradise/examples/advanced/022_autogenerated_CSS_rounded_borders.rb +142 -0
  55. data/lib/gtk_paradise/examples/advanced/023_append_image_to_buffer.rb +145 -0
  56. data/lib/gtk_paradise/examples/advanced/024_notebook_with_tab_example.rb +151 -0
  57. data/lib/gtk_paradise/examples/advanced/025_showing_a_gold_caret_on_black_background.rb +144 -0
  58. data/lib/gtk_paradise/examples/advanced/026_status_bar_example.rb +153 -0
  59. data/lib/gtk_paradise/examples/advanced/027_customized_frame_example.rb +141 -0
  60. data/lib/gtk_paradise/examples/advanced/028_widgets_described_in_a_yaml_file.rb +240 -0
  61. data/lib/gtk_paradise/examples/cairo/basic_cairo_shapes.rb +1 -1
  62. data/lib/gtk_paradise/examples/cairo/cairo_transparent_rectangles.rb +9 -5
  63. data/lib/gtk_paradise/examples/cairo/cairo_write_via_custom_font.rb +81 -0
  64. data/lib/gtk_paradise/examples/cairo/donut_shape.rb +19 -6
  65. data/lib/gtk_paradise/examples/cairo/ping_pong_game.rb +2 -3
  66. data/lib/gtk_paradise/examples/controller/README.md +4 -0
  67. data/lib/gtk_paradise/examples/controller/controller.rb +2 -0
  68. data/lib/gtk_paradise/examples/css/001_border_examples.rb +30 -13
  69. data/lib/gtk_paradise/examples/css/002_import_CSS_file.rb +10 -5
  70. data/lib/gtk_paradise/examples/drawing/001_example.rb +61 -0
  71. data/lib/gtk_paradise/examples/drawing/002_example.rb +51 -0
  72. data/lib/gtk_paradise/examples/drawing/003_example.rb +38 -0
  73. data/lib/gtk_paradise/examples/drawing/004_example.rb +36 -0
  74. data/lib/gtk_paradise/examples/drawing/005_example.rb +92 -0
  75. data/lib/gtk_paradise/examples/drawing/006_example.rb +58 -0
  76. data/lib/gtk_paradise/examples/drawing/007_example.rb +22 -0
  77. data/lib/gtk_paradise/examples/drawing/008_example.rb +43 -0
  78. data/lib/gtk_paradise/examples/drawing/009_example.rb +43 -0
  79. data/lib/gtk_paradise/examples/drawing/010_example.rb +25 -0
  80. data/lib/gtk_paradise/examples/drawing/011_example.rb +72 -0
  81. data/lib/gtk_paradise/examples/drawing/012_example.rb +59 -0
  82. data/lib/gtk_paradise/examples/drawing/README.md +3 -0
  83. data/lib/gtk_paradise/examples/drawing/moving_turtle_example.rb +43 -0
  84. data/lib/gtk_paradise/examples/gdk/001_gdk_screen_properties.rb +58 -0
  85. data/lib/gtk_paradise/examples/gdk_pixbuf/save_image_example.rb +1 -1
  86. data/lib/gtk_paradise/examples/gir_ffi/001_hello_world.rb +29 -0
  87. data/lib/gtk_paradise/examples/gir_ffi/002_upgraded_hello_world.rb +40 -0
  88. data/lib/gtk_paradise/examples/gir_ffi/003_gtk_application_example.rb +30 -0
  89. data/lib/gtk_paradise/examples/gir_ffi/004_treeview_example.rb +64 -0
  90. data/lib/gtk_paradise/examples/gir_ffi/005_complex_example.rb +104 -0
  91. data/lib/gtk_paradise/examples/gir_ffi/README.md +5 -0
  92. data/lib/gtk_paradise/examples/glib/parse_glib_settings.rb +1 -1
  93. data/lib/gtk_paradise/examples/gtk2/008_list_store_example.rb +1 -1
  94. data/lib/gtk_paradise/examples/gtk3/{061_gtk_entry.rb → 001_gtk_entry.rb} +11 -6
  95. data/lib/gtk_paradise/examples/gtk3/{009_scrolled_window_example.rb → 002_scrolled_window_example.rb} +6 -4
  96. data/lib/gtk_paradise/examples/gtk3/{062_toggle_button_example.rb → 003_toggle_button_example.rb} +3 -2
  97. data/lib/gtk_paradise/examples/gtk3/{081_simple_dialog_example.rb → 004_simple_dialog_example.rb} +19 -12
  98. data/lib/gtk_paradise/examples/gtk3/005_spinner_example.rb +30 -10
  99. data/lib/gtk_paradise/examples/gtk3/006_text_view_example.rb +78 -0
  100. data/lib/gtk_paradise/examples/gtk3/{079_two_windows_example.rb → 007_two_windows_example.rb} +3 -1
  101. data/lib/gtk_paradise/examples/gtk3/008_search_bar_example.rb +91 -0
  102. data/lib/gtk_paradise/examples/gtk3/{002_simple_window.rb → 009_simple_window.rb} +14 -6
  103. data/lib/gtk_paradise/examples/gtk3/{025_switch_example.rb → 010_switch_example.rb} +6 -7
  104. data/lib/gtk_paradise/examples/gtk3/011_colour_chooser_example.rb +71 -0
  105. data/lib/gtk_paradise/examples/gtk3/012_show_the_xid_example.rb +18 -0
  106. data/lib/gtk_paradise/examples/gtk3/013_grab_pointer_forcefully.rb +31 -0
  107. data/lib/gtk_paradise/examples/gtk3/{083_bottom_left_placement.rb → 015_bottom_left_placement.rb} +3 -1
  108. data/lib/gtk_paradise/examples/gtk3/{082_scrolling_example.rb → 016_scrolling_example.rb} +2 -2
  109. data/lib/gtk_paradise/examples/gtk3/{080_extensive_markup_example.rb → 017_extensive_markup_example.rb} +8 -7
  110. data/lib/gtk_paradise/examples/gtk3/{078_message_dialog_example.rb → 018_message_dialog_example.rb} +3 -5
  111. data/lib/gtk_paradise/examples/gtk3/{075_tiny_button_via_css.rb → 021_tiny_button_via_css.rb} +1 -0
  112. data/lib/gtk_paradise/examples/gtk3/{001_font_related_information.rb → 022_font_related_information.rb} +1 -1
  113. data/lib/gtk_paradise/examples/gtk3/023_sorted_tree.rb +166 -0
  114. data/lib/gtk_paradise/examples/gtk3/{004_small_paned_example.rb → 024_small_paned_example.rb} +4 -3
  115. data/lib/gtk_paradise/examples/gtk3/{007_progress_bar_example.rb → 026_progress_bar_example.rb} +1 -2
  116. data/lib/gtk_paradise/examples/gtk3/{008_menubar_example.rb → 027_menubar_example.rb} +1 -1
  117. data/lib/gtk_paradise/examples/gtk3/{010_paned_widget_example.rb → 028_paned_widget_example.rb} +1 -0
  118. data/lib/gtk_paradise/examples/gtk3/{011_sockets.rb → 029_sockets.rb} +1 -0
  119. data/lib/gtk_paradise/examples/gtk3/{012_notebook_example.rb → 030_notebook_example.rb} +1 -0
  120. data/lib/gtk_paradise/examples/gtk3/{013_icon_theme_example.rb → 031_icon_theme_example.rb} +6 -0
  121. data/lib/gtk_paradise/examples/gtk3/{014_switcher_window.rb → 032_switcher_window.rb} +16 -10
  122. data/lib/gtk_paradise/examples/gtk3/{016_hello_world_in_gtk3_and_bold_font.rb → 034_hello_world_in_gtk3_and_bold_font.rb} +1 -1
  123. data/lib/gtk_paradise/examples/gtk3/{017_grid_example.rb → 035_grid_example.rb} +5 -1
  124. data/lib/gtk_paradise/examples/gtk3/{018_buttons_showcasing_the_relief.rb → 036_buttons_showcasing_the_relief.rb} +1 -0
  125. data/lib/gtk_paradise/examples/gtk3/{019_text_buffer_example.rb → 037_text_buffer_example.rb} +12 -10
  126. data/lib/gtk_paradise/examples/gtk3/{022_popup_example.rb → 040_popup_example.rb} +2 -2
  127. data/lib/gtk_paradise/examples/gtk3/{023_horizontal_and_vertical_scale.rb → 041_horizontal_and_vertical_scale.rb} +1 -1
  128. data/lib/gtk_paradise/examples/gtk3/{026_hover_button_example_via_css.rb → 043_hover_button_example_via_css.rb} +3 -1
  129. data/lib/gtk_paradise/examples/gtk3/{027_spin_button_example.rb → 044_spin_button_example.rb} +4 -3
  130. data/lib/gtk_paradise/examples/gtk3/{028_radio_menu_item_example.rb → 045_radio_menu_item_example.rb} +4 -1
  131. data/lib/gtk_paradise/examples/gtk3/{029_gtk_dialog_sample.rb → 046_gtk_dialog_sample.rb} +4 -1
  132. data/lib/gtk_paradise/examples/gtk3/{030_draw_rectangles.rb → 047_draw_rectangles.rb} +1 -1
  133. data/lib/gtk_paradise/examples/gtk3/{031_colour_choose_button.rb → 048_colour_choose_button.rb} +17 -3
  134. data/lib/gtk_paradise/examples/gtk3/{032_drag_and_drop_example.rb → 049_drag_and_drop_example.rb} +13 -5
  135. data/lib/gtk_paradise/examples/gtk3/{033_cell_renderer_pixbuf_example.rb → 050_cell_renderer_pixbuf_example.rb} +17 -6
  136. data/lib/gtk_paradise/examples/gtk3/051_combo_box_example.rb +74 -0
  137. data/lib/gtk_paradise/examples/gtk3/{037_css_example_of_a_button_changing_the_background_colour_on_click_event.rb → 053_css_example_of_a_button_changing_the_background_colour_on_click_event.rb} +14 -4
  138. data/lib/gtk_paradise/examples/gtk3/{036_revealer_example.rb → 053_revealer_example.rb} +10 -6
  139. data/lib/gtk_paradise/examples/gtk3/{038_ten_labels_in_a_vertical_box_example.rb → 054_ten_labels_in_a_vertical_box_example.rb} +1 -1
  140. data/lib/gtk_paradise/examples/gtk3/{039_threads_example.rb → 055_threads_example.rb} +1 -1
  141. data/lib/gtk_paradise/examples/gtk3/{042_colourized_button_example.rb → 058_colourized_button_example.rb} +1 -2
  142. data/lib/gtk_paradise/examples/gtk3/{043_form_example.rb → 059_form_example.rb} +1 -3
  143. data/lib/gtk_paradise/examples/gtk3/{044_check_button.rb → 060_check_button.rb} +4 -2
  144. data/lib/gtk_paradise/examples/gtk3/{046_event_box_example.rb → 062_event_box_example.rb} +2 -1
  145. data/lib/gtk_paradise/examples/gtk3/{047_examples_with_css.rb → 063_examples_with_css.rb} +91 -3
  146. data/lib/gtk_paradise/examples/gtk3/{048_accel_group_example.rb → 064_accel_group_example.rb} +1 -0
  147. data/lib/gtk_paradise/examples/gtk3/{049_change_the_application_theme.rb → 065_change_the_application_theme.rb} +4 -2
  148. data/lib/gtk_paradise/examples/gtk3/{050_header_bar_example.rb → 066_header_bar_example.rb} +3 -0
  149. data/lib/gtk_paradise/examples/gtk3/{051_gtk_label_example.rb → 067_gtk_label_example.rb} +3 -2
  150. data/lib/gtk_paradise/examples/gtk3/{052_popover_example.rb → 068_popover_example.rb} +2 -2
  151. data/lib/gtk_paradise/examples/gtk3/{053_entry_completion.rb → 069_entry_completion.rb} +2 -0
  152. data/lib/gtk_paradise/examples/gtk3/{055_button_demo.rb → 071_button_demo.rb} +6 -5
  153. data/lib/gtk_paradise/examples/gtk3/{056_text_iterator_example.rb → 072_text_iterator_example.rb} +30 -21
  154. data/lib/gtk_paradise/examples/gtk3/{057_image_example.rb → 073_image_example.rb} +1 -1
  155. data/lib/gtk_paradise/examples/gtk3/{058_frame_example.rb → 074_frame_example.rb} +1 -1
  156. data/lib/gtk_paradise/examples/gtk3/{059_gtk_expander.rb → 075_gtk_expander.rb} +2 -0
  157. data/lib/gtk_paradise/examples/gtk3/{060_ten_vboxes_example.rb → 076_ten_vboxes_example.rb} +1 -0
  158. data/lib/gtk_paradise/examples/gtk3/{063_button_box_example.rb → 077_button_box_example.rb} +11 -1
  159. data/lib/gtk_paradise/examples/gtk3/{064_tree_view_column_example.rb → 078_tree_view_column_example.rb} +2 -1
  160. data/lib/gtk_paradise/examples/gtk3/{066_vertical_boxes.rb → 080_vertical_boxes.rb} +2 -1
  161. data/lib/gtk_paradise/examples/gtk3/{067_vbox_with_spacing_and_border_width.rb → 081_vbox_with_spacing_and_border_width.rb} +2 -1
  162. data/lib/gtk_paradise/examples/gtk3/{069_file_chooser_dialog.rb → 082_file_chooser_dialog.rb} +3 -0
  163. data/lib/gtk_paradise/examples/gtk3/{070_bindings.rb → 083_bindings.rb} +14 -8
  164. data/lib/gtk_paradise/examples/gtk3/{072_recent_chooser_dialog.rb → 084_recent_chooser_dialog.rb} +2 -2
  165. data/lib/gtk_paradise/examples/gtk3/{073_showcase_the_cursors.rb → 085_showcase_the_cursors.rb} +30 -5
  166. data/lib/gtk_paradise/examples/gtk3/{074_app_chooser_button_example.rb → 086_app_chooser_button_example.rb} +1 -0
  167. data/lib/gtk_paradise/examples/gtk3/087_calendar_example.rb +41 -0
  168. data/lib/gtk_paradise/examples/gtk4/001_gtk_entry.rb +88 -0
  169. data/lib/gtk_paradise/examples/gtk4/002_scrolled_window_example.rb +62 -0
  170. data/lib/gtk_paradise/examples/gtk4/003_toggle_button_example.rb +23 -0
  171. data/lib/gtk_paradise/examples/gtk4/004_simple_dialog_example.rb +41 -0
  172. data/lib/gtk_paradise/examples/gtk4/005_spinner_example.rb +64 -0
  173. data/lib/gtk_paradise/examples/gtk4/006_text_view_example.rb +77 -0
  174. data/lib/gtk_paradise/examples/gtk4/007_two_windows_example.rb +55 -0
  175. data/lib/gtk_paradise/examples/gtk4/008_search_bar_example.rb +88 -0
  176. data/lib/gtk_paradise/examples/gtk4/009_text_view_example.rb +30 -0
  177. data/lib/gtk_paradise/examples/gtk4/010_switch_example.rb +52 -0
  178. data/lib/gtk_paradise/examples/gtk4/074_frame_example.rb +105 -0
  179. data/lib/gtk_paradise/examples/gtk4/076_ten_vboxes_example.rb +35 -0
  180. data/lib/gtk_paradise/examples/gtk4/087_calendar_example.rb +47 -0
  181. data/lib/gtk_paradise/examples/gtk4/100_changed_events_example.rb +77 -0
  182. data/lib/gtk_paradise/examples/gtk4/101_actionbar_example.rb +55 -0
  183. data/lib/gtk_paradise/examples/gtk4/102_picture_example.rb +35 -0
  184. data/lib/gtk_paradise/examples/pango/pango_power.rb +1 -0
  185. data/lib/gtk_paradise/experimental/experimental.rb +3 -11
  186. data/lib/gtk_paradise/experimental/experimental_for_gtk4.rb +92 -0
  187. data/lib/gtk_paradise/fonts/fonts.rb +5 -1
  188. data/lib/gtk_paradise/gdk/cursor.rb +2 -2
  189. data/lib/gtk_paradise/{base_module/e.rb → gdk/event_crossing.rb} +6 -8
  190. data/lib/gtk_paradise/gdk/gdk.rb +1 -1
  191. data/lib/gtk_paradise/gtk_classes/about.rb +11 -2
  192. data/lib/gtk_paradise/gtk_classes/about_dialog.rb +6 -2
  193. data/lib/gtk_paradise/gtk_classes/alignment.rb +4 -1
  194. data/lib/gtk_paradise/gtk_classes/application.rb +94 -4
  195. data/lib/gtk_paradise/gtk_classes/application_window.rb +25 -0
  196. data/lib/gtk_paradise/gtk_classes/box.rb +116 -279
  197. data/lib/gtk_paradise/gtk_classes/button.rb +55 -37
  198. data/lib/gtk_paradise/gtk_classes/button_box.rb +9 -1
  199. data/lib/gtk_paradise/gtk_classes/cell_renderer_text.rb +5 -3
  200. data/lib/gtk_paradise/gtk_classes/check_button.rb +27 -8
  201. data/lib/gtk_paradise/gtk_classes/combo_box.rb +4 -1
  202. data/lib/gtk_paradise/gtk_classes/combo_box_entry.rb +17 -11
  203. data/lib/gtk_paradise/gtk_classes/combo_box_text.rb +21 -19
  204. data/lib/gtk_paradise/gtk_classes/dialog.rb +2 -2
  205. data/lib/gtk_paradise/gtk_classes/entry.rb +256 -124
  206. data/lib/gtk_paradise/gtk_classes/entry_completion.rb +4 -0
  207. data/lib/gtk_paradise/gtk_classes/event_box.rb +21 -2
  208. data/lib/gtk_paradise/gtk_classes/event_button.rb +1 -1
  209. data/lib/gtk_paradise/gtk_classes/expander.rb +8 -1
  210. data/lib/gtk_paradise/gtk_classes/file_chooser_dialog.rb +1 -1
  211. data/lib/gtk_paradise/gtk_classes/file_filter.rb +4 -2
  212. data/lib/gtk_paradise/gtk_classes/file_selection.rb +4 -3
  213. data/lib/gtk_paradise/gtk_classes/frame.rb +19 -1
  214. data/lib/gtk_paradise/gtk_classes/grid.rb +206 -160
  215. data/lib/gtk_paradise/gtk_classes/hbox.rb +145 -0
  216. data/lib/gtk_paradise/gtk_classes/header_bar.rb +19 -8
  217. data/lib/gtk_paradise/gtk_classes/image.rb +1 -1
  218. data/lib/gtk_paradise/gtk_classes/label.rb +174 -135
  219. data/lib/gtk_paradise/gtk_classes/menu.rb +7 -3
  220. data/lib/gtk_paradise/gtk_classes/menu_bar.rb +1 -1
  221. data/lib/gtk_paradise/gtk_classes/menu_item.rb +1 -1
  222. data/lib/gtk_paradise/gtk_classes/notebook.rb +114 -64
  223. data/lib/gtk_paradise/gtk_classes/paned.rb +52 -0
  224. data/lib/gtk_paradise/gtk_classes/radio_menu_item.rb +19 -1
  225. data/lib/gtk_paradise/gtk_classes/scale_button.rb +16 -1
  226. data/lib/gtk_paradise/gtk_classes/scrolled_window.rb +8 -6
  227. data/lib/gtk_paradise/gtk_classes/search_bar.rb +1 -1
  228. data/lib/gtk_paradise/gtk_classes/source_buffer.rb +4 -5
  229. data/lib/gtk_paradise/gtk_classes/spin_button.rb +9 -1
  230. data/lib/gtk_paradise/gtk_classes/spinner.rb +32 -2
  231. data/lib/gtk_paradise/gtk_classes/status_icon.rb +2 -0
  232. data/lib/gtk_paradise/gtk_classes/statusbar.rb +1 -0
  233. data/lib/gtk_paradise/gtk_classes/style_context.rb +71 -0
  234. data/lib/gtk_paradise/gtk_classes/text_buffer.rb +45 -19
  235. data/lib/gtk_paradise/gtk_classes/text_view.rb +20 -3
  236. data/lib/gtk_paradise/gtk_classes/toggle_button.rb +3 -0
  237. data/lib/gtk_paradise/gtk_classes/toolbar.rb +2 -2
  238. data/lib/gtk_paradise/gtk_classes/tree_iter.rb +1 -1
  239. data/lib/gtk_paradise/gtk_classes/tree_view.rb +93 -70
  240. data/lib/gtk_paradise/gtk_classes/tree_view_column.rb +2 -1
  241. data/lib/gtk_paradise/gtk_classes/vbox.rb +71 -10
  242. data/lib/gtk_paradise/gtk_classes/vscale.rb +2 -2
  243. data/lib/gtk_paradise/gtk_classes/widget.rb +1057 -590
  244. data/lib/gtk_paradise/gtk_classes/window.rb +37 -2
  245. data/lib/gtk_paradise/hello_world/README.md +1 -1
  246. data/lib/gtk_paradise/hello_world/hello_world_gtk4.rb +20 -0
  247. data/lib/gtk_paradise/images/icons/close_image.png +0 -0
  248. data/lib/gtk_paradise/images/icons/closed.png +0 -0
  249. data/lib/gtk_paradise/images/icons/directory.png +0 -0
  250. data/lib/gtk_paradise/images/icons/icon_cool.gif +0 -0
  251. data/lib/gtk_paradise/images/icons/icon_lol.gif +0 -0
  252. data/lib/gtk_paradise/images/icons/icon_smile.gif +0 -0
  253. data/lib/gtk_paradise/images/icons/opened.png +0 -0
  254. data/lib/gtk_paradise/images/internal/gtk_label_example.png +0 -0
  255. data/lib/gtk_paradise/images/misc/wiki_logo.png +0 -0
  256. data/lib/gtk_paradise/images/small/GREEN_CIRCLE.png +0 -0
  257. data/lib/gtk_paradise/images/small/README.md +2 -0
  258. data/lib/gtk_paradise/images/small/RED_CIRCLE.png +0 -0
  259. data/lib/gtk_paradise/pango/{pango_fonts.rb → fonts.rb} +2 -2
  260. data/lib/gtk_paradise/pango/{pango.rb → layout.rb} +1 -1
  261. data/lib/gtk_paradise/pango/pango_renderer.rb +9 -2
  262. data/lib/gtk_paradise/project/project.rb +4 -3
  263. data/lib/gtk_paradise/prototypes/README.md +8 -0
  264. data/lib/gtk_paradise/prototypes/gtk3_standalone.rb +8 -21
  265. data/lib/gtk_paradise/prototypes/gtk4_standalone.rb +135 -0
  266. data/lib/gtk_paradise/prototypes/shared_code.rb +5 -15
  267. data/lib/gtk_paradise/prototypes/unified_gtk_prototype.rb +179 -0
  268. data/lib/gtk_paradise/require_gtk4.rb +7 -0
  269. data/lib/gtk_paradise/requires/require_base_module.rb +7 -0
  270. data/lib/gtk_paradise/requires/require_files_irrespective_of_the_gtk_version_at_hand.rb +25 -16
  271. data/lib/gtk_paradise/requires/require_gtk2.rb +6 -4
  272. data/lib/gtk_paradise/requires/{require_gtk2_or_gtk3.rb → require_gtk2_or_gtk3_or_gtk4.rb} +33 -12
  273. data/lib/gtk_paradise/requires/require_gtk3.rb +5 -20
  274. data/lib/gtk_paradise/requires/require_gtk4.rb +13 -0
  275. data/lib/gtk_paradise/requires/require_gtk_runner.rb +1 -0
  276. data/lib/gtk_paradise/requires/require_the_base_module_and_gtk_run.rb +1 -1
  277. data/lib/gtk_paradise/requires/require_the_base_module_the_app_module_and_the_toplevel_methods.rb +9 -0
  278. data/lib/gtk_paradise/requires/require_the_classes_files_for_gtk4.rb +11 -0
  279. data/lib/gtk_paradise/requires/require_the_colours_gem.rb +9 -0
  280. data/lib/gtk_paradise/requires/require_the_default_gtk_version.rb +4 -2
  281. data/lib/gtk_paradise/requires/require_the_toplevel_methods.rb +1 -1
  282. data/lib/gtk_paradise/run.rb +1 -0
  283. data/lib/gtk_paradise/run_this_widget/run_this_widget.rb +7 -3
  284. data/lib/gtk_paradise/threads/threads.rb +15 -10
  285. data/lib/gtk_paradise/toplevel_methods/css.rb +183 -35
  286. data/lib/gtk_paradise/toplevel_methods/cursor.rb +17 -3
  287. data/lib/gtk_paradise/toplevel_methods/determine_which_gtk_version_is_in_use.rb +90 -8
  288. data/lib/gtk_paradise/toplevel_methods/events.rb +6 -0
  289. data/lib/gtk_paradise/toplevel_methods/keys.rb +1 -1
  290. data/lib/gtk_paradise/toplevel_methods/screen_resolution.rb +32 -5
  291. data/lib/gtk_paradise/toplevel_methods/text_buffer_tags.rb +13 -4
  292. data/lib/gtk_paradise/toplevel_methods/tokenizer.rb +18 -3
  293. data/lib/gtk_paradise/toplevel_methods/{misc.rb → toplevel_methods.rb} +728 -181
  294. data/lib/gtk_paradise/utility_scripts/commandline_to_automatic_gui.rb +244 -0
  295. data/lib/gtk_paradise/version/version.rb +2 -2
  296. data/lib/gtk_paradise/widgets/gtk2/cat_merge.rb +2 -6
  297. data/lib/gtk_paradise/widgets/gtk2/cell_renderer_progress_example.rb +0 -5
  298. data/lib/gtk_paradise/widgets/gtk2/foto_lister.rb +2 -6
  299. data/lib/gtk_paradise/widgets/gtk2/gidnight_commander/gidnight_commander.rb +3 -3
  300. data/lib/gtk_paradise/widgets/gtk2/hbox_example.rb +1 -5
  301. data/lib/gtk_paradise/widgets/gtk2/multiple_select_in_a_tree_view_widget.rb +2 -6
  302. data/lib/gtk_paradise/widgets/gtk2/paned_example.rb +1 -1
  303. data/lib/gtk_paradise/widgets/gtk2/slider_changing_button.rb +2 -6
  304. data/lib/gtk_paradise/widgets/gtk2/status_icon_example.rb +2 -6
  305. data/lib/gtk_paradise/widgets/gtk2/table2.rb +2 -6
  306. data/lib/gtk_paradise/widgets/gtk2/toolbar_example.rb +2 -6
  307. data/lib/gtk_paradise/widgets/{version_agnostic → gtk3/audio_button}/audio_button.rb +15 -26
  308. data/lib/gtk_paradise/widgets/gtk3/burn_this_iso_file/burn_this_iso_file.rb +2 -6
  309. data/lib/gtk_paradise/widgets/{version_agnostic → gtk3/button_open_remote_webpage}/button_open_remote_webpage.rb +105 -50
  310. data/lib/gtk_paradise/widgets/gtk3/button_with_border/button_with_border.rb +155 -0
  311. data/lib/gtk_paradise/widgets/{version_agnostic → gtk3/button_xorg_buffer}/button_xorg_buffer.rb +76 -18
  312. data/lib/gtk_paradise/widgets/gtk3/calculator/calculator.rb +183 -76
  313. data/lib/gtk_paradise/widgets/gtk3/checkbox_image/checkbox_image.rb +3 -7
  314. data/lib/gtk_paradise/widgets/{version_agnostic → gtk3/coloured_button}/coloured_button.rb +94 -24
  315. data/lib/gtk_paradise/widgets/gtk3/coloured_square/coloured_square.rb +2 -6
  316. data/lib/gtk_paradise/widgets/gtk3/coloured_unit/coloured_unit.rb +151 -0
  317. data/lib/gtk_paradise/widgets/gtk3/cpu_widget/cpu_widget.rb +2 -6
  318. data/lib/gtk_paradise/widgets/gtk3/directory_content_widget/directory_content_widget.rb +937 -7
  319. data/lib/gtk_paradise/widgets/gtk3/editor/connect_skeleton.rb +33 -38
  320. data/lib/gtk_paradise/widgets/gtk3/editor/create.rb +66 -41
  321. data/lib/gtk_paradise/widgets/gtk3/editor/editor.rb +256 -270
  322. data/lib/gtk_paradise/widgets/gtk3/editor/internal_widgets/goto_line_widget.rb +52 -65
  323. data/lib/gtk_paradise/widgets/gtk3/editor/misc.rb +358 -111
  324. data/lib/gtk_paradise/widgets/gtk3/files_in_directory/files_in_directory.rb +2 -7
  325. data/lib/gtk_paradise/widgets/gtk3/flexible_vte/flexible_vte.rb +3 -7
  326. data/lib/gtk_paradise/widgets/gtk3/font_size_widget/action_button.rb +1 -5
  327. data/lib/gtk_paradise/widgets/gtk3/font_size_widget/font_size_widget.rb +2 -6
  328. data/lib/gtk_paradise/widgets/{gtk2 → gtk3}/gidnight_commander/gidnight_commander.config +1 -2
  329. data/lib/gtk_paradise/widgets/gtk3/gidnight_commander/gidnight_commander.rb +165 -125
  330. data/lib/gtk_paradise/widgets/gtk3/image_close_on_click_action/image_close_on_click_action.rb +34 -2
  331. data/lib/gtk_paradise/widgets/gtk3/image_viewer/image_viewer.rb +23 -26
  332. data/lib/gtk_paradise/widgets/gtk3/information_about_the_harddisc/harddisc_information.rb +161 -0
  333. data/lib/gtk_paradise/widgets/gtk3/insert_character/insert_character.rb +24 -29
  334. data/lib/gtk_paradise/widgets/gtk3/linux_users/linux_users.rb +32 -32
  335. data/lib/gtk_paradise/widgets/gtk3/my_calendar/my_calendar.rb +330 -7
  336. data/lib/gtk_paradise/widgets/gtk3/my_image_menu_item/my_image_menu_item.rb +179 -0
  337. data/lib/gtk_paradise/widgets/gtk3/non_numbers_only/non_numbers_only.rb +136 -0
  338. data/lib/gtk_paradise/widgets/gtk3/note_window/note_window.rb +199 -0
  339. data/lib/gtk_paradise/widgets/gtk3/notebook_controller/notebook_controller.rb +311 -7
  340. data/lib/gtk_paradise/widgets/gtk3/notebook_tab_with_icon/notebook_tab_with_icon.rb +402 -7
  341. data/lib/gtk_paradise/widgets/gtk3/numbered_lines/numbered_lines.rb +128 -82
  342. data/lib/gtk_paradise/widgets/{version_agnostic → gtk3/numbers_only}/numbers_only.rb +15 -3
  343. data/lib/gtk_paradise/widgets/gtk3/ping_widget/ping_widget.rb +491 -8
  344. data/lib/gtk_paradise/widgets/gtk3/regex_matcher/regex_matcher.rb +362 -43
  345. data/lib/gtk_paradise/widgets/gtk3/rename_widget/rename_widget.rb +8 -25
  346. data/lib/gtk_paradise/widgets/gtk3/show_which_key_was_pressed/show_which_key_was_pressed.rb +190 -0
  347. data/lib/gtk_paradise/widgets/gtk3/stopwatch/stopwatch.rb +318 -7
  348. data/lib/gtk_paradise/widgets/gtk3/sys_message/sys_message.rb +219 -7
  349. data/lib/gtk_paradise/widgets/gtk3/system_information/system_information.rb +58 -34
  350. data/lib/gtk_paradise/widgets/gtk3/tabble/admin_panel.rb +2 -6
  351. data/lib/gtk_paradise/widgets/gtk3/tabble/image_and_button.rb +2 -6
  352. data/lib/gtk_paradise/widgets/gtk3/tabble/tabble.rb +2 -6
  353. data/lib/gtk_paradise/widgets/gtk3/view_webpage/view_webpage.rb +2 -6
  354. data/lib/gtk_paradise/widgets/gtk3/wiki/README.md +4 -0
  355. data/lib/gtk_paradise/widgets/gtk3/wiki/wiki.rb +388 -0
  356. data/lib/gtk_paradise/widgets/gtk4/ping_widget/ping_widget.rb +4 -0
  357. data/lib/gtk_paradise/widgets/gtk4/show_icon_theme/show_icon_theme.rb +134 -0
  358. data/lib/gtk_paradise/widgets/gtk4/sys_message/sys_message.rb +269 -0
  359. data/lib/gtk_paradise/widgets/{gtk2/stopwatch/stopwatch.rb → gtk4/xpm_loader/xpm_loader.rb} +13 -11
  360. data/lib/gtk_paradise/widgets/shared_code/browser/browser_module.rb +4 -16
  361. data/lib/gtk_paradise/widgets/shared_code/cdripper/cdripper_module.rb +1 -1
  362. data/lib/gtk_paradise/widgets/shared_code/colour_filled_widget/colour_filled_widget_module.rb +25 -28
  363. data/lib/gtk_paradise/widgets/shared_code/colour_palette/colour_palette_module.rb +2 -2
  364. data/lib/gtk_paradise/widgets/shared_code/contacts/contacts_module.rb +62 -64
  365. data/lib/gtk_paradise/widgets/shared_code/flip_state_widget/flip_state_widget_module.rb +3 -19
  366. data/lib/gtk_paradise/widgets/shared_code/information_about_the_harddisc/harddisc_information.rb +0 -155
  367. data/lib/gtk_paradise/widgets/shared_code/information_about_the_harddisc/information_about_the_harddisc_module.rb +0 -444
  368. data/lib/gtk_paradise/widgets/shared_code/lsmod/lsmod_module.rb +22 -26
  369. data/lib/gtk_paradise/widgets/shared_code/lspci/lspci_module.rb +24 -36
  370. data/lib/gtk_paradise/widgets/shared_code/mini_clock/mini_clock_module.rb +74 -58
  371. data/lib/gtk_paradise/widgets/shared_code/my_calendar/my_calendar_module.rb +0 -327
  372. data/lib/gtk_paradise/widgets/shared_code/pid_displayer/pid_displayer_module.rb +53 -41
  373. data/lib/gtk_paradise/widgets/shared_code/random_image/random_image_module.rb +46 -29
  374. data/lib/gtk_paradise/widgets/shared_code/select_file/select_file_module.rb +1 -1
  375. data/lib/gtk_paradise/widgets/shared_code/show_icon_theme/show_icon_theme_module.rb +56 -44
  376. data/lib/gtk_paradise/widgets/shared_code/simple_clock/simple_clock_module.rb +1 -12
  377. data/lib/gtk_paradise/widgets/shared_code/stopwatch/stopwatch_module.rb +0 -341
  378. data/lib/gtk_paradise/widgets/shared_code/sys_message/sys_message_module.rb +0 -211
  379. data/lib/gtk_paradise/widgets/shared_code/tabby/tabby_module.rb +3 -15
  380. data/lib/gtk_paradise/widgets/shared_code/xpm_loader/xpm_loader_module.rb +15 -23
  381. data/lib/gtk_paradise/www/index.cgi +2 -2
  382. data/lib/gtk_paradise/yaml/browser_URLs.yml +3 -4
  383. data/lib/gtk_paradise/yaml/configuration_options_for_class_gtk_runner.yml +6 -6
  384. data/lib/gtk_paradise/yaml/experimental/README.md +3 -0
  385. data/lib/gtk_paradise/yaml/experimental/all_widgets.yml +37 -0
  386. data/lib/gtk_paradise/yaml/menu.yml +6 -3
  387. data/lib/gtk_paradise/yaml/notebook_controller.yml +62 -29
  388. data/lib/gtk_paradise.rb +0 -5
  389. data/test/gtk2/testing_combo_box.rb +1 -0
  390. data/test/gtk2/testing_display.rb +23 -0
  391. data/test/gtk2/testing_gtk_image.rb +4 -3
  392. data/test/gtk2/testing_hbox_and_vbox.rb +37 -0
  393. data/test/gtk2/testing_label_with_ampersand.rb +5 -2
  394. data/test/gtk2/testing_notebook.rb +11 -5
  395. data/test/gtk3/test_widget.rb +2 -1
  396. data/test/gtk3/testing_app.rb +0 -1
  397. data/test/gtk3/testing_base_module.rb +2 -1
  398. data/test/gtk3/testing_numbered_lines.rb +20 -0
  399. data/test/gtk3/testing_project_base_directory.rb +6 -1
  400. data/test/gtk3/testing_the_html_pseudo_tags.rb +2 -2
  401. data/test/gtk4/testing_gtk_entry.rb +24 -0
  402. data/test/misc/testing_a_gtk_frame.rb +14 -0
  403. data/test/misc/testing_gtk4_simplifications.rb +105 -0
  404. data/test/misc/testing_gtk_paradise_runner.rb +19 -4
  405. data/test/misc/testing_the_gtk_classes.rb +83 -0
  406. metadata +246 -199
  407. data/lib/gtk_paradise/base_module/change_directory.rb +0 -22
  408. data/lib/gtk_paradise/base_module/combo_box_and_combo_box_entry.rb +0 -113
  409. data/lib/gtk_paradise/base_module/commandline_arguments.rb +0 -36
  410. data/lib/gtk_paradise/base_module/configuration.rb +0 -50
  411. data/lib/gtk_paradise/base_module/constants.rb +0 -23
  412. data/lib/gtk_paradise/base_module/debug.rb +0 -127
  413. data/lib/gtk_paradise/base_module/draggable.rb +0 -95
  414. data/lib/gtk_paradise/base_module/emoji.rb +0 -107
  415. data/lib/gtk_paradise/base_module/esystem.rb +0 -22
  416. data/lib/gtk_paradise/base_module/events.rb +0 -111
  417. data/lib/gtk_paradise/base_module/fonts.rb +0 -119
  418. data/lib/gtk_paradise/base_module/graphics_display.rb +0 -47
  419. data/lib/gtk_paradise/base_module/gtk3.rb +0 -43
  420. data/lib/gtk_paradise/base_module/gtk_buttons.rb +0 -562
  421. data/lib/gtk_paradise/base_module/gtk_entry.rb +0 -126
  422. data/lib/gtk_paradise/base_module/gtk_fixed.rb +0 -18
  423. data/lib/gtk_paradise/base_module/gtk_grid.rb +0 -61
  424. data/lib/gtk_paradise/base_module/gtk_image.rb +0 -501
  425. data/lib/gtk_paradise/base_module/gtk_label.rb +0 -211
  426. data/lib/gtk_paradise/base_module/gtk_notebook.rb +0 -88
  427. data/lib/gtk_paradise/base_module/gtk_scrolled_window.rb +0 -155
  428. data/lib/gtk_paradise/base_module/misc.rb +0 -2949
  429. data/lib/gtk_paradise/base_module/pango.rb +0 -24
  430. data/lib/gtk_paradise/base_module/popover.rb +0 -241
  431. data/lib/gtk_paradise/base_module/register_sigint.rb +0 -20
  432. data/lib/gtk_paradise/base_module/reset.rb +0 -128
  433. data/lib/gtk_paradise/base_module/return_corresponding_gtk_stock_item.rb +0 -92
  434. data/lib/gtk_paradise/base_module/roebe.rb +0 -19
  435. data/lib/gtk_paradise/base_module/table.rb +0 -438
  436. data/lib/gtk_paradise/base_module/time.rb +0 -35
  437. data/lib/gtk_paradise/constants/available_cursors.rb +0 -52
  438. data/lib/gtk_paradise/constants/fonts.rb +0 -38
  439. data/lib/gtk_paradise/constants/misc.rb +0 -56
  440. data/lib/gtk_paradise/constants/newline.rb +0 -14
  441. data/lib/gtk_paradise/constants/xbm_icons.rb +0 -121
  442. data/lib/gtk_paradise/examples/gtk3/003_sorted_tree.rb +0 -141
  443. data/lib/gtk_paradise/examples/gtk3/034_combo_box_example.rb +0 -49
  444. data/lib/gtk_paradise/examples/gtk3/068_text_view_example.rb +0 -34
  445. data/lib/gtk_paradise/examples/gtk3/071_search_bar_example.rb +0 -59
  446. data/lib/gtk_paradise/gtk_classes/colours/colours.rb +0 -158
  447. data/lib/gtk_paradise/requires/require_the_minesweeper_files.rb +0 -11
  448. data/lib/gtk_paradise/toplevel_methods/allow_only_numbers.rb +0 -59
  449. data/lib/gtk_paradise/toplevel_methods/csv.rb +0 -102
  450. data/lib/gtk_paradise/toplevel_methods/e.rb +0 -18
  451. data/lib/gtk_paradise/toplevel_methods/enable_and_disable_warnings.rb +0 -58
  452. data/lib/gtk_paradise/toplevel_methods/keyboard.rb +0 -25
  453. data/lib/gtk_paradise/toplevel_methods/main_file.rb +0 -31
  454. data/lib/gtk_paradise/toplevel_methods/register_sigint.rb +0 -17
  455. data/lib/gtk_paradise/toplevel_methods/roebe.rb +0 -22
  456. data/lib/gtk_paradise/toplevel_methods/select_file.rb +0 -168
  457. data/lib/gtk_paradise/toplevel_methods/spacer.rb +0 -55
  458. data/lib/gtk_paradise/toplevel_methods/tooltips.rb +0 -71
  459. data/lib/gtk_paradise/toplevel_methods/we_use_this_gtk_version.rb +0 -65
  460. data/lib/gtk_paradise/widgets/gtk2/directory_content_widget/directory_content_widget.rb +0 -30
  461. data/lib/gtk_paradise/widgets/gtk2/my_calendar/my_calendar.config +0 -6
  462. data/lib/gtk_paradise/widgets/gtk2/my_calendar/my_calendar.rb +0 -34
  463. data/lib/gtk_paradise/widgets/gtk2/notebook_tab_with_icon/notebook_tab_with_icon.rb +0 -30
  464. data/lib/gtk_paradise/widgets/gtk2/ping_widget/ping_widget.rb +0 -30
  465. data/lib/gtk_paradise/widgets/gtk2/sys_message/sys_message.config +0 -6
  466. data/lib/gtk_paradise/widgets/gtk2/sys_message/sys_message.rb +0 -29
  467. data/lib/gtk_paradise/widgets/shared_code/directory_content_widget/constants.rb +0 -53
  468. data/lib/gtk_paradise/widgets/shared_code/directory_content_widget/directory_content_widget_module.rb +0 -777
  469. data/lib/gtk_paradise/widgets/shared_code/directory_content_widget/handle_this_file_or_symlink.rb +0 -83
  470. data/lib/gtk_paradise/widgets/shared_code/notebook_controller/notebook_controller_module.rb +0 -339
  471. data/lib/gtk_paradise/widgets/shared_code/notebook_tab_with_icon/notebook_tab_with_icon_module.rb +0 -297
  472. data/lib/gtk_paradise/widgets/shared_code/ping_widget/ping_widget_module.rb +0 -326
  473. data/lib/gtk_paradise/widgets/version_agnostic/button_with_border.rb +0 -63
  474. data/lib/gtk_paradise/widgets/version_agnostic/coloured_unit.rb +0 -54
  475. data/lib/gtk_paradise/widgets/version_agnostic/my_image_menu_item.rb +0 -103
  476. data/lib/gtk_paradise/widgets/version_agnostic/my_menu_item_separator.rb +0 -31
  477. data/lib/gtk_paradise/widgets/version_agnostic/non_numbers_only.rb +0 -66
  478. data/lib/gtk_paradise/widgets/version_agnostic/note_window.rb +0 -107
  479. /data/lib/gtk_paradise/examples/gtk3/{084_undecorated_window_example.rb → 014_undecorated_window_example.rb} +0 -0
  480. /data/lib/gtk_paradise/examples/gtk3/{077_status_icon_example.rb → 019_status_icon_example.rb} +0 -0
  481. /data/lib/gtk_paradise/examples/gtk3/{076_stack_example.rb → 020_stack_example.rb} +0 -0
  482. /data/lib/gtk_paradise/examples/gtk3/{006_password_example.rb → 025_password_example.rb} +0 -0
  483. /data/lib/gtk_paradise/examples/gtk3/{015_list_box_example.rb → 033_list_box_example.rb} +0 -0
  484. /data/lib/gtk_paradise/examples/gtk3/{020_radio_button_window.rb → 038_radio_button_window.rb} +0 -0
  485. /data/lib/gtk_paradise/examples/gtk3/{021_scale_button_demo.rb → 039_scale_button_demo.rb} +0 -0
  486. /data/lib/gtk_paradise/examples/gtk3/{024_installation_assistant.rb → 042_installation_assistant.rb} +0 -0
  487. /data/lib/gtk_paradise/examples/gtk3/{035_notebook_css_example.rb → 052_notebook_css_example.rb} +0 -0
  488. /data/lib/gtk_paradise/examples/gtk3/{040_font_chooser_dialog_example.rb → 056_font_chooser_dialog_example.rb} +0 -0
  489. /data/lib/gtk_paradise/examples/gtk3/{041_flowbox.rb → 057_flowbox.rb} +0 -0
  490. /data/lib/gtk_paradise/examples/gtk3/{045_fixed_example.rb → 061_fixed_example.rb} +0 -0
  491. /data/lib/gtk_paradise/examples/gtk3/{054_svg_viewer.rb → 070_svg_viewer.rb} +0 -0
  492. /data/lib/gtk_paradise/examples/gtk3/{065_tooltips_example.rb → 079_tooltips_example.rb} +0 -0
@@ -11,7 +11,7 @@
11
11
  # You can also include this module into instances of Gtk::Window via
12
12
  # extend(). Look at the end of this file for an example in this regard.
13
13
  # =========================================================================== #
14
- # require 'gtk_paradise/app/app_module.rb'
14
+ # require 'gtk_paradise/app/app_module/app_module.rb'
15
15
  # include Gtk::AppModule
16
16
  # =========================================================================== #
17
17
  module Gtk
@@ -29,9 +29,9 @@ module AppModule
29
29
  require 'fileutils'
30
30
  require 'yaml'
31
31
  require 'gtk_paradise/project/project.rb'
32
- require 'gtk_paradise/toplevel_methods/determine_which_gtk_version_is_in_use.rb'
33
- require 'gtk_paradise/toplevel_methods/keys.rb'
34
- require 'gtk_paradise/toplevel_methods/roebe.rb'
32
+ require 'gtk_paradise/toplevel_methods/toplevel_methods.rb'
33
+ require 'gtk_paradise/toplevel_methods/screen_resolution.rb'
34
+ require 'gtk_paradise/gtk_classes/status_icon.rb'
35
35
 
36
36
  # ========================================================================= #
37
37
  # === DEFAULT_WIDTH
@@ -73,7 +73,7 @@ module AppModule
73
73
  # === internal_reset (reset tag)
74
74
  # ========================================================================= #
75
75
  def internal_reset
76
- initialize_the_internal_hash
76
+ initialize_the_internal_hash # Create and then populate @internal_hash here.
77
77
  handle_the_destroy_event
78
78
  try_to_load_the_configuration_file
79
79
  # ======================================================================= #
@@ -100,6 +100,13 @@ module AppModule
100
100
  # ======================================================================= #
101
101
  @internal_hash[:title] = nil
102
102
  # ======================================================================= #
103
+ # === :may_we_modify_the_title
104
+ #
105
+ # This can be disabled via a method call. If disabled then we will not
106
+ # allow the internal title-setter to rename the widget anymore.
107
+ # ======================================================================= #
108
+ @internal_hash[:may_we_modify_the_title] = true
109
+ # ======================================================================= #
103
110
  # === :width
104
111
  # ======================================================================= #
105
112
  set_width(DEFAULT_WIDTH)
@@ -108,6 +115,10 @@ module AppModule
108
115
  # ======================================================================= #
109
116
  set_height(DEFAULT_HEIGHT)
110
117
  # ======================================================================= #
118
+ # === :favicon
119
+ # ======================================================================= #
120
+ @internal_hash[:favicon] = nil
121
+ # ======================================================================= #
111
122
  # === :filename
112
123
  #
113
124
  # :filename is initially a "dummy" variable. It was added to allow
@@ -120,10 +131,6 @@ module AppModule
120
131
  # ======================================================================= #
121
132
  @internal_hash[:child_widget] = nil
122
133
  # ======================================================================= #
123
- # === :favicon
124
- # ======================================================================= #
125
- @internal_hash[:favicon] = nil
126
- # ======================================================================= #
127
134
  # === :border_width
128
135
  # ======================================================================= #
129
136
  @internal_hash[:border_width] = 0
@@ -145,111 +152,110 @@ module AppModule
145
152
  alias reset_internal_app_module initialize_the_internal_hash # === reset_internal_app_module
146
153
 
147
154
  # ========================================================================= #
148
- # === create_accel_group
149
- #
150
- # Normally you dont need to change anything here.
151
- # ========================================================================= #
152
- def create_accel_group
153
- @accel_group = ::Gtk::AccelGroup.new
154
- add_accel_group(@accel_group) if respond_to?(:add_accel_group)
155
- end; private :create_accel_group
156
-
157
- # ========================================================================= #
158
- # === set_favicon
155
+ # === set_width
159
156
  #
160
- # Ensures that the icon exists before setting it.
157
+ # Use only this method when setting the @internal_hash[:width] variable.
161
158
  #
162
- # Some symbol-shortcuts are allowed here, which are hardcoded towards
163
- # my own system
159
+ # If we pass in a string that also includes a '%' character then
160
+ # we assume that the user wishes to use a percentage value derived
161
+ # from whatever Gdk::Screen.default returns.
164
162
  # ========================================================================= #
165
- def set_favicon(i)
166
- if i.nil? and is_on_roebe?
167
- i = :default
168
- end
169
- if i.is_a?(String) and i.start_with?(':')
170
- i = i.delete(':').to_sym
171
- end
172
- case i
173
- # ======================================================================= #
174
- # === :lotus
175
- # ======================================================================= #
176
- when :lotus
177
- i = '/home/x/data/images/RPG/STD/LOTUS_MASKE.png'
178
- # ======================================================================= #
179
- # === :tabble_image
180
- #
181
- # This entry point is currently aliased to ":default" - thus, it is
182
- # the default value.
183
- # ======================================================================= #
184
- when :tabble_image,
185
- :tabble,
186
- :default
187
- i = ::Gtk::PROJECT_BASE_DIRECTORY+'images/misc/tabble.png'
188
- # ======================================================================= #
189
- # === :pc_favicon
190
- # ======================================================================= #
191
- when :pc_favicon
192
- i = '/home/x/data/images/PC/PC_FAVICON.png'
193
- # ======================================================================= #
194
- # === :task_image
195
- # ======================================================================= #
196
- when :tasks_image,
197
- :tasks
198
- i = '/home/x/data/images/PC/TASKS.jpg'
199
- # ======================================================================= #
200
- # === :audio_favicon
201
- # ======================================================================= #
202
- when :audio_favicon
203
- i = '/home/x/data/images/AUDIO/AUDIO_FAVICON.png'
204
- end
163
+ def set_width(i = DEFAULT_WIDTH)
205
164
  if i
206
- begin
207
- if File.exist? i
208
- @favicon = i
209
- else
210
- e "(in gtk_paradise/run.rb) No file exists at this location: `#{i}`"
211
- end
212
- rescue Exception => error
213
- pp error
214
- pp i
215
- end
216
- else
217
- if is_on_roebe?
218
- e 'Please provide an icon_location to the method set_favicon()'
165
+ # ===================================================================== #
166
+ # === Handle percentage values given to this method next
167
+ #
168
+ # These must be a String, and must include a '%' - otherwise it will
169
+ # not be handled in this method.
170
+ # ===================================================================== #
171
+ if i.is_a? String and i.include? '%'
172
+ i = i.to_f # This is percentage.
173
+ i = (::Gtk.max_width? * i) / 100
219
174
  end
175
+ i = i.first if i.is_a? Array
176
+ i = i.to_i
177
+ @internal_hash[:width] = i
220
178
  end
221
- @internal_hash[:favicon] = i
222
- end; alias set_icon_location set_favicon # === set_icon_location
223
- alias icon_location= set_favicon # === icon_location=
224
- alias icon= set_favicon # === icon?
225
- alias set_this_favicon set_favicon # === set_this_favicon
226
- alias set_logo set_favicon # === set_logo
227
- alias favicon= set_favicon # === favicon=
179
+ end; alias width= set_width # === width=
228
180
 
229
181
  # ========================================================================= #
230
- # === favicon?
182
+ # === set_height
183
+ #
184
+ # Use only this method when wishing to set to @internal_hash[:height].
231
185
  # ========================================================================= #
232
- def favicon?
233
- @internal_hash[:favicon]
234
- end
186
+ def set_height(i)
187
+ if i
188
+ if i.is_a? String and i.include? '%'
189
+ i = i.to_f # This is percentage.
190
+ i = (::Gtk.max_height? * i) / 100
191
+ end
192
+ i = i.to_i
193
+ @internal_hash[:height] = i
194
+ end
195
+ end; alias height= set_height # === height=
235
196
 
236
197
  # ========================================================================= #
237
- # === connect_key
198
+ # === shortcut_keys (keybindings tag, shortcut tag)
238
199
  #
239
- # This method can be used to simply map a String, such as 'alt+1' to
240
- # a specific key combination. In fact: it is required that the input
241
- # at hand includes a '+' character.
200
+ # Use this to add a new shortcut to your application.
242
201
  #
243
- # Usage example:
202
+ # The second argument, `this_method`, specifies which method we will use
203
+ # and invoke.
244
204
  #
245
- # connect_key('alt+1') { 'xid' }
205
+ # Usage examples:
206
+ #
207
+ # r.add_shortcut(:q, 'name_of_method_that_will_be_called')
208
+ # r.add_shortcut(:q, 'fill_up_buffer')
209
+ # r.add_shortcut(:e, 'focus_entry', :alt)
210
+ # r.add_shortcut('e', 'focus_entry', :shift)
211
+ # r.add_shortcut(1, 'focus_entry(1)', :alt)
212
+ # r.add_shortcut(0, 'invoke_this_method', :alt)
213
+ #
214
+ # Or with self:
215
+ #
216
+ # self.add_shortcut(1, '@notebook.set_page(0)', :ctrl)
217
+ #
218
+ # An even simpler variant is the following API:
219
+ #
220
+ # r.keybinding 'Alt+1', 'do_ask_new_question'
221
+ # r.keybinding 'Alt+2', 'do_reveal_the_answer'
246
222
  #
247
223
  # ========================================================================= #
248
- def connect_key(i)
249
- splitted = i.split('+')
250
- key = splitted[0]
251
- shortcut = splitted[1]
252
- case key.to_sym
224
+ def shortcut_keys(
225
+ shortcut_key_to_use,
226
+ this_method,
227
+ modifier_key = :control,
228
+ &block
229
+ )
230
+ # ======================================================================= #
231
+ # Remove ' ' characters.
232
+ # ======================================================================= #
233
+ if shortcut_key_to_use.is_a?(String) and
234
+ shortcut_key_to_use.include?(' ')
235
+ # ===================================================================== #
236
+ # Since as of 12.05.2021 we will remove ' '.
237
+ # ===================================================================== #
238
+ shortcut_key_to_use.delete!(' ')
239
+ end
240
+ # ======================================================================= #
241
+ # Next handle cases such as "strg+s".
242
+ # ======================================================================= #
243
+ if (shortcut_key_to_use.is_a?(String) and
244
+ shortcut_key_to_use.include?('+')) or
245
+ (shortcut_key_to_use.is_a?(Symbol) and
246
+ shortcut_key_to_use.to_s.include?('+'))
247
+ splitted = shortcut_key_to_use.to_s.split('+')
248
+ modifier_key = splitted.first.to_sym
249
+ shortcut_key_to_use = splitted.last
250
+ end
251
+ case modifier_key
252
+ # ======================================================================= #
253
+ # === :strg_alt
254
+ # ======================================================================= #
255
+ when :strg_alt, # recall ourself
256
+ :strgalt
257
+ add_shortcut(shortcut_key_to_use, this_method, :strg)
258
+ modifier_key = Gdk::Window::MOD1_MASK # but pass through for ALT
253
259
  # ======================================================================= #
254
260
  # === :control
255
261
  # ======================================================================= #
@@ -262,57 +268,135 @@ module AppModule
262
268
  '',
263
269
  'strg',
264
270
  'string'
265
- key = :control_mask
271
+ modifier_key = :control_mask
266
272
  # ======================================================================= #
267
273
  # === :alt
268
274
  # ======================================================================= #
269
- when :alt
270
- key = Gdk::Window::MOD1_MASK
275
+ when :alt, # This is the alt-key.
276
+ 'Alt',
277
+ /^alt/
278
+ if ::Gtk.use_gtk2?
279
+ modifier_key = Gdk::Window::MOD1_MASK
280
+ else
281
+ modifier_key = :mod1_mask
282
+ end
271
283
  # ======================================================================= #
272
284
  # === :shift
273
285
  # ======================================================================= #
274
286
  when :shift,
275
287
  :pfeil_oben
276
- key = Gdk::Window::SHIFT_MASK
288
+ modifier_key = Gdk::Window::SHIFT_MASK
277
289
  end
278
290
  # ======================================================================= #
279
- # Obtain the shortcut-key next, which wraps over Gdk::Keyval.from_name().
291
+ # Obtain the proper shortcut key next.
280
292
  # ======================================================================= #
281
- shortcut = Gtk.get_shortcut_key(key)
282
- @accel_group.connect(shortcut, key, :visible) {
283
- # # then we use arguments
284
- # if this_method.include? '('
285
- # _ = this_method.split '('
286
- # method_name= _[0]
287
- # argument_to_it= _[1][0..-2] # get arguments
288
- # child_widget?.send(method_name, argument_to_it)
289
- # else
290
- # @child_widget.send(this_method)
291
- # end
292
- e 'PRESSED!'
293
- }
293
+ case shortcut_key_to_use
294
294
  # ======================================================================= #
295
- # The next part is probably debug-related code, but I forgot to add
296
- # a comment explaining what this code was supposed to be used for. :(
297
- # result = yield if block_given? # Example: xid
298
- # if result
299
- # e 'The result was:'
300
- # pp result
301
- # end
295
+ # Match against Alt+1, Alt+2, Alt+3 and so forth.
296
+ #
297
+ # Regex to test this:
298
+ #
299
+ # https://rubular.com/r/vA6bxNh9C2oB26
300
+ #
302
301
  # ======================================================================= #
303
- end
302
+ when /^Alt\+(\d{1,2})/i,
303
+ /^Alt\+([A-Za-z←→])/i
304
+ modifier_key = :mod1_mask
305
+ if use_gtk2?
306
+ modifier_key = Gdk::Window::MOD1_MASK
307
+ end
308
+ shortcut_key_to_use = $1.to_s.dup
309
+ end
310
+ case modifier_key
311
+ when :Alt
312
+ modifier_key = :mod1_mask
313
+ end
314
+ shortcut_key_to_use = Gtk.get_shortcut_key(shortcut_key_to_use) # Gdk::Keyval.from_name()
315
+ # ======================================================================= #
316
+ # === Ensure that @accel_group exists
317
+ #
318
+ # Create a new accel-group if no prior accel group exists:
319
+ # ======================================================================= #
320
+ unless defined? @accel_group
321
+ create_accel_group
322
+ end
323
+ # ======================================================================= #
324
+ # Pass to the @accel_group next.
325
+ # ======================================================================= #
326
+ if use_gtk4?
327
+ e 'accel_group.connect() has not yet been added for ruby-gtk4.'
328
+ e 'It may be implemented at a later time.'
329
+ else
330
+ @accel_group.connect(shortcut_key_to_use, modifier_key, :visible) {
331
+ # then we use arguments
332
+ if this_method.include? '('
333
+ _ = this_method.split '('
334
+ method_name = _[0]
335
+ argument_to_it = _[1][0..-2] # get arguments
336
+ # =================================================================== #
337
+ # We send the method to the child widget next.
338
+ # =================================================================== #
339
+ child_widget?.send(method_name, argument_to_it)
340
+ else
341
+ if child_widget?.respond_to? this_method.to_sym
342
+ child_widget?.send(this_method)
343
+ else
344
+ case this_method.to_s
345
+ # ================================================================= #
346
+ # === exit_program
347
+ # ================================================================= #
348
+ when 'exit_program'
349
+ ::Gtk.main_quit
350
+ end
351
+ end
352
+ end
353
+ }
354
+ end
355
+ end; alias add_this_shortcut shortcut_keys # === add_this_shortcut
356
+ alias add_shortcut shortcut_keys # === add_shortcut
357
+ alias keybinding shortcut_keys # === keybinding
304
358
 
305
359
  # ========================================================================= #
306
- # === shortcut
360
+ # === shortcuts
307
361
  #
308
- # This variant requires a '+' character to be used.
362
+ # This method may be used like so:
309
363
  #
310
- # Usage example:
364
+ # r.shortcuts {
365
+ # [1, 'click_on_button_number(0)', :alt], # for alt+1 key combination
366
+ # }
367
+ #
368
+ # ========================================================================= #
369
+ def shortcuts(&block)
370
+ # ======================================================================= #
371
+ # === Handle blocks next
372
+ # ======================================================================= #
373
+ if block_given?
374
+ yielded = yield
375
+ if yielded.is_a? Array
376
+ yielded.each {|inner_array|
377
+ add_shortcut(
378
+ inner_array[0],
379
+ inner_array[1],
380
+ inner_array[2]
381
+ )
382
+ }
383
+ end
384
+ end
385
+ end
386
+
387
+ # ========================================================================= #
388
+ # === shortcut
389
+ #
390
+ # This variant requires a '+' character to be used.
391
+ #
392
+ # Usage example:
311
393
  #
312
394
  # r.shortcut('alt+1') { 'focus_on(@entry_pid_number)' }
313
395
  #
314
396
  # ========================================================================= #
315
- def shortcut(key_combination_to_use, &block)
397
+ def shortcut(
398
+ key_combination_to_use, &block
399
+ )
316
400
  splitted = key_combination_to_use.split('+')
317
401
  number = splitted.last.to_i
318
402
  modifier_key_to_use = splitted.first.to_sym
@@ -324,33 +408,72 @@ module AppModule
324
408
  end
325
409
 
326
410
  # ========================================================================= #
327
- # === resize_to_child_widget_dimension
411
+ # === enable_quick_exit
412
+ #
413
+ # This method enables quick "alt+Q" key-combination to quit the
414
+ # application. Since as of September 2020, we also use strg+q
415
+ # (which is ctrl+q, actually).
328
416
  # ========================================================================= #
329
- def resize_to_child_widget_dimension
330
- _ = child_widget?
331
- if _
332
- set_size_request(_.width?, _.height?)
333
- end
334
- end
417
+ def enable_quick_exit
418
+ add_shortcut(:q, 'exit_program', :alt)
419
+ add_shortcut(:q, 'exit_program', :strg)
420
+ end; alias easy_exit enable_quick_exit # === easy_exit
421
+ alias easy_quit enable_quick_exit # === easy_quit
422
+ alias quick_exit enable_quick_exit # === quick_exit
423
+ alias enable_simple_exit enable_quick_exit # === enable_simple_exit
424
+ alias simple_exit enable_quick_exit # === simple_exit
425
+ alias enable_easy_exit enable_quick_exit # === enable_easy_exit
335
426
 
336
427
  # ========================================================================= #
337
- # === window_position_none
428
+ # === status_icon
429
+ #
430
+ # This method add a StatusIcon to a gtk-widget.
338
431
  # ========================================================================= #
339
- def window_position_none
432
+ def status_icon(
433
+ use_this_as_the_icon = favicon?
434
+ )
340
435
  if ::Gtk.use_gtk2?
341
- i = Gtk::Window::POS_NONE
436
+ _ = ::Gtk::StatusIcon.new
437
+ _.use_this_image = use_this_as_the_icon
342
438
  else
343
- i = :none
439
+ _ = ::Gtk::StatusIcon.new(filename: use_this_as_the_icon)
344
440
  end
345
- set_window_position(i)
441
+ return _
346
442
  end
347
443
 
348
444
  # ========================================================================= #
349
- # === set_font_in_use
445
+ # === set_background_colour
446
+ #
447
+ # This method (or an alias to this method) can be used to set the
448
+ # background colour.
350
449
  # ========================================================================= #
351
- def set_font_in_use(i)
352
- ::Gtk.set_font(i)
353
- end
450
+ def set_background_colour(i)
451
+ if i
452
+ @internal_hash[:background_colour] = i.to_s
453
+ # ===================================================================== #
454
+ # Note that if we input an incorrect colour then this will fail. This
455
+ # explains the following code in the rescue-clause.
456
+ # ===================================================================== #
457
+ begin
458
+ parsed_colour = ::Gdk::Color.parse(@internal_hash[:background_colour])
459
+ rescue ArgumentError
460
+ @internal_hash[:background_colour] = 'white'
461
+ parsed_colour = ::Gdk::Color.parse('white')
462
+ end
463
+ if ::Gtk.use_gtk2?
464
+ modify_bg(::Gtk::STATE_NORMAL, parsed_colour)
465
+ else # else assume gtk3 is in use
466
+ if parsed_colour.is_a? Gdk::Color
467
+ parsed_colour = Gdk::RGBA.new(
468
+ parsed_colour.red,
469
+ parsed_colour.green,
470
+ parsed_colour.blue
471
+ )
472
+ end
473
+ override_background_color(:normal, parsed_colour)
474
+ end
475
+ end
476
+ end; alias background_colour set_background_colour # === background_colour
354
477
 
355
478
  # ========================================================================= #
356
479
  # === modify_bg
@@ -358,7 +481,8 @@ module AppModule
358
481
  # Modify the background here.
359
482
  # ========================================================================= #
360
483
  def modify_bg(
361
- state, colour = 'lightblue'
484
+ state,
485
+ colour = 'lightblue'
362
486
  )
363
487
  if colour.is_a? String
364
488
  colour = Gdk::Color.parse(colour)
@@ -368,288 +492,416 @@ module AppModule
368
492
  if use_gtk2?
369
493
  super(state, colour)
370
494
  else
371
- e 'Presently override_background_color(state, colour) is not implemented.'
495
+ e 'Presently override_background_color(state, colour) is '\
496
+ 'not implemented.'
372
497
  end
373
498
  end
374
499
 
375
500
  # ========================================================================= #
376
- # === do_maximize_width
501
+ # === original_width?
502
+ #
503
+ # Determine the default width of the screen on the target computer system.
377
504
  # ========================================================================= #
378
- def do_maximize_width(
379
- width = max_width?,
380
- height = height?
381
- )
382
- set_size_request(width, height)
505
+ def original_width?
506
+ Gdk::Screen.default.width
507
+ end; alias max_width? original_width? # === max_width?
508
+
509
+ # ========================================================================= #
510
+ # === disallow_resizing
511
+ #
512
+ # This method will prevent the user from resizing the window.
513
+ # ========================================================================= #
514
+ def disallow_resizing
515
+ set_resizable(false)
383
516
  end
384
517
 
385
518
  # ========================================================================= #
386
- # === width_height
519
+ # === is_resizable
387
520
  # ========================================================================= #
388
- def width_height(width, height)
389
- set_size_request(width, height)
521
+ def is_resizable
522
+ self.resizable = true
390
523
  end
391
524
 
392
525
  # ========================================================================= #
393
- # === top_middle
394
- #
395
- # Position the Gtk::Runner widget on the very top, but middle position.
396
- #
397
- # This must be calculated:
398
- #
399
- # (1) first we must determine the max-width, and divide it by 2
400
- # (2) then we also need to determine the width of the widget
401
- # that will be spawned. This will default to a hardcoded
402
- # value, but Gtk::Runner can modify this accordingly
526
+ # === do_maximize
403
527
  #
528
+ # Use this when you want to maximize the window, to the full-screen.
404
529
  # ========================================================================= #
405
- def top_middle(
406
- use_this_subwidget_width = :default
407
- )
408
- case use_this_subwidget_width
409
- # ======================================================================= #
410
- # === :default
411
- # ======================================================================= #
412
- when :default
413
- use_this_subwidget_width = 250
414
- end
415
- calculated_value = Gdk::Screen.default.width / 2
416
- calculated_value -= use_this_subwidget_width
417
- move(calculated_value, 0)
418
- end
530
+ def do_maximize
531
+ self.maximize
532
+ end; alias max do_maximize # === max
419
533
 
420
534
  # ========================================================================= #
421
- # === top_middle_then_run
535
+ # === width?
422
536
  # ========================================================================= #
423
- def top_middle_then_run(i = :default)
424
- top_middle(i)
425
- run
537
+ def width?
538
+ @internal_hash[:width]
426
539
  end
427
540
 
428
541
  # ========================================================================= #
429
- # === accel_group?
430
- #
431
- # So that we can manipulate the AccelGroup.
542
+ # === height?
432
543
  # ========================================================================= #
433
- def accel_group?
434
- @accel_group
435
- end; alias accel_group accel_group? # === accel_group
544
+ def height?
545
+ @internal_hash[:height]
546
+ end
436
547
 
437
548
  # ========================================================================= #
438
- # === filename=
549
+ # === minimum_size
550
+ #
551
+ # This can be used to specify a minimum size. It is advised to pass
552
+ # a Hash.
439
553
  # ========================================================================= #
440
- def filename=(i)
441
- @internal_hash[:filename] = i
554
+ def minimum_size(
555
+ hash = {
556
+ width: '25%',
557
+ height: '15%'
558
+ }
559
+ )
560
+ set_size_request(hash[:width], hash[:height])
442
561
  end
443
562
 
444
563
  # ========================================================================= #
445
- # === filename?
564
+ # === max_resolution?
446
565
  # ========================================================================= #
447
- def filename?
448
- @internal_hash[:filename]
566
+ def max_resolution?
567
+ ::Gtk.screen_resolution?
449
568
  end
450
569
 
451
570
  # ========================================================================= #
452
- # === shortcut_keys (keybindings tag, shortcut tag)
453
- #
454
- # Use this to add a new shortcut to your application.
455
- #
456
- # The second argument, `this_method`, specifies which method we will use
457
- # and invoke.
458
- #
459
- # Usage examples:
460
- #
461
- # r.add_shortcut(:q, 'name_of_method_that_will_be_called')
462
- # r.add_shortcut(:q, 'fill_up_buffer')
463
- # r.add_shortcut(:e, 'focus_entry', :alt)
464
- # r.add_shortcut('e', 'focus_entry', :shift)
465
- # r.add_shortcut(1, 'focus_entry(1)', :alt)
466
- # r.add_shortcut(0, 'invoke_this_method', :alt)
467
- #
468
- # Or with self:
469
- #
470
- # self.add_shortcut(1, '@notebook.set_page(0)', :ctrl)
571
+ # === position=
471
572
  #
472
- # An even simpler variant is the following API:
573
+ # Usage example:
473
574
  #
474
- # r.keybinding 'Alt+1', 'do_ask_new_question'
475
- # r.keybinding 'Alt+2', 'do_reveal_the_answer'
575
+ # .position = :mouse
476
576
  #
477
577
  # ========================================================================= #
478
- def shortcut_keys(
479
- shortcut_key_to_use,
480
- this_method,
481
- modifier_key = :control,
482
- &block
483
- )
578
+ def position=(i)
579
+ case i # case tag
484
580
  # ======================================================================= #
485
- # Remove ' ' characters.
581
+ # === :mouse
486
582
  # ======================================================================= #
487
- if shortcut_key_to_use.is_a?(String) and
488
- shortcut_key_to_use.include?(' ')
489
- # ===================================================================== #
490
- # Since as of 12.05.2021 we will remove ' '.
491
- # ===================================================================== #
492
- shortcut_key_to_use.delete!(' ')
493
- end
583
+ when :mouse
584
+ i = Gtk::Window::POS_MOUSE if ::Gtk.use_gtk2?
494
585
  # ======================================================================= #
495
- # Next handle cases such as "strg+s".
586
+ # === :none
496
587
  # ======================================================================= #
497
- if (shortcut_key_to_use.is_a?(String) and
498
- shortcut_key_to_use.include?('+')) or
499
- (shortcut_key_to_use.is_a?(Symbol) and
500
- shortcut_key_to_use.to_s.include?('+'))
501
- splitted = shortcut_key_to_use.to_s.split('+')
502
- modifier_key = splitted.first.to_sym
503
- shortcut_key_to_use = splitted.last
504
- end
505
- case modifier_key
588
+ when :none
589
+ i = Gtk::Window::POS_NONE if ::Gtk.use_gtk2?
506
590
  # ======================================================================= #
507
- # === :strg_alt
591
+ # === :center_always
508
592
  # ======================================================================= #
509
- when :strg_alt, # recall ourself
510
- :strgalt
511
- add_shortcut(shortcut_key_to_use, this_method, :strg)
512
- modifier_key = Gdk::Window::MOD1_MASK # but pass through for ALT
593
+ when :center_always,
594
+ :always_center,
595
+ :center2,
596
+ nil
597
+ i = Gtk::Window::POS_CENTER_ALWAYS
513
598
  # ======================================================================= #
514
- # === :control
599
+ # === :center_on_parent
515
600
  # ======================================================================= #
516
- when :control,
517
- :ctrl,
518
- :strg,
519
- :str,
520
- nil,
521
- :default,
522
- '',
523
- 'strg',
524
- 'string'
525
- modifier_key = :control_mask
601
+ when :center_on_parent
602
+ i = Gtk::Window::POS_CENTER_ON_PARENT
526
603
  # ======================================================================= #
527
- # === :alt
604
+ # === :center
528
605
  # ======================================================================= #
529
- when :alt, # This is the alt-key.
530
- 'Alt',
531
- /^alt/
532
- if ::Gtk.use_gtk2?
533
- modifier_key = Gdk::Window::MOD1_MASK
534
- else
535
- modifier_key = :mod1_mask
536
- end
606
+ when :center
607
+ i = Gtk::Window::POS_CENTER
608
+ else
609
+ e "We do not know: #{simp(i.to_s)}"
610
+ end
611
+ set_window_position(i)
612
+ end
613
+
614
+ require 'gtk_paradise/toplevel_methods/screen_resolution.rb'
615
+ # ========================================================================= #
616
+ # === resolution?
617
+ #
618
+ # Query the resolution of the target computer.
619
+ # ========================================================================= #
620
+ def resolution?
621
+ ::Gtk.resolution?
622
+ end
623
+
624
+ # ========================================================================= #
625
+ # === connect_key
626
+ #
627
+ # This method can be used to simply map a String, such as 'alt+1' to
628
+ # a specific key combination. In fact: it is required that the input
629
+ # at hand includes a '+' character.
630
+ #
631
+ # Usage example:
632
+ #
633
+ # connect_key('alt+1') { 'xid' }
634
+ #
635
+ # ========================================================================= #
636
+ def connect_key(i)
637
+ unless i.include? '+'
638
+ e 'The input to connect_key() needs to have a "+" character.'
639
+ return
640
+ end
641
+ splitted = i.split('+')
642
+ key = splitted[0]
643
+ shortcut = splitted[1]
644
+ case key.to_sym
537
645
  # ======================================================================= #
538
- # === :shift
646
+ # === :control
539
647
  # ======================================================================= #
540
- when :shift,
541
- :pfeil_oben
542
- modifier_key = Gdk::Window::SHIFT_MASK
543
- end
648
+ when :control,
649
+ :ctrl,
650
+ :strg,
651
+ :str,
652
+ nil,
653
+ :default,
654
+ '',
655
+ 'strg',
656
+ 'string'
657
+ key = :control_mask
544
658
  # ======================================================================= #
545
- # Obtain the proper shortcut key next.
659
+ # === :alt
546
660
  # ======================================================================= #
547
- case shortcut_key_to_use
661
+ when :alt
662
+ key = Gdk::Window::MOD1_MASK
548
663
  # ======================================================================= #
549
- # Match against Alt+1, Alt+2, Alt+3 and so forth.
550
- #
551
- # Regex to test this:
552
- #
553
- # https://rubular.com/r/vA6bxNh9C2oB26
554
- #
664
+ # === :shift
555
665
  # ======================================================================= #
556
- when /^Alt\+(\d{1,2})/i,
557
- /^Alt\+([A-Za-z←→])/i
558
- if use_gtk2?
559
- modifier_key = Gdk::Window::MOD1_MASK
560
- else
561
- modifier_key = :mod1_mask
562
- end
563
- shortcut_key_to_use = $1.to_s.dup
666
+ when :shift,
667
+ :pfeil_oben
668
+ key = Gdk::Window::SHIFT_MASK
564
669
  end
565
- shortcut_key_to_use = Gtk.get_shortcut_key(shortcut_key_to_use) # Gdk::Keyval.from_name()
566
670
  # ======================================================================= #
567
- # === Ensure that @accel_group exists
568
- #
569
- # Create a new accel-group if no prior accel group exists:
671
+ # Obtain the shortcut-key next, which wraps over Gdk::Keyval.from_name().
570
672
  # ======================================================================= #
571
- unless defined? @accel_group
572
- create_accel_group
573
- end
673
+ shortcut = Gtk.get_shortcut_key(key)
674
+ @accel_group.connect(shortcut, key, :visible) {
675
+ # # then we use arguments
676
+ # if this_method.include? '('
677
+ # _ = this_method.split '('
678
+ # method_name= _[0]
679
+ # argument_to_it= _[1][0..-2] # get arguments
680
+ # child_widget?.send(method_name, argument_to_it)
681
+ # else
682
+ # @child_widget.send(this_method)
683
+ # end
684
+ e 'PRESSED!'
685
+ }
574
686
  # ======================================================================= #
575
- # Pass to the @accel_group next.
687
+ # The next part is probably debug-related code, but I forgot to add
688
+ # a comment explaining what this code was supposed to be used for. :(
689
+ # result = yield if block_given? # Example: xid
690
+ # if result
691
+ # e 'The result was:'
692
+ # pp result
693
+ # end
576
694
  # ======================================================================= #
577
- @accel_group.connect(shortcut_key_to_use, modifier_key, :visible) {
578
- # then we use arguments
579
- if this_method.include? '('
580
- _ = this_method.split '('
581
- method_name = _[0]
582
- argument_to_it = _[1][0..-2] # get arguments
583
- # =================================================================== #
584
- # We send the method to the child widget next.
585
- # =================================================================== #
586
- child_widget?.send(method_name, argument_to_it)
695
+ end
696
+
697
+ # ========================================================================= #
698
+ # === add_delete_event
699
+ #
700
+ # Register the :delete_event here.
701
+ # ========================================================================= #
702
+ def add_delete_event
703
+ if use_gtk4?
704
+ e 'The .delete_event() has not yet been added to ruby-gtk4.'
705
+ e 'At a later time this will be reviewed.'
706
+ else
707
+ signal_connect(:delete_event) { exit_application }
708
+ end
709
+ end
710
+
711
+ # ========================================================================= #
712
+ # === favicon?
713
+ # ========================================================================= #
714
+ def favicon?
715
+ @internal_hash[:favicon]
716
+ end
717
+
718
+ # ========================================================================= #
719
+ # === create_accel_group
720
+ #
721
+ # Normally you dont need to change anything here.
722
+ # ========================================================================= #
723
+ def create_accel_group
724
+ @accel_group = ::Gtk::AccelGroup.new
725
+ add_accel_group(@accel_group) if respond_to?(:add_accel_group)
726
+ end; private :create_accel_group
727
+
728
+ # ========================================================================= #
729
+ # === determine_the_title_from_the_child_widget
730
+ #
731
+ # The first argument is the widget that we will use, under the assumption
732
+ # that it will be the child-widget.
733
+ # ========================================================================= #
734
+ def determine_the_title_from_the_child_widget(
735
+ child_widget = child_widget?
736
+ )
737
+ if child_widget
738
+ if child_widget.respond_to?(:my_title?)
739
+ title = child_widget.my_title?
740
+ set_my_title_then_apply_it(title)
587
741
  else
588
- if child_widget?.respond_to? this_method.to_sym
589
- child_widget?.send(this_method)
590
- else
591
- case this_method.to_s
592
- when 'exit_program'
593
- ::Gtk.main_quit
594
- end
595
- end
742
+ e 'The child-widget (class '+child_widget.name.to_s+
743
+ ') does not respond to the method called .my_title?' unless child_widget.nil?
596
744
  end
597
- }
598
- end; alias add_this_shortcut shortcut_keys # === add_this_shortcut
599
- alias keybinding shortcut_keys # === keybinding
600
- alias add_shortcut shortcut_keys # === add_shortcut
745
+ else
746
+ e 'No child-widget was provided. Showing the caller() trace next:'
747
+ e
748
+ pp caller()
749
+ e
750
+ end
751
+ end; alias automatic_title determine_the_title_from_the_child_widget # === automatic_title
752
+ alias determine_the_title determine_the_title_from_the_child_widget # === determine_the_title
753
+ alias determine_the_title_automatically determine_the_title_from_the_child_widget # === determine_the_title_automatically
754
+ alias infer_the_title_from_the_child_widget determine_the_title_from_the_child_widget # === infer_the_title_from_the_child_widget
755
+ alias title_from_child_widget determine_the_title_from_the_child_widget # === title_from_child_widget
756
+ alias automatic_title determine_the_title_from_the_child_widget # === automatic_title
601
757
 
602
758
  # ========================================================================= #
603
- # === show_then_run
759
+ # === enable_simple_exit_then_run
604
760
  # ========================================================================= #
605
- def show_then_run
606
- show_all
761
+ def enable_simple_exit_then_run
762
+ enable_simple_exit
607
763
  run
608
- end; alias show_all_then_run show_then_run # === show_all_then_run
764
+ end
609
765
 
610
766
  # ========================================================================= #
611
- # === top_left_show_all_then_run
767
+ # === set_global_font_size
768
+ #
769
+ # The first input-argument to this method should be a number.
612
770
  # ========================================================================= #
613
- def top_left_show_all_then_run
614
- top_left_and_show_all
615
- run
616
- end; alias top_left_show_all_then_run top_left_show_all_then_run # === top_left_show_all_then_run
617
- alias top_left_then_show_all_then_run top_left_show_all_then_run # === top_left_then_show_all_then_run
771
+ def set_global_font_size(
772
+ i = 20,
773
+ use_this_font_family = 'Sans'
774
+ )
775
+ Gtk::Settings.default.gtk_font_name = "#{use_this_font_family} #{i}"
776
+ end
618
777
 
619
778
  # ========================================================================= #
620
- # === add_delete_event
621
- #
622
- # Register the :delete_event here.
779
+ # === handle_the_destroy_event
623
780
  # ========================================================================= #
624
- def add_delete_event
625
- signal_connect(:delete_event) { exit_application }
781
+ def handle_the_destroy_event
782
+ signal_connect(:destroy) { exit_application }
626
783
  end
627
784
 
628
785
  # ========================================================================= #
629
- # === try_to_load_the_configuration_file
786
+ # === exit_application
787
+ #
788
+ # Use this to quit from an application.
630
789
  # ========================================================================= #
631
- def try_to_load_the_configuration_file
632
- path_to_the_configuration_file =
633
- 'configuration_options_for_class_gtk_runner.yml'
634
- _ = ::Gtk.project_base_directory?+
635
- 'yaml/'+
636
- path_to_the_configuration_file
637
- if File.exist? _
638
- @internal_hash[:yaml_dataset] = YAML.load_file(_)
639
- # ===================================================================== #
640
- # Next check any configuration value - for now we only handle one
641
- # setting.
642
- # ===================================================================== #
643
- if @internal_hash[:yaml_dataset].has_key? 'shall_we_enable_simple_exit_for_all_instances_of_gtk_runner'
644
- if @internal_hash[:yaml_dataset]['shall_we_enable_simple_exit_for_all_instances_of_gtk_runner'] == true
645
- enable_easy_exit
646
- end
647
- end
790
+ def exit_application
791
+ ::Gtk.main_quit
792
+ end; alias exit_program exit_application # === exit_program
793
+ alias do_quit exit_application # === do_quit
794
+
795
+ # ========================================================================= #
796
+ # === interactively_create_directory
797
+ #
798
+ # This convenience method can be used to create a new directory.
799
+ # ========================================================================= #
800
+ def interactively_create_directory(
801
+ use_this_as_parent_widget
802
+ )
803
+ result = ''
804
+ text = gtk_text(
805
+ 'Input the name of the directory to be created:'
806
+ )
807
+ entry = gtk_entry
808
+
809
+ popup_box = gtk_vbox
810
+ popup_box.set_padding(12)
811
+ popup_box.set_size_request(800, 240)
812
+ popup_box.set_font(:hack_20)
813
+ popup_box.minimal(text, 2)
814
+ popup_box.maximal(entry, 2)
815
+
816
+ dialog = ::Gtk::Dialog.new(parent: use_this_as_parent_widget,
817
+ title: 'Interactively create a directory',
818
+ flags: [:modal, :destroy_with_parent],
819
+ buttons: [['_Cancel', :cancel],
820
+ ['_Create the directory', :ok]])
821
+ content_area = dialog.content_area
822
+ content_area.pack_start(popup_box)
823
+ content_area.show_all
824
+
825
+ response = dialog.run
826
+
827
+ case response
828
+ when :ok # This is <Gtk::ResponseType ok>
829
+ result << entry.text?
830
+ end
831
+
832
+ if File.directory? result
833
+ e 'The directory '+result+' already exists.'
648
834
  else
649
- e 'No file exists at '+sfile(_)
835
+ e 'Creating the directory '+result+' next.'
836
+ FileUtils.mkdir_p(result)
650
837
  end
838
+
839
+ dialog.destroy
651
840
  end
652
841
 
842
+ # ========================================================================= #
843
+ # === set_my_title
844
+ #
845
+ # Use this method to set the title.
846
+ # ========================================================================= #
847
+ def set_my_title(
848
+ i = internal_title?
849
+ )
850
+ if @internal_hash[:may_we_modify_the_title]
851
+ i = __FILE__ if i == '__FILE__'
852
+ @internal_hash[:title] = i
853
+ # ======================================================================= #
854
+ # Next delegate towards apply_the_internal_title().
855
+ # ======================================================================= #
856
+ apply_the_internal_title
857
+ end
858
+ end; alias title set_my_title # === title
859
+ alias name= set_my_title # === name=
860
+ alias fancy_title set_my_title # === fancy_title
861
+ alias set_my_title_then_apply_it set_my_title # === set_my_title_then_apply_it
862
+ alias set_title_then_apply set_my_title # === set_title_then_apply
863
+
864
+ # ========================================================================= #
865
+ # === missing_the_internal_hash?
866
+ # ========================================================================= #
867
+ def missing_the_internal_hash?
868
+ _ = false
869
+ _ = true if defined?(:@internal_hash)
870
+ _ = true if @internal_hash.nil?
871
+ return _
872
+ end
873
+
874
+ # ========================================================================= #
875
+ # === border_width?
876
+ # ========================================================================= #
877
+ def border_width?
878
+ @internal_hash[:border_width]
879
+ end; alias padding? border_width? # === padding?
880
+
881
+ # ========================================================================= #
882
+ # === easy_exit_top_left_then_run
883
+ #
884
+ # This method combines the easy-exit functionality, with the "put widget
885
+ # window on the top left corner of the screen", before "running" the
886
+ # application at hand (aka, starting it).
887
+ # ========================================================================= #
888
+ def easy_exit_top_left_then_run
889
+ easy_exit
890
+ top_left_then_run
891
+ end; alias easy_exit_then_top_left_and_run easy_exit_top_left_then_run # === easy_exit_then_top_left_and_run
892
+ alias enable_quick_exit_then_top_left_then_run easy_exit_top_left_then_run # === enable_quick_exit_then_top_left_then_run
893
+ alias easy_exit_then_top_left_then_run easy_exit_top_left_then_run # === easy_exit_then_top_left_then_run
894
+
895
+ # ========================================================================= #
896
+ # === top_left_and_show_all
897
+ # ========================================================================= #
898
+ def top_left_and_show_all
899
+ top_left
900
+ show_all
901
+ end; alias top_left_then_show top_left_and_show_all # === top_left_then_show
902
+ alias top_left_then_show_all top_left_and_show_all # === top_left_then_show_all
903
+ alias top_left_show_all top_left_and_show_all # === top_left_show_all
904
+
653
905
  # ========================================================================= #
654
906
  # === top_left_then_run
655
907
  #
@@ -664,11 +916,11 @@ module AppModule
664
916
  &block
665
917
  )
666
918
  if optional_add_this_widget
919
+ # ===================================================================== #
920
+ # === Handle Hashes next. We have several "aliases" such as
921
+ # :with, :with_this_widget or :use_this_widget.
922
+ # ===================================================================== #
667
923
  if optional_add_this_widget.is_a? Hash
668
- # =================================================================== #
669
- # === Handle Hashes next. We have several "aliases" such as
670
- # :with, :with_this_widget or :use_this_widget.
671
- # =================================================================== #
672
924
  # =================================================================== #
673
925
  # === :use_this_widget
674
926
  #
@@ -712,404 +964,340 @@ module AppModule
712
964
  end
713
965
  end
714
966
  top_left
715
- run
716
- end; alias top_left_run top_left_then_run # === top_left_run
717
- alias move_top_left_then_run top_left_then_run # === move_top_left_then_run
718
-
719
- # ========================================================================= #
720
- # === easy_exit_top_left_then_run
721
- #
722
- # This method combines the easy-exit functionality, with the "put widget
723
- # window on the top left corner of the screen", before "running" the
724
- # application at hand (aka, starting it).
725
- # ========================================================================= #
726
- def easy_exit_top_left_then_run
727
- easy_exit
728
- top_left_then_run
729
- end; alias easy_exit_then_top_left_and_run easy_exit_top_left_then_run # === easy_exit_then_top_left_and_run
730
- alias enable_quick_exit_then_top_left_then_run easy_exit_top_left_then_run # === enable_quick_exit_then_top_left_then_run
731
- alias easy_exit_then_top_left_then_run easy_exit_top_left_then_run # === easy_exit_then_top_left_then_run
732
-
733
- require 'gtk_paradise/toplevel_methods/screen_resolution.rb'
734
- # ========================================================================= #
735
- # === resolution?
736
- #
737
- # Query the resolution of the target computer.
738
- # ========================================================================= #
739
- def resolution?
740
- ::Gtk.resolution?
741
- end
742
-
743
- # ========================================================================= #
744
- # === top_left_and_show_all
745
- # ========================================================================= #
746
- def top_left_and_show_all
747
- top_left
748
- show_all
749
- end; alias top_left_then_show top_left_and_show_all # === top_left_then_show
750
- alias top_left_then_show_all top_left_and_show_all # === top_left_then_show_all
751
- alias top_left_show_all top_left_and_show_all # === top_left_show_all
752
-
753
- # ========================================================================= #
754
- # === position=
755
- #
756
- # Usage example:
757
- #
758
- # .position = :mouse
759
- #
760
- # ========================================================================= #
761
- def position=(i)
762
- case i # case tag
763
- # ======================================================================= #
764
- # === :mouse
765
- # ======================================================================= #
766
- when :mouse
767
- i = Gtk::Window::POS_MOUSE if ::Gtk.use_gtk2?
768
- # ======================================================================= #
769
- # === :none
770
- # ======================================================================= #
771
- when :none
772
- i = Gtk::Window::POS_NONE if ::Gtk.use_gtk2?
773
- # ======================================================================= #
774
- # === :center_always
775
- # ======================================================================= #
776
- when :center_always,
777
- :always_center,
778
- :center2,
779
- nil
780
- i = Gtk::Window::POS_CENTER_ALWAYS
781
- # ======================================================================= #
782
- # === :center_on_parent
783
- # ======================================================================= #
784
- when :center_on_parent
785
- i = Gtk::Window::POS_CENTER_ON_PARENT
786
- # ======================================================================= #
787
- # === :center
788
- # ======================================================================= #
789
- when :center
790
- i = Gtk::Window::POS_CENTER
791
- else
792
- e "We do not know: #{simp(i.to_s)}"
793
- end
794
- set_window_position(i)
795
- end
967
+ run
968
+ end; alias top_left_run top_left_then_run # === top_left_run
969
+ alias move_top_left_then_run top_left_then_run # === move_top_left_then_run
796
970
 
797
971
  # ========================================================================= #
798
- # === alt_shortcut
799
- #
800
- # This method enables a key-shortcut via the alt-key.
801
- #
802
- # The second argument is the method that you wish to call / invoke.
803
- #
804
- # Specific usage examples:
805
- #
806
- # r.alt_key(1, 'focus_entry(1)')
807
- # r.alt_shortcut(1) { 'focus_entry(1)' }
808
- #
972
+ # === try_to_load_the_configuration_file
809
973
  # ========================================================================= #
810
- def alt_shortcut(
811
- key_combination_to_use,
812
- method_to_call = nil
974
+ def try_to_load_the_configuration_file(
975
+ path_to_the_configuration_file =
976
+ 'configuration_options_for_class_gtk_runner.yml'
813
977
  )
814
- use_this_shortcut = "alt+#{key_combination_to_use}"
815
- if block_given?
816
- yielded = yield
817
- method_to_call = yielded if method_to_call.nil?
818
- shortcut(use_this_shortcut) { method_to_call }
978
+ _ = ::Gtk.project_base_directory?+
979
+ 'yaml/'+
980
+ path_to_the_configuration_file
981
+ if File.exist? _
982
+ @internal_hash[:yaml_dataset] = YAML.load_file(_)
983
+ # ===================================================================== #
984
+ # Next check any configuration value - for now we only handle one
985
+ # setting.
986
+ # ===================================================================== #
987
+ if @internal_hash[:yaml_dataset].has_key? 'shall_we_enable_simple_exit_for_all_instances_of_gtk_runner'
988
+ if @internal_hash[:yaml_dataset]['shall_we_enable_simple_exit_for_all_instances_of_gtk_runner'] == true
989
+ enable_easy_exit
990
+ end
991
+ end
819
992
  else
820
- shortcut(use_this_shortcut) { method_to_call }
993
+ e "No file exists at `#{sfile(_)}`."
821
994
  end
822
- end; alias alt_key alt_shortcut # === alt_key
995
+ end
823
996
 
824
997
  # ========================================================================= #
825
- # === feedback
826
- #
827
- # Just feedback some info to the user.
998
+ # === show_then_run
828
999
  # ========================================================================= #
829
- def feedback
830
- unless Object.const_defined? :Colours
831
- begin
832
- require 'colours'
833
- rescue LoadError; end
834
- end
835
- e
836
- e " #{::Colours.rev}widget-width is: #{::Colours.sfancy(@width)}"
837
- e " #{::Colours.rev}widget-height is: #{::Colours.sfancy(@height)}"
838
- e
839
- end
1000
+ def show_then_run
1001
+ show_all
1002
+ run
1003
+ end; alias show_all_then_run show_then_run # === show_all_then_run
840
1004
 
841
1005
  # ========================================================================= #
842
- # === size=
1006
+ # === accel_group?
843
1007
  #
844
- # Set width and height here. Input argument to this method should be an
845
- # Array.
1008
+ # So that we can manipulate the AccelGroup.
846
1009
  # ========================================================================= #
847
- def size=(array)
848
- set_width(array[0])
849
- set_height(array[1] )
1010
+ def accel_group?
1011
+ @accel_group
1012
+ end; alias accel_group accel_group? # === accel_group
1013
+
1014
+ # ========================================================================= #
1015
+ # === filename=
1016
+ # ========================================================================= #
1017
+ def filename=(i)
1018
+ @internal_hash[:filename] = i
1019
+ end; alias set_filename filename= # === set_filename
1020
+
1021
+ # ========================================================================= #
1022
+ # === filename?
1023
+ # ========================================================================= #
1024
+ def filename?
1025
+ @internal_hash[:filename]
850
1026
  end
851
1027
 
852
1028
  # ========================================================================= #
853
- # === original_width?
1029
+ # === set_my_border_width
854
1030
  #
855
- # Determine the default width of the screen on the target computer system.
1031
+ # Set the border-width for Gtk::Runner.
856
1032
  # ========================================================================= #
857
- def original_width?
858
- Gdk::Screen.default.width
859
- end; alias max_width? original_width? # === max_width?
1033
+ def set_my_border_width(
1034
+ i = 0
1035
+ )
1036
+ case i
1037
+ when nil
1038
+ i = 0
1039
+ end
1040
+ @internal_hash[:border_width] = i.to_i
1041
+ set_border_width(@internal_hash[:border_width])
1042
+ end; alias padding= set_my_border_width # === padding=
1043
+ alias border= set_my_border_width # === border=
1044
+ alias set_padding set_my_border_width # === set_padding
1045
+ alias set_border_size set_my_border_width # === set_border_size
860
1046
 
861
1047
  # ========================================================================= #
862
- # === border_width?
1048
+ # === middle_of_the_screen_then_run
1049
+ #
1050
+ # Use this method if you want to position the Gtk::App widget in the
1051
+ # center of the screen, before calling .run() on it.
863
1052
  # ========================================================================= #
864
- def border_width?
865
- @internal_hash[:border_width]
866
- end; alias padding? border_width? # === padding?
1053
+ def middle_of_the_screen_then_run
1054
+ middle_of_the_screen
1055
+ run
1056
+ end; alias middle_then_run middle_of_the_screen_then_run # === middle_then_run
1057
+ alias start_in_the_middle middle_of_the_screen_then_run # === start_in_the_middle
867
1058
 
868
1059
  # ========================================================================= #
869
- # === is_resizable
1060
+ # === top_left_then_show_then_run
870
1061
  # ========================================================================= #
871
- def is_resizable
872
- self.resizable = true
1062
+ def top_left_then_show_then_run
1063
+ top_left
1064
+ show
1065
+ run
873
1066
  end
874
1067
 
875
- require 'gtk_paradise/toplevel_methods/screen_resolution.rb'
876
1068
  # ========================================================================= #
877
- # === max_resolution?
1069
+ # === middle_of_the_screen
1070
+ #
1071
+ # This method allows the user to position the window in the middle of
1072
+ # the screen.
878
1073
  # ========================================================================= #
879
- def max_resolution?
880
- ::Gtk.screen_resolution?
1074
+ def middle_of_the_screen(
1075
+ use_this_as_the_positional_argument =
1076
+ ::Gtk::WindowPosition::CENTER
1077
+ )
1078
+ set_window_position(
1079
+ use_this_as_the_positional_argument
1080
+ )
881
1081
  end
882
1082
 
883
1083
  # ========================================================================= #
884
- # === set_my_title
885
- #
886
- # Use this to set the title.
1084
+ # === internal_hash?
887
1085
  # ========================================================================= #
888
- def set_my_title(
889
- i = internal_title?
890
- )
891
- i = __FILE__ if i == '__FILE__'
892
- @internal_hash[:title] = i
893
- # ======================================================================= #
894
- # Next delegate towards apply_the_internal_title().
895
- # ======================================================================= #
896
- apply_the_internal_title
897
- end; alias title set_my_title # === title
898
- alias name= set_my_title # === name=
1086
+ def internal_hash?
1087
+ @internal_hash
1088
+ end; alias main_hash? internal_hash? # === main_hash?
1089
+ alias hash? internal_hash? # === hash?
899
1090
 
900
1091
  # ========================================================================= #
901
- # === apply_the_internal_title
1092
+ # === top_middle
1093
+ #
1094
+ # Position the Gtk::Runner widget on the very top, but middle position.
1095
+ #
1096
+ # This must be calculated properly:
1097
+ #
1098
+ # (1) first we must determine the max-width of the monitor, and then
1099
+ # divide it by 2
1100
+ # (2) then we also need to determine the width of the widget
1101
+ # that will be spawned. This will default to a hardcoded
1102
+ # value, but Gtk::Runner can modify this accordingly via
1103
+ # the argument
902
1104
  #
903
- # This method should be used if you wish to apply the internally set title.
904
1105
  # ========================================================================= #
905
- def apply_the_internal_title(i = internal_title?)
906
- if i and respond_to?(:set_title)
907
- set_title(i)
1106
+ def top_middle(
1107
+ use_this_subwidget_width = :default # This argument can be a number.
1108
+ )
1109
+ case use_this_subwidget_width
1110
+ # ======================================================================= #
1111
+ # === :default
1112
+ # ======================================================================= #
1113
+ when :default
1114
+ use_this_subwidget_width = 250
908
1115
  end
1116
+ calculated_value = Gdk::Screen.default.width / 2
1117
+ calculated_value -= use_this_subwidget_width
1118
+ move(calculated_value, 0)
909
1119
  end
910
1120
 
911
1121
  # ========================================================================= #
912
- # === enable_quick_exit_then_run
1122
+ # === top_middle_then_run
913
1123
  # ========================================================================= #
914
- def enable_quick_exit_then_run
915
- enable_quick_exit
1124
+ def top_middle_then_run(
1125
+ i = :default
1126
+ )
1127
+ top_middle(i)
916
1128
  run
917
1129
  end
918
1130
 
919
1131
  # ========================================================================= #
920
- # === set_background_colour
921
- #
922
- # This method (or an alias to this method) can be used to set the
923
- # background colour.
1132
+ # === top_left_show_all_then_run
924
1133
  # ========================================================================= #
925
- def set_background_colour(i)
926
- if i
927
- @internal_hash[:background_colour] = i.to_s
928
- # ===================================================================== #
929
- # Note that if we input an incorrect colour then this will fail. This
930
- # explains the code in the rescue-clause.
931
- # ===================================================================== #
932
- begin
933
- parsed_colour = ::Gdk::Color.parse(@internal_hash[:background_colour])
934
- rescue ArgumentError
935
- @internal_hash[:background_colour] = 'white'
936
- parsed_colour = ::Gdk::Color.parse('white')
937
- end
938
- if ::Gtk.use_gtk2?
939
- modify_bg(::Gtk::STATE_NORMAL, parsed_colour)
940
- else # else assume gtk3 is in use.
941
- override_background_color(:normal, parsed_colour)
942
- end
943
- end
944
- end; alias background_colour set_background_colour # === background_colour
1134
+ def top_left_show_all_then_run
1135
+ top_left_and_show_all
1136
+ run
1137
+ end; alias top_left_show_all_then_run top_left_show_all_then_run # === top_left_show_all_then_run
1138
+ alias top_left_then_show_all_then_run top_left_show_all_then_run # === top_left_then_show_all_then_run
945
1139
 
946
1140
  # ========================================================================= #
947
- # === determine_the_title_from_the_child_widget
1141
+ # === feedback
948
1142
  #
949
- # The first argument is the widget that we will use, under the assumption
950
- # that it will be the child-widget.
1143
+ # Just feedback some info to the user.
951
1144
  # ========================================================================= #
952
- def determine_the_title_from_the_child_widget(
953
- child_widget = child_widget?
954
- )
955
- if child_widget and child_widget.respond_to?(:my_title?)
956
- title = child_widget.my_title?
957
- set_title_then_apply(title)
958
- else
959
- e 'The child-widget (class '+child_widget.name.to_s+
960
- ') does not respond to the method called .my_title?' unless child_widget.nil?
1145
+ def feedback
1146
+ unless Object.const_defined? :Colours
1147
+ begin
1148
+ require 'colours'
1149
+ rescue LoadError; end
961
1150
  end
962
- end; alias automatic_title determine_the_title_from_the_child_widget # === automatic_title
963
- alias determine_the_title determine_the_title_from_the_child_widget # === determine_the_title
964
- alias determine_the_title_automatically determine_the_title_from_the_child_widget # === determine_the_title_automatically
965
- alias infer_the_title_from_the_child_widget determine_the_title_from_the_child_widget # === infer_the_title_from_the_child_widget
966
- alias title_from_child_widget determine_the_title_from_the_child_widget # === title_from_child_widget
967
- alias automatic_title determine_the_title_from_the_child_widget # === automatic_title
1151
+ e
1152
+ e " #{::Colours.rev}widget-width is: #{::Colours.sfancy(@width)}"
1153
+ e " #{::Colours.rev}widget-height is: #{::Colours.sfancy(@height)}"
1154
+ e
1155
+ end
968
1156
 
969
1157
  # ========================================================================= #
970
- # === set_title_then_apply
1158
+ # === enable_quick_exit_then_run
971
1159
  # ========================================================================= #
972
- def set_title_then_apply(i)
973
- set_my_title(i)
974
- apply_the_internal_title
975
- end; alias set_my_title_then_apply_it set_title_then_apply # === set_my_title_then_apply_it
1160
+ def enable_quick_exit_then_run
1161
+ enable_quick_exit
1162
+ run
1163
+ end
976
1164
 
977
1165
  # ========================================================================= #
978
- # === missing_the_internal_hash?
1166
+ # === type_hint=
979
1167
  # ========================================================================= #
980
- def missing_the_internal_hash?
981
- _ = false
982
- _ = true if defined?(:@internal_hash)
983
- _ = true if @internal_hash.nil?
984
- return _
1168
+ def type_hint=(i = :dock)
1169
+ window.type_hint = Gdk::WindowTypeHint[i]
985
1170
  end
986
1171
 
987
1172
  # ========================================================================= #
988
- # === internal_title?
1173
+ # === register_sigint
989
1174
  # ========================================================================= #
990
- def internal_title?
991
- @internal_hash[:title]
992
- end; alias my_title? internal_title? # === my_title?
993
- alias title? internal_title? # === title?
1175
+ def register_sigint
1176
+ ::Gtk.register_sigint
1177
+ end
994
1178
 
995
1179
  # ========================================================================= #
996
- # === set_internal_title
1180
+ # === set_internal_child_widget
997
1181
  # ========================================================================= #
998
- def set_internal_title(i)
999
- @internal_hash[:title] = i
1000
- end
1182
+ def set_internal_child_widget(i)
1183
+ @internal_hash[:child_widget] = i
1184
+ end; alias set_child_widget set_internal_child_widget # === set_internal_child_widget
1001
1185
 
1002
1186
  # ========================================================================= #
1003
- # === enable_simple_exit_then_run
1187
+ # === child_widget?
1004
1188
  # ========================================================================= #
1005
- def enable_simple_exit_then_run
1006
- enable_simple_exit
1007
- run
1008
- end
1189
+ def child_widget?
1190
+ @internal_hash[:child_widget]
1191
+ end; alias child_widget child_widget? # === child_widget
1192
+ alias child? child_widget? # === child?
1009
1193
 
1010
1194
  # ========================================================================= #
1011
- # === interactively_create_directory
1195
+ # === top_left
1012
1196
  #
1013
- # This convenience method can be used to create a new directory.
1197
+ # Position the Gtk::Runner widget on the very top left position.
1014
1198
  # ========================================================================= #
1015
- def interactively_create_directory(
1016
- use_this_as_parent_widget
1017
- )
1018
- result = ''
1019
- text = gtk_text(
1020
- 'Input the name of the directory to be created:'
1021
- )
1022
- entry = gtk_entry
1023
-
1024
- popup_box = gtk_vbox
1025
- popup_box.set_padding(12)
1026
- popup_box.set_size_request(800, 240)
1027
- popup_box.set_font(:hack_20)
1028
- popup_box.minimal(text, 2)
1029
- popup_box.maximal(entry, 2)
1030
-
1031
- dialog = ::Gtk::Dialog.new(parent: use_this_as_parent_widget,
1032
- title: 'Interactively create a directory',
1033
- flags: [:modal, :destroy_with_parent],
1034
- buttons: [['_Cancel', :cancel],
1035
- ['_Create the directory', :ok]])
1036
- content_area = dialog.content_area
1037
- content_area.pack_start(popup_box)
1038
- content_area.show_all
1039
-
1040
- response = dialog.run
1041
-
1042
- case response
1043
- when :ok # This is <Gtk::ResponseType ok>
1044
- result << entry.text?
1045
- end
1046
-
1047
- if File.directory? result
1048
- e 'The directory '+result+' already exists.'
1199
+ def top_left
1200
+ if respond_to?(:move)
1201
+ move(0, 0)
1049
1202
  else
1050
- e 'Creating the directory '+result+' next.'
1051
- FileUtils.mkdir_p(result)
1203
+ pp __LINE__
1204
+ e 'The widget does not respond to :move.'
1052
1205
  end
1206
+ end; alias move_top_left top_left # === move_top_left
1053
1207
 
1054
- dialog.destroy
1208
+ # ========================================================================= #
1209
+ # === set_font_in_use
1210
+ # ========================================================================= #
1211
+ def set_font_in_use(i)
1212
+ ::Gtk.set_font(i)
1055
1213
  end
1056
1214
 
1057
1215
  # ========================================================================= #
1058
- # === handle_the_destroy_event
1216
+ # === width_height
1059
1217
  # ========================================================================= #
1060
- def handle_the_destroy_event
1061
- signal_connect(:destroy) { exit_application }
1218
+ def width_height(width, height)
1219
+ set_size_request(width, height)
1062
1220
  end
1063
1221
 
1064
1222
  # ========================================================================= #
1065
- # === exit_application
1066
- #
1067
- # Use this to quit from an application.
1223
+ # === set_default_size
1068
1224
  # ========================================================================= #
1069
- def exit_application
1070
- ::Gtk.main_quit
1071
- end; alias exit_program exit_application # === exit_program
1072
- alias do_quit exit_application # === do_quit
1225
+ def set_default_size(
1226
+ w = DEFAULT_WIDTH,
1227
+ h = DEFAULT_HEIGHT
1228
+ )
1229
+ set_width(w)
1230
+ set_height(h)
1231
+ end
1073
1232
 
1074
1233
  # ========================================================================= #
1075
- # === set_global_font_size
1076
- #
1077
- # The first input-argument to this method should be a number.
1234
+ # === do_maximize_width
1078
1235
  # ========================================================================= #
1079
- def set_global_font_size(
1080
- i, use_this_font_family = 'Sans'
1236
+ def do_maximize_width(
1237
+ width = max_width?, # Obtain the max-width here.
1238
+ height = height?
1081
1239
  )
1082
- Gtk::Settings.default.gtk_font_name = "#{use_this_font_family} #{i}"
1240
+ set_size_request(width, height)
1083
1241
  end
1084
1242
 
1085
1243
  # ========================================================================= #
1086
- # === do_maximize
1087
- #
1088
- # Use this when you want to maximize the window, to the full-screen.
1244
+ # === window_position_none
1089
1245
  # ========================================================================= #
1090
- def do_maximize
1091
- self.maximize
1092
- end; alias max do_maximize # === max
1246
+ def window_position_none(
1247
+ i = :none
1248
+ )
1249
+ if ::Gtk.use_gtk2?
1250
+ i = Gtk::Window::POS_NONE
1251
+ end
1252
+ set_window_position(i)
1253
+ end
1093
1254
 
1094
1255
  # ========================================================================= #
1095
- # === disallow_resizing
1256
+ # === resize_to_child_widget_dimension
1096
1257
  #
1097
- # This method will prevent the user from resizing the window.
1258
+ # This method can be used to resize to the child-widget's dimension.
1098
1259
  # ========================================================================= #
1099
- def disallow_resizing
1100
- set_resizable(false)
1260
+ def resize_to_child_widget_dimension
1261
+ _ = child_widget?
1262
+ set_size_request(_.width?, _.height?) if _
1101
1263
  end
1102
1264
 
1103
1265
  # ========================================================================= #
1104
- # === minimum_size
1266
+ # === alt_shortcut
1267
+ #
1268
+ # This method enables a key-shortcut via the alt-key.
1269
+ #
1270
+ # The second argument is the method that you wish to call / invoke.
1271
+ #
1272
+ # Specific usage examples:
1273
+ #
1274
+ # r.alt_key(1, 'focus_entry(1)')
1275
+ # r.alt_shortcut(1) { 'focus_entry(1)' }
1105
1276
  #
1106
- # This can be used to specify a minimum size. It is advised to pass
1107
- # a Hash.
1108
1277
  # ========================================================================= #
1109
- def minimum_size(
1110
- hash = { width: '30%', height: '20%' }
1278
+ def alt_shortcut(
1279
+ key_combination_to_use,
1280
+ method_to_call = nil
1111
1281
  )
1112
- set_size_request(hash[:width], hash[:height])
1282
+ use_this_shortcut = "alt+#{key_combination_to_use}"
1283
+ if block_given?
1284
+ yielded = yield
1285
+ method_to_call = yielded if method_to_call.nil?
1286
+ shortcut(use_this_shortcut) { method_to_call }
1287
+ else
1288
+ shortcut(use_this_shortcut) { method_to_call }
1289
+ end
1290
+ end; alias alt_key alt_shortcut # === alt_key
1291
+
1292
+ # ========================================================================= #
1293
+ # === size=
1294
+ #
1295
+ # Set width and height here. Input argument to this method should be an
1296
+ # Array.
1297
+ # ========================================================================= #
1298
+ def size=(array)
1299
+ set_width(array[0])
1300
+ set_height(array[1])
1113
1301
  end
1114
1302
 
1115
1303
  # ========================================================================= #
@@ -1121,7 +1309,8 @@ module AppModule
1121
1309
  # boat cursor will be used.
1122
1310
  # ========================================================================= #
1123
1311
  def set_cursor(
1124
- which_cursor_to_use = :in_method_default
1312
+ which_cursor_to_use =
1313
+ :in_method_default
1125
1314
  )
1126
1315
  case which_cursor_to_use
1127
1316
  # ======================================================================= #
@@ -1225,12 +1414,24 @@ module AppModule
1225
1414
  # ======================================================================= #
1226
1415
  when :hand2
1227
1416
  cursor = Gdk::Cursor::HAND2
1417
+ # ======================================================================= #
1418
+ # === :heart
1419
+ # ======================================================================= #
1228
1420
  when :heart
1229
1421
  cursor = Gdk::Cursor::HEART
1422
+ # ======================================================================= #
1423
+ # === :icon
1424
+ # ======================================================================= #
1230
1425
  when :icon
1231
1426
  cursor = Gdk::Cursor::ICON
1427
+ # ======================================================================= #
1428
+ # === :iron
1429
+ # ======================================================================= #
1232
1430
  when :iron
1233
1431
  cursor = Gdk::Cursor::IRON_CROSS
1432
+ # ======================================================================= #
1433
+ # === :default
1434
+ # ======================================================================= #
1234
1435
  when :default_cursor,
1235
1436
  :default
1236
1437
  cursor = Gdk::Cursor::LEFT_PTR
@@ -1252,139 +1453,52 @@ module AppModule
1252
1453
  cursor = Gdk::Cursor::LEFTBUTTON
1253
1454
  # ======================================================================= #
1254
1455
  # === :left_angle
1255
- # ======================================================================= #
1256
- when :left_angle
1257
- cursor = Gdk::Cursor::LL_ANGLE
1258
- else
1259
- cursor = Gdk::Cursor::WATCH
1260
- end
1261
- unless which_cursor_to_use == 'rand'
1262
- window.set_cursor(Gdk::Cursor.new(cursor))
1263
- end
1264
- end
1265
-
1266
- require 'gtk_paradise/toplevel_methods/register_sigint.rb'
1267
- # ========================================================================= #
1268
- # === register_sigint
1269
- # ========================================================================= #
1270
- def register_sigint
1271
- ::Gtk.register_sigint
1272
- end
1273
-
1274
- # ========================================================================= #
1275
- # === type_hint=
1276
- # ========================================================================= #
1277
- def type_hint=(i = :dock)
1278
- window.type_hint = Gdk::WindowTypeHint[i]
1279
- end
1280
-
1281
- # ========================================================================= #
1282
- # === child_widget?
1283
- # ========================================================================= #
1284
- def child_widget?
1285
- @internal_hash[:child_widget]
1286
- end; alias child_widget child_widget? # === child_widget
1287
- alias child? child_widget? # === child?
1288
-
1289
- require 'gtk_paradise/gtk_classes/status_icon.rb'
1290
- # ========================================================================= #
1291
- # === status_icon
1292
- #
1293
- # This method add a StatusIcon to a gtk-widget.
1294
- # ========================================================================= #
1295
- def status_icon(
1296
- use_this_as_the_icon = favicon?
1297
- )
1298
- if ::Gtk.use_gtk2?
1299
- _ = ::Gtk::StatusIcon.new
1300
- _.use_this_image = use_this_as_the_icon
1301
- else
1302
- _ = ::Gtk::StatusIcon.new(file: use_this_as_the_icon)
1303
- end
1304
- return _
1305
- end
1306
-
1307
- # ========================================================================= #
1308
- # === top_left
1309
- #
1310
- # Position the Gtk::Runner widget on the very top left position.
1311
- # ========================================================================= #
1312
- def top_left
1313
- move(0, 0) if respond_to?(:move)
1314
- end; alias move_top_left top_left # === move_top_left
1315
-
1316
- # ========================================================================= #
1317
- # === set_internal_child_widget
1318
- # ========================================================================= #
1319
- def set_internal_child_widget(i)
1320
- @internal_hash[:child_widget] = i
1321
- end; alias set_child_widget set_internal_child_widget # === set_internal_child_widget
1322
-
1323
- # ========================================================================= #
1324
- # === enable_quick_exit
1325
- #
1326
- # This method enables quick "alt+Q" key-combination to quit the
1327
- # application. Since as of September 2020, we also use strg+q
1328
- # (which is ctrl+q, actually).
1329
- # ========================================================================= #
1330
- def enable_quick_exit
1331
- add_shortcut(:q, 'exit_program', :alt)
1332
- add_shortcut(:q, 'exit_program', :strg)
1333
- end; alias easy_exit enable_quick_exit # === easy_exit
1334
- alias quick_exit enable_quick_exit # === quick_exit
1335
- alias enable_simple_exit enable_quick_exit # === enable_simple_exit
1336
- alias simple_exit enable_quick_exit # === simple_exit
1337
- alias enable_easy_exit enable_quick_exit # === enable_easy_exit
1338
-
1339
- # ========================================================================= #
1340
- # === shortcuts
1341
- #
1342
- # This may be used like so:
1343
- #
1344
- # r.shortcuts {
1345
- # [1, 'click_on_button_number(0)', :alt],
1346
- # }
1347
- #
1348
- # ========================================================================= #
1349
- def shortcuts(&block)
1350
- # ======================================================================= #
1351
- # === Handle blocks next
1352
- # ======================================================================= #
1353
- if block_given?
1354
- yielded = yield
1355
- if yielded.is_a? Array
1356
- yielded.each {|inner_array|
1357
- add_shortcut(
1358
- inner_array[0],
1359
- inner_array[1],
1360
- inner_array[2]
1361
- )
1362
- }
1363
- end
1456
+ # ======================================================================= #
1457
+ when :left_angle
1458
+ cursor = Gdk::Cursor::LL_ANGLE
1459
+ else
1460
+ cursor = Gdk::Cursor::WATCH
1461
+ end
1462
+ unless which_cursor_to_use == 'rand'
1463
+ window.set_cursor(Gdk::Cursor.new(cursor))
1364
1464
  end
1365
1465
  end
1366
1466
 
1367
1467
  # ========================================================================= #
1368
- # === run (run tag, start tag, def run)
1468
+ # === infer_default_size
1369
1469
  #
1370
- # Start the application via this method.
1470
+ # This variant will use the size from the child-widget. Thus, for this
1471
+ # method to properly work, a child-widget has to exist.
1371
1472
  # ========================================================================= #
1372
- def run(
1373
- optional_show_all = true
1374
- )
1375
- if child_widget? and child_widget?.respond_to? :my_title?
1376
- set_my_title(child_widget?.my_title?)
1473
+ def infer_default_size
1474
+ if child_widget?
1475
+ set_default_size(
1476
+ child_widget?.width?,
1477
+ child_widget?.height?
1478
+ )
1377
1479
  end
1378
- show_all if optional_show_all
1480
+ end; alias clever_size infer_default_size # === clever_size
1481
+ alias infer_the_size infer_default_size # === infer_the_size
1482
+
1483
+ # ========================================================================= #
1484
+ # === automatic_size
1485
+ #
1486
+ # This method currently combines two methods. I am unsure whether this
1487
+ # will be retained in the long run, but for now (2022) it will be
1488
+ # retained as-is.
1489
+ # ========================================================================= #
1490
+ def automatic_size(
1491
+ width = width?,
1492
+ height = height?
1493
+ )
1494
+ set_default_size(width.to_i, height.to_i)
1379
1495
  # ======================================================================= #
1380
- # The next code clause is probably no longer necessary, as .add() will
1381
- # handle these cases.
1496
+ # The next line actually causes the resize-action.
1382
1497
  # ======================================================================= #
1383
- # if width? and height?
1384
- # set_default_size(width?, height?)
1385
- # end
1386
- ::Gtk.main # Finally, run the application here.
1387
- end; alias start run # === start
1498
+ set_size_request(width.to_i, height.to_i)
1499
+ end; alias use_default_size_from_the_config_file automatic_size # === use_default_size_from_the_config_file
1500
+ alias determine_the_size_from_the_child_widget automatic_size # === determine_the_size_from_the_child_widget
1501
+ alias size_from_child automatic_size # === size_from_child
1388
1502
 
1389
1503
  # ========================================================================= #
1390
1504
  # === automatic_size_then_automatic_title
@@ -1405,12 +1519,18 @@ module AppModule
1405
1519
  alias automatic automatic_size_then_automatic_title # === automatic
1406
1520
 
1407
1521
  # ========================================================================= #
1408
- # === internal_hash?
1522
+ # === disallow_modification_of_the_title
1409
1523
  # ========================================================================= #
1410
- def internal_hash?
1411
- @internal_hash
1412
- end; alias main_hash? internal_hash? # === main_hash?
1413
- alias hash? internal_hash? # === hash?
1524
+ def disallow_modification_of_the_title
1525
+ @internal_hash[:may_we_modify_the_title] = false
1526
+ end
1527
+
1528
+ # ========================================================================= #
1529
+ # === may_we_modify_the_title?
1530
+ # ========================================================================= #
1531
+ def may_we_modify_the_title?
1532
+ @internal_hash[:may_we_modify_the_title]
1533
+ end
1414
1534
 
1415
1535
  # ========================================================================= #
1416
1536
  # === << (add tag)
@@ -1425,10 +1545,17 @@ module AppModule
1425
1545
  # too, via set_internal_child_widget().
1426
1546
  # ========================================================================= #
1427
1547
  def <<(child_widget)
1428
- initialize_the_internal_hash unless @internal_hash.is_a? Hash
1548
+ unless @internal_hash.is_a? Hash
1549
+ initialize_the_internal_hash
1550
+ end
1429
1551
  builder = ::Gtk::Builder.new
1430
1552
  set_internal_child_widget(child_widget)
1431
- add_child(builder, child_widget) # add_child(builder, child, type)
1553
+ unless use_gtk4?
1554
+ # This part may have to be re-visited at a later time.
1555
+ # builder.set_child(child_widget)
1556
+ # else
1557
+ add_child(builder, child_widget) # add_child(builder, child, type)
1558
+ end
1432
1559
  # ======================================================================= #
1433
1560
  # === Apply the ad-hoc CSS rules next
1434
1561
  #
@@ -1446,8 +1573,10 @@ module AppModule
1446
1573
  # ======================================================================= #
1447
1574
  # === :my_title?
1448
1575
  # ======================================================================= #
1449
- if child_widget.respond_to? :my_title?
1450
- set_title(child_widget.my_title?)
1576
+ if child_widget and
1577
+ child_widget.respond_to?(:my_title?) and
1578
+ may_we_modify_the_title?
1579
+ set_my_title(child_widget.my_title?)
1451
1580
  end
1452
1581
  # ======================================================================= #
1453
1582
  # === :width?
@@ -1476,7 +1605,8 @@ module AppModule
1476
1605
  # ======================================================================= #
1477
1606
  # === :border_size
1478
1607
  # ======================================================================= #
1479
- if child_widget.respond_to? :border_size?
1608
+ if child_widget.respond_to?(:border_size?) and
1609
+ child_widget.respond_to?(:set_border_width?)
1480
1610
  child_widget.set_border_width(child_widget.border_size?)
1481
1611
  end
1482
1612
  # ======================================================================= #
@@ -1578,158 +1708,193 @@ module AppModule
1578
1708
  end #; alias add << # === add
1579
1709
 
1580
1710
  # ========================================================================= #
1581
- # === width?
1711
+ # === set_internal_title
1582
1712
  # ========================================================================= #
1583
- def width?
1584
- @internal_hash[:width]
1713
+ def set_internal_title(i)
1714
+ @internal_hash[:title] = i
1585
1715
  end
1586
1716
 
1587
1717
  # ========================================================================= #
1588
- # === height?
1718
+ # === internal_title?
1589
1719
  # ========================================================================= #
1590
- def height?
1591
- @internal_hash[:height]
1592
- end
1720
+ def internal_title?
1721
+ @internal_hash[:title]
1722
+ end; alias my_title? internal_title? # === my_title?
1723
+ alias title? internal_title? # === title?
1593
1724
 
1594
1725
  # ========================================================================= #
1595
- # === set_width
1596
- #
1597
- # Use only this method when setting @width.
1726
+ # === apply_the_internal_title
1598
1727
  #
1599
- # If we pass in a string that also includes a '%' character then
1600
- # we assume that the user wishes to use Gdk::Screen.default instead.
1601
- # ========================================================================= #
1602
- def set_width(i = DEFAULT_WIDTH)
1603
- if i
1604
- # ===================================================================== #
1605
- # === Handle percentage values given to this method next
1606
- # ===================================================================== #
1607
- if i.is_a? String and i.include? '%'
1608
- i = i.to_f # This is percentage.
1609
- i = (Gdk::Screen.default.width * i) / 100
1610
- end
1611
- i = i.first if i.is_a? Array
1612
- i = i.to_i
1613
- @internal_hash[:width] = i
1614
- end
1615
- end; alias width= set_width # === width=
1616
-
1617
- # ========================================================================= #
1618
- # === set_height
1728
+ # This method should be used if you wish to apply the internally set title.
1619
1729
  #
1620
- # Use only this method when wishing to set to @height.
1730
+ # It has a few if/else clauses largely because there was a bug in effect
1731
+ # where .set_title() was not called properly. Now there is no way around
1732
+ # notifying the user when something goes awry.
1621
1733
  # ========================================================================= #
1622
- def set_height(i)
1734
+ def apply_the_internal_title(
1735
+ i = internal_title?
1736
+ )
1623
1737
  if i
1624
- if i.is_a? String and i.include? '%'
1625
- i = i.to_f # This is percentage.
1626
- i = (Gdk::Screen.default.height * i) / 100
1738
+ if respond_to?(:set_title)
1739
+ set_title(i)
1740
+ else
1741
+ e 'Input was given to '+__method__.to_s+' but the class does not'
1742
+ e 'respond to .set_title().'
1627
1743
  end
1628
- i = i.to_i
1629
- @internal_hash[:height] = i
1744
+ else
1745
+ # e 'No title was given. This is unusual - please investigate the cause.'
1746
+ # pp caller()
1630
1747
  end
1631
- end; alias height= set_height # === height=
1632
-
1633
- # ========================================================================= #
1634
- # === automatic_size
1635
- # ========================================================================= #
1636
- def automatic_size(
1637
- width = width?,
1638
- height = height?
1639
- )
1640
- set_default_size(width.to_i, height.to_i)
1641
- # ======================================================================= #
1642
- # The next line actually causes the resize-action.
1643
- # ======================================================================= #
1644
- set_size_request(width.to_i, height.to_i)
1645
- end; alias use_default_size_from_the_config_file automatic_size # === use_default_size_from_the_config_file
1646
- alias determine_the_size_from_the_child_widget automatic_size # === determine_the_size_from_the_child_widget
1647
- alias size_from_child automatic_size # === size_from_child
1748
+ end
1648
1749
 
1649
1750
  # ========================================================================= #
1650
- # === set_default_size
1751
+ # === add_context_menu_with_the_default_accel_group
1651
1752
  # ========================================================================= #
1652
- def set_default_size(
1653
- w = DEFAULT_WIDTH,
1654
- h = DEFAULT_HEIGHT
1655
- )
1656
- set_width(w)
1657
- set_height(h)
1753
+ def add_context_menu_with_the_default_accel_group
1754
+ add_accel_group(@accel_group = gtk_accel_group)
1755
+ enable_context_menu
1658
1756
  end
1659
1757
 
1660
1758
  # ========================================================================= #
1661
- # === set_my_border_width
1759
+ # === set_favicon
1662
1760
  #
1663
- # Set the border-width for Gtk::Runner.
1761
+ # Ensures that the icon exists before setting it.
1762
+ #
1763
+ # Some symbol-shortcuts are allowed here, which are hardcoded towards my
1764
+ # own system.
1664
1765
  # ========================================================================= #
1665
- def set_my_border_width(i = 0)
1766
+ def set_favicon(i)
1767
+ if i.nil? and is_on_roebe?
1768
+ i = :default
1769
+ end
1770
+ if i.is_a?(String) and i.start_with?(':')
1771
+ i = i.delete(':').to_sym
1772
+ end
1666
1773
  case i
1667
- when nil
1668
- i = 0
1774
+ # ======================================================================= #
1775
+ # === :RMC
1776
+ # ======================================================================= #
1777
+ when :RMC,
1778
+ :rmc
1779
+ i = ::Gtk.project_base_directory?+'images/misc/RMC.jpg'
1780
+ # ======================================================================= #
1781
+ # === :lotus
1782
+ # ======================================================================= #
1783
+ when :lotus
1784
+ i = '/home/x/data/images/RPG/STD/LOTUS_MASKE.png'
1785
+ # ======================================================================= #
1786
+ # === :tabble_image
1787
+ #
1788
+ # This entry point is currently aliased to ":default" - thus, it is
1789
+ # the default value.
1790
+ # ======================================================================= #
1791
+ when :tabble_image,
1792
+ :tabble,
1793
+ :default
1794
+ i = ::Gtk.project_base_directory?+'images/misc/tabble.png'
1795
+ # ======================================================================= #
1796
+ # === :pc_favicon
1797
+ # ======================================================================= #
1798
+ when :pc_favicon
1799
+ i = '/home/x/data/images/PC/PC_FAVICON.png'
1800
+ # ======================================================================= #
1801
+ # === :task_image
1802
+ # ======================================================================= #
1803
+ when :tasks_image,
1804
+ :tasks
1805
+ i = '/home/x/data/images/PC/TASKS.jpg'
1806
+ # ======================================================================= #
1807
+ # === :audio_favicon
1808
+ # ======================================================================= #
1809
+ when :audio_favicon
1810
+ i = '/home/x/data/images/AUDIO/AUDIO_FAVICON.png'
1669
1811
  end
1670
- @internal_hash[:border_width] = i.to_i
1671
- set_border_width(@internal_hash[:border_width])
1672
- end; alias padding= set_my_border_width # === padding=
1673
- alias border= set_my_border_width # === border=
1674
- alias set_padding set_my_border_width # === set_padding
1675
- alias set_border_size set_my_border_width # === set_border_size
1676
-
1677
- # ========================================================================= #
1678
- # === top_left_then_show_then_run
1679
- # ========================================================================= #
1680
- def top_left_then_show_then_run
1681
- top_left
1682
- show
1683
- run
1684
- end
1812
+ if i
1813
+ begin
1814
+ if File.exist? i
1815
+ @internal_hash[:favicon] = i
1816
+ else
1817
+ e "(in gtk_paradise/run.rb) No file exists at this location: `#{i}`"
1818
+ end
1819
+ rescue Exception => error
1820
+ pp error
1821
+ pp i
1822
+ end
1823
+ else
1824
+ if is_on_roebe?
1825
+ e 'Please provide an icon_location to the method set_favicon()'
1826
+ end
1827
+ end
1828
+ @internal_hash[:favicon] = i
1829
+ end; alias set_icon_location set_favicon # === set_icon_location
1830
+ alias icon_location= set_favicon # === icon_location=
1831
+ alias icon= set_favicon # === icon?
1832
+ alias set_this_favicon set_favicon # === set_this_favicon
1833
+ alias set_logo set_favicon # === set_logo
1834
+ alias favicon= set_favicon # === favicon=
1685
1835
 
1686
1836
  # ========================================================================= #
1687
- # === middle_of_the_screen
1837
+ # === default_width_and_height
1838
+ #
1839
+ # This variant is a bit different for two reasons:
1840
+ #
1841
+ # (1) by default it will use a percentage value for both width
1842
+ # and height
1843
+ # (2) it will also do a set_size_request() to try to get the
1844
+ # new width and height; in particular this point is quite
1845
+ # different to the regular .width_height() method.
1688
1846
  #
1689
- # This method allows the user to position the window in the middle of
1690
- # the screen.
1691
- # ========================================================================= #
1692
- def middle_of_the_screen(
1693
- use_this_as_the_positional_argument = ::Gtk::WindowPosition::CENTER
1694
- )
1695
- set_window_position(use_this_as_the_positional_argument)
1696
- end
1697
-
1698
- # ========================================================================= #
1699
- # === middle_of_the_screen_then_run
1700
1847
  # ========================================================================= #
1701
- def middle_of_the_screen_then_run
1702
- middle_of_the_screen
1703
- run
1704
- end; alias middle_then_run middle_of_the_screen_then_run # === middle_then_run
1705
- alias start_in_the_middle middle_of_the_screen_then_run # === start_in_the_middle
1848
+ def default_width_and_height(
1849
+ width = '80%',
1850
+ height = '75%'
1851
+ )
1852
+ set_width(width)
1853
+ set_height(height)
1854
+ set_size_request(width?, height?)
1855
+ end; alias default_width_height default_width_and_height # === default_width_height
1856
+ alias determine_width_and_height default_width_and_height # === determine_width_and_height
1706
1857
 
1707
1858
  # ========================================================================= #
1708
- # === infer_default_size
1859
+ # === run (run tag, start tag, def run)
1709
1860
  #
1710
- # This variant will use the size from the child-widget. Thus, for this
1711
- # method to properly work, a child-widget has to exist.
1861
+ # Start the application via this method.
1712
1862
  # ========================================================================= #
1713
- def infer_default_size
1714
- if child_widget?
1715
- set_default_size(
1716
- child_widget?.width?,
1717
- child_widget?.height?
1718
- )
1863
+ def run(
1864
+ optional_show_all = true
1865
+ )
1866
+ show_all if optional_show_all
1867
+ # ======================================================================= #
1868
+ # The next code clause is probably no longer necessary, as .add() will
1869
+ # handle these cases.
1870
+ # ======================================================================= #
1871
+ # if width? and height?
1872
+ # set_default_size(width?, height?)
1873
+ # end
1874
+ if use_gtk2? or use_gtk3?
1875
+ ::Gtk.main # Finally, run the application here.
1719
1876
  end
1720
- end; alias clever_size infer_default_size # === clever_size
1721
- alias infer_the_size infer_default_size # === infer_the_size
1877
+ end; alias start run # === start
1722
1878
 
1723
1879
  end; end
1724
1880
 
1725
1881
  if __FILE__ == $PROGRAM_NAME
1882
+ alias e puts
1726
1883
  require 'gtk3'
1884
+ # require 'gtk_paradise/gtk_classes/widget.rb'
1885
+ # require 'gtk_paradise/gtk_classes/window.rb'
1886
+ require 'gtk_paradise/gtk_classes/window.rb'
1887
+ e
1888
+ e 'Testing Gtk::AppModule next:'
1889
+ e
1727
1890
  window = Gtk::Window.new
1728
1891
  window.extend(Gtk::AppModule)
1729
1892
  window.internal_reset
1730
- window.internal_title?
1731
- window.set_internal_title('YO THERE')
1893
+ e window.internal_title?
1894
+ window.set_internal_title('YO THERE - THIS IS A GREAT TITLE!')
1895
+ e window.internal_title?
1732
1896
  window.apply_the_internal_title
1897
+ window.use_this_font = :hack_30
1733
1898
  window.add(Gtk::Label.new('This is a test.'))
1734
1899
  window.show_all
1735
1900
  window.top_left