gtk_paradise 0.9.120 → 0.12.25

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