gtk_paradise 0.9.120 → 0.11.19

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

Potentially problematic release.


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

Files changed (492) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4521 -2997
  3. data/bin/genity +26 -0
  4. data/bin/gtk_editor +7 -0
  5. data/doc/README.gen +4484 -2975
  6. data/doc/todo/TODO_FOR_THE_GTK_PARADISE_PROJECT.md +281 -218
  7. data/doc/todo/recurring_todo_tasks.md +4 -3
  8. data/gtk_paradise.gemspec +28 -17
  9. data/lib/gtk_paradise/app/app.rb +77 -45
  10. data/lib/gtk_paradise/app/{app_module.rb → app_module/app_module.rb} +1064 -899
  11. data/lib/gtk_paradise/base_module/base_module.rb +7043 -33
  12. data/lib/gtk_paradise/base_module/class_methods/class_methods.rb +0 -0
  13. data/lib/gtk_paradise/base_module/css.rb +200 -268
  14. data/lib/gtk_paradise/base_module/experimental.rb +119 -0
  15. data/lib/gtk_paradise/base_module/html_support.rb +40 -15
  16. data/lib/gtk_paradise/base_module/these_methods_work_for_gtk3_and_gtk4.rb +155 -0
  17. data/lib/gtk_paradise/base_module_and_app_module/base_module_and_app_module.rb +1 -1
  18. data/lib/gtk_paradise/colours/colour_palette/material_design.rb +239 -0
  19. data/lib/gtk_paradise/colours/gtk_colour_constants.rb +8 -2
  20. data/lib/gtk_paradise/colours/parse.rb +8 -1
  21. data/lib/gtk_paradise/commandline/commandline.rb +20 -19
  22. data/lib/gtk_paradise/constants/constants.rb +227 -7
  23. data/lib/gtk_paradise/css_files/borders.css +81 -0
  24. data/lib/gtk_paradise/css_files/colours.css +329 -328
  25. data/lib/gtk_paradise/css_files/css_accordion.css +6 -2
  26. data/lib/gtk_paradise/css_files/hover_effects.css +588 -0
  27. data/lib/gtk_paradise/css_files/project.css +153 -189
  28. data/lib/gtk_paradise/drawing/README.md +3 -0
  29. data/lib/gtk_paradise/drawing/drawing.rb +68 -0
  30. data/lib/gtk_paradise/{base_module/colours.rb → drawing/event.rb} +37 -45
  31. data/lib/gtk_paradise/drawing/star.rb +96 -0
  32. data/lib/gtk_paradise/drawing/tool.rb +268 -0
  33. data/lib/gtk_paradise/drawing/turtle.rb +138 -0
  34. data/lib/gtk_paradise/emojis/emojis.rb +14 -13
  35. data/lib/gtk_paradise/examples/advanced/001_5x5_grid_example.rb +35 -50
  36. data/lib/gtk_paradise/examples/advanced/002_advanced_drag_and_drop_example.rb +21 -13
  37. data/lib/gtk_paradise/examples/advanced/003_html_like_support.rb +4 -25
  38. data/lib/gtk_paradise/examples/advanced/004_on_hover_example_on_gtk_entry.rb +4 -4
  39. data/lib/gtk_paradise/examples/advanced/005_csv_example.rb +6 -2
  40. data/lib/gtk_paradise/examples/advanced/007_label_responding_to_events_example.rb +1 -10
  41. data/lib/gtk_paradise/examples/advanced/008_options_example.rb +6 -3
  42. data/lib/gtk_paradise/examples/advanced/009_key_events.rb +1 -1
  43. data/lib/gtk_paradise/examples/advanced/010_extensive_text_view_example.rb +18 -17
  44. data/lib/gtk_paradise/examples/advanced/011_moving_blocks_example.rb +3 -3
  45. data/lib/gtk_paradise/examples/advanced/012_cell_data_sorting_example.rb +3 -4
  46. data/lib/gtk_paradise/examples/advanced/013_advanced_css_example.rb +86 -49
  47. data/lib/gtk_paradise/examples/advanced/014_popup_example.rb +9 -9
  48. data/lib/gtk_paradise/examples/advanced/015_advanced_button_example.rb +7 -19
  49. data/lib/gtk_paradise/examples/advanced/017_lean_CSS_example.rb +10 -13
  50. data/lib/gtk_paradise/examples/advanced/018_coloured_text_example.rb +7 -13
  51. data/lib/gtk_paradise/examples/advanced/019_gtk_entry_showing_the_cursor_position.rb +1 -1
  52. data/lib/gtk_paradise/examples/advanced/020_scale_this_image.rb +1 -10
  53. data/lib/gtk_paradise/examples/advanced/021_scroll_events_on_gtk_entry.rb +4 -0
  54. data/lib/gtk_paradise/examples/advanced/022_autogenerated_CSS_rounded_borders.rb +142 -0
  55. data/lib/gtk_paradise/examples/advanced/023_append_image_to_buffer.rb +145 -0
  56. data/lib/gtk_paradise/examples/advanced/024_notebook_with_tab_example.rb +151 -0
  57. data/lib/gtk_paradise/examples/advanced/025_showing_a_gold_caret_on_black_background.rb +144 -0
  58. data/lib/gtk_paradise/examples/advanced/026_status_bar_example.rb +153 -0
  59. data/lib/gtk_paradise/examples/advanced/027_customized_frame_example.rb +141 -0
  60. data/lib/gtk_paradise/examples/advanced/028_widgets_described_in_a_yaml_file.rb +240 -0
  61. data/lib/gtk_paradise/examples/cairo/basic_cairo_shapes.rb +1 -1
  62. data/lib/gtk_paradise/examples/cairo/cairo_transparent_rectangles.rb +9 -5
  63. data/lib/gtk_paradise/examples/cairo/cairo_write_via_custom_font.rb +81 -0
  64. data/lib/gtk_paradise/examples/cairo/donut_shape.rb +19 -6
  65. data/lib/gtk_paradise/examples/cairo/ping_pong_game.rb +2 -3
  66. data/lib/gtk_paradise/examples/controller/README.md +4 -0
  67. data/lib/gtk_paradise/examples/controller/controller.rb +2 -0
  68. data/lib/gtk_paradise/examples/css/001_border_examples.rb +30 -13
  69. data/lib/gtk_paradise/examples/css/002_import_CSS_file.rb +10 -5
  70. data/lib/gtk_paradise/examples/drawing/001_example.rb +61 -0
  71. data/lib/gtk_paradise/examples/drawing/002_example.rb +51 -0
  72. data/lib/gtk_paradise/examples/drawing/003_example.rb +38 -0
  73. data/lib/gtk_paradise/examples/drawing/004_example.rb +36 -0
  74. data/lib/gtk_paradise/examples/drawing/005_example.rb +92 -0
  75. data/lib/gtk_paradise/examples/drawing/006_example.rb +58 -0
  76. data/lib/gtk_paradise/examples/drawing/007_example.rb +22 -0
  77. data/lib/gtk_paradise/examples/drawing/008_example.rb +43 -0
  78. data/lib/gtk_paradise/examples/drawing/009_example.rb +43 -0
  79. data/lib/gtk_paradise/examples/drawing/010_example.rb +25 -0
  80. data/lib/gtk_paradise/examples/drawing/011_example.rb +72 -0
  81. data/lib/gtk_paradise/examples/drawing/012_example.rb +59 -0
  82. data/lib/gtk_paradise/examples/drawing/README.md +3 -0
  83. data/lib/gtk_paradise/examples/drawing/moving_turtle_example.rb +43 -0
  84. data/lib/gtk_paradise/examples/gdk/001_gdk_screen_properties.rb +58 -0
  85. data/lib/gtk_paradise/examples/gdk_pixbuf/save_image_example.rb +1 -1
  86. data/lib/gtk_paradise/examples/gir_ffi/001_hello_world.rb +29 -0
  87. data/lib/gtk_paradise/examples/gir_ffi/002_upgraded_hello_world.rb +40 -0
  88. data/lib/gtk_paradise/examples/gir_ffi/003_gtk_application_example.rb +30 -0
  89. data/lib/gtk_paradise/examples/gir_ffi/004_treeview_example.rb +64 -0
  90. data/lib/gtk_paradise/examples/gir_ffi/005_complex_example.rb +104 -0
  91. data/lib/gtk_paradise/examples/gir_ffi/README.md +5 -0
  92. data/lib/gtk_paradise/examples/glib/parse_glib_settings.rb +1 -1
  93. data/lib/gtk_paradise/examples/gtk2/008_list_store_example.rb +1 -1
  94. data/lib/gtk_paradise/examples/gtk3/{061_gtk_entry.rb → 001_gtk_entry.rb} +11 -6
  95. data/lib/gtk_paradise/examples/gtk3/{009_scrolled_window_example.rb → 002_scrolled_window_example.rb} +6 -4
  96. data/lib/gtk_paradise/examples/gtk3/{062_toggle_button_example.rb → 003_toggle_button_example.rb} +3 -2
  97. data/lib/gtk_paradise/examples/gtk3/{081_simple_dialog_example.rb → 004_simple_dialog_example.rb} +19 -12
  98. data/lib/gtk_paradise/examples/gtk3/005_spinner_example.rb +30 -10
  99. data/lib/gtk_paradise/examples/gtk3/006_text_view_example.rb +78 -0
  100. data/lib/gtk_paradise/examples/gtk3/{079_two_windows_example.rb → 007_two_windows_example.rb} +3 -1
  101. data/lib/gtk_paradise/examples/gtk3/008_search_bar_example.rb +91 -0
  102. data/lib/gtk_paradise/examples/gtk3/{002_simple_window.rb → 009_simple_window.rb} +14 -6
  103. data/lib/gtk_paradise/examples/gtk3/{025_switch_example.rb → 010_switch_example.rb} +6 -7
  104. data/lib/gtk_paradise/examples/gtk3/011_colour_chooser_example.rb +71 -0
  105. data/lib/gtk_paradise/examples/gtk3/012_show_the_xid_example.rb +18 -0
  106. data/lib/gtk_paradise/examples/gtk3/013_grab_pointer_forcefully.rb +31 -0
  107. data/lib/gtk_paradise/examples/gtk3/{083_bottom_left_placement.rb → 015_bottom_left_placement.rb} +3 -1
  108. data/lib/gtk_paradise/examples/gtk3/{082_scrolling_example.rb → 016_scrolling_example.rb} +2 -2
  109. data/lib/gtk_paradise/examples/gtk3/{080_extensive_markup_example.rb → 017_extensive_markup_example.rb} +8 -7
  110. data/lib/gtk_paradise/examples/gtk3/{078_message_dialog_example.rb → 018_message_dialog_example.rb} +3 -5
  111. data/lib/gtk_paradise/examples/gtk3/{075_tiny_button_via_css.rb → 021_tiny_button_via_css.rb} +1 -0
  112. data/lib/gtk_paradise/examples/gtk3/{001_font_related_information.rb → 022_font_related_information.rb} +1 -1
  113. data/lib/gtk_paradise/examples/gtk3/023_sorted_tree.rb +166 -0
  114. data/lib/gtk_paradise/examples/gtk3/{004_small_paned_example.rb → 024_small_paned_example.rb} +4 -3
  115. data/lib/gtk_paradise/examples/gtk3/{007_progress_bar_example.rb → 026_progress_bar_example.rb} +1 -2
  116. data/lib/gtk_paradise/examples/gtk3/{008_menubar_example.rb → 027_menubar_example.rb} +1 -1
  117. data/lib/gtk_paradise/examples/gtk3/{010_paned_widget_example.rb → 028_paned_widget_example.rb} +1 -0
  118. data/lib/gtk_paradise/examples/gtk3/{011_sockets.rb → 029_sockets.rb} +1 -0
  119. data/lib/gtk_paradise/examples/gtk3/{012_notebook_example.rb → 030_notebook_example.rb} +1 -0
  120. data/lib/gtk_paradise/examples/gtk3/{013_icon_theme_example.rb → 031_icon_theme_example.rb} +6 -0
  121. data/lib/gtk_paradise/examples/gtk3/{014_switcher_window.rb → 032_switcher_window.rb} +16 -10
  122. data/lib/gtk_paradise/examples/gtk3/{016_hello_world_in_gtk3_and_bold_font.rb → 034_hello_world_in_gtk3_and_bold_font.rb} +1 -1
  123. data/lib/gtk_paradise/examples/gtk3/{017_grid_example.rb → 035_grid_example.rb} +5 -1
  124. data/lib/gtk_paradise/examples/gtk3/{018_buttons_showcasing_the_relief.rb → 036_buttons_showcasing_the_relief.rb} +1 -0
  125. data/lib/gtk_paradise/examples/gtk3/{019_text_buffer_example.rb → 037_text_buffer_example.rb} +12 -10
  126. data/lib/gtk_paradise/examples/gtk3/{022_popup_example.rb → 040_popup_example.rb} +2 -2
  127. data/lib/gtk_paradise/examples/gtk3/{023_horizontal_and_vertical_scale.rb → 041_horizontal_and_vertical_scale.rb} +1 -1
  128. data/lib/gtk_paradise/examples/gtk3/{026_hover_button_example_via_css.rb → 043_hover_button_example_via_css.rb} +3 -1
  129. data/lib/gtk_paradise/examples/gtk3/{027_spin_button_example.rb → 044_spin_button_example.rb} +4 -3
  130. data/lib/gtk_paradise/examples/gtk3/{028_radio_menu_item_example.rb → 045_radio_menu_item_example.rb} +4 -1
  131. data/lib/gtk_paradise/examples/gtk3/{029_gtk_dialog_sample.rb → 046_gtk_dialog_sample.rb} +4 -1
  132. data/lib/gtk_paradise/examples/gtk3/{030_draw_rectangles.rb → 047_draw_rectangles.rb} +1 -1
  133. data/lib/gtk_paradise/examples/gtk3/{031_colour_choose_button.rb → 048_colour_choose_button.rb} +17 -3
  134. data/lib/gtk_paradise/examples/gtk3/{032_drag_and_drop_example.rb → 049_drag_and_drop_example.rb} +13 -5
  135. data/lib/gtk_paradise/examples/gtk3/{033_cell_renderer_pixbuf_example.rb → 050_cell_renderer_pixbuf_example.rb} +17 -6
  136. data/lib/gtk_paradise/examples/gtk3/051_combo_box_example.rb +74 -0
  137. data/lib/gtk_paradise/examples/gtk3/{037_css_example_of_a_button_changing_the_background_colour_on_click_event.rb → 053_css_example_of_a_button_changing_the_background_colour_on_click_event.rb} +14 -4
  138. data/lib/gtk_paradise/examples/gtk3/{036_revealer_example.rb → 053_revealer_example.rb} +10 -6
  139. data/lib/gtk_paradise/examples/gtk3/{038_ten_labels_in_a_vertical_box_example.rb → 054_ten_labels_in_a_vertical_box_example.rb} +1 -1
  140. data/lib/gtk_paradise/examples/gtk3/{039_threads_example.rb → 055_threads_example.rb} +1 -1
  141. data/lib/gtk_paradise/examples/gtk3/{042_colourized_button_example.rb → 058_colourized_button_example.rb} +1 -2
  142. data/lib/gtk_paradise/examples/gtk3/{043_form_example.rb → 059_form_example.rb} +1 -3
  143. data/lib/gtk_paradise/examples/gtk3/{044_check_button.rb → 060_check_button.rb} +4 -2
  144. data/lib/gtk_paradise/examples/gtk3/{046_event_box_example.rb → 062_event_box_example.rb} +2 -1
  145. data/lib/gtk_paradise/examples/gtk3/{047_examples_with_css.rb → 063_examples_with_css.rb} +91 -3
  146. data/lib/gtk_paradise/examples/gtk3/{048_accel_group_example.rb → 064_accel_group_example.rb} +1 -0
  147. data/lib/gtk_paradise/examples/gtk3/{049_change_the_application_theme.rb → 065_change_the_application_theme.rb} +4 -2
  148. data/lib/gtk_paradise/examples/gtk3/{050_header_bar_example.rb → 066_header_bar_example.rb} +3 -0
  149. data/lib/gtk_paradise/examples/gtk3/{051_gtk_label_example.rb → 067_gtk_label_example.rb} +3 -2
  150. data/lib/gtk_paradise/examples/gtk3/{052_popover_example.rb → 068_popover_example.rb} +2 -2
  151. data/lib/gtk_paradise/examples/gtk3/{053_entry_completion.rb → 069_entry_completion.rb} +2 -0
  152. data/lib/gtk_paradise/examples/gtk3/{055_button_demo.rb → 071_button_demo.rb} +6 -5
  153. data/lib/gtk_paradise/examples/gtk3/{056_text_iterator_example.rb → 072_text_iterator_example.rb} +30 -21
  154. data/lib/gtk_paradise/examples/gtk3/{057_image_example.rb → 073_image_example.rb} +1 -1
  155. data/lib/gtk_paradise/examples/gtk3/{058_frame_example.rb → 074_frame_example.rb} +1 -1
  156. data/lib/gtk_paradise/examples/gtk3/{059_gtk_expander.rb → 075_gtk_expander.rb} +2 -0
  157. data/lib/gtk_paradise/examples/gtk3/{060_ten_vboxes_example.rb → 076_ten_vboxes_example.rb} +1 -0
  158. data/lib/gtk_paradise/examples/gtk3/{063_button_box_example.rb → 077_button_box_example.rb} +11 -1
  159. data/lib/gtk_paradise/examples/gtk3/{064_tree_view_column_example.rb → 078_tree_view_column_example.rb} +2 -1
  160. data/lib/gtk_paradise/examples/gtk3/{066_vertical_boxes.rb → 080_vertical_boxes.rb} +2 -1
  161. data/lib/gtk_paradise/examples/gtk3/{067_vbox_with_spacing_and_border_width.rb → 081_vbox_with_spacing_and_border_width.rb} +2 -1
  162. data/lib/gtk_paradise/examples/gtk3/{069_file_chooser_dialog.rb → 082_file_chooser_dialog.rb} +3 -0
  163. data/lib/gtk_paradise/examples/gtk3/{070_bindings.rb → 083_bindings.rb} +14 -8
  164. data/lib/gtk_paradise/examples/gtk3/{072_recent_chooser_dialog.rb → 084_recent_chooser_dialog.rb} +2 -2
  165. data/lib/gtk_paradise/examples/gtk3/{073_showcase_the_cursors.rb → 085_showcase_the_cursors.rb} +30 -5
  166. data/lib/gtk_paradise/examples/gtk3/{074_app_chooser_button_example.rb → 086_app_chooser_button_example.rb} +1 -0
  167. data/lib/gtk_paradise/examples/gtk3/087_calendar_example.rb +41 -0
  168. data/lib/gtk_paradise/examples/gtk4/001_gtk_entry.rb +88 -0
  169. data/lib/gtk_paradise/examples/gtk4/002_scrolled_window_example.rb +62 -0
  170. data/lib/gtk_paradise/examples/gtk4/003_toggle_button_example.rb +23 -0
  171. data/lib/gtk_paradise/examples/gtk4/004_simple_dialog_example.rb +41 -0
  172. data/lib/gtk_paradise/examples/gtk4/005_spinner_example.rb +64 -0
  173. data/lib/gtk_paradise/examples/gtk4/006_text_view_example.rb +77 -0
  174. data/lib/gtk_paradise/examples/gtk4/007_two_windows_example.rb +55 -0
  175. data/lib/gtk_paradise/examples/gtk4/008_search_bar_example.rb +88 -0
  176. data/lib/gtk_paradise/examples/gtk4/009_text_view_example.rb +30 -0
  177. data/lib/gtk_paradise/examples/gtk4/010_switch_example.rb +52 -0
  178. data/lib/gtk_paradise/examples/gtk4/074_frame_example.rb +105 -0
  179. data/lib/gtk_paradise/examples/gtk4/076_ten_vboxes_example.rb +35 -0
  180. data/lib/gtk_paradise/examples/gtk4/087_calendar_example.rb +47 -0
  181. data/lib/gtk_paradise/examples/gtk4/100_changed_events_example.rb +77 -0
  182. data/lib/gtk_paradise/examples/gtk4/101_actionbar_example.rb +55 -0
  183. data/lib/gtk_paradise/examples/gtk4/102_picture_example.rb +35 -0
  184. data/lib/gtk_paradise/examples/pango/pango_power.rb +1 -0
  185. data/lib/gtk_paradise/experimental/experimental.rb +3 -11
  186. data/lib/gtk_paradise/experimental/experimental_for_gtk4.rb +92 -0
  187. data/lib/gtk_paradise/fonts/fonts.rb +5 -1
  188. data/lib/gtk_paradise/gdk/cursor.rb +2 -2
  189. data/lib/gtk_paradise/{base_module/e.rb → gdk/event_crossing.rb} +6 -8
  190. data/lib/gtk_paradise/gdk/gdk.rb +1 -1
  191. data/lib/gtk_paradise/gtk_classes/about.rb +11 -2
  192. data/lib/gtk_paradise/gtk_classes/about_dialog.rb +6 -2
  193. data/lib/gtk_paradise/gtk_classes/alignment.rb +4 -1
  194. data/lib/gtk_paradise/gtk_classes/application.rb +94 -4
  195. data/lib/gtk_paradise/gtk_classes/application_window.rb +25 -0
  196. data/lib/gtk_paradise/gtk_classes/box.rb +116 -279
  197. data/lib/gtk_paradise/gtk_classes/button.rb +55 -37
  198. data/lib/gtk_paradise/gtk_classes/button_box.rb +9 -1
  199. data/lib/gtk_paradise/gtk_classes/cell_renderer_text.rb +5 -3
  200. data/lib/gtk_paradise/gtk_classes/check_button.rb +27 -8
  201. data/lib/gtk_paradise/gtk_classes/combo_box.rb +4 -1
  202. data/lib/gtk_paradise/gtk_classes/combo_box_entry.rb +17 -11
  203. data/lib/gtk_paradise/gtk_classes/combo_box_text.rb +21 -19
  204. data/lib/gtk_paradise/gtk_classes/dialog.rb +2 -2
  205. data/lib/gtk_paradise/gtk_classes/entry.rb +256 -124
  206. data/lib/gtk_paradise/gtk_classes/entry_completion.rb +4 -0
  207. data/lib/gtk_paradise/gtk_classes/event_box.rb +21 -2
  208. data/lib/gtk_paradise/gtk_classes/event_button.rb +1 -1
  209. data/lib/gtk_paradise/gtk_classes/expander.rb +8 -1
  210. data/lib/gtk_paradise/gtk_classes/file_chooser_dialog.rb +1 -1
  211. data/lib/gtk_paradise/gtk_classes/file_filter.rb +4 -2
  212. data/lib/gtk_paradise/gtk_classes/file_selection.rb +4 -3
  213. data/lib/gtk_paradise/gtk_classes/frame.rb +19 -1
  214. data/lib/gtk_paradise/gtk_classes/grid.rb +206 -160
  215. data/lib/gtk_paradise/gtk_classes/hbox.rb +145 -0
  216. data/lib/gtk_paradise/gtk_classes/header_bar.rb +19 -8
  217. data/lib/gtk_paradise/gtk_classes/image.rb +1 -1
  218. data/lib/gtk_paradise/gtk_classes/label.rb +174 -135
  219. data/lib/gtk_paradise/gtk_classes/menu.rb +7 -3
  220. data/lib/gtk_paradise/gtk_classes/menu_bar.rb +1 -1
  221. data/lib/gtk_paradise/gtk_classes/menu_item.rb +1 -1
  222. data/lib/gtk_paradise/gtk_classes/notebook.rb +114 -64
  223. data/lib/gtk_paradise/gtk_classes/paned.rb +52 -0
  224. data/lib/gtk_paradise/gtk_classes/radio_menu_item.rb +19 -1
  225. data/lib/gtk_paradise/gtk_classes/scale_button.rb +16 -1
  226. data/lib/gtk_paradise/gtk_classes/scrolled_window.rb +8 -6
  227. data/lib/gtk_paradise/gtk_classes/search_bar.rb +1 -1
  228. data/lib/gtk_paradise/gtk_classes/source_buffer.rb +4 -5
  229. data/lib/gtk_paradise/gtk_classes/spin_button.rb +9 -1
  230. data/lib/gtk_paradise/gtk_classes/spinner.rb +32 -2
  231. data/lib/gtk_paradise/gtk_classes/status_icon.rb +2 -0
  232. data/lib/gtk_paradise/gtk_classes/statusbar.rb +1 -0
  233. data/lib/gtk_paradise/gtk_classes/style_context.rb +71 -0
  234. data/lib/gtk_paradise/gtk_classes/text_buffer.rb +45 -19
  235. data/lib/gtk_paradise/gtk_classes/text_view.rb +20 -3
  236. data/lib/gtk_paradise/gtk_classes/toggle_button.rb +3 -0
  237. data/lib/gtk_paradise/gtk_classes/toolbar.rb +2 -2
  238. data/lib/gtk_paradise/gtk_classes/tree_iter.rb +1 -1
  239. data/lib/gtk_paradise/gtk_classes/tree_view.rb +93 -70
  240. data/lib/gtk_paradise/gtk_classes/tree_view_column.rb +2 -1
  241. data/lib/gtk_paradise/gtk_classes/vbox.rb +71 -10
  242. data/lib/gtk_paradise/gtk_classes/vscale.rb +2 -2
  243. data/lib/gtk_paradise/gtk_classes/widget.rb +1057 -590
  244. data/lib/gtk_paradise/gtk_classes/window.rb +37 -2
  245. data/lib/gtk_paradise/hello_world/README.md +1 -1
  246. data/lib/gtk_paradise/hello_world/hello_world_gtk4.rb +20 -0
  247. data/lib/gtk_paradise/images/icons/close_image.png +0 -0
  248. data/lib/gtk_paradise/images/icons/closed.png +0 -0
  249. data/lib/gtk_paradise/images/icons/directory.png +0 -0
  250. data/lib/gtk_paradise/images/icons/icon_cool.gif +0 -0
  251. data/lib/gtk_paradise/images/icons/icon_lol.gif +0 -0
  252. data/lib/gtk_paradise/images/icons/icon_smile.gif +0 -0
  253. data/lib/gtk_paradise/images/icons/opened.png +0 -0
  254. data/lib/gtk_paradise/images/internal/gtk_label_example.png +0 -0
  255. data/lib/gtk_paradise/images/misc/wiki_logo.png +0 -0
  256. data/lib/gtk_paradise/images/small/GREEN_CIRCLE.png +0 -0
  257. data/lib/gtk_paradise/images/small/README.md +2 -0
  258. data/lib/gtk_paradise/images/small/RED_CIRCLE.png +0 -0
  259. data/lib/gtk_paradise/pango/{pango_fonts.rb → fonts.rb} +2 -2
  260. data/lib/gtk_paradise/pango/{pango.rb → layout.rb} +1 -1
  261. data/lib/gtk_paradise/pango/pango_renderer.rb +9 -2
  262. data/lib/gtk_paradise/project/project.rb +4 -3
  263. data/lib/gtk_paradise/prototypes/README.md +8 -0
  264. data/lib/gtk_paradise/prototypes/gtk3_standalone.rb +8 -21
  265. data/lib/gtk_paradise/prototypes/gtk4_standalone.rb +135 -0
  266. data/lib/gtk_paradise/prototypes/shared_code.rb +5 -15
  267. data/lib/gtk_paradise/prototypes/unified_gtk_prototype.rb +179 -0
  268. data/lib/gtk_paradise/require_gtk4.rb +7 -0
  269. data/lib/gtk_paradise/requires/require_base_module.rb +7 -0
  270. data/lib/gtk_paradise/requires/require_files_irrespective_of_the_gtk_version_at_hand.rb +25 -16
  271. data/lib/gtk_paradise/requires/require_gtk2.rb +6 -4
  272. data/lib/gtk_paradise/requires/{require_gtk2_or_gtk3.rb → require_gtk2_or_gtk3_or_gtk4.rb} +33 -12
  273. data/lib/gtk_paradise/requires/require_gtk3.rb +5 -20
  274. data/lib/gtk_paradise/requires/require_gtk4.rb +13 -0
  275. data/lib/gtk_paradise/requires/require_gtk_runner.rb +1 -0
  276. data/lib/gtk_paradise/requires/require_the_base_module_and_gtk_run.rb +1 -1
  277. data/lib/gtk_paradise/requires/require_the_base_module_the_app_module_and_the_toplevel_methods.rb +9 -0
  278. data/lib/gtk_paradise/requires/require_the_classes_files_for_gtk4.rb +11 -0
  279. data/lib/gtk_paradise/requires/require_the_colours_gem.rb +9 -0
  280. data/lib/gtk_paradise/requires/require_the_default_gtk_version.rb +4 -2
  281. data/lib/gtk_paradise/requires/require_the_toplevel_methods.rb +1 -1
  282. data/lib/gtk_paradise/run.rb +1 -0
  283. data/lib/gtk_paradise/run_this_widget/run_this_widget.rb +7 -3
  284. data/lib/gtk_paradise/threads/threads.rb +15 -10
  285. data/lib/gtk_paradise/toplevel_methods/css.rb +183 -35
  286. data/lib/gtk_paradise/toplevel_methods/cursor.rb +17 -3
  287. data/lib/gtk_paradise/toplevel_methods/determine_which_gtk_version_is_in_use.rb +90 -8
  288. data/lib/gtk_paradise/toplevel_methods/events.rb +6 -0
  289. data/lib/gtk_paradise/toplevel_methods/keys.rb +1 -1
  290. data/lib/gtk_paradise/toplevel_methods/screen_resolution.rb +32 -5
  291. data/lib/gtk_paradise/toplevel_methods/text_buffer_tags.rb +13 -4
  292. data/lib/gtk_paradise/toplevel_methods/tokenizer.rb +18 -3
  293. data/lib/gtk_paradise/toplevel_methods/{misc.rb → toplevel_methods.rb} +728 -181
  294. data/lib/gtk_paradise/utility_scripts/commandline_to_automatic_gui.rb +244 -0
  295. data/lib/gtk_paradise/version/version.rb +2 -2
  296. data/lib/gtk_paradise/widgets/gtk2/cat_merge.rb +2 -6
  297. data/lib/gtk_paradise/widgets/gtk2/cell_renderer_progress_example.rb +0 -5
  298. data/lib/gtk_paradise/widgets/gtk2/foto_lister.rb +2 -6
  299. data/lib/gtk_paradise/widgets/gtk2/gidnight_commander/gidnight_commander.rb +3 -3
  300. data/lib/gtk_paradise/widgets/gtk2/hbox_example.rb +1 -5
  301. data/lib/gtk_paradise/widgets/gtk2/multiple_select_in_a_tree_view_widget.rb +2 -6
  302. data/lib/gtk_paradise/widgets/gtk2/paned_example.rb +1 -1
  303. data/lib/gtk_paradise/widgets/gtk2/slider_changing_button.rb +2 -6
  304. data/lib/gtk_paradise/widgets/gtk2/status_icon_example.rb +2 -6
  305. data/lib/gtk_paradise/widgets/gtk2/table2.rb +2 -6
  306. data/lib/gtk_paradise/widgets/gtk2/toolbar_example.rb +2 -6
  307. data/lib/gtk_paradise/widgets/{version_agnostic → gtk3/audio_button}/audio_button.rb +15 -26
  308. data/lib/gtk_paradise/widgets/gtk3/burn_this_iso_file/burn_this_iso_file.rb +2 -6
  309. data/lib/gtk_paradise/widgets/{version_agnostic → gtk3/button_open_remote_webpage}/button_open_remote_webpage.rb +105 -50
  310. data/lib/gtk_paradise/widgets/gtk3/button_with_border/button_with_border.rb +155 -0
  311. data/lib/gtk_paradise/widgets/{version_agnostic → gtk3/button_xorg_buffer}/button_xorg_buffer.rb +76 -18
  312. data/lib/gtk_paradise/widgets/gtk3/calculator/calculator.rb +183 -76
  313. data/lib/gtk_paradise/widgets/gtk3/checkbox_image/checkbox_image.rb +3 -7
  314. data/lib/gtk_paradise/widgets/{version_agnostic → gtk3/coloured_button}/coloured_button.rb +94 -24
  315. data/lib/gtk_paradise/widgets/gtk3/coloured_square/coloured_square.rb +2 -6
  316. data/lib/gtk_paradise/widgets/gtk3/coloured_unit/coloured_unit.rb +151 -0
  317. data/lib/gtk_paradise/widgets/gtk3/cpu_widget/cpu_widget.rb +2 -6
  318. data/lib/gtk_paradise/widgets/gtk3/directory_content_widget/directory_content_widget.rb +937 -7
  319. data/lib/gtk_paradise/widgets/gtk3/editor/connect_skeleton.rb +33 -38
  320. data/lib/gtk_paradise/widgets/gtk3/editor/create.rb +66 -41
  321. data/lib/gtk_paradise/widgets/gtk3/editor/editor.rb +256 -270
  322. data/lib/gtk_paradise/widgets/gtk3/editor/internal_widgets/goto_line_widget.rb +52 -65
  323. data/lib/gtk_paradise/widgets/gtk3/editor/misc.rb +358 -111
  324. data/lib/gtk_paradise/widgets/gtk3/files_in_directory/files_in_directory.rb +2 -7
  325. data/lib/gtk_paradise/widgets/gtk3/flexible_vte/flexible_vte.rb +3 -7
  326. data/lib/gtk_paradise/widgets/gtk3/font_size_widget/action_button.rb +1 -5
  327. data/lib/gtk_paradise/widgets/gtk3/font_size_widget/font_size_widget.rb +2 -6
  328. data/lib/gtk_paradise/widgets/{gtk2 → gtk3}/gidnight_commander/gidnight_commander.config +1 -2
  329. data/lib/gtk_paradise/widgets/gtk3/gidnight_commander/gidnight_commander.rb +165 -125
  330. data/lib/gtk_paradise/widgets/gtk3/image_close_on_click_action/image_close_on_click_action.rb +34 -2
  331. data/lib/gtk_paradise/widgets/gtk3/image_viewer/image_viewer.rb +23 -26
  332. data/lib/gtk_paradise/widgets/gtk3/information_about_the_harddisc/harddisc_information.rb +161 -0
  333. data/lib/gtk_paradise/widgets/gtk3/insert_character/insert_character.rb +24 -29
  334. data/lib/gtk_paradise/widgets/gtk3/linux_users/linux_users.rb +32 -32
  335. data/lib/gtk_paradise/widgets/gtk3/my_calendar/my_calendar.rb +330 -7
  336. data/lib/gtk_paradise/widgets/gtk3/my_image_menu_item/my_image_menu_item.rb +179 -0
  337. data/lib/gtk_paradise/widgets/gtk3/non_numbers_only/non_numbers_only.rb +136 -0
  338. data/lib/gtk_paradise/widgets/gtk3/note_window/note_window.rb +199 -0
  339. data/lib/gtk_paradise/widgets/gtk3/notebook_controller/notebook_controller.rb +311 -7
  340. data/lib/gtk_paradise/widgets/gtk3/notebook_tab_with_icon/notebook_tab_with_icon.rb +402 -7
  341. data/lib/gtk_paradise/widgets/gtk3/numbered_lines/numbered_lines.rb +128 -82
  342. data/lib/gtk_paradise/widgets/{version_agnostic → gtk3/numbers_only}/numbers_only.rb +15 -3
  343. data/lib/gtk_paradise/widgets/gtk3/ping_widget/ping_widget.rb +491 -8
  344. data/lib/gtk_paradise/widgets/gtk3/regex_matcher/regex_matcher.rb +362 -43
  345. data/lib/gtk_paradise/widgets/gtk3/rename_widget/rename_widget.rb +8 -25
  346. data/lib/gtk_paradise/widgets/gtk3/show_which_key_was_pressed/show_which_key_was_pressed.rb +190 -0
  347. data/lib/gtk_paradise/widgets/gtk3/stopwatch/stopwatch.rb +318 -7
  348. data/lib/gtk_paradise/widgets/gtk3/sys_message/sys_message.rb +219 -7
  349. data/lib/gtk_paradise/widgets/gtk3/system_information/system_information.rb +58 -34
  350. data/lib/gtk_paradise/widgets/gtk3/tabble/admin_panel.rb +2 -6
  351. data/lib/gtk_paradise/widgets/gtk3/tabble/image_and_button.rb +2 -6
  352. data/lib/gtk_paradise/widgets/gtk3/tabble/tabble.rb +2 -6
  353. data/lib/gtk_paradise/widgets/gtk3/view_webpage/view_webpage.rb +2 -6
  354. data/lib/gtk_paradise/widgets/gtk3/wiki/README.md +4 -0
  355. data/lib/gtk_paradise/widgets/gtk3/wiki/wiki.rb +388 -0
  356. data/lib/gtk_paradise/widgets/gtk4/ping_widget/ping_widget.rb +4 -0
  357. data/lib/gtk_paradise/widgets/gtk4/show_icon_theme/show_icon_theme.rb +134 -0
  358. data/lib/gtk_paradise/widgets/gtk4/sys_message/sys_message.rb +269 -0
  359. data/lib/gtk_paradise/widgets/{gtk2/stopwatch/stopwatch.rb → gtk4/xpm_loader/xpm_loader.rb} +13 -11
  360. data/lib/gtk_paradise/widgets/shared_code/browser/browser_module.rb +4 -16
  361. data/lib/gtk_paradise/widgets/shared_code/cdripper/cdripper_module.rb +1 -1
  362. data/lib/gtk_paradise/widgets/shared_code/colour_filled_widget/colour_filled_widget_module.rb +25 -28
  363. data/lib/gtk_paradise/widgets/shared_code/colour_palette/colour_palette_module.rb +2 -2
  364. data/lib/gtk_paradise/widgets/shared_code/contacts/contacts_module.rb +62 -64
  365. data/lib/gtk_paradise/widgets/shared_code/flip_state_widget/flip_state_widget_module.rb +3 -19
  366. data/lib/gtk_paradise/widgets/shared_code/information_about_the_harddisc/harddisc_information.rb +0 -155
  367. data/lib/gtk_paradise/widgets/shared_code/information_about_the_harddisc/information_about_the_harddisc_module.rb +0 -444
  368. data/lib/gtk_paradise/widgets/shared_code/lsmod/lsmod_module.rb +22 -26
  369. data/lib/gtk_paradise/widgets/shared_code/lspci/lspci_module.rb +24 -36
  370. data/lib/gtk_paradise/widgets/shared_code/mini_clock/mini_clock_module.rb +74 -58
  371. data/lib/gtk_paradise/widgets/shared_code/my_calendar/my_calendar_module.rb +0 -327
  372. data/lib/gtk_paradise/widgets/shared_code/pid_displayer/pid_displayer_module.rb +53 -41
  373. data/lib/gtk_paradise/widgets/shared_code/random_image/random_image_module.rb +46 -29
  374. data/lib/gtk_paradise/widgets/shared_code/select_file/select_file_module.rb +1 -1
  375. data/lib/gtk_paradise/widgets/shared_code/show_icon_theme/show_icon_theme_module.rb +56 -44
  376. data/lib/gtk_paradise/widgets/shared_code/simple_clock/simple_clock_module.rb +1 -12
  377. data/lib/gtk_paradise/widgets/shared_code/stopwatch/stopwatch_module.rb +0 -341
  378. data/lib/gtk_paradise/widgets/shared_code/sys_message/sys_message_module.rb +0 -211
  379. data/lib/gtk_paradise/widgets/shared_code/tabby/tabby_module.rb +3 -15
  380. data/lib/gtk_paradise/widgets/shared_code/xpm_loader/xpm_loader_module.rb +15 -23
  381. data/lib/gtk_paradise/www/index.cgi +2 -2
  382. data/lib/gtk_paradise/yaml/browser_URLs.yml +3 -4
  383. data/lib/gtk_paradise/yaml/configuration_options_for_class_gtk_runner.yml +6 -6
  384. data/lib/gtk_paradise/yaml/experimental/README.md +3 -0
  385. data/lib/gtk_paradise/yaml/experimental/all_widgets.yml +37 -0
  386. data/lib/gtk_paradise/yaml/menu.yml +6 -3
  387. data/lib/gtk_paradise/yaml/notebook_controller.yml +62 -29
  388. data/lib/gtk_paradise.rb +0 -5
  389. data/test/gtk2/testing_combo_box.rb +1 -0
  390. data/test/gtk2/testing_display.rb +23 -0
  391. data/test/gtk2/testing_gtk_image.rb +4 -3
  392. data/test/gtk2/testing_hbox_and_vbox.rb +37 -0
  393. data/test/gtk2/testing_label_with_ampersand.rb +5 -2
  394. data/test/gtk2/testing_notebook.rb +11 -5
  395. data/test/gtk3/test_widget.rb +2 -1
  396. data/test/gtk3/testing_app.rb +0 -1
  397. data/test/gtk3/testing_base_module.rb +2 -1
  398. data/test/gtk3/testing_numbered_lines.rb +20 -0
  399. data/test/gtk3/testing_project_base_directory.rb +6 -1
  400. data/test/gtk3/testing_the_html_pseudo_tags.rb +2 -2
  401. data/test/gtk4/testing_gtk_entry.rb +24 -0
  402. data/test/misc/testing_a_gtk_frame.rb +14 -0
  403. data/test/misc/testing_gtk4_simplifications.rb +105 -0
  404. data/test/misc/testing_gtk_paradise_runner.rb +19 -4
  405. data/test/misc/testing_the_gtk_classes.rb +83 -0
  406. metadata +246 -199
  407. data/lib/gtk_paradise/base_module/change_directory.rb +0 -22
  408. data/lib/gtk_paradise/base_module/combo_box_and_combo_box_entry.rb +0 -113
  409. data/lib/gtk_paradise/base_module/commandline_arguments.rb +0 -36
  410. data/lib/gtk_paradise/base_module/configuration.rb +0 -50
  411. data/lib/gtk_paradise/base_module/constants.rb +0 -23
  412. data/lib/gtk_paradise/base_module/debug.rb +0 -127
  413. data/lib/gtk_paradise/base_module/draggable.rb +0 -95
  414. data/lib/gtk_paradise/base_module/emoji.rb +0 -107
  415. data/lib/gtk_paradise/base_module/esystem.rb +0 -22
  416. data/lib/gtk_paradise/base_module/events.rb +0 -111
  417. data/lib/gtk_paradise/base_module/fonts.rb +0 -119
  418. data/lib/gtk_paradise/base_module/graphics_display.rb +0 -47
  419. data/lib/gtk_paradise/base_module/gtk3.rb +0 -43
  420. data/lib/gtk_paradise/base_module/gtk_buttons.rb +0 -562
  421. data/lib/gtk_paradise/base_module/gtk_entry.rb +0 -126
  422. data/lib/gtk_paradise/base_module/gtk_fixed.rb +0 -18
  423. data/lib/gtk_paradise/base_module/gtk_grid.rb +0 -61
  424. data/lib/gtk_paradise/base_module/gtk_image.rb +0 -501
  425. data/lib/gtk_paradise/base_module/gtk_label.rb +0 -211
  426. data/lib/gtk_paradise/base_module/gtk_notebook.rb +0 -88
  427. data/lib/gtk_paradise/base_module/gtk_scrolled_window.rb +0 -155
  428. data/lib/gtk_paradise/base_module/misc.rb +0 -2949
  429. data/lib/gtk_paradise/base_module/pango.rb +0 -24
  430. data/lib/gtk_paradise/base_module/popover.rb +0 -241
  431. data/lib/gtk_paradise/base_module/register_sigint.rb +0 -20
  432. data/lib/gtk_paradise/base_module/reset.rb +0 -128
  433. data/lib/gtk_paradise/base_module/return_corresponding_gtk_stock_item.rb +0 -92
  434. data/lib/gtk_paradise/base_module/roebe.rb +0 -19
  435. data/lib/gtk_paradise/base_module/table.rb +0 -438
  436. data/lib/gtk_paradise/base_module/time.rb +0 -35
  437. data/lib/gtk_paradise/constants/available_cursors.rb +0 -52
  438. data/lib/gtk_paradise/constants/fonts.rb +0 -38
  439. data/lib/gtk_paradise/constants/misc.rb +0 -56
  440. data/lib/gtk_paradise/constants/newline.rb +0 -14
  441. data/lib/gtk_paradise/constants/xbm_icons.rb +0 -121
  442. data/lib/gtk_paradise/examples/gtk3/003_sorted_tree.rb +0 -141
  443. data/lib/gtk_paradise/examples/gtk3/034_combo_box_example.rb +0 -49
  444. data/lib/gtk_paradise/examples/gtk3/068_text_view_example.rb +0 -34
  445. data/lib/gtk_paradise/examples/gtk3/071_search_bar_example.rb +0 -59
  446. data/lib/gtk_paradise/gtk_classes/colours/colours.rb +0 -158
  447. data/lib/gtk_paradise/requires/require_the_minesweeper_files.rb +0 -11
  448. data/lib/gtk_paradise/toplevel_methods/allow_only_numbers.rb +0 -59
  449. data/lib/gtk_paradise/toplevel_methods/csv.rb +0 -102
  450. data/lib/gtk_paradise/toplevel_methods/e.rb +0 -18
  451. data/lib/gtk_paradise/toplevel_methods/enable_and_disable_warnings.rb +0 -58
  452. data/lib/gtk_paradise/toplevel_methods/keyboard.rb +0 -25
  453. data/lib/gtk_paradise/toplevel_methods/main_file.rb +0 -31
  454. data/lib/gtk_paradise/toplevel_methods/register_sigint.rb +0 -17
  455. data/lib/gtk_paradise/toplevel_methods/roebe.rb +0 -22
  456. data/lib/gtk_paradise/toplevel_methods/select_file.rb +0 -168
  457. data/lib/gtk_paradise/toplevel_methods/spacer.rb +0 -55
  458. data/lib/gtk_paradise/toplevel_methods/tooltips.rb +0 -71
  459. data/lib/gtk_paradise/toplevel_methods/we_use_this_gtk_version.rb +0 -65
  460. data/lib/gtk_paradise/widgets/gtk2/directory_content_widget/directory_content_widget.rb +0 -30
  461. data/lib/gtk_paradise/widgets/gtk2/my_calendar/my_calendar.config +0 -6
  462. data/lib/gtk_paradise/widgets/gtk2/my_calendar/my_calendar.rb +0 -34
  463. data/lib/gtk_paradise/widgets/gtk2/notebook_tab_with_icon/notebook_tab_with_icon.rb +0 -30
  464. data/lib/gtk_paradise/widgets/gtk2/ping_widget/ping_widget.rb +0 -30
  465. data/lib/gtk_paradise/widgets/gtk2/sys_message/sys_message.config +0 -6
  466. data/lib/gtk_paradise/widgets/gtk2/sys_message/sys_message.rb +0 -29
  467. data/lib/gtk_paradise/widgets/shared_code/directory_content_widget/constants.rb +0 -53
  468. data/lib/gtk_paradise/widgets/shared_code/directory_content_widget/directory_content_widget_module.rb +0 -777
  469. data/lib/gtk_paradise/widgets/shared_code/directory_content_widget/handle_this_file_or_symlink.rb +0 -83
  470. data/lib/gtk_paradise/widgets/shared_code/notebook_controller/notebook_controller_module.rb +0 -339
  471. data/lib/gtk_paradise/widgets/shared_code/notebook_tab_with_icon/notebook_tab_with_icon_module.rb +0 -297
  472. data/lib/gtk_paradise/widgets/shared_code/ping_widget/ping_widget_module.rb +0 -326
  473. data/lib/gtk_paradise/widgets/version_agnostic/button_with_border.rb +0 -63
  474. data/lib/gtk_paradise/widgets/version_agnostic/coloured_unit.rb +0 -54
  475. data/lib/gtk_paradise/widgets/version_agnostic/my_image_menu_item.rb +0 -103
  476. data/lib/gtk_paradise/widgets/version_agnostic/my_menu_item_separator.rb +0 -31
  477. data/lib/gtk_paradise/widgets/version_agnostic/non_numbers_only.rb +0 -66
  478. data/lib/gtk_paradise/widgets/version_agnostic/note_window.rb +0 -107
  479. /data/lib/gtk_paradise/examples/gtk3/{084_undecorated_window_example.rb → 014_undecorated_window_example.rb} +0 -0
  480. /data/lib/gtk_paradise/examples/gtk3/{077_status_icon_example.rb → 019_status_icon_example.rb} +0 -0
  481. /data/lib/gtk_paradise/examples/gtk3/{076_stack_example.rb → 020_stack_example.rb} +0 -0
  482. /data/lib/gtk_paradise/examples/gtk3/{006_password_example.rb → 025_password_example.rb} +0 -0
  483. /data/lib/gtk_paradise/examples/gtk3/{015_list_box_example.rb → 033_list_box_example.rb} +0 -0
  484. /data/lib/gtk_paradise/examples/gtk3/{020_radio_button_window.rb → 038_radio_button_window.rb} +0 -0
  485. /data/lib/gtk_paradise/examples/gtk3/{021_scale_button_demo.rb → 039_scale_button_demo.rb} +0 -0
  486. /data/lib/gtk_paradise/examples/gtk3/{024_installation_assistant.rb → 042_installation_assistant.rb} +0 -0
  487. /data/lib/gtk_paradise/examples/gtk3/{035_notebook_css_example.rb → 052_notebook_css_example.rb} +0 -0
  488. /data/lib/gtk_paradise/examples/gtk3/{040_font_chooser_dialog_example.rb → 056_font_chooser_dialog_example.rb} +0 -0
  489. /data/lib/gtk_paradise/examples/gtk3/{041_flowbox.rb → 057_flowbox.rb} +0 -0
  490. /data/lib/gtk_paradise/examples/gtk3/{045_fixed_example.rb → 061_fixed_example.rb} +0 -0
  491. /data/lib/gtk_paradise/examples/gtk3/{054_svg_viewer.rb → 070_svg_viewer.rb} +0 -0
  492. /data/lib/gtk_paradise/examples/gtk3/{065_tooltips_example.rb → 079_tooltips_example.rb} +0 -0
@@ -1,2949 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # === Gtk::BaseModule
6
- # =========================================================================== #
7
- # require 'gtk_paradise/base_module/misc.rb'
8
- # include ::Gtk::BaseModule
9
- # =========================================================================== #
10
- module Gtk
11
-
12
- module BaseModule
13
-
14
- require 'gtk_paradise/base_module/configuration.rb'
15
- require 'gtk_paradise/base_module/commandline_arguments.rb'
16
- require 'gtk_paradise/base_module/draggable.rb'
17
- require 'gtk_paradise/base_module/graphics_display.rb'
18
- require 'gtk_paradise/base_module/gtk_grid.rb'
19
- require 'gtk_paradise/base_module/gtk_notebook.rb'
20
- require 'gtk_paradise/base_module/popover.rb'
21
- require 'gtk_paradise/base_module/roebe.rb'
22
- require 'gtk_paradise/base_module/time.rb'
23
-
24
- # ========================================================================= #
25
- # Next, require .rb files that belong to gtk_paradise/gtk_classes/:
26
- # ========================================================================= #
27
- require 'gtk_paradise/gtk_classes/about_dialog.rb'
28
- require 'gtk_paradise/gtk_classes/accel_group.rb'
29
- require 'gtk_paradise/gtk_classes/button.rb'
30
- require 'gtk_paradise/gtk_classes/cairo/context.rb'
31
- require 'gtk_paradise/gtk_classes/calendar.rb'
32
- require 'gtk_paradise/gtk_classes/check_button.rb'
33
- require 'gtk_paradise/gtk_classes/cell_renderer_text.rb'
34
- require 'gtk_paradise/gtk_classes/combo_box_text.rb'
35
- require 'gtk_paradise/gtk_classes/entry.rb'
36
- require 'gtk_paradise/gtk_classes/entry_completion.rb'
37
- require 'gtk_paradise/gtk_classes/event_box.rb'
38
- require 'gtk_paradise/gtk_classes/event_button.rb'
39
- require 'gtk_paradise/gtk_classes/file_filter.rb'
40
- require 'gtk_paradise/gtk_classes/file_selection.rb'
41
- require 'gtk_paradise/gtk_classes/header_bar.rb'
42
- require 'gtk_paradise/gtk_classes/image.rb'
43
- require 'gtk_paradise/gtk_classes/list_store.rb'
44
- require 'gtk_paradise/gtk_classes/menu.rb'
45
- require 'gtk_paradise/gtk_classes/menu_bar.rb'
46
- require 'gtk_paradise/gtk_classes/menu_item.rb'
47
- require 'gtk_paradise/gtk_classes/popover.rb'
48
- require 'gtk_paradise/gtk_classes/text_buffer.rb'
49
- require 'gtk_paradise/gtk_classes/toggle_button.rb'
50
- require 'gtk_paradise/gtk_classes/toolbar.rb'
51
- require 'gtk_paradise/gtk_classes/tree_view.rb'
52
- require 'gtk_paradise/gtk_classes/tree_view_column.rb'
53
- require 'gtk_paradise/gtk_classes/widget.rb'
54
-
55
- # ========================================================================= #
56
- # Next, toplevel_methods/ files.
57
- # ========================================================================= #
58
- require 'gtk_paradise/toplevel_methods/main_file.rb'
59
- require 'gtk_paradise/toplevel_methods/misc.rb'
60
- require 'gtk_paradise/toplevel_methods/text_buffer_tags.rb'
61
-
62
- # ========================================================================= #
63
- # === is_not_decorated
64
- # ========================================================================= #
65
- def is_not_decorated
66
- set_decorated(false)
67
- end
68
-
69
- # ========================================================================= #
70
- # === scroll_up?
71
- # ========================================================================= #
72
- def scroll_up?(event)
73
- ::Gtk.scroll_up_event?(event)
74
- end
75
-
76
- # ========================================================================= #
77
- # === scroll_down?
78
- # ========================================================================= #
79
- def scroll_down?(event)
80
- ::Gtk.scroll_down_event?(event)
81
- end
82
-
83
- # ========================================================================= #
84
- # === gtk_list_store
85
- #
86
- # This method can be invoked like this:
87
- #
88
- # gtk_list_store(String, Float)
89
- #
90
- # ========================================================================= #
91
- def gtk_list_store(*i)
92
- ::Gtk::ListStore.new(*i)
93
- end; alias gtk_liststore gtk_list_store # === gtk_liststore
94
- alias liststore gtk_list_store # === liststore
95
-
96
- # ========================================================================= #
97
- # === populate_this_list_store3
98
- #
99
- # This variant works with 3 entries.
100
- # ========================================================================= #
101
- def populate_this_list_store3(
102
- this_list_store, this_dataset
103
- )
104
- this_dataset.each { |first, second, third|
105
- iter = this_list_store.append
106
- iter.set_value(0, first.to_s)
107
- iter.set_value(1, second.to_s)
108
- iter.set_value(2, third.to_s)
109
- }
110
- end; alias populate_this_list_store_with_that_array3 populate_this_list_store3 # === populate_this_list_store_with_that_array3
111
-
112
- # ========================================================================= #
113
- # === gtk_vseparator
114
- # ========================================================================= #
115
- def gtk_vseparator
116
- if use_gtk2?
117
- ::Gtk::VSeparator.new
118
- else
119
- ::Gtk::Separator.new(:vertical)
120
- end
121
- end; alias top_to_bottom_separator gtk_vseparator # === top_to_bottom_separator
122
- alias gtk_vertical_separator gtk_vseparator # === gtk_vertical_separator
123
-
124
- # ========================================================================= #
125
- # === replace_with_proper_tags
126
- # ========================================================================= #
127
- def replace_with_proper_tags(i)
128
- text = ::Gtk.replace_with_proper_tags(i)
129
- _ = gtk_text(text)
130
- _.do_markify
131
- return _
132
- end; alias replace_colours_with_html_colours replace_with_proper_tags # === replace_colours_with_html_colours
133
- alias replace_html_colours replace_with_proper_tags # === replace_html_colours
134
-
135
- # ========================================================================= #
136
- # === gtk_themed_icon
137
- # ========================================================================= #
138
- def gtk_themed_icon(
139
- use_this_icon = 'mail-send-receive-symbolic'
140
- )
141
- button = gtk_button
142
- # ======================================================================= #
143
- # === Handle symbols next
144
- # ======================================================================= #
145
- if use_this_icon.is_a? Symbol
146
- # ===================================================================== #
147
- # We handle Symbols a bit differently here. If it is a Symbol and if
148
- # that Symbol includes a '_' character then it is assumed that the
149
- # user instead wants to use '-'. Thus, we convert the Symbols to
150
- # the correct variant in this case.
151
- #
152
- # So, for instance, from :open_file to :open-file.
153
- # ===================================================================== #
154
- if use_this_icon.to_s.include? '_'
155
- use_this_icon = use_this_icon.to_s.tr('_','-').to_sym
156
- end
157
- end
158
- icon = Gio::ThemedIcon.new(use_this_icon)
159
- image = ::Gtk::Image.new(icon: icon, size: :button)
160
- button.set_image(image)
161
- return button
162
- end; alias themed_icon gtk_themed_icon # === themed_icon
163
- alias icon_theme_image gtk_themed_icon # === icon_theme_image
164
- alias icon_theme gtk_themed_icon # === icon_theme
165
-
166
- # ========================================================================= #
167
- # === horizontal_spacer
168
- # ========================================================================= #
169
- def horizontal_spacer
170
- ::Gtk.horizontal_spacer
171
- end; alias hspacer horizontal_spacer # === hspacer
172
- alias gtk_hspacer horizontal_spacer # === gtk_hspacer
173
- alias gtk_horizontal_spacer horizontal_spacer # === gtk_horizontal_spacer
174
-
175
- # ========================================================================= #
176
- # === add_horizontal_spacer
177
- # ========================================================================= #
178
- def add_horizontal_spacer
179
- add(gtk_horizontal_spacer)
180
- end
181
-
182
- # ========================================================================= #
183
- # === gtk_spinner
184
- # ========================================================================= #
185
- def gtk_spinner
186
- return ::Gtk::Spinner.new
187
- end; alias default_spinner gtk_spinner # === default_spinner
188
-
189
- # ========================================================================= #
190
- # === return_inactive_spinner
191
- # ========================================================================= #
192
- def return_inactive_spinner
193
- spinner = default_spinner
194
- spinner.set_active(false)
195
- return spinner
196
- end; alias inactive_spinner return_inactive_spinner # === inactive_spinner
197
-
198
- # ========================================================================= #
199
- # === return_active_spinner
200
- # ========================================================================= #
201
- def return_active_spinner
202
- spinner = default_spinner
203
- spinner.set_active(true)
204
- return spinner
205
- end; alias active_spinner return_active_spinner # === active_spinner
206
-
207
- # ========================================================================= #
208
- # === gtk_message_dialog
209
- #
210
- # This method will create a new instance of Gtk::MessageDialog,
211
- # without much further ado.
212
- # ========================================================================= #
213
- def gtk_message_dialog(
214
- show_this_text = '',
215
- parent_widget = :new_window
216
- )
217
- case parent_widget
218
- # ======================================================================= #
219
- # === :new_window
220
- # ======================================================================= #
221
- when :new_window,
222
- :window
223
- parent_widget = ::Gtk::Window.new
224
- end
225
- # ======================================================================= #
226
- # Instantiate a new message-dialog next.
227
- # ======================================================================= #
228
- if use_gtk2?
229
- message_dialog = ::Gtk::MessageDialog.new(
230
- parent_widget,
231
- Gtk::Dialog::MODAL,
232
- Gtk::MessageDialog::ERROR,
233
- Gtk::MessageDialog::BUTTONS_CLOSE,
234
- show_this_text
235
- )
236
- else # This is for ruby-gtk3, but it currently does not work properly.
237
- message_dialog = ::Gtk::MessageDialog.new(
238
- parent_widget,
239
- Gtk::Dialog::MODAL,
240
- Gtk::MessageDialog::ERROR,
241
- Gtk::MessageDialog::BUTTONS_CLOSE,
242
- show_this_text
243
- )
244
- end
245
- # ======================================================================= #
246
- # Then invoke:
247
- #
248
- # message_dialog.run
249
- # message_dialog.destroy
250
- #
251
- # ======================================================================= #
252
- return message_dialog
253
- end; alias gtk_message gtk_message_dialog # === gtk_message
254
- alias message_box gtk_message_dialog # === message_box
255
- alias message_dialog gtk_message_dialog # === message_dialog
256
-
257
- # ========================================================================= #
258
- # === destroy_then_quit
259
- # ========================================================================= #
260
- def destroy_then_quit
261
- signal_connect(:destroy) { ::Gtk.main_quit }
262
- end; alias signal_destroy_then_quit destroy_then_quit # === signal_destroy_then_quit
263
- alias exit_on_destroy_signal destroy_then_quit # === exit_on_destroy_signal
264
- alias exit_on_delete_event destroy_then_quit # === exit_on_delete_event
265
-
266
- # ========================================================================= #
267
- # === upon_delete_event_quit_the_application
268
- #
269
- # This method can be used to "cleanly" exit a Gtk-application again.
270
- # ========================================================================= #
271
- def upon_delete_event_quit_the_application
272
- signal_connect(:delete_event) { ::Gtk.main_quit }
273
- end; alias on_delete_event_quit_the_application upon_delete_event_quit_the_application # === on_delete_event_quit_the_application
274
- alias destroy_on_exit upon_delete_event_quit_the_application # === destroy_on_exit
275
-
276
- # ========================================================================= #
277
- # === exit_program
278
- # ========================================================================= #
279
- def exit_program
280
- ::Gtk.main_quit
281
- end; alias do_quit exit_program # === do_quit
282
- alias do_exit exit_program # === do_exit
283
- alias exit_the_application exit_program # === exit_the_application
284
- alias exit_application exit_program # === exit_application
285
-
286
- # ========================================================================= #
287
- # === is_mouse_button_release_event?
288
- # ========================================================================= #
289
- def is_mouse_button_release_event?(event)
290
- event.respond_to?(:name?) and
291
- event.name? == 'GDK_BUTTON_RELEASE'
292
- end
293
-
294
- # ========================================================================= #
295
- # === set_width
296
- # ========================================================================= #
297
- def set_width(i)
298
- if i.is_a?(String) and i.include?('%')
299
- # ===================================================================== #
300
- # Handle something like '80%'. Since as of October 2021 this also
301
- # has to handle input such as '30% or minimum 300px'.
302
- # ===================================================================== #
303
- if i.include? ' '
304
- if i.include? 'minimum'
305
- splitted = i.split(' ')
306
- minimum_value = splitted.last.to_s.delete('px').to_f
307
- assumed_new_value = splitted.first.delete('%').to_f
308
- assumed_new_value = (max_width? * assumed_new_value) / 100.0
309
- i = assumed_new_value
310
- if minimum_value > assumed_new_value
311
- i = minimum_value
312
- end
313
- end
314
- else # this handles '50%'
315
- i = (max_width? * i.delete('%').to_f) / 100.0
316
- end
317
- end
318
- @width = i.to_i
319
- end
320
-
321
- # ========================================================================= #
322
- # === gtk_image_menu_item
323
- # ========================================================================= #
324
- def gtk_image_menu_item(
325
- use_this_image = ::Gtk::Stock::QUIT
326
- )
327
- if ::Gtk.use_gtk2?
328
- ::Gtk::ImageMenuItem.new(use_this_image)
329
- else
330
- ::Gtk::ImageMenuItem.new(stock_id: use_this_image)
331
- end
332
- end; alias image_menu_item gtk_image_menu_item # === image_menu_item
333
-
334
- require 'gtk_paradise/gtk_classes/status_icon.rb'
335
- # ========================================================================= #
336
- # === gtk_status_icon
337
- #
338
- # The first argument may be a path to an image.
339
- # ========================================================================= #
340
- def gtk_status_icon(
341
- optional_file_path = nil
342
- )
343
- # ======================================================================= #
344
- # Instantiate a new status-icon next:
345
- # ======================================================================= #
346
- status_icon = ::Gtk::StatusIcon.new
347
- if optional_file_path
348
- if optional_file_path.is_a? Symbol
349
- status_icon.stock = ::Gtk::Stock.const_get(
350
- optional_file_path.to_s.upcase.to_sym
351
- )
352
- else
353
- if use_gtk2?
354
- status_icon.use_this_image = optional_file_path
355
- else
356
- e 'status_icon.use_this_image = has not yet been adapted.'
357
- end
358
- end
359
- end
360
- return status_icon
361
- end; alias status_icon gtk_status_icon # === status_icon
362
- alias return_status_icon gtk_status_icon # === return_status_icon
363
-
364
- # ========================================================================= #
365
- # === gtk_header_bar
366
- #
367
- # Invocation example:
368
- #
369
- # header_bar = gtk_header_bar { :with_close_button }
370
- #
371
- # ========================================================================= #
372
- def gtk_header_bar(&block)
373
- _ = ::Gtk::HeaderBar.new
374
- # ======================================================================= #
375
- # === Handle blocks next
376
- # ======================================================================= #
377
- if block_given?
378
- yielded = yield
379
- case yielded
380
- # ===================================================================== #
381
- # === :with_close_button
382
- # ===================================================================== #
383
- when :with_close_button,
384
- :close_button
385
- _.set_show_close_button(true) # Show the close-button too.
386
- # ===================================================================== #
387
- # === :with_close_button_and_inferred_title
388
- # ===================================================================== #
389
- when :with_close_button_and_inferred_title
390
- _.set_show_close_button(true) # Show the close-button too.
391
- _.set_title(title?)
392
- end
393
- end
394
- return _
395
- end; alias header_bar gtk_header_bar # === header_bar
396
-
397
- # ========================================================================= #
398
- # === return_top_bar
399
- #
400
- # This method can be customized via blocks such as:
401
- #
402
- # return_default_header_bar { :with_close_button_and_inferred_title }
403
- #
404
- # ========================================================================= #
405
- def return_top_bar(&block)
406
- if block_given?
407
- header_bar = gtk_header_bar(&block)
408
- else
409
- header_bar = gtk_header_bar { :with_close_button }
410
- end
411
- header_bar.spacing = 2
412
- return header_bar
413
- end; alias top_bar return_top_bar # === top_bar
414
- alias default_header_bar return_top_bar # === default_header_bar
415
- alias default_top_bar return_top_bar # === default_top_bar
416
- alias gtk_top_bar return_top_bar # === gtk_top_bar
417
- alias return_default_header_bar return_top_bar # === return_default_header_bar
418
-
419
- # ========================================================================= #
420
- # === drag_start
421
- #
422
- # The source-widget must connect to the 'drag-data-get' signal.
423
- # ========================================================================= #
424
- def drag_start
425
- drag_source_set(Gdk::ModifierType::BUTTON1_MASK |
426
- Gdk::ModifierType::BUTTON2_MASK,
427
- [['test', Gtk::TargetFlags::SAME_APP, 12345]],
428
- Gdk::DragAction::COPY |
429
- Gdk::DragAction::MOVE)
430
- end
431
-
432
- # ========================================================================= #
433
- # === drag_stop
434
- #
435
- # The destination-widget must connect to the 'drag-data-received' signal.
436
- # ========================================================================= #
437
- def drag_stop
438
- drag_dest_set(Gtk::DestDefaults::MOTION |
439
- Gtk::DestDefaults::HIGHLIGHT,
440
- [['test', :same_app, 12345]],
441
- Gdk::DragAction::COPY |
442
- Gdk::DragAction::MOVE)
443
- end
444
-
445
- # ========================================================================= #
446
- # === gtk_input_field
447
- #
448
- # This is essentially a wrapper over Gtk::Entry.
449
- # ========================================================================= #
450
- def gtk_input_field(&block)
451
- ::Gtk.input_field(&block)
452
- end; alias input_field gtk_input_field # === input_field
453
-
454
- require 'gtk_paradise/gtk_classes/text_view.rb'
455
- # ========================================================================= #
456
- # === gtk_text_view
457
- #
458
- # Instantiate a new TreeView widget, by delegating towards Gtk.textview().
459
- #
460
- # Since as of November 2020 the first entry is the text-buffer that
461
- # is to be used.
462
- # ========================================================================= #
463
- def gtk_text_view(
464
- use_this_text_buffer = ::Gtk::TextBuffer.new,
465
- left_margin = 2,
466
- right_margin = 2,
467
- is_editable = true
468
- )
469
- ::Gtk.textview(
470
- use_this_text_buffer,
471
- left_margin,
472
- right_margin,
473
- is_editable
474
- )
475
- end; alias gtk_textview gtk_text_view # === gtk_textview
476
- alias gtk_textbox gtk_text_view # === gtk_textbox
477
- alias gtk_textarea gtk_text_view # === gtk_textarea
478
- alias gtk_text_area gtk_text_view # === gtk_text_area
479
- alias gtk_text_viewer gtk_text_view # === gtk_text_viewer
480
- alias textview gtk_text_view # === textview
481
- alias text_view gtk_text_view # === text_view
482
-
483
- require 'gtk_paradise/gtk_classes/expander.rb'
484
- # ========================================================================= #
485
- # === gtk_expander
486
- #
487
- # The first argument is the text on the label that is to be used.
488
- # ========================================================================= #
489
- def gtk_expander(
490
- text_on_the_label,
491
- use_markup = false,
492
- &block
493
- )
494
- if ::Gtk.use_gtk2?
495
- expander = ::Gtk::Expander.new(text_on_the_label, use_markup)
496
- else
497
- expander = ::Gtk::Expander.new(text_on_the_label)
498
- end
499
- # ======================================================================= #
500
- # === Handle blocks next
501
- # ======================================================================= #
502
- if block_given?
503
- yielded = yield
504
- # ===================================================================== #
505
- # === :widget
506
- # ===================================================================== #
507
- if yielded.has_key? :widget
508
- expander.add(yielded.delete(:widget))
509
- end
510
- end
511
- return expander
512
- end
513
-
514
- # ========================================================================= #
515
- # === gtk_size_group
516
- # ========================================================================= #
517
- def gtk_size_group(i = :horizontal)
518
- orientation_to_use = :horizontal
519
- orientation_to_use = ::Gtk::SizeGroup::HORIZONTAL if use_gtk2?
520
- case i
521
- when :horizontal
522
- return ::Gtk::SizeGroup.new(orientation_to_use)
523
- end
524
- end
525
-
526
- require 'gtk_paradise/gtk_classes/search_bar.rb'
527
- # ========================================================================= #
528
- # === gtk_search_bar
529
- #
530
- # The first argument, which is optional, should be of class
531
- # Gtk::SearchEntry if provided.
532
- #
533
- # Upstream API documentation can be seen here:
534
- #
535
- # https://developer.gnome.org/gtk3/stable/GtkSearchBar.html
536
- #
537
- # ========================================================================= #
538
- def gtk_search_bar(
539
- optional_widget = nil
540
- )
541
- search_bar = ::Gtk::SearchBar.new
542
- if optional_widget
543
- search_bar.connect_entry(optional_widget)
544
- search_bar.add(optional_widget)
545
- end
546
- return search_bar
547
- end
548
-
549
- # ========================================================================= #
550
- # === remove_html
551
- # ========================================================================= #
552
- def remove_html(i)
553
- return i.gsub(/\<.+?\>/,'')
554
- end
555
-
556
- # ========================================================================= #
557
- # === word_wrap
558
- #
559
- # long_string.word_wrap(75)
560
- # ========================================================================= #
561
- def word_wrap(
562
- string,
563
- line_width = 80,
564
- optional_padding = ''
565
- )
566
- new_text = string.dup.gsub(
567
- /(.{1,#{line_width}})(\s+|$)/, optional_padding+"\\1\n"
568
- )
569
- return new_text
570
- end
571
-
572
- # ========================================================================= #
573
- # === drop_down_find_box
574
- #
575
- # This method will return an Array of the two widgets that may be
576
- # useful, if the user wants to create a search-bar.
577
- # ========================================================================= #
578
- def drop_down_find_box
579
- search_entry = gtk_search_entry
580
- search_bar = gtk_search_bar(search_entry)
581
- return [search_bar, search_entry]
582
- end
583
-
584
- # ========================================================================= #
585
- # === gtk_search_entry
586
- # ========================================================================= #
587
- def gtk_search_entry
588
- ::Gtk::SearchEntry.new
589
- end; alias search_entry gtk_search_entry # === search_entry
590
-
591
- # ========================================================================= #
592
- # === modify_foreground
593
- # ========================================================================= #
594
- def modify_foreground(
595
- colour = :steelblue,
596
- state = ::Gtk::StateType::NORMAL
597
- )
598
- colour = ::Gtk.colour_parse(colour)
599
- modify_fg(
600
- state, colour # Flip it here.
601
- )
602
- end
603
-
604
- # ========================================================================= #
605
- # === gtk_dialog
606
- # ========================================================================= #
607
- def gtk_dialog
608
- ::Gtk::Dialog.new
609
- end
610
-
611
- # ========================================================================= #
612
- # === gtk_toolbar
613
- # ========================================================================= #
614
- def gtk_toolbar
615
- ::Gtk::Toolbar.new
616
- end
617
-
618
- # ========================================================================= #
619
- # === gtk_state_normal
620
- # ========================================================================= #
621
- def gtk_state_normal
622
- ::Gtk::StateType::NORMAL
623
- end
624
-
625
- # ========================================================================= #
626
- # === gtk_colour_black
627
- # ========================================================================= #
628
- def gtk_colour_black
629
- ::Gtk::Colours::BLACK
630
- end
631
-
632
- # ========================================================================= #
633
- # === project_base_directory?
634
- # ========================================================================= #
635
- def project_base_directory?
636
- ::Gtk.project_base_directory?
637
- end
638
-
639
- # ========================================================================= #
640
- # === gtk_text
641
- # ========================================================================= #
642
- def gtk_text(i = '')
643
- ::Gtk.text(i)
644
- end
645
-
646
- require 'gtk_paradise/gtk_classes/box.rb'
647
- # ========================================================================= #
648
- # === gtk_eventbox
649
- #
650
- # Wrapper to creating a new Gtk::EventBox instance.
651
- # ========================================================================= #
652
- def gtk_eventbox(i = nil)
653
- ::Gtk.eventbox(i)
654
- end; alias gtk_event_box gtk_eventbox # === gtk_event_box
655
- alias event_box gtk_eventbox # === event_box
656
-
657
- # ========================================================================= #
658
- # === gtk_vruler
659
- # ========================================================================= #
660
- def gtk_vruler
661
- ::Gtk::VRuler.new
662
- end
663
-
664
- # ========================================================================= #
665
- # === gtk_drawing_area
666
- # ========================================================================= #
667
- def gtk_drawing_area
668
- ::Gtk::DrawingArea.new
669
- end
670
-
671
- # ========================================================================= #
672
- # === create_entry_with_text_and_max_length
673
- # ========================================================================= #
674
- def create_entry_with_text_and_max_length(i = '')
675
- ::Gtk.create_entry_with_text_and_max_length(i)
676
- end
677
-
678
- # ========================================================================= #
679
- # === gtk_adjustment
680
- # ========================================================================= #
681
- def gtk_adjustment(*i)
682
- ::Gtk::Adjustment.new(*i)
683
- end
684
-
685
- # ========================================================================= #
686
- # === standard_file_chooser_dialog
687
- # ========================================================================= #
688
- def standard_file_chooser_dialog(title, widget)
689
- ::Gtk.send(__method__, title, widget)
690
- end
691
-
692
- # ========================================================================= #
693
- # === gtk_message_dialog_run_then_destroy
694
- # ========================================================================= #
695
- def gtk_message_dialog_run_then_destroy(
696
- content_to_show = 'This functionality is not yet enabled.'
697
- )
698
- _ = gtk_message_dialog(content_to_show)
699
- _.run
700
- _.destroy
701
- return _
702
- end
703
-
704
- # ========================================================================= #
705
- # === create_paned_hbox_first_big
706
- # ========================================================================= #
707
- def create_paned_hbox_first_big(*i)
708
- ::Gtk.create_paned_hbox_first_big(i)
709
- end
710
-
711
- # ========================================================================= #
712
- # === directory_to_the_images?
713
- #
714
- # This method will return the directory to the images.
715
- # ========================================================================= #
716
- def directory_to_the_images?
717
- IMG_DIR
718
- end
719
-
720
- # ========================================================================= #
721
- # === gtk_tooltip_set_tip
722
- # ========================================================================= #
723
- def gtk_tooltip_set_tip(
724
- widget,
725
- text = ''
726
- )
727
- ::Gtk::Tooltips.new.set_tip(widget, text, nil)
728
- end
729
-
730
- # ========================================================================= #
731
- # === gtk_expanded_expander
732
- #
733
- # This variant will expand the newly created gtk-expander at hand.
734
- # ========================================================================= #
735
- def gtk_expanded_expander(text = '', &block)
736
- expander = gtk_expander(text, &block) # Create a new Gtk::Expander instance here.
737
- expander.do_expand
738
- return expander
739
- end
740
-
741
- # ========================================================================= #
742
- # === gtk_password
743
- #
744
- # This variant can be used like a "password-protected input device".
745
- # ========================================================================= #
746
- def gtk_password(
747
- use_this_as_invisibility_char = 42
748
- )
749
- password = gtk_entry
750
- password.set_visibility(false)
751
- password.invisible_char = use_this_as_invisibility_char # This is '*' in unicode.
752
- return password
753
- end
754
-
755
- # ========================================================================= #
756
- # === white_background
757
- # ========================================================================= #
758
- def white_background
759
- modify_background(:normal, :white)
760
- end
761
-
762
- # ========================================================================= #
763
- # === gtk_button_xorg_buffer
764
- #
765
- # This will return a new instance of the xorg-buffer button.
766
- # ========================================================================= #
767
- def gtk_button_xorg_buffer(
768
- optional_use_this_as_label = nil
769
- )
770
- require 'gtk_paradise/widgets/version_agnostic/button_xorg_buffer.rb'
771
- return ::Gtk::ButtonXorgBuffer.new(optional_use_this_as_label)
772
- end; alias button_xorg_buffer gtk_button_xorg_buffer # === button_xorg_buffer
773
-
774
- # ========================================================================= #
775
- # === use_gtk2?
776
- # ========================================================================= #
777
- def use_gtk2?
778
- ::Gtk.use_gtk2?
779
- end
780
-
781
- # ========================================================================= #
782
- # === gtk_file_filter
783
- #
784
- # A filter may be provided, such as:
785
- #
786
- # '.pdf'
787
- #
788
- # As input.
789
- # ========================================================================= #
790
- def gtk_file_filter(
791
- optional_file_filter_to_use = nil
792
- )
793
- _ = ::Gtk::FileFilter.new
794
- if optional_file_filter_to_use
795
- if optional_file_filter_to_use.is_a? Symbol
796
- # Such as: :pdf_files
797
- optional_file_filter_to_use = optional_file_filter_to_use.to_s
798
- end
799
- if optional_file_filter_to_use.include? '_'
800
- optional_file_filter_to_use = optional_file_filter_to_use.split('_').first
801
- end
802
- _.name = "#{optional_file_filter_to_use} files"
803
- _.add_pattern("*#{optional_file_filter_to_use}")
804
- end
805
- return _
806
- end
807
-
808
- # ========================================================================= #
809
- # === create_clipboard
810
- # ========================================================================= #
811
- def create_clipboard
812
- ::Gtk.create_clipboard
813
- end
814
-
815
- # ========================================================================= #
816
- # === clipboard_text?
817
- # ========================================================================= #
818
- def clipboard_text?
819
- ::Gtk.clipboard_text?
820
- end
821
-
822
- require 'gtk_paradise/toplevel_methods/tooltips.rb'
823
- # ========================================================================= #
824
- # === gtk_tooltip_widget
825
- # ========================================================================= #
826
- def gtk_tooltip_widget(
827
- tooltip, widget
828
- )
829
- ::Gtk.tooltip_widget(
830
- tooltip, widget
831
- )
832
- end; alias gtk_tooltip gtk_tooltip_widget # === gtk_tooltip
833
-
834
- # ========================================================================= #
835
- # === gtk_colour_grey
836
- # ========================================================================= #
837
- def gtk_colour_grey
838
- ::Gtk::Colours::GREY
839
- end
840
-
841
- # ========================================================================= #
842
- # === gtk_window
843
- # ========================================================================= #
844
- def gtk_window(
845
- optional_title = nil
846
- )
847
- if optional_title
848
- Gtk::Window.new(optional_title)
849
- else
850
- Gtk::Window.new
851
- end
852
- end
853
-
854
- # ========================================================================= #
855
- # === gtk_vbutton_box
856
- #
857
- # This variant is specifically for ruby-gtk2.
858
- # ========================================================================= #
859
- def gtk_vbutton_box(*optional_arguments)
860
- box = ::Gtk::VButtonBox.new
861
- if optional_arguments and !optional_arguments.empty?
862
- optional_arguments.each {|entry| box.pack_start(entry, true, true) }
863
- end
864
- return box
865
- end
866
-
867
- # ========================================================================= #
868
- # === gtk_hbutton_box
869
- #
870
- # This variant is specifically for ruby-gtk2.
871
- # ========================================================================= #
872
- def gtk_hbutton_box(*optional_arguments)
873
- box = ::Gtk::HButtonBox.new
874
- if optional_arguments and !optional_arguments.empty?
875
- optional_arguments.each {|entry| box.pack_start(entry, true, true) }
876
- end
877
- return box
878
- end
879
-
880
- require 'gtk_paradise/gtk_classes/frame.rb'
881
- # ========================================================================= #
882
- # === gtk_frame
883
- #
884
- # This must be able to support a String, which is then used as the
885
- # label, and a widget, in which case it will be embedded.
886
- #
887
- # Alternative usage example:
888
- #
889
- # gtk_frame(small_scrolled_window) {{ title: 'Last exam question' }}
890
- #
891
- # ========================================================================= #
892
- def gtk_frame(
893
- optional_title = ''
894
- )
895
- if optional_title.to_s.start_with?('#<Gtk::') and
896
- !optional_title.is_a?(String)
897
- frame = ::Gtk::Frame.new
898
- frame.add(optional_title)
899
- else
900
- frame = ::Gtk::Frame.new(optional_title)
901
- end
902
- # ======================================================================= #
903
- # === Handle blocks given next
904
- # ======================================================================= #
905
- if block_given?
906
- yielded = yield
907
- if yielded.is_a? Hash
908
- # =================================================================== #
909
- # === :title
910
- # =================================================================== #
911
- if yielded.has_key? :title
912
- frame.set_text(yielded.delete(:title))
913
- end
914
- end
915
- end
916
- return frame
917
- end
918
-
919
- # ========================================================================= #
920
- # === gtk_bold_frame
921
- # ========================================================================= #
922
- def gtk_bold_frame(i)
923
- frame = gtk_frame(i)
924
- frame.make_bold
925
- return frame
926
- end
927
-
928
- # ========================================================================= #
929
- # === gdk_screen
930
- # ========================================================================= #
931
- def gdk_screen
932
- Gdk::Screen.default
933
- end
934
-
935
- # ========================================================================= #
936
- # === gdk_selection_clipboard
937
- # ========================================================================= #
938
- def gdk_selection_clipboard
939
- ::Gdk::Selection::CLIPBOARD
940
- end
941
-
942
- # ========================================================================= #
943
- # === to_utf
944
- # ========================================================================= #
945
- def to_utf(i = '')
946
- ::Gtk.to_utf8(i)
947
- end
948
-
949
- # ========================================================================= #
950
- # === gtk_alignment
951
- #
952
- # The first argument is the uniform-padding value that is to be used.
953
- #
954
- # If more than one argument is given, the method will assign
955
- # the corresponding alignment.
956
- # ========================================================================= #
957
- def gtk_alignment(
958
- a = 0.98,
959
- b = nil,
960
- c = nil,
961
- d = nil
962
- )
963
- # ======================================================================= #
964
- # The next three lines are to default to "uniform padding values".
965
- # ======================================================================= #
966
- case a
967
- # ======================================================================= #
968
- # === :center
969
- #
970
- # This is simply an alias really, to allow something like:
971
- #
972
- # gtk_alignment(:center)
973
- #
974
- # ======================================================================= #
975
- when :center
976
- a = 0.5; b = 0.5; c = 0; d = 0
977
- end
978
- b = a if b.nil?
979
- c = a if c.nil?
980
- d = a if d.nil?
981
- ::Gtk::Alignment.new(a, b, c, d)
982
- end
983
-
984
- # ========================================================================= #
985
- # === allow_only_numbers
986
- # ========================================================================= #
987
- def allow_only_numbers(
988
- gtk_entry_widget,
989
- be_not_too_strict = true
990
- )
991
- ::Gtk.allow_only_numbers(
992
- gtk_entry_widget,
993
- be_not_too_strict
994
- )
995
- end
996
-
997
- # ========================================================================= #
998
- # === create_paned_vbox
999
- # ========================================================================= #
1000
- def create_paned_vbox(*i)
1001
- ::Gtk.create_paned_vbox(i)
1002
- end
1003
-
1004
- # ========================================================================= #
1005
- # === paned_hbox
1006
- # ========================================================================= #
1007
- def paned_hbox(*i)
1008
- ::Gtk.create_paned_hbox(i)
1009
- end; alias create_paned_hbox paned_hbox # === create_paned_hbox
1010
-
1011
- # ========================================================================= #
1012
- # === paned_vbox
1013
- # ========================================================================= #
1014
- def paned_vbox(*i)
1015
- ::Gtk.create_paned_vbox(i)
1016
- end
1017
-
1018
- # ========================================================================= #
1019
- # === unicode_horizontal_spacer
1020
- # ========================================================================= #
1021
- def unicode_horizontal_spacer
1022
- ::Gtk.unicode_horizontal_spacer
1023
- end; alias horizontal_unicode_bar unicode_horizontal_spacer # === horizontal_unicode_bar
1024
-
1025
- # ========================================================================= #
1026
- # === gtk_resize_grip
1027
- #
1028
- # This method needs two widgets as input. It will then instantiate a
1029
- # new Gtk::VPaned instance.
1030
- #
1031
- # Typical usage example:
1032
- #
1033
- # widget = gtk_resize_grip(@tree_view, @text_view_at_bottom)
1034
- # pack_start(widget, true, true, 4)
1035
- #
1036
- # ========================================================================= #
1037
- def gtk_resize_grip(widget1, widget2)
1038
- # ======================================================================= #
1039
- # Since Gtk::VPaned has been deprecated in ruby-gtk3, we have to query
1040
- # the version of gtk in use next.
1041
- # ======================================================================= #
1042
- if ::Gtk.use_gtk2?
1043
- vpaned = ::Gtk::VPaned.new
1044
- else
1045
- vpaned = ::Gtk::Paned.new(:vertical)
1046
- end
1047
- vpaned.add1(widget1)
1048
- vpaned.add2(widget2)
1049
- return vpaned
1050
- end; alias gtk_resize_handle gtk_resize_grip # === gtk_resize_handle
1051
- alias draggable_spacer gtk_resize_grip # === draggable_spacer
1052
- alias horizontal_drag gtk_resize_grip # === horizontal_drag
1053
- alias horizontal_dragger gtk_resize_grip # === horizontal_dragger
1054
- alias draggable_hpane gtk_resize_grip # === draggable_hpane
1055
- alias gtk_draggable_hpane gtk_resize_grip # === gtk_draggable_hpane
1056
-
1057
- # ========================================================================= #
1058
- # === create_paned_vbox_last_big
1059
- # ========================================================================= #
1060
- def create_paned_vbox_last_big(*i)
1061
- ::Gtk.create_paned_vbox_last_big(i)
1062
- end
1063
-
1064
- # ========================================================================= #
1065
- # === gtk_source_view
1066
- #
1067
- # Usage example:
1068
- #
1069
- # gtk_sourceview { :sane_defaults }
1070
- #
1071
- # ========================================================================= #
1072
- def gtk_source_view(
1073
- optional_buffer = nil, &block
1074
- )
1075
- require 'gtk_paradise/gtk_classes/source_view.rb'
1076
- if optional_buffer.nil?
1077
- source_view = ::Gtk::SourceView.new
1078
- else
1079
- source_view = ::Gtk::SourceView.new(optional_buffer)
1080
- end
1081
- # ======================================================================= #
1082
- # === Handle blocks next
1083
- # ======================================================================= #
1084
- if block_given?
1085
- yielded = yield
1086
- case yielded
1087
- # ===================================================================== #
1088
- # === :do_use_sane_defaults
1089
- # ===================================================================== #
1090
- when :do_use_sane_defaults,
1091
- :sane_defaults
1092
- source_view.do_use_sane_defaults
1093
- end
1094
- end
1095
- return source_view
1096
- end; alias gtk_sourceview gtk_source_view # === gtk_sourceview
1097
-
1098
- # ========================================================================= #
1099
- # === use_gtk3?
1100
- # ========================================================================= #
1101
- def use_gtk3?
1102
- we_use_this_gtk_version? == :gtk3
1103
- end
1104
-
1105
- require 'gtk_paradise/toplevel_methods/we_use_this_gtk_version.rb'
1106
- # ========================================================================= #
1107
- # === we_use_this_gtk_version?
1108
- # ========================================================================= #
1109
- def we_use_this_gtk_version?
1110
- ::Gtk.we_use_this_gtk_version?
1111
- end; alias we_use_which_gtk_version? we_use_this_gtk_version? # === we_use_which_gtk_version?
1112
-
1113
- # ========================================================================= #
1114
- # === return_pwd
1115
- # ========================================================================= #
1116
- def return_pwd
1117
- "#{Dir.pwd}/".squeeze('/')
1118
- end
1119
-
1120
- # ========================================================================= #
1121
- # === main_file?
1122
- #
1123
- # This is a wrapper over the toplevel-method that normally keeps track
1124
- # of the "active" file.
1125
- # ========================================================================= #
1126
- def main_file?
1127
- ::Gtk.main_file?
1128
- end; alias assigned_main_file? main_file? # === assigned_main_file?
1129
- alias filename? main_file? # === filename?
1130
-
1131
- # ========================================================================= #
1132
- # === gtk_hpaned
1133
- #
1134
- # Simply pass the widgets into this method - ideally only use two
1135
- # widgets though.
1136
- #
1137
- # An usage example for this method follows:
1138
- #
1139
- # hpaned = gtk_hpaned(
1140
- # widget1,
1141
- # widget2
1142
- # )
1143
- #
1144
- # Or:
1145
- #
1146
- # hpaned = gtk_hpaned(
1147
- # widget1,
1148
- # widget2
1149
- # ) {{ border_width: 5 }}
1150
- #
1151
- # ========================================================================= #
1152
- def gtk_hpaned(*optional_arguments)
1153
- if ::Gtk.use_gtk2?
1154
- hpaned = ::Gtk::HPaned.new
1155
- else
1156
- hpaned = ::Gtk::Paned.new(:horizontal)
1157
- end
1158
- if optional_arguments and !optional_arguments.empty?
1159
- optional_arguments.each {|widget|
1160
- hpaned.add(widget)
1161
- }
1162
- end
1163
- # ======================================================================= #
1164
- # === Handle blocks next
1165
- # ======================================================================= #
1166
- if block_given?
1167
- yielded = yield
1168
- if yielded.is_a? Hash
1169
- # =================================================================== #
1170
- # === :border_width
1171
- # =================================================================== #
1172
- if yielded.has_key? :border_width
1173
- set_border_width(
1174
- yielded.delete(:border_width)
1175
- )
1176
- end
1177
- end
1178
- end
1179
- return hpaned
1180
- end; alias gtk_draggable_vpane gtk_hpaned # === gtk_draggable_vpane
1181
- alias gtk_horizontal_pane gtk_hpaned # === gtk_horizontal_pane
1182
-
1183
- # ========================================================================= #
1184
- # === gtk_vpaned
1185
- # ========================================================================= #
1186
- def gtk_vpaned(*optional_arguments)
1187
- if ::Gtk.use_gtk2?
1188
- vpaned = ::Gtk::VPaned.new
1189
- else
1190
- vpaned = ::Gtk::Paned.new(:vertical)
1191
- end
1192
- if optional_arguments and !optional_arguments.empty?
1193
- optional_arguments.each {|widget|
1194
- vpaned.add(widget)
1195
- }
1196
- end
1197
- return vpaned
1198
- end
1199
-
1200
- # ========================================================================= #
1201
- # === Gtk::BaseModule.included
1202
- #
1203
- # This could be enabled if we want to act on a per-inclusion basis,
1204
- # via a hook.
1205
- # ========================================================================= #
1206
- # def self.included(i)
1207
- # case i.name.to_s
1208
- # when 'Gtk::BaseModuleAndAppModule'
1209
- # # ======================================================================= #
1210
- # # This is activated whenever Gtk::BaseModuleAndAppModule is
1211
- # # included.
1212
- # # ======================================================================= #
1213
- # puts "#{i} included #{self} - next work on CSS stuff."
1214
- # end
1215
- # end
1216
-
1217
- # ========================================================================= #
1218
- # === mouse_button_double_click?
1219
- #
1220
- # The argument should be an event.
1221
- # ========================================================================= #
1222
- def mouse_button_double_click?(event)
1223
- if ::Gtk.use_gtk2?
1224
- event.event_type == Gdk::Event::BUTTON2_PRESS and
1225
- event.button == 1
1226
- else
1227
- event.event_type == Gdk::EventType::BUTTON2_PRESS and
1228
- event.button == 1
1229
- end
1230
- end; alias double_click? mouse_button_double_click? # === double_click?
1231
-
1232
- # ========================================================================= #
1233
- # === gtk_progress_bar
1234
- # ========================================================================= #
1235
- def gtk_progress_bar
1236
- _ = ::Gtk::ProgressBar.new
1237
- return _
1238
- end
1239
-
1240
- # ========================================================================= #
1241
- # === gtk_base_module
1242
- # ========================================================================= #
1243
- def gtk_base_module
1244
- ::Gtk::BaseModule
1245
- end
1246
-
1247
- # ========================================================================= #
1248
- # === gtk_hbox_with_vertical_pane
1249
- #
1250
- # This method will generate a hbox (horizontal box) which is separated
1251
- # by a vertical drag-pane.
1252
- # ========================================================================= #
1253
- def gtk_hbox_with_vertical_pane(
1254
- *i,
1255
- &block
1256
- )
1257
- if use_gtk2?
1258
- _ = ::Gtk::VPaned.new
1259
- else
1260
- _ = Gtk::Paned.new(:vertical)
1261
- end
1262
- _.add1(i.first)
1263
- _.add2(i.last)
1264
- return _
1265
- end; alias vpane_split gtk_hbox_with_vertical_pane # === vpane_split
1266
- alias draggable_vbox gtk_hbox_with_vertical_pane # === draggable_vbox
1267
- alias horizontal_pane gtk_hbox_with_vertical_pane # === horizontal_pane
1268
-
1269
- # ========================================================================= #
1270
- # === set_this_widget
1271
- #
1272
- # Note that this will not work for every widget; the main use case is to
1273
- # leverage it for gtk-frame widgets.
1274
- # ========================================================================= #
1275
- def set_this_widget(i)
1276
- set_label_widget(i)
1277
- end
1278
-
1279
- # ========================================================================= #
1280
- # === percentage_widget
1281
- # ========================================================================= #
1282
- def percentage_widget(
1283
- lower_bound = 50,
1284
- upper_bound = 100
1285
- )
1286
- current_value = (lower_bound.to_f * 100) / upper_bound
1287
- progress_bar = ::Gtk::ProgressBar.new
1288
- progress_bar.set_name('progressbar1') # Enable default styling here.
1289
- new_value = 100.0 / current_value
1290
- if new_value.is_a? Float
1291
- new_value = new_value.round(2)
1292
- end
1293
- progress_bar.set_fraction(new_value) # n%.
1294
- return progress_bar
1295
- end
1296
-
1297
- # ========================================================================= #
1298
- # === percentage_widget_with_this_text
1299
- #
1300
- # Note that the :default symbol means to show the percentage value
1301
- # calculated.
1302
- # ========================================================================= #
1303
- def percentage_widget_with_this_text(
1304
- lower_bound = 50,
1305
- upper_bound = 100,
1306
- this_text = :default
1307
- )
1308
- case this_text
1309
- when :default
1310
- this_text = (
1311
- (lower_bound.to_f * 100) / upper_bound
1312
- ).to_s.to_f.round(2).to_s+'%'
1313
- end
1314
- progress_bar = percentage_widget(lower_bound, upper_bound)
1315
- progress_bar.set_show_text(true)
1316
- progress_bar.set_text(this_text)
1317
- return progress_bar
1318
- end; alias percentage_widget_with_text percentage_widget_with_this_text # === percentage_widget_with_text
1319
-
1320
- require 'gtk_paradise/gtk_classes/radio_menu_item.rb'
1321
- # ========================================================================= #
1322
- # === gtk_radio_menu_item
1323
- # ========================================================================= #
1324
- def gtk_radio_menu_item(
1325
- group_to_use = nil, label_to_use = ''
1326
- )
1327
- ::Gtk.gtk_radio_menu_item(
1328
- group_to_use, label_to_use
1329
- )
1330
- end
1331
-
1332
- # ========================================================================= #
1333
- # === options
1334
- #
1335
- # This shall be similar to the HTML drop-down options menu. The user
1336
- # will make a selection.
1337
- #
1338
- # This method will return an Array; the first entry is the vbox that
1339
- # can be used, such as when you embed it into another gtk-application.
1340
- # The second entry is the array containing all the radio-buttons.
1341
- # These allow us to query the state.
1342
- #
1343
- # Usage example:
1344
- #
1345
- # vbox, array_radio_buttons = options()
1346
- #
1347
- # ========================================================================= #
1348
- def options(*i)
1349
- return ::Gtk.options(i)
1350
- end; alias dropdown_menu options # === dropdown_menu
1351
-
1352
- # ========================================================================= #
1353
- # === ungrab_application
1354
- #
1355
- # Not sure if this is in use right now.
1356
- # ========================================================================= #
1357
- def ungrab_application
1358
- Gdk.pointer_ungrab(Gdk::Event::CURRENT_TIME)
1359
- end
1360
-
1361
- # ========================================================================= #
1362
- # === internal_hash?
1363
- #
1364
- # Query-method to obtain @internal_hash.
1365
- # ========================================================================= #
1366
- def internal_hash?
1367
- @internal_hash
1368
- end
1369
-
1370
- # ========================================================================= #
1371
- # === xid_value?
1372
- # ========================================================================= #
1373
- def xid_value?
1374
- window.xid.to_s
1375
- end; alias xid? xid_value? # === xid?
1376
-
1377
- # ========================================================================= #
1378
- # === gtk_tree_store
1379
- # ========================================================================= #
1380
- def gtk_tree_store(*i)
1381
- ::Gtk::TreeStore.new(i)
1382
- end
1383
-
1384
- require 'gtk_paradise/gtk_classes/option_menu.rb'
1385
- # ========================================================================= #
1386
- # === gtk_option_menu
1387
- # ========================================================================= #
1388
- def gtk_option_menu
1389
- ::Gtk.gtk_option_menu
1390
- end
1391
-
1392
- # ========================================================================= #
1393
- # === gtk_menu
1394
- # ========================================================================= #
1395
- def gtk_menu
1396
- ::Gtk::Menu.new
1397
- end
1398
-
1399
- # ========================================================================= #
1400
- # === gtk_menu_item
1401
- #
1402
- # This can be used like so:
1403
- #
1404
- # filem1 = gtk_menu_item('File') {{
1405
- # submenu: filemenu
1406
- # }}
1407
- #
1408
- # Or so:
1409
- #
1410
- # gtk_menu_item(label: 'Test1')
1411
- # gtk_menu_item('Test1')
1412
- #
1413
- # ========================================================================= #
1414
- def gtk_menu_item(
1415
- i = 'File',
1416
- use_underline = false,
1417
- &block
1418
- )
1419
- if i and i.respond_to?(:include?) and i.include?('_')
1420
- use_underline = true
1421
- end
1422
- if ::Gtk.use_gtk2?
1423
- menu_item = ::Gtk::MenuItem.new(i, use_underline)
1424
- else # else for ruby-gtk3
1425
- hash = {}
1426
- if i.is_a? Hash
1427
- # In this case we can just pass-through, as-is.
1428
- else
1429
- i = { label: i } # And in that cased we have to turn it into a Hash first.
1430
- end
1431
- hash.merge!(i)
1432
- hash.merge!({use_underline: use_underline})
1433
- menu_item = ::Gtk::MenuItem.new(hash)
1434
- end
1435
- # ======================================================================= #
1436
- # === Handle blocks next
1437
- # ======================================================================= #
1438
- if block_given?
1439
- yielded = yield
1440
- if yielded.is_a? Hash
1441
- if yielded.has_key? :submenu
1442
- menu_item.set_submenu(yielded[:submenu])
1443
- end
1444
- elsif yielded.is_a? Symbol
1445
- case yielded
1446
- # =================================================================== #
1447
- # === :on_activate_quit
1448
- # =================================================================== #
1449
- when :on_activate_quit
1450
- menu_item.on_activate { Gtk.main_quit }
1451
- end
1452
- end
1453
- end
1454
- return menu_item
1455
- end; alias menu_item gtk_menu_item # === menu_item
1456
-
1457
- # ========================================================================= #
1458
- # === pixbuf_loader
1459
- # ========================================================================= #
1460
- def pixbuf_loader
1461
- GdkPixbuf::PixbufLoader.new
1462
- end
1463
-
1464
- # ========================================================================= #
1465
- # === abort_on_exception
1466
- # ========================================================================= #
1467
- def abort_on_exception
1468
- Thread.abort_on_exception = true
1469
- end
1470
-
1471
- # ========================================================================= #
1472
- # === create_context_menu
1473
- #
1474
- # This method can be used to create dynamic context-menus
1475
- # "on the fly". These must be sufficiently flexible.
1476
- # ========================================================================= #
1477
- def create_context_menu(
1478
- parent_widget = nil
1479
- )
1480
- context_menu = gtk_menu
1481
- # ======================================================================= #
1482
- # === Handle blocks given to this method next
1483
- # ======================================================================= #
1484
- if block_given?
1485
- yielded = yield
1486
- if yielded.is_a? Hash
1487
- # =================================================================== #
1488
- # === :actions
1489
- #
1490
- # This entry point associates the context-menu entries with
1491
- # specific "actions". These actions are typically simply
1492
- # methods that you can call.
1493
- # =================================================================== #
1494
- if yielded.has_key? :actions
1495
- yielded[:actions].each_pair {|title_to_use, method_to_call|
1496
- # =============================================================== #
1497
- # Example how this may look:
1498
- #
1499
- # 'FoobarAction1': :foobar_action1
1500
- #
1501
- # =============================================================== #
1502
- menu_item = gtk_menu_item(title_to_use)
1503
- context_menu << menu_item
1504
- menu_item.signal_connect(:activate) { |widget|
1505
- if parent_widget
1506
- case method_to_call
1507
- when :interactively_create_directory
1508
- parent_widget.send(method_to_call.to_sym, parent_widget)
1509
- else # This is the default.
1510
- parent_widget.send(method_to_call.to_sym)
1511
- end
1512
- end
1513
- }
1514
- }
1515
- # =================================================================== #
1516
- # === :numbered_actions
1517
- #
1518
- # This entry point will simply iterate over the elements and add
1519
- # a number, such as "1", "2" and so forth, to denote which number
1520
- # is associated with which particular Gtk::Menu entry.
1521
- # =================================================================== #
1522
- elsif yielded.has_key? :numbered_actions
1523
- index = 0
1524
- yielded[:numbered_actions].each_pair {|title_to_use, method_to_call| index += 1
1525
- menu_item = gtk_menu_item("(#{index}) #{title_to_use}")
1526
- context_menu << menu_item
1527
- menu_item.signal_connect(:activate) { |widget|
1528
- if parent_widget
1529
- case method_to_call
1530
- when :interactively_create_directory
1531
- parent_widget.send(method_to_call.to_sym, parent_widget)
1532
- else # This is the default.
1533
- parent_widget.send(method_to_call.to_sym)
1534
- end
1535
- end
1536
- }
1537
- }
1538
- end
1539
- # =================================================================== #
1540
- # === n_entries
1541
- # =================================================================== #
1542
- if yielded.has_key? :n_entries
1543
- yielded[:n_entries].times {|n_run|
1544
- menu_item = gtk_menu_item("Test#{n_run}")
1545
- context_menu << menu_item
1546
- menu_item.signal_connect(:activate) { |widget|
1547
- puts "#{widget.class} - #{menu_item.text?}"
1548
- }
1549
- }
1550
- end
1551
- end
1552
- end
1553
- context_menu.show_all
1554
- return context_menu
1555
- end; alias return_context_menu create_context_menu # === return_context_menu
1556
-
1557
- # ========================================================================= #
1558
- # === gtk_coloured_bar
1559
- # ========================================================================= #
1560
- def gtk_coloured_bar
1561
- ::Gtk::ColouredBar.new
1562
- end
1563
-
1564
- # ========================================================================= #
1565
- # === cell_renderer_progress
1566
- # ========================================================================= #
1567
- def cell_renderer_progress(i = nil)
1568
- _ = ::Gtk::CellRendererProgress.new
1569
- _.set_value(i) if i
1570
- return _
1571
- end
1572
-
1573
- # ========================================================================= #
1574
- # === gtk_tree_view_column
1575
- #
1576
- # The second argument to this method should be the gtk cell-renderer,
1577
- # which defaults to a textual representation. This object can then
1578
- # also be manipulated via invocations such as:
1579
- #
1580
- # renderer.foreground = "#ff0000"
1581
- #
1582
- # To use this, do something like this:
1583
- #
1584
- # gtk_tree_view_column('Buy', gtk_cell_renderer, text: BUY_IT)
1585
- # gtk_tree_view_column('Item', gtk_cell_renderer_centered_text, text: BUY_IT)
1586
- #
1587
- # ========================================================================= #
1588
- def gtk_tree_view_column(
1589
- title_of_the_column = 'Testing',
1590
- gtk_renderer_to_use = gtk_cell_renderer_text, # or gtk_cell_renderer_centered_text
1591
- text_position = 0
1592
- )
1593
- # ======================================================================= #
1594
- # Not sure why the following code queried for a Hash. If I ever find
1595
- # out, I will note it down back here, but for now it is commented
1596
- # out. (06.12.2020)
1597
- #if text_position.is_a? Hash
1598
- # if text_position.has_key? :text
1599
- # text_position = text_position.delete(:text)
1600
- # end
1601
- #elsif text_position.is_a? Integer
1602
- # ======================================================================= #
1603
- if text_position.is_a? Integer
1604
- text_position = { text: text_position }
1605
- end
1606
- ::Gtk::TreeViewColumn.new(
1607
- title_of_the_column,
1608
- gtk_renderer_to_use,
1609
- text_position
1610
- )
1611
- end
1612
-
1613
- # ========================================================================= #
1614
- # === populate_this_list_store
1615
- #
1616
- # Note that this method currently only works for one or two entries,
1617
- # which explains the odd alias-name to this. At a later point we may
1618
- # change this, though.
1619
- #
1620
- # It is recommended to use the aliased name, aka:
1621
- #
1622
- # populate_this_list_store2(@list_store, dataset_here)
1623
- #
1624
- # This is not as elegant, but at some point in the future we may
1625
- # change the main alias, but the numbered-variants such as _store2
1626
- # or _store3 will always remain backwards-compatible. Keep that
1627
- # in mind when using this method.
1628
- # ========================================================================= #
1629
- def populate_this_list_store(
1630
- this_list_store, this_dataset
1631
- )
1632
- this_dataset.each { |first, second|
1633
- iter = this_list_store.append
1634
- iter.set_value(0, first.to_s)
1635
- iter.set_value(1, second.to_s) if second
1636
- }
1637
- end; alias populate_this_list_store2 populate_this_list_store # === populate_this_list_store2
1638
- alias populate_this_list_store_with_that_array populate_this_list_store # === populate_this_list_store_with_that_array
1639
-
1640
- # ========================================================================= #
1641
- # === check_for_a_manifest_yaml_file
1642
- #
1643
- # This method will query whether a file called manifest.yml exists. If so
1644
- # it will load this dataset and evaluate it. Unfortunately this does
1645
- # not work properly right now (February 2021); I may have to re-evaluate
1646
- # this again in the future.
1647
- # ========================================================================= #
1648
- def check_for_a_manifest_yaml_file
1649
- _ = 'manifest.yml'
1650
- if @configuration
1651
- this_file = @configuration[1]+'/'+_
1652
- if File.exist? this_file
1653
- dataset = YAML.load_file(this_file)
1654
- # =================================================================== #
1655
- # Next, parse it.
1656
- # =================================================================== #
1657
- if dataset.has_key? 'buttons'
1658
- dataset['buttons'].each_pair {|name_of_the_instance_variable, value|
1659
- # =============================================================== #
1660
- # First refer to the Hash, so that we can re-use it a later time.
1661
- # =============================================================== #
1662
- hash = dataset['buttons'][name_of_the_instance_variable]
1663
- if name_of_the_instance_variable.frozen?
1664
- name_of_the_instance_variable = name_of_the_instance_variable.dup
1665
- end
1666
- unless name_of_the_instance_variable.start_with? '@'
1667
- name_of_the_instance_variable[0,0] = '@'
1668
- end
1669
- _ = gtk_button
1670
- instance_variable_set(name_of_the_instance_variable.to_sym, _)
1671
- hash.each_pair {|key, value|
1672
- case key
1673
- when 'text'
1674
- _.set_text(value)
1675
- when 'use_mnemonic'
1676
- old_text = _.text?
1677
- _.set_text(old_text, use_mnemonics: true)
1678
- when 'colour','color'
1679
- override_color(:normal, value.to_sym)
1680
- when 'tooltip'
1681
- _.hint = value
1682
- when 'weight'
1683
- if value == 'bold'
1684
- _.make_bold
1685
- end
1686
- when 'width'
1687
- _.width_height(value, hash['height'])
1688
- end
1689
- }
1690
- }
1691
- end
1692
- end
1693
- end
1694
- end
1695
-
1696
- require 'gtk_paradise/toplevel_methods/misc.rb'
1697
- # ========================================================================= #
1698
- # === return_editable_cell_renderer_text
1699
- # ========================================================================= #
1700
- def return_editable_cell_renderer_text
1701
- ::Gtk.return_editable_cell_renderer_text
1702
- end
1703
-
1704
- # ========================================================================= #
1705
- # === response_type_ok?
1706
- # ========================================================================= #
1707
- def response_type_ok?(i)
1708
- i == Gtk::ResponseType::OK
1709
- end
1710
-
1711
- # ========================================================================= #
1712
- # === gtk_colour_selection_dialog
1713
- # ========================================================================= #
1714
- def gtk_colour_selection_dialog(use_this_title = 'Select a color')
1715
- _ = ::Gtk::ColorSelectionDialog.new(title: use_this_title)
1716
- _colour_selection = _.color_selection
1717
- colour = _.current_rgba
1718
- e colour
1719
- return _
1720
- end; alias colour_selection_dialog gtk_colour_selection_dialog # === colour_selection_dialog
1721
-
1722
- # ========================================================================= #
1723
- # === gtk_vbox
1724
- #
1725
- # The alias vbox exists, but I am not entirely sure whether this will
1726
- # be retained or not. The second variant, thus, for the time being,
1727
- # allows something like this:
1728
- #
1729
- # vbox {
1730
- # label 'Hello'
1731
- # button 'World !'
1732
- # }
1733
- #
1734
- # ========================================================================= #
1735
- def gtk_vbox(*i, &block)
1736
- if i.empty?
1737
- vbox = ::Gtk.vbox
1738
- elsif block_given? and i.empty?
1739
- vbox = ::Gtk.vbox(yield)
1740
- else
1741
- vbox = ::Gtk.vbox(i)
1742
- end
1743
- if block_given?
1744
- yielded = yield
1745
- if yielded.is_a?(Hash) and yielded.has_key?(:spacing)
1746
- vbox.spacing = yielded[:spacing]
1747
- end
1748
- end
1749
- return vbox
1750
- end; alias vbox gtk_vbox # === vbox
1751
- alias gtk_box gtk_vbox # === gtk_box
1752
-
1753
- # ========================================================================= #
1754
- # === vte_terminal
1755
- #
1756
- # This method will instantiate a new vte-terminal.
1757
- #
1758
- # You can pass in a hash to the block, such as in this way:
1759
- #
1760
- # terminal = vte_terminal {{ font: USE_THIS_FONT }}
1761
- #
1762
- # ========================================================================= #
1763
- def vte_terminal
1764
- terminal = Vte::Terminal.new
1765
- if block_given?
1766
- yielded = yield
1767
- if yielded.is_a? Hash
1768
- # =================================================================== #
1769
- # === :font
1770
- # =================================================================== #
1771
- if yielded.has_key? :font
1772
- terminal.use_this_font = yielded[:font]
1773
- end
1774
- end
1775
- end
1776
- return terminal
1777
- end
1778
-
1779
- # ========================================================================= #
1780
- # === gtk_scrollbar
1781
- # ========================================================================= #
1782
- def gtk_scrollbar(a = :vertical, b = @terminal.vadjustment)
1783
- ::Gtk::Scrollbar.new(a, b)
1784
- end
1785
-
1786
- # ========================================================================= #
1787
- # === gtk_pixbuf
1788
- #
1789
- # This is essentially just a wrapper over:
1790
- #
1791
- # image = Gtk::Image.new(pixbuf: icon)
1792
- #
1793
- # I am not sure whether it will be kept as it is, as the name is a
1794
- # bit of a misnomer.
1795
- # ========================================================================= #
1796
- def gtk_pixbuf(
1797
- i, optional_width = nil, optional_height = nil
1798
- )
1799
- if optional_width
1800
- ::Gtk::Image.new(pixbuf: i, width: optional_width, height: optional_height)
1801
- else
1802
- ::Gtk::Image.new(pixbuf: i)
1803
- end
1804
- end; alias gdk_pixbuf gtk_pixbuf # === gdk_pixbuf
1805
-
1806
- # ========================================================================= #
1807
- # === pixbuf_from_file
1808
- # ========================================================================= #
1809
- def pixbuf_from_file(this_file)
1810
- GdkPixbuf::Pixbuf.new(file: this_file)
1811
- end
1812
-
1813
- # ========================================================================= #
1814
- # === directory_content_widget
1815
- # ========================================================================= #
1816
- def directory_content_widget(
1817
- i = return_pwd
1818
- )
1819
- ::Gtk::DirectoryContentWidget.new(i)
1820
- end; alias return_directory_widget directory_content_widget # === return_directory_widget
1821
-
1822
- # ========================================================================= #
1823
- # === button_hover_colour
1824
- # ========================================================================= #
1825
- def button_hover_colour(
1826
- i = '#cef0ea; /* This is a very light blue. */'
1827
- )
1828
- i = i.to_s.dup
1829
- in_file_css '
1830
- button:hover {
1831
- background: '+i+'
1832
- }'
1833
- end
1834
-
1835
- # ========================================================================= #
1836
- # === gtk_switch
1837
- #
1838
- # This is a "toggle" button in the sense of having a switch state.
1839
- #
1840
- # The two possible states are "on" and "off".
1841
- # ========================================================================= #
1842
- def gtk_switch
1843
- ::Gtk::Switch.new
1844
- end
1845
-
1846
- # ========================================================================= #
1847
- # === gtk_entry_completion
1848
- #
1849
- # This will create a new instance of Gtk::EntryCompletion.
1850
- #
1851
- # The first argument can be used to attach the completion-object to
1852
- # the widget. An Array can be passed as well.
1853
- # ========================================================================= #
1854
- def gtk_entry_completion(i = nil)
1855
- entry_completion = ::Gtk::EntryCompletion.new
1856
- if i and i.is_a?(Array)
1857
- list_store = ::Gtk::ListStore.new(String)
1858
- i.each { |entry|
1859
- iter = list_store.append
1860
- iter[0] = entry
1861
- }
1862
- entry_completion.model = list_store
1863
- end
1864
- return entry_completion
1865
- end
1866
-
1867
- # ========================================================================= #
1868
- # === gtk_tree_view
1869
- #
1870
- # Usage examples:
1871
- #
1872
- # @treeview = gtk_tree_view(@liststore)
1873
- # @treeview = gtk_tree_view(@liststore) { :clickable_headers }
1874
- #
1875
- # ========================================================================= #
1876
- def gtk_tree_view(
1877
- optional_input = nil
1878
- )
1879
- if optional_input
1880
- widget = ::Gtk::TreeView.new(optional_input)
1881
- else
1882
- widget = ::Gtk::TreeView.new
1883
- end
1884
- if block_given?
1885
- yielded = yield
1886
- case yielded
1887
- # ===================================================================== #
1888
- # === :clickable_headers
1889
- # ===================================================================== #
1890
- when :clickable_headers
1891
- widget.headers_clickable = true
1892
- end
1893
- end
1894
- widget
1895
- end; alias gtk_treeview gtk_tree_view # === gtk_treeview
1896
- alias tree_view gtk_tree_view # === tree_view
1897
-
1898
- # ========================================================================= #
1899
- # === gtk_runner_module
1900
- # ========================================================================= #
1901
- def gtk_runner_module
1902
- ::Gtk::AppModule
1903
- end; alias gtk_app_module gtk_runner_module # === gtk_app_module
1904
-
1905
- # ========================================================================= #
1906
- # === set_parent_widget
1907
- # ========================================================================= #
1908
- def set_parent_widget(i)
1909
- @parent_widget = i
1910
- end
1911
-
1912
- # ========================================================================= #
1913
- # === gtk_hseparator
1914
- #
1915
- # This is a horizontal separator.
1916
- # ========================================================================= #
1917
- def gtk_hseparator
1918
- if use_gtk2?
1919
- ::Gtk::HSeparator.new
1920
- else
1921
- ::Gtk::Separator.new(:horizontal)
1922
- end
1923
- end; alias gtk_separator gtk_hseparator # === gtk_separator
1924
- alias horizontal_separator gtk_hseparator # === horizontal_separator
1925
-
1926
- # ========================================================================= #
1927
- # === override_normal_background_color
1928
- # ========================================================================= #
1929
- def override_normal_background_color(
1930
- colour_to_use = Gdk::RGBA.new(0.999, 0.999, 0.999, 1)
1931
- )
1932
- override_background_color(:normal, colour_to_use)
1933
- end
1934
-
1935
- # ========================================================================= #
1936
- # === cliner
1937
- # ========================================================================= #
1938
- def cliner
1939
- e '=' * 80
1940
- end
1941
-
1942
- # ========================================================================= #
1943
- # === Gtk::BaseModule.extended
1944
- #
1945
- # Whenever this module is extended, .reset_the_internal_variables()
1946
- # is called, in order to initialize @configuration and other
1947
- # important instance-variables.
1948
- # ========================================================================= #
1949
- def self.extended(i)
1950
- i.reset_the_internal_variables
1951
- end
1952
-
1953
- # ========================================================================= #
1954
- # === gtk_source_buffer
1955
- # ========================================================================= #
1956
- def gtk_source_buffer
1957
- begin
1958
- ::Gtk::SourceBuffer.new
1959
- rescue LoadError => error
1960
- puts 'Gtk::SourceBuffer does not appear to be available.'
1961
- pp error
1962
- end
1963
- end; alias return_sourcecode gtk_source_buffer # === return_sourcecode
1964
-
1965
- # ========================================================================= #
1966
- # === two_strings
1967
- #
1968
- # This is simply a list-store with two Strings per row.
1969
- # ========================================================================= #
1970
- def two_strings
1971
- gtk_list_store(
1972
- String, String
1973
- )
1974
- end
1975
-
1976
- # ========================================================================= #
1977
- # === three_strings
1978
- #
1979
- # This is simply a list-store with three Strings per row.
1980
- # ========================================================================= #
1981
- def three_strings
1982
- gtk_list_store(
1983
- String, String, String
1984
- )
1985
- end
1986
-
1987
- # ========================================================================= #
1988
- # === four_strings
1989
- # ========================================================================= #
1990
- def four_strings
1991
- gtk_list_store(
1992
- String, String, String, String
1993
- )
1994
- end
1995
-
1996
- # ========================================================================= #
1997
- # === five_strings
1998
- #
1999
- # This is simply a list-store with five Strings per row.
2000
- # ========================================================================= #
2001
- def five_strings
2002
- gtk_list_store(
2003
- String, String, String, String, String
2004
- )
2005
- end
2006
-
2007
- # ========================================================================= #
2008
- # === six_strings
2009
- #
2010
- # This is simply a list-store with six Strings per row.
2011
- # ========================================================================= #
2012
- def six_strings
2013
- gtk_list_store(
2014
- String, String, String, String, String, String
2015
- )
2016
- end
2017
-
2018
- # ========================================================================= #
2019
- # === seven_strings
2020
- #
2021
- # This is simply a list-store with seven Strings per row.
2022
- # ========================================================================= #
2023
- def seven_strings
2024
- gtk_list_store(
2025
- String, String, String, String, String, String, String
2026
- )
2027
- end
2028
-
2029
- # ========================================================================= #
2030
- # === eight_strings
2031
- #
2032
- # This is simply a list-store with eight Strings per row.
2033
- # ========================================================================= #
2034
- def eight_strings
2035
- gtk_list_store(
2036
- String, String, String, String, String, String, String, String, String, String
2037
- )
2038
- end
2039
-
2040
- # ========================================================================= #
2041
- # === set_background
2042
- # ========================================================================= #
2043
- def set_background(
2044
- use_this_colour = :grey
2045
- )
2046
- use_this_colour = ::Gtk.colour_parse(use_this_colour)
2047
- if ::Gtk.use_gtk2?
2048
- modify_bg(
2049
- ::Gtk::StateType::NORMAL, use_this_colour
2050
- )
2051
- else
2052
- if use_this_colour.is_a? Gdk::Color
2053
- # =================================================================== #
2054
- # Convert it into RGB values next.
2055
- # =================================================================== #
2056
- array = [
2057
- (use_this_colour.red * 100.0 / 65535) / 100,
2058
- (use_this_colour.green * 100.0 / 65535) / 100,
2059
- (use_this_colour.blue * 100.0 / 65535) / 100,
2060
- 1.0
2061
- ]
2062
- use_this_colour = Gdk::RGBA.new(*array)
2063
- end
2064
- override_background_color(:normal, use_this_colour)
2065
- end
2066
- end; alias background= set_background # === background=
2067
- alias set_bg set_background # === set_bg
2068
- alias background_colour set_background # === background_colour
2069
- alias set_background_colour set_background # === set_background_colour
2070
-
2071
- # ========================================================================= #
2072
- # === gtk_accel_group
2073
- # ========================================================================= #
2074
- def gtk_accel_group
2075
- ::Gtk::AccelGroup.new
2076
- end; alias gtk_accelgroup gtk_accel_group # === gtk_accelgroup
2077
-
2078
- # ========================================================================= #
2079
- # === create_and_add_gtk_accel_group
2080
- # ========================================================================= #
2081
- def create_and_add_gtk_accel_group
2082
- accel_group = gtk_accel_group
2083
- add_accel_group(accel_group) if respond_to? :add_accel_group
2084
- return accel_group
2085
- end
2086
-
2087
- # ========================================================================= #
2088
- # === gtk_cell_renderer_combo
2089
- # ========================================================================= #
2090
- def gtk_cell_renderer_combo
2091
- ::Gtk::CellRendererCombo.new
2092
- end
2093
-
2094
- # ========================================================================= #
2095
- # === gtk_cell_renderer_pixbuf
2096
- # ========================================================================= #
2097
- def gtk_cell_renderer_pixbuf
2098
- ::Gtk::CellRendererPixbuf.new
2099
- end; alias cell_renderer_pixbuf gtk_cell_renderer_pixbuf # === cell_renderer_pixbuf
2100
-
2101
- # ========================================================================= #
2102
- # === gtk_cell_renderer_centered_text
2103
- # ========================================================================= #
2104
- def gtk_cell_renderer_centered_text
2105
- _ = gtk_cell_renderer_text
2106
- _.center
2107
- return _
2108
- end
2109
-
2110
- # ========================================================================= #
2111
- # === gtk_cell_renderer_text
2112
- # ========================================================================= #
2113
- def gtk_cell_renderer_text
2114
- ::Gtk::CellRendererText.new
2115
- end; alias gtk_cellrenderer_text gtk_cell_renderer_text # === gtk_cellrenderer_text
2116
- alias gtk_cell_renderer gtk_cell_renderer_text # === gtk_cell_renderer
2117
-
2118
- # ========================================================================= #
2119
- # === gtk_cell_renderer_right_aligned
2120
- # ========================================================================= #
2121
- def gtk_cell_renderer_right_aligned
2122
- _ = ::Gtk::CellRendererText.new
2123
- _.set_xalign(1.0)
2124
- return _
2125
- end
2126
-
2127
- # ========================================================================= #
2128
- # === gtk_menu_bar
2129
- # ========================================================================= #
2130
- def gtk_menu_bar
2131
- ::Gtk::MenuBar.new
2132
- end
2133
-
2134
- # ========================================================================= #
2135
- # === gtk_font_chooser_dialog
2136
- # ========================================================================= #
2137
- def gtk_font_chooser_dialog(use_this_title = nil)
2138
- _ = ::Gtk::FontChooserDialog.new
2139
- if use_this_title
2140
- _.set_title(use_this_title)
2141
- # Could also do: _.move(0, 0)
2142
- end
2143
- response = _.run # Run it at once.
2144
- if response == Gtk::ResponseType::OK
2145
- ::Gtk.set_main_file(_.font.to_s)
2146
- end
2147
- return _
2148
- end; alias font_chooser_dialog gtk_font_chooser_dialog # === font_chooser_dialog
2149
-
2150
- # ========================================================================= #
2151
- # === gtk_dropdown
2152
- #
2153
- # This creates a "drop-down" box, a combo-box entry.
2154
- # ========================================================================= #
2155
- def gtk_dropdown(*i)
2156
- i.flatten!
2157
- dropdown_box = gtk_combo_box(true)
2158
- # Next, append every element given to this method.
2159
- i.each { |entry| dropdown_box.append_text(entry) }
2160
- return dropdown_box
2161
- end; alias gtk_dropdown_box gtk_dropdown # === gtk_dropdown_box
2162
-
2163
- # ========================================================================= #
2164
- # === enable_these_key_combinations
2165
- #
2166
- # Right now this method requires a Hash. At some point in the future
2167
- # we may ease up on that constraint.
2168
- # ========================================================================= #
2169
- def enable_these_key_combinations(
2170
- hash
2171
- )
2172
- unless hash.is_a? Hash
2173
- e 'We need a Hash for now. This may change at a later moment in'
2174
- e 'time, though.'
2175
- exit
2176
- end
2177
- # ======================================================================= #
2178
- # The Hash that is passed into this method may look like this:
2179
- #
2180
- # "ctrl+s"=>"save_the_buffer", :"strg+s"=>"save_the_buffer"}
2181
- #
2182
- # ======================================================================= #
2183
- hash.each_pair {|this_shortcut_is_to_be_used, call_this_method|
2184
- # ===================================================================== #
2185
- # Remove ' ' characters.
2186
- # ===================================================================== #
2187
- if this_shortcut_is_to_be_used.is_a?(String) and
2188
- this_shortcut_is_to_be_used.include?(' ')
2189
- # =================================================================== #
2190
- # Since as of 12.05.2021 we will remove ' '.
2191
- # =================================================================== #
2192
- if this_shortcut_is_to_be_used.frozen?
2193
- this_shortcut_is_to_be_used = this_shortcut_is_to_be_used.dup
2194
- end
2195
- this_shortcut_is_to_be_used.delete!(' ')
2196
- end
2197
- @parent_widget.keybinding(
2198
- this_shortcut_is_to_be_used,
2199
- call_this_method
2200
- )
2201
- }
2202
- end
2203
-
2204
- # ========================================================================= #
2205
- # === gtk_text_buffer
2206
- #
2207
- # The argument to this method can be used as argument to set_text(), aka
2208
- # you can set a default (startup) text for this text-buffer instance.
2209
- # ========================================================================= #
2210
- def gtk_text_buffer(
2211
- optional_input = nil
2212
- )
2213
- text_buffer = ::Gtk::TextBuffer.new
2214
- if optional_input and optional_input.is_a?(String)
2215
- text_buffer.set_text(optional_input)
2216
- end
2217
- return text_buffer
2218
- end; alias text_buffer gtk_text_buffer # === text_buffer
2219
-
2220
- # ========================================================================= #
2221
- # === app_chooser_button
2222
- # ========================================================================= #
2223
- def app_chooser_button(
2224
- i = 'x-scheme-handler/mailto'
2225
- )
2226
- ::Gtk::AppChooserButton.new(i)
2227
- end; alias choose_app app_chooser_button # === choose_app
2228
-
2229
- # ========================================================================= #
2230
- # === string_list_store
2231
- # ========================================================================= #
2232
- def string_list_store
2233
- ::Gtk::ListStore.new(String)
2234
- end
2235
-
2236
- # ========================================================================= #
2237
- # === return_numbered_lines_widget
2238
- #
2239
- # This method will yield - and return - the numbered-lines widget.
2240
- # ========================================================================= #
2241
- def return_numbered_lines_widget(
2242
- pass_this_hash = {
2243
- upper_range: 100
2244
- },
2245
- &block
2246
- )
2247
- unless Gtk.const_defined? :NumberedLines
2248
- require 'gtk_paradise/requires/numbered_lines.rb'
2249
- end
2250
- if block_given?
2251
- yielded = yield
2252
- if yielded.is_a? Hash
2253
- pass_this_hash = yielded
2254
- end
2255
- end
2256
- return ::Gtk::NumberedLines.new { pass_this_hash }
2257
- end; alias return_widget_with_line_numbers return_numbered_lines_widget # === return_widget_with_line_numbers
2258
- alias return_numbered_lines_widget return_numbered_lines_widget # === return_numbered_lines_widget
2259
-
2260
- # ========================================================================= #
2261
- # === gtk_main_quit
2262
- # ========================================================================= #
2263
- def gtk_main_quit
2264
- ::Gtk.main_quit
2265
- end; alias gtk_quit gtk_main_quit # === gtk_quit
2266
- alias gtk_main_exit gtk_main_quit # === gtk_main_exit
2267
-
2268
- # ========================================================================= #
2269
- # === resize_based_on_width_and_height_attributes
2270
- #
2271
- # This method will resize based on .width? and .height? results.
2272
- # ========================================================================= #
2273
- def resize_based_on_width_and_height_attributes(
2274
- optional_arguments = nil
2275
- )
2276
- width = width?
2277
- height = height?
2278
- if width.is_a?(String) and width.include?('%')
2279
- # ===================================================================== #
2280
- # Handle something like '80%'.
2281
- # ===================================================================== #
2282
- width = (max_width? * width.delete('%').to_f) / 100.0
2283
- end
2284
- if height.is_a?(String) and height.include?('%')
2285
- # ===================================================================== #
2286
- # Handle something like '80%'.
2287
- # ===================================================================== #
2288
- height = (max_height? * height.delete('%').to_f) / 100.0
2289
- end
2290
- case optional_arguments
2291
- # ======================================================================= #
2292
- # === :debug
2293
- # ======================================================================= #
2294
- when :debug
2295
- e 'Width and Height are: '+width.to_s+', '+height.to_s
2296
- end
2297
- set_size_request(width.to_i, height.to_i)
2298
- end; alias infer_the_size_automatically resize_based_on_width_and_height_attributes # === infer_the_size_automatically
2299
- alias infer_size_request resize_based_on_width_and_height_attributes # === infer_size_request
2300
- alias determine_the_default_size resize_based_on_width_and_height_attributes # === determine_the_default_size
2301
-
2302
- # ========================================================================= #
2303
- # === padded_hbox
2304
- # ========================================================================= #
2305
- def padded_hbox
2306
- _ = ::Gtk.hbox
2307
- _.pad5px
2308
- return _
2309
- end
2310
-
2311
- # ========================================================================= #
2312
- # === padded_vbox
2313
- # ========================================================================= #
2314
- def padded_vbox
2315
- _ = ::Gtk.vbox
2316
- _.pad5px
2317
- return _
2318
- end
2319
-
2320
- # ========================================================================= #
2321
- # === set_title
2322
- # ========================================================================= #
2323
- def set_title(i)
2324
- @title = i
2325
- end
2326
-
2327
- # ========================================================================= #
2328
- # === title?
2329
- # ========================================================================= #
2330
- def title?(i = @title)
2331
- i
2332
- end; alias my_title? title? # === my_title?
2333
-
2334
- # ========================================================================= #
2335
- # === top_left
2336
- #
2337
- # This method may only work on Gtk::Window, I think.
2338
- # ========================================================================= #
2339
- def top_left
2340
- move(0, 0) if respond_to? :move
2341
- end
2342
-
2343
- # ========================================================================= #
2344
- # === set_height
2345
- # ========================================================================= #
2346
- def set_height(i)
2347
- if i.is_a?(String) and i.include?('%')
2348
- # ===================================================================== #
2349
- # Handle something like '80%'.
2350
- # ===================================================================== #
2351
- i = (max_height? * i.delete('%').to_f) / 100.0
2352
- end
2353
- @height = i.to_i
2354
- end
2355
-
2356
- # ========================================================================= #
2357
- # === height?
2358
- # ========================================================================= #
2359
- def height?(i = @height)
2360
- i
2361
- end
2362
-
2363
- # ========================================================================= #
2364
- # === width?
2365
- # ========================================================================= #
2366
- def width?(i = @width)
2367
- i
2368
- end
2369
-
2370
- # ========================================================================= #
2371
- # === gtk_statusbar_with_handle
2372
- # ========================================================================= #
2373
- def gtk_statusbar_with_handle
2374
- gtk_statusbar { :with_handle }
2375
- end
2376
-
2377
- require 'gtk_paradise/gtk_classes/statusbar.rb'
2378
- # ========================================================================= #
2379
- # === gtk_statusbar
2380
- #
2381
- # Local documentation is available, on my system, via:
2382
- #
2383
- # rf ruby gtk_statusbar
2384
- # http://localhost:10000/gtk#gtk_statusbar
2385
- #
2386
- # Variants may include this:
2387
- #
2388
- # gtk_statusbar { :with_resize_grip }
2389
- # gtk_statusbar { :has_resize_grip }
2390
- # gtk_statusbar { :resize_grip }
2391
- # gtk_statusbar { :with_a_resize_grip }
2392
- #
2393
- # ========================================================================= #
2394
- def gtk_statusbar(
2395
- optional_use_this_as_status_bar = nil
2396
- )
2397
- statusbar = ::Gtk::Statusbar.new
2398
- if optional_use_this_as_status_bar
2399
- @status_bar_context_id = status_bar.get_context_id(optional_use_this_as_status_bar)
2400
- end
2401
- # ======================================================================= #
2402
- # === Handle blocks next
2403
- # ======================================================================= #
2404
- if block_given?
2405
- case yield
2406
- # ===================================================================== #
2407
- # === :with_resize_grip
2408
- # ===================================================================== #
2409
- when :with_resize_grip,
2410
- :with_a_resize_grip,
2411
- :has_resize_grip,
2412
- :resize_grip,
2413
- :with_handle,
2414
- :grip
2415
- statusbar.has_resize_grip = true if respond_to?(:has_resize_grip)
2416
- end
2417
- end
2418
- return statusbar # And return it here.
2419
- end; alias gtk_status_bar gtk_statusbar # === gtk_status_bar
2420
- alias return_default_status_bar gtk_statusbar # === return_default_status_bar
2421
-
2422
- # ========================================================================= #
2423
- # === interactive_change_the_font
2424
- #
2425
- # Unfortunately this does not work as I would have expected, in 2021 ...
2426
- # ========================================================================= #
2427
- def interactive_change_the_font
2428
- vbox = gtk_vbox
2429
- label = gtk_label('Enter the font:')
2430
- vbox << label
2431
- entry = gtk_entry
2432
- entry.center
2433
- vbox << entry
2434
- a_quit_button = gtk_button('_Quit')
2435
- vbox << a_quit_button
2436
- r = ::Gtk.run
2437
- r << vbox
2438
- r.top_left_then_run
2439
- a_quit_button.on_clicked {
2440
- set_font(entry.text?)
2441
- r.destroy
2442
- }
2443
- end
2444
-
2445
- # ========================================================================= #
2446
- # === is_it_an_enter_key?
2447
- #
2448
- # This method will query whether the given event equals the enter-key.
2449
- #
2450
- # Two different keys may be used for that on most keyboard-devices,
2451
- # which explaines why two when-checks are done, ultimately.
2452
- # ========================================================================= #
2453
- def is_it_an_enter_key?(event)
2454
- case Gdk::Keyval.to_name(event.keyval)
2455
- when 'Return','KP_Enter'
2456
- return true
2457
- else
2458
- return false
2459
- end
2460
- end; alias enter_key? is_it_an_enter_key? # === enter_key?
2461
- alias is_enter_key? is_it_an_enter_key? # === is_enter_key?
2462
-
2463
- require 'gtk_paradise/gtk_classes/file_chooser_dialog.rb'
2464
- # ========================================================================= #
2465
- # === gtk_file_chooser_dialog
2466
- #
2467
- # This method is simply a wrapper over Gtk::FileChooserDialog.
2468
- # ========================================================================= #
2469
- def gtk_file_chooser_dialog(
2470
- label_to_use = '',
2471
- which_widget_to_use,
2472
- which_action_type,
2473
- whatever_here,
2474
- array_cancel,
2475
- array_accept
2476
- )
2477
- ::Gtk::FileChooserDialog.new(
2478
- label_to_use,
2479
- which_widget_to_use,
2480
- which_action_type,
2481
- whatever_here,
2482
- array_cancel,
2483
- array_accept
2484
- )
2485
- end
2486
-
2487
- # ========================================================================= #
2488
- # === gtk_file_chooser_button
2489
- #
2490
- # The first argument to this method is the default text that is to
2491
- # appear on the file-chooser button.
2492
- #
2493
- # Currently (November 2020) you have to handle the click-event in
2494
- # your application.
2495
- #
2496
- # You can use the following line of code for this:
2497
- #
2498
- # file_chooser = gtk_file_chooser_button
2499
- # file_chooser.on_click { create_a_new_file_chooser_dialog(this_widget, use_this_text) }
2500
- #
2501
- # ========================================================================= #
2502
- def gtk_file_chooser_button(
2503
- use_this_text = 'Open File',
2504
- options_hash = {
2505
- use_tooltip_hint: true
2506
- }
2507
- )
2508
- _ = gtk_button(use_this_text)
2509
- # ======================================================================= #
2510
- # === Handle the Hash, the assumed second argument to this method
2511
- # ======================================================================= #
2512
- if options_hash.is_a? Hash
2513
- # ===================================================================== #
2514
- # === :use_tooltip_hint
2515
- # ===================================================================== #
2516
- if options_hash[:use_tooltip_hint]
2517
- _.hint = 'Click on this button to open a local file.'
2518
- end
2519
- end
2520
- return _
2521
- end; alias gtk_file_open_button gtk_file_chooser_button # === gtk_file_open_button
2522
- alias return_file_chooser_button gtk_file_chooser_button # === return_file_chooser_button
2523
- alias default_choose_filer gtk_file_chooser_button # === default_choose_filer
2524
-
2525
- # ========================================================================= #
2526
- # === absolute_file_path
2527
- # ========================================================================= #
2528
- def absolute_file_path(i)
2529
- File.absolute_path(i)
2530
- end
2531
-
2532
- # ========================================================================= #
2533
- # === add_a_horizontal_spacer
2534
- #
2535
- # This variant will automatically add the horizontal-spacer as-is.
2536
- # ========================================================================= #
2537
- def add_a_horizontal_spacer
2538
- add(horizontal_spacer)
2539
- end
2540
-
2541
- # ========================================================================= #
2542
- # === vertical_spacer
2543
- # ========================================================================= #
2544
- def vertical_spacer
2545
- ::Gtk.vertical_spacer
2546
- end; alias vspacer vertical_spacer # === vspacer
2547
- alias gtk_vspacer vertical_spacer # === gtk_vspacer
2548
-
2549
- require 'gtk_paradise/toplevel_methods/spacer.rb'
2550
- # ========================================================================= #
2551
- # === spacer
2552
- # ========================================================================= #
2553
- def spacer
2554
- ::Gtk.spacer
2555
- end; alias gtk_spacer spacer # === gtk_spacer
2556
-
2557
- # ========================================================================= #
2558
- # === create_skeleton_then_connect_skeleton
2559
- #
2560
- # Note that you may have to create your own methods called
2561
- # connect_skeleton() and connect_skeleton().
2562
- # ========================================================================= #
2563
- def create_skeleton_then_connect_skeleton
2564
- create_skeleton
2565
- connect_skeleton
2566
- end
2567
-
2568
- # ========================================================================= #
2569
- # === window_or_vbox
2570
- #
2571
- # This is currently only a vbox. In the future this may be changed,
2572
- # but for now (November 2021) this is how it is.
2573
- #
2574
- # Note that currently the optional_menu argument is ignored.
2575
- # ========================================================================= #
2576
- def window_or_vbox(
2577
- optional_title = '',
2578
- optional_width = 800,
2579
- optional_height = 640,
2580
- optional_menu = 0 # This may also be a Hash.
2581
- )
2582
- _ = vbox
2583
- if optional_title
2584
- _.set_title(optional_title) if _.respond_to?(:set_title)
2585
- end
2586
- if optional_width or optional_height
2587
- _.set_size_request(optional_width, optional_height)
2588
- end
2589
- return _
2590
- end
2591
-
2592
- # ========================================================================= #
2593
- # === run_main
2594
- #
2595
- # This is simply a wrapper over Gtk.main. It was added
2596
- # ========================================================================= #
2597
- def run_main
2598
- Gtk.main
2599
- end
2600
-
2601
- # ========================================================================= #
2602
- # === use_gtk?
2603
- #
2604
- # This is an ad-hoc method; it was used primarily to simplify transitioning
2605
- # into SimpleWidgets.
2606
- # ========================================================================= #
2607
- def use_gtk?
2608
- true
2609
- end
2610
-
2611
- # ========================================================================= #
2612
- # === use_libui?
2613
- #
2614
- # Whether this object is making use of libui. This is logically false if
2615
- # we use gtk, but the reason this method was added was to be able to
2616
- # use different GUIs, so a simple check is useful for that purpose.
2617
- # ========================================================================= #
2618
- def use_libui?
2619
- false
2620
- end
2621
-
2622
- # ========================================================================= #
2623
- # === icon_theme?
2624
- # ========================================================================= #
2625
- def icon_theme?
2626
- ::Gtk::IconTheme.default
2627
- end
2628
-
2629
- # ========================================================================= #
2630
- # === text_then_entry
2631
- #
2632
- # This method will return a hbox, which in turn contains a text, and
2633
- # then an entry for user input.
2634
- #
2635
- # Three elements will be returned: the hbox, then the text (a gtk-label)
2636
- # and finally the entry (a gtk-entry).
2637
- #
2638
- # The method may be called with some variation, such as:
2639
- #
2640
- # text_then_entry('Name of the card', padding: 5)
2641
- #
2642
- # ========================================================================= #
2643
- def text_then_entry(
2644
- this_text = '',
2645
- use_this_padding = 0
2646
- )
2647
- hbox = gtk_hbox
2648
- text = gtk_text(this_text)
2649
- entry = gtk_entry
2650
- hbox.minimal(text, use_this_padding)
2651
- hbox.minimal(entry, use_this_padding)
2652
- return [hbox, text, entry]
2653
- end
2654
-
2655
- # ========================================================================= #
2656
- # === gtk_hbox
2657
- #
2658
- # Wrapper-method towards Gtk::HBox. In other words, this method will
2659
- # create a new horizontal-box.
2660
- #
2661
- # Note that you can also pass a Hash, as a block.
2662
- #
2663
- # Example:
2664
- #
2665
- # hbox = gtk_hbox {{ spacing: 10 }}
2666
- #
2667
- # ========================================================================= #
2668
- def gtk_hbox(
2669
- *i,
2670
- &block
2671
- )
2672
- if i and i.is_a?(Array) and i.empty? and block_given?
2673
- i = [yield]
2674
- end
2675
- if i.is_a? Array
2676
- first = i.first
2677
- # ===================================================================== #
2678
- # === Handle the situation when the first element is a Hash
2679
- # ===================================================================== #
2680
- if first.is_a? Hash
2681
- new_result = []
2682
- # =================================================================== #
2683
- # {:label=>"File path:", :entry=>#<Gtk::Entry:0x7fae47a04cc0 ptr=0x7fae481e6450>}
2684
- # =================================================================== #
2685
- first.each_pair {|key, value|
2686
- case key
2687
- # ================================================================= #
2688
- # === :label
2689
- # ================================================================= #
2690
- when :label
2691
- new_result << ::Gtk.label(value)
2692
- # ================================================================= #
2693
- # === :entry
2694
- # ================================================================= #
2695
- when :entry
2696
- new_result << ::Gtk.entry # (value)
2697
- # ================================================================= #
2698
- # === :button
2699
- # ================================================================= #
2700
- when :button
2701
- new_result << ::Gtk.button
2702
- end
2703
- }
2704
- i = new_result unless new_result.empty?
2705
- end
2706
- end
2707
- i.flatten! if i.is_a? Array
2708
- ::Gtk.hbox(i, &block)
2709
- end; alias create_hbox gtk_hbox # === create_hbox
2710
- alias hbox gtk_hbox # === hbox
2711
-
2712
- # ========================================================================= #
2713
- # === create_a_new_file_chooser_dialog
2714
- #
2715
- # The first argument should be a Gtk::Window instance.
2716
- #
2717
- # Usage examples:
2718
- #
2719
- # create_a_new_file_chooser_dialog {{ filter: '.pdf' }}
2720
- # create_a_new_file_chooser_dialog {{ filter_for: '.pdb' }}
2721
- # create_a_new_file_chooser_dialog {{ filter_for: '.md', additional_folders: '/Depot/j/' }}
2722
- # create_a_new_file_chooser_dialog {{ filter_for: '.md', additional_folders: '/Depot/j/', start_dir: '/tmp/' }}
2723
- #
2724
- # ========================================================================= #
2725
- def create_a_new_file_chooser_dialog(
2726
- this_widget = self,
2727
- use_this_text = 'Open File',
2728
- &block
2729
- )
2730
- action_open = :open
2731
- if ::Gtk.use_gtk2?
2732
- action_open = ::Gtk::FileChooser::ACTION_OPEN
2733
- end
2734
- case this_widget
2735
- when nil
2736
- this_widget = self
2737
- end
2738
- # ======================================================================= #
2739
- # Assign to the @file_chooser_dialog variable next.
2740
- # ======================================================================= #
2741
- if ::Gtk.use_gtk2?
2742
- @file_chooser_dialog = FileChooserDialog.new(
2743
- use_this_text,
2744
- this_widget,
2745
- action_open,
2746
- nil,
2747
- [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
2748
- [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT]
2749
- )
2750
- else # else assume ruby-gtk3.
2751
- @file_chooser_dialog = FileChooserDialog.new(
2752
- title: use_this_text,
2753
- action: action_open,
2754
- buttons: [[Gtk::Stock::OPEN, :accept],
2755
- [Gtk::Stock::CANCEL, :cancel]]
2756
- )
2757
- # ===================================================================== #
2758
- # Give it a name - that way people can re-define the looks as-is
2759
- # via CSS.
2760
- # ===================================================================== #
2761
- @file_chooser_dialog.set_name('custom_file_chooser_dialog')
2762
- end
2763
- @file_chooser_dialog.current_folder = return_pwd
2764
- @file_chooser_dialog.show_hidden = true # Do show hidden files.
2765
- # ======================================================================= #
2766
- # === Handle blocks next
2767
- # ======================================================================= #
2768
- if block_given?
2769
- yielded = yield
2770
- # ===================================================================== #
2771
- # === Handle Hashes next
2772
- # ===================================================================== #
2773
- if yielded.is_a? Hash
2774
- # =================================================================== #
2775
- # === additional_folders
2776
- #
2777
- # This can be used like so:
2778
- #
2779
- # additional_folders: '/Depot/j/'
2780
- #
2781
- # =================================================================== #
2782
- if yielded.has_key? :additional_folders
2783
- _ = yielded[:additional_folders]
2784
- if _.is_a? Array
2785
- _.each {|this_entry|
2786
- @file_chooser_dialog.add_this_directory(this_entry)
2787
- }
2788
- else
2789
- @file_chooser_dialog.add_this_directory(_)
2790
- end
2791
- # =================================================================== #
2792
- # === additional_directories
2793
- #
2794
- # This is an alias to the above.
2795
- # =================================================================== #
2796
- elsif yielded.has_key? :additional_directories
2797
- _ = yielded[:additional_directories]
2798
- if _.is_a? Array
2799
- _.flatten.each {|this_entry|
2800
- @file_chooser_dialog.add_this_directory(this_entry)
2801
- }
2802
- else
2803
- @file_chooser_dialog.add_this_directory(_)
2804
- end
2805
- end
2806
- # =================================================================== #
2807
- # === :start_dir
2808
- #
2809
- # This allows us to use another start-directory.
2810
- # =================================================================== #
2811
- if yielded.has_key? :start_dir
2812
- _ = yielded[:start_dir].to_s
2813
- @file_chooser_dialog.cd_to(_)
2814
- # =================================================================== #
2815
- # === :start_directory
2816
- # =================================================================== #
2817
- elsif yielded.has_key? :start_directory
2818
- _ = yielded[:start_directory].to_s
2819
- @file_chooser_dialog.cd_to(_)
2820
- end
2821
- # =================================================================== #
2822
- # === :current_folder
2823
- #
2824
- # This is different to :start_directory, because the former only
2825
- # cds, whereas the entry here does both.
2826
- # =================================================================== #
2827
- if yielded.has_key? :current_folder
2828
- _ = yielded[:current_folder]
2829
- if _ and File.directory?(_)
2830
- @file_chooser_dialog.current_folder = _
2831
- @file_chooser_dialog.cd_to(_)
2832
- end
2833
- end
2834
- # =================================================================== #
2835
- # === :filter
2836
- #
2837
- # This allows us to filter towards a particular file-type.
2838
- # =================================================================== #
2839
- if yielded.has_key? :filter
2840
- _ = yielded[:filter]
2841
- @file_chooser_dialog.add_filter(
2842
- gtk_file_filter(_) # Apply the file-filter here.
2843
- )
2844
- # =================================================================== #
2845
- # === :filter_for
2846
- # =================================================================== #
2847
- elsif yielded.has_key? :filter_for
2848
- _ = yielded[:filter_for].to_s
2849
- @file_chooser_dialog.add_filter(
2850
- gtk_file_filter(_) # Apply the file-filter here.
2851
- )
2852
- end
2853
- # =================================================================== #
2854
- # === :extra_widget
2855
- # =================================================================== #
2856
- if yielded.has_key? :extra_widget
2857
- _ = yielded[:extra_widget]
2858
- @file_chooser_dialog.extra_widget = _
2859
- end
2860
- # =================================================================== #
2861
- # === :show_hidden
2862
- # =================================================================== #
2863
- if yielded.has_key? :show_hidden
2864
- _ = yielded[:show_hidden]
2865
- @file_chooser_dialog.show_hidden = _
2866
- end
2867
- # =================================================================== #
2868
- # === :show_hidden_files
2869
- # =================================================================== #
2870
- if yielded.has_key? :show_hidden_files
2871
- @file_chooser_dialog.show_hidden = true # Do show hidden files.
2872
- end
2873
- end
2874
- end
2875
- response_accept = Gtk::ResponseType::ACCEPT
2876
- if ::Gtk.use_gtk2?
2877
- response_accept = Gtk::Dialog::RESPONSE_ACCEPT
2878
- end
2879
- case @file_chooser_dialog.run
2880
- when response_accept
2881
- filename = @file_chooser_dialog.filename
2882
- # ===================================================================== #
2883
- # We will next store the filename on the toplevel "namespace". This
2884
- # allows the user to query the designated file via a query-method.
2885
- #
2886
- # This can be queried via: Gtk.main_file?
2887
- # ===================================================================== #
2888
- ::Gtk.set_main_file(filename)
2889
- end
2890
- @file_chooser_dialog.destroy
2891
- return @file_chooser_dialog
2892
- end; alias new_file_chooser_dialog create_a_new_file_chooser_dialog # === new_file_chooser_dialog
2893
- alias open_local_file create_a_new_file_chooser_dialog # === open_local_file
2894
- alias do_open_a_file create_a_new_file_chooser_dialog # === do_open_a_file
2895
- alias look_for_a_local_file create_a_new_file_chooser_dialog # === look_for_a_local_file
2896
-
2897
- # ========================================================================= #
2898
- # === gtk_about_dialog
2899
- # ========================================================================= #
2900
- def gtk_about_dialog
2901
- ::Gtk::AboutDialog.new
2902
- end
2903
-
2904
- require 'gtk_paradise/gtk_classes/hscale.rb'
2905
- # ========================================================================= #
2906
- # === gtk_hscale
2907
- # ========================================================================= #
2908
- def gtk_hscale(a = 0.5, b = 0, c = 0)
2909
- if a.is_a? Hash
2910
- if a.has_key? :n_digits
2911
- a = a[:n_digits]
2912
- a = ::Gtk::Adjustment.new(a, b, c, 0, 0, 0)
2913
- end
2914
- end
2915
- if ::Gtk.use_gtk2?
2916
- ::Gtk::HScale.new(a, b, c)
2917
- else
2918
- ::Gtk::Scale.new(:horizontal, a, b, c)
2919
- end
2920
- end; alias hscale gtk_hscale # === hscale
2921
-
2922
- require 'gtk_paradise/gtk_classes/vscale.rb'
2923
- # ========================================================================= #
2924
- # === gtk_vscale
2925
- # ========================================================================= #
2926
- def gtk_vscale(a = 0.5, b = 0, c = 0)
2927
- if a.is_a? Hash
2928
- if a.has_key? :n_digits
2929
- a = a[:n_digits]
2930
- a = ::Gtk::Adjustment.new(a, b, c, 0, 0, 0)
2931
- end
2932
- end
2933
- if ::Gtk.use_gtk2?
2934
- ::Gtk::VScale.new(a, b, c)
2935
- else
2936
- ::Gtk::Scale.new(:vertical, a, b, c)
2937
- end
2938
- end; alias vscale gtk_vscale # === vscale
2939
-
2940
- end
2941
-
2942
- # =========================================================================== #
2943
- # === Gtk.directory_to_the_images?
2944
- # =========================================================================== #
2945
- def self.directory_to_the_images?
2946
- ::Gtk::BaseModule::IMG_DIR
2947
- end
2948
-
2949
- end