gtk_paradise 0.12.25 → 0.13.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +997 -1065
- data/bin/gtk_display_this_file +0 -2
- data/bin/run_this_widget +7 -0
- data/doc/README.gen +995 -1063
- data/doc/todo/recurring_todo_tasks.md +8 -8
- data/doc/todo/{TODO_FOR_THE_GTK_EDITOR.md → todo_for_the_gtk_editor.md} +4 -3
- data/doc/todo/{TODO_FOR_THE_GTK_PARADISE_PROJECT.md → todo_for_the_gtk_paradise_project.md} +55 -36
- data/gtk_paradise.gemspec +0 -7
- data/lib/gtk_paradise/base_module/base_module.rb +5965 -5054
- data/lib/gtk_paradise/base_module/internal_hash_module/internal_hash_module.rb +205 -0
- data/lib/gtk_paradise/{base_module_and_app_module/base_module_and_app_module.rb → base_module_and_run_module/base_module_and_run_module.rb} +5 -5
- data/lib/gtk_paradise/{base_module/widgets/widgets.rb → base_module_widgets/base_module_widgets.rb} +28 -5
- data/lib/gtk_paradise/{css_files → cascading_style_sheets}/colours.css +58 -57
- data/lib/gtk_paradise/{css_files → cascading_style_sheets}/css_accordion.css +2 -1
- data/lib/gtk_paradise/{css_files → cascading_style_sheets}/hover_effects.css +0 -1
- data/lib/gtk_paradise/{css_files → cascading_style_sheets}/project.css +16 -13
- data/lib/gtk_paradise/colours/colour_palette/material_design.rb +35 -18
- data/lib/gtk_paradise/colours/parse.rb +4 -2
- data/lib/gtk_paradise/commandline/commandline.rb +13 -7
- data/lib/gtk_paradise/constants/constants.rb +84 -174
- data/lib/gtk_paradise/{gtk_classes → core_classes}/about.rb +2 -2
- data/lib/gtk_paradise/{gtk_classes → core_classes}/about_dialog.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/accel_group.rb +3 -7
- data/lib/gtk_paradise/{gtk_classes → core_classes}/alignment.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/application.rb +2 -2
- data/lib/gtk_paradise/{gtk_classes → core_classes}/application_window.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/box.rb +11 -7
- data/lib/gtk_paradise/{gtk_classes → core_classes}/button.rb +59 -61
- data/lib/gtk_paradise/{gtk_classes → core_classes}/button_box.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/cairo/context.rb +2 -2
- data/lib/gtk_paradise/{gtk_classes → core_classes}/calendar.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/cell_renderer_text.rb +2 -2
- data/lib/gtk_paradise/{gtk_classes → core_classes}/check_button.rb +60 -58
- data/lib/gtk_paradise/{gtk_classes → core_classes}/combo_box.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/combo_box_entry.rb +5 -4
- data/lib/gtk_paradise/{gtk_classes → core_classes}/combo_box_text.rb +54 -18
- data/lib/gtk_paradise/{gtk_classes → core_classes}/dialog.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/entry.rb +17 -3
- data/lib/gtk_paradise/{gtk_classes → core_classes}/entry_completion.rb +5 -3
- data/lib/gtk_paradise/{gtk_classes → core_classes}/event_box.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/event_button.rb +6 -8
- data/lib/gtk_paradise/{gtk_classes → core_classes}/event_key.rb +2 -2
- data/lib/gtk_paradise/{gtk_classes → core_classes}/expander.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/file_chooser_dialog.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/file_filter.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/file_selection.rb +11 -7
- data/lib/gtk_paradise/{gtk_classes → core_classes}/frame.rb +4 -4
- data/lib/gtk_paradise/{gtk_classes → core_classes}/grid.rb +136 -80
- data/lib/gtk_paradise/{gtk_classes → core_classes}/hbox.rb +4 -2
- data/lib/gtk_paradise/{gtk_classes → core_classes}/header_bar.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/hscale.rb +5 -7
- data/lib/gtk_paradise/{gtk_classes → core_classes}/image.rb +15 -12
- data/lib/gtk_paradise/{gtk_classes → core_classes}/image_menu_item.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/label.rb +29 -22
- data/lib/gtk_paradise/{gtk_classes → core_classes}/list_store.rb +6 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/menu.rb +2 -6
- data/lib/gtk_paradise/{gtk_classes → core_classes}/menu_bar.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/menu_item.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/notebook.rb +35 -20
- data/lib/gtk_paradise/{gtk_classes → core_classes}/option_menu.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/paned.rb +7 -4
- data/lib/gtk_paradise/{gtk_classes → core_classes}/popover.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/radio_button.rb +2 -2
- data/lib/gtk_paradise/{gtk_classes → core_classes}/radio_menu_item.rb +6 -14
- data/lib/gtk_paradise/{gtk_classes → core_classes}/scale_button.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/scrolled_window.rb +75 -48
- data/lib/gtk_paradise/{gtk_classes → core_classes}/search_bar.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/size_group.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/source_buffer.rb +2 -2
- data/lib/gtk_paradise/{gtk_classes → core_classes}/source_view.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/spin_button.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/spinner.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/status_icon.rb +2 -6
- data/lib/gtk_paradise/{gtk_classes → core_classes}/statusbar.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/style_context.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/text_buffer.rb +3 -7
- data/lib/gtk_paradise/{gtk_classes → core_classes}/text_tag.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/text_view.rb +19 -14
- data/lib/gtk_paradise/{gtk_classes → core_classes}/toggle_button.rb +2 -2
- data/lib/gtk_paradise/{gtk_classes → core_classes}/toolbar.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/tree_iter.rb +2 -2
- data/lib/gtk_paradise/{gtk_classes → core_classes}/tree_selection.rb +5 -3
- data/lib/gtk_paradise/{gtk_classes → core_classes}/tree_view.rb +28 -39
- data/lib/gtk_paradise/{gtk_classes → core_classes}/tree_view_column.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/vbox.rb +2 -2
- data/lib/gtk_paradise/{gtk_classes → core_classes}/vscale.rb +5 -7
- data/lib/gtk_paradise/{gtk_classes → core_classes}/vte.rb +1 -1
- data/lib/gtk_paradise/{gtk_classes → core_classes}/widget.rb +1086 -1111
- data/lib/gtk_paradise/{gtk_classes → core_classes}/window.rb +25 -12
- data/lib/gtk_paradise/drawing/README.md +2 -2
- data/lib/gtk_paradise/drawing/drawing.rb +6 -4
- data/lib/gtk_paradise/drawing/event.rb +7 -5
- data/lib/gtk_paradise/drawing/star.rb +20 -9
- data/lib/gtk_paradise/drawing/tool.rb +3 -1
- data/lib/gtk_paradise/drawing/turtle.rb +4 -2
- data/lib/gtk_paradise/emojis/emojis.rb +4 -676
- data/lib/gtk_paradise/examples/advanced/001_5x5_grid_example.rb +4 -7
- data/lib/gtk_paradise/examples/advanced/002_advanced_drag_and_drop_example.rb +3 -9
- data/lib/gtk_paradise/examples/advanced/003_html_like_support.rb +4 -11
- data/lib/gtk_paradise/examples/advanced/005_csv_example.rb +0 -2
- data/lib/gtk_paradise/examples/advanced/006_file_chooser_button_example.rb +6 -13
- data/lib/gtk_paradise/examples/advanced/007_label_responding_to_events_example.rb +5 -13
- data/lib/gtk_paradise/examples/advanced/008_options_example.rb +0 -4
- data/lib/gtk_paradise/examples/advanced/009_key_events.rb +3 -12
- data/lib/gtk_paradise/examples/advanced/010_extensive_text_view_example.rb +2 -10
- data/lib/gtk_paradise/examples/advanced/011_moving_blocks_example.rb +0 -7
- data/lib/gtk_paradise/examples/advanced/012_cell_data_sorting_example.rb +0 -4
- data/lib/gtk_paradise/examples/advanced/013_advanced_css_example.rb +3 -12
- data/lib/gtk_paradise/examples/advanced/014_popup_example.rb +3 -12
- data/lib/gtk_paradise/examples/advanced/015_advanced_button_example.rb +8 -13
- data/lib/gtk_paradise/examples/advanced/016_change_background_on_click_event.rb +0 -2
- data/lib/gtk_paradise/examples/advanced/017_lean_CSS_example.rb +2 -10
- data/lib/gtk_paradise/examples/advanced/018_coloured_text_example.rb +2 -10
- data/lib/gtk_paradise/examples/advanced/019_gtk_entry_showing_the_cursor_position.rb +1 -3
- data/lib/gtk_paradise/examples/advanced/020_scale_this_image.rb +8 -12
- data/lib/gtk_paradise/examples/advanced/021_scroll_events_on_gtk_entry.rb +0 -1
- data/lib/gtk_paradise/examples/advanced/022_autogenerated_CSS_rounded_borders.rb +15 -19
- data/lib/gtk_paradise/examples/advanced/023_append_image_to_buffer.rb +8 -14
- data/lib/gtk_paradise/examples/advanced/024_notebook_with_tab_example.rb +1 -1
- data/lib/gtk_paradise/examples/advanced/025_showing_a_gold_caret_on_black_background.rb +6 -5
- data/lib/gtk_paradise/examples/advanced/026_status_bar_example.rb +2 -5
- data/lib/gtk_paradise/examples/advanced/027_customized_frame_example.rb +4 -7
- data/lib/gtk_paradise/examples/advanced/028_widgets_described_in_a_yaml_file.rb +17 -20
- data/lib/gtk_paradise/examples/advanced/029_entry_completion_example.rb +4 -9
- data/lib/gtk_paradise/examples/advanced/030_parse_into_table_example.rb +132 -0
- data/lib/gtk_paradise/{widgets/gtk3/calculator/calculator.rb → examples/advanced/031_combo_box_example.rb} +77 -92
- data/lib/gtk_paradise/examples/cairo/three_rectangles.rb +4 -4
- data/lib/gtk_paradise/examples/controller/controller.rb +27 -24
- data/lib/gtk_paradise/examples/gir_ffi/advanced/001_advanced_treeview_example.rb +1 -1
- data/lib/gtk_paradise/examples/gir_ffi/gtk2/001_hello_world.rb +30 -0
- data/lib/gtk_paradise/examples/gir_ffi/gtk2/002_upgraded_hello_world.rb +42 -0
- data/lib/gtk_paradise/examples/gir_ffi/gtk2/004_treeview_example.rb +62 -0
- data/lib/gtk_paradise/examples/gir_ffi/gtk2/005_complex_example.rb +102 -0
- data/lib/gtk_paradise/examples/gir_ffi/gtk2/101_all_in_one_example.rb +23 -0
- data/lib/gtk_paradise/examples/gir_ffi/{005_complex_example.rb → gtk3/005_complex_example.rb} +2 -2
- data/lib/gtk_paradise/examples/glib/parse_glib_settings.rb +1 -1
- data/lib/gtk_paradise/examples/gtk2/001_tooltips_example.rb +15 -6
- data/lib/gtk_paradise/examples/gtk2/003_draw_rectangle.rb +1 -1
- data/lib/gtk_paradise/examples/gtk2/011_password_example.rb +10 -4
- data/lib/gtk_paradise/examples/gtk2/README.md +5 -0
- data/lib/gtk_paradise/examples/gtk3/001_examples_with_css.rb +320 -0
- data/lib/gtk_paradise/examples/gtk3/{077_button_box_example.rb → 003_button_box_example.rb} +13 -4
- data/lib/gtk_paradise/examples/gtk3/{056_font_chooser_dialog_example.rb → 005_font_chooser_dialog_example.rb} +3 -2
- data/lib/gtk_paradise/examples/gtk3/{073_image_example.rb → 007_image_example.rb} +4 -1
- data/lib/gtk_paradise/examples/gtk3/{051_combo_box_example.rb → 009_combo_box_example.rb} +3 -2
- data/lib/gtk_paradise/examples/gtk3/{033_list_box_example.rb → 010_list_box_example.rb} +1 -0
- data/lib/gtk_paradise/examples/gtk3/{021_tiny_button_via_css.rb → 013_tiny_button_via_css.rb} +4 -3
- data/lib/gtk_paradise/examples/gtk3/{025_password_example.rb → 014_password_example.rb} +3 -2
- data/lib/gtk_paradise/examples/gtk3/{047_draw_rectangles.rb → 016_draw_rectangles.rb} +4 -0
- data/lib/gtk_paradise/examples/gtk3/{005_spinner_example.rb → 017_spinner_example.rb} +1 -0
- data/lib/gtk_paradise/examples/gtk3/{078_tree_view_column_example.rb → 018_tree_view_column_example.rb} +1 -1
- data/lib/gtk_paradise/examples/gtk3/{084_recent_chooser_dialog.rb → 019_recent_chooser_dialog.rb} +1 -0
- data/lib/gtk_paradise/examples/gtk3/{072_text_iterator_example.rb → 021_text_iterator_example.rb} +13 -6
- data/lib/gtk_paradise/examples/gtk3/{067_gtk_label_example.rb → 024_gtk_label_example.rb} +3 -3
- data/lib/gtk_paradise/examples/gtk3/{081_vbox_with_spacing_and_border_width.rb → 032_vbox_with_spacing_and_border_width.rb} +1 -1
- data/lib/gtk_paradise/examples/gtk3/{006_text_view_example.rb → 034_text_view_example.rb} +2 -1
- data/lib/gtk_paradise/examples/gtk3/{054_ten_labels_in_a_vertical_box_example.rb → 036_ten_labels_in_a_vertical_box_example.rb} +1 -0
- data/lib/gtk_paradise/examples/gtk3/{029_sockets.rb → 039_sockets.rb} +2 -2
- data/lib/gtk_paradise/examples/gtk3/{053_revealer_example.rb → 041_revealer_example.rb} +11 -2
- data/lib/gtk_paradise/examples/gtk3/{034_hello_world_in_gtk3_and_bold_font.rb → 042_hello_world_in_gtk3_and_bold_font.rb} +1 -1
- data/lib/gtk_paradise/examples/gtk3/{052_notebook_css_example.rb → 043_notebook_css_example.rb} +6 -4
- data/lib/gtk_paradise/examples/gtk3/{038_radio_button_window.rb → 055_radio_button_window.rb} +1 -1
- data/lib/gtk_paradise/examples/gtk3/{085_showcase_the_cursors.rb → 058_showcase_the_cursors.rb} +10 -1
- data/lib/gtk_paradise/examples/gtk3/{024_small_paned_example.rb → 059_small_paned_example.rb} +1 -0
- data/lib/gtk_paradise/examples/gtk3/{039_scale_button_demo.rb → 060_scale_button_demo.rb} +2 -2
- data/lib/gtk_paradise/examples/gtk3/{010_switch_example.rb → 062_switch_example.rb} +2 -1
- data/lib/gtk_paradise/examples/gtk3/{009_simple_window.rb → 063_simple_window.rb} +1 -0
- data/lib/gtk_paradise/examples/gtk3/{043_hover_button_example_via_css.rb → 066_hover_button_example_via_css.rb} +1 -0
- data/lib/gtk_paradise/examples/gtk3/{020_stack_example.rb → 069_stack_example.rb} +1 -1
- data/lib/gtk_paradise/examples/gtk3/{031_icon_theme_example.rb → 072_icon_theme_example.rb} +8 -4
- data/lib/gtk_paradise/examples/gtk3/{041_horizontal_and_vertical_scale.rb → 073_horizontal_and_vertical_scale.rb} +2 -1
- data/lib/gtk_paradise/examples/gtk3/{022_font_related_information.rb → 076_font_related_information.rb} +5 -3
- data/lib/gtk_paradise/examples/gtk3/{004_simple_dialog_example.rb → 079_simple_dialog_example.rb} +1 -1
- data/lib/gtk_paradise/examples/gtk3/vte/vte3_terminal.rb +1 -1
- data/lib/gtk_paradise/examples/gtk4/001_examples_with_css.rb +320 -0
- data/lib/gtk_paradise/examples/gtk4/{076_ten_vboxes_example.rb → 023_ten_vboxes_example.rb} +10 -10
- data/lib/gtk_paradise/examples/gtk4/{030_notebook_example.rb → 061_notebook_example.rb} +3 -4
- data/lib/gtk_paradise/examples/gtk4/{007_two_windows_example.rb → 087_two_windows_example.rb} +4 -1
- data/lib/gtk_paradise/examples/gtk4/{100_changed_events_example.rb → 200_changed_events_example.rb} +0 -1
- data/lib/gtk_paradise/examples/gtk4/{102_picture_example.rb → 202_picture_example.rb} +1 -1
- data/lib/gtk_paradise/examples/pango/pango_power.rb +11 -6
- data/lib/gtk_paradise/experimental/experimental.rb +2 -2
- data/lib/gtk_paradise/gdk/event_crossing.rb +1 -1
- data/lib/gtk_paradise/gdk/gdk.rb +3 -29
- data/lib/gtk_paradise/gdk/screen.rb +29 -0
- data/lib/gtk_paradise/gnome/README.md +3 -0
- data/lib/gtk_paradise/hello_world/README.md +7 -7
- data/lib/gtk_paradise/hello_world/hello_world_gtk4.rb +1 -1
- data/lib/gtk_paradise/images/misc/investigate.png +0 -0
- data/lib/gtk_paradise/pango/fonts.rb +1 -3
- data/lib/gtk_paradise/pango/pango_renderer.rb +2 -0
- data/lib/gtk_paradise/project/project.rb +2 -1
- data/lib/gtk_paradise/prototypes/gtk3_standalone.rb +7 -7
- data/lib/gtk_paradise/prototypes/gtk4_standalone.rb +1 -1
- data/lib/gtk_paradise/prototypes/unified_gtk_prototype.rb +1 -1
- data/lib/gtk_paradise/requires/{base_module_and_app_module.rb → base_module_and_run_module.rb} +1 -1
- data/lib/gtk_paradise/requires/do_require_the_files_under_the_gtk_classes_subdirectory.rb +2 -2
- data/lib/gtk_paradise/requires/require_files_irrespective_of_the_gtk_version_at_hand.rb +2 -2
- data/lib/gtk_paradise/requires/require_gtk2.rb +16 -3
- data/lib/gtk_paradise/requires/require_gtk3.rb +7 -3
- data/lib/gtk_paradise/requires/{require_gtk2_or_gtk3_or_gtk4.rb → require_gtk3_or_gtk4.rb} +1 -3
- data/lib/gtk_paradise/requires/require_gtk4.rb +7 -4
- data/lib/gtk_paradise/requires/require_the_base_module_and_gtk_run.rb +1 -1
- data/lib/gtk_paradise/requires/{require_the_base_module_the_app_module_and_the_toplevel_methods.rb → require_the_base_module_the_run_module_and_the_toplevel_methods.rb} +2 -2
- data/lib/gtk_paradise/requires/require_the_base_module_widgets.rb +9 -0
- data/lib/gtk_paradise/requires/require_the_default_gtk_version.rb +1 -1
- data/lib/gtk_paradise/requires/run_this_widget.rb +1 -1
- data/lib/gtk_paradise/run/run.rb +410 -0
- data/lib/gtk_paradise/run.rb +5 -29
- data/lib/gtk_paradise/{app/app_module/app_module.rb → run_module/run_module.rb} +946 -1016
- data/lib/gtk_paradise/toplevel_methods/css.rb +18 -15
- data/lib/gtk_paradise/toplevel_methods/cursor.rb +5 -4
- data/lib/gtk_paradise/toplevel_methods/determine_which_gtk_version_is_in_use.rb +1 -1
- data/lib/gtk_paradise/toplevel_methods/e.rb +12 -0
- data/lib/gtk_paradise/toplevel_methods/keys.rb +1 -1
- data/lib/gtk_paradise/toplevel_methods/screen_resolution.rb +7 -6
- data/lib/gtk_paradise/toplevel_methods/{text_buffer_tags.rb → tokenizer_and_text_buffer_tags.rb} +115 -0
- data/lib/gtk_paradise/toplevel_methods/toplevel_methods.rb +667 -673
- data/lib/gtk_paradise/utility_scripts/commandline_to_automatic_gui.rb +8 -8
- data/lib/gtk_paradise/utility_scripts/generate_gtk_prototype.rb +5 -31
- data/lib/gtk_paradise/version/upstream_gtk_version.rb +3 -25
- data/lib/gtk_paradise/version/version.rb +4 -3
- data/lib/gtk_paradise/widgets/gtk2/README.md +5 -0
- data/lib/gtk_paradise/widgets/gtk2/pdfwalker/imgview.rb +1 -2
- data/lib/gtk_paradise/widgets/gtk2/table_example.rb +0 -1
- data/lib/gtk_paradise/widgets/gtk3/audio_button/audio_button.rb +13 -7
- data/lib/gtk_paradise/widgets/gtk3/burn_this_iso_file/burn_this_iso_file.rb +5 -21
- data/lib/gtk_paradise/widgets/gtk3/button_open_remote_webpage/button_open_remote_webpage.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/button_with_border/button_with_border.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/button_xorg_buffer/button_xorg_buffer.rb +6 -20
- data/lib/gtk_paradise/widgets/gtk3/checkbox_image/checkbox_image.rb +4 -20
- data/lib/gtk_paradise/widgets/gtk3/coloured_button/coloured_button.rb +3 -6
- data/lib/gtk_paradise/widgets/gtk3/coloured_unit/coloured_unit.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/cpu_widget/cpu_widget.rb +3 -15
- data/lib/gtk_paradise/widgets/gtk3/directory_content_widget/directory_content_widget.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/editor/editor.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/editor/internal_widgets/goto_line_widget.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/files_in_directory/files_in_directory.rb +1 -13
- data/lib/gtk_paradise/widgets/gtk3/font_size_widget/action_button.rb +2 -4
- data/lib/gtk_paradise/widgets/gtk3/font_size_widget/font_size_widget.rb +6 -27
- data/lib/gtk_paradise/widgets/gtk3/four_components_entry/four_components_entry.rb +8 -8
- data/lib/gtk_paradise/widgets/gtk3/gidnight_commander/gidnight_commander.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/image_viewer/image_viewer.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/keyboard/keyboard.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/linux_users/linux_users.rb +9 -9
- data/lib/gtk_paradise/widgets/gtk3/my_calendar/my_calendar.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/my_image_menu_item/my_image_menu_item.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/non_numbers_only/non_numbers_only.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/note_window/note_window.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/notebook_tab_with_icon/notebook_tab_with_icon.rb +2 -3
- data/lib/gtk_paradise/widgets/gtk3/notebook_with_storage_functionality/notebook_with_storage_functionality.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/numbers_only/numbers_only.rb +9 -3
- data/lib/gtk_paradise/widgets/gtk3/regex_matcher/regex_matcher.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/rename_widget/rename_widget.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/show_which_key_was_pressed/show_which_key_was_pressed.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/stopwatch/stopwatch.rb +12 -14
- data/lib/gtk_paradise/widgets/gtk3/sys_message/sys_message.rb +2 -4
- data/lib/gtk_paradise/widgets/gtk3/system_information/system_information.rb +2 -2
- data/lib/gtk_paradise/widgets/gtk3/type_trainer/type_trainer.rb +14 -6
- data/lib/gtk_paradise/widgets/gtk3/view_webpage/view_webpage.rb +16 -28
- data/lib/gtk_paradise/widgets/gtk3/widget_switcher/widget_switcher.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk3/wiki/README.md +3 -4
- data/lib/gtk_paradise/widgets/gtk3/wiki/wiki.rb +13 -15
- data/lib/gtk_paradise/widgets/gtk4/show_icon_theme/show_icon_theme.rb +1 -1
- data/lib/gtk_paradise/widgets/gtk4/sys_message/sys_message.rb +1 -1
- data/lib/gtk_paradise/widgets/shared_code/browser/browser_module.rb +5 -8
- data/lib/gtk_paradise/widgets/shared_code/burning_widget/burning_widget_module.rb +3 -20
- data/lib/gtk_paradise/widgets/shared_code/cdripper/cdripper_module.rb +2 -18
- data/lib/gtk_paradise/widgets/shared_code/colour_filled_widget/colour_filled_widget_module.rb +2 -3
- data/lib/gtk_paradise/widgets/shared_code/colour_palette/colour_palette_module.rb +4 -20
- data/lib/gtk_paradise/widgets/shared_code/conky/conky_module.rb +18 -29
- data/lib/gtk_paradise/widgets/shared_code/customizable_dialog/customizable_dialog.rb +1 -6
- data/lib/gtk_paradise/widgets/shared_code/emoji_toggle_widget/emoji_toggle_widget_module.rb +2 -14
- data/lib/gtk_paradise/widgets/shared_code/emoji_widget/emoji_widget_module.rb +3 -12
- data/lib/gtk_paradise/widgets/shared_code/error_widget/error_widget_module.rb +4 -8
- data/lib/gtk_paradise/widgets/shared_code/file_path_widget/file_path_widget_module.rb +5 -3
- data/lib/gtk_paradise/widgets/shared_code/file_viewer/file_viewer_module.rb +2 -34
- data/lib/gtk_paradise/widgets/shared_code/lsmod/lsmod_module.rb +1 -1
- data/lib/gtk_paradise/widgets/shared_code/lspci/lspci_module.rb +2 -5
- data/lib/gtk_paradise/widgets/shared_code/mini_clock/mini_clock_module.rb +1 -3
- data/lib/gtk_paradise/widgets/shared_code/pid_displayer/pid_displayer_module.rb +7 -18
- data/lib/gtk_paradise/widgets/shared_code/random_image/random_image_module.rb +6 -18
- data/lib/gtk_paradise/widgets/shared_code/select_file/select_file_module.rb +2 -18
- data/lib/gtk_paradise/widgets/shared_code/user/user_module.rb +43 -32
- data/lib/gtk_paradise/widgets/shared_code/wget_wrapper/wget_wrapper_module.rb +10 -27
- data/lib/gtk_paradise/www/index.cgi +4 -4
- data/lib/gtk_paradise/xbm_icons/xbm_icons.rb +118 -0
- data/lib/gtk_paradise/yaml/browser_URLs.yml +4 -4
- data/lib/gtk_paradise/yaml/notebook_controller.yml +0 -2
- data/lib/gtk_paradise.rb +0 -0
- data/test/gir_ffi_gtk/testing_gir_ffi_gtk2.rb +55 -0
- data/test/gir_ffi_gtk/testing_gir_ffi_gtk3.rb +55 -0
- data/test/gtk3/testing_app.rb +1 -1
- data/test/gtk3/testing_base_module.rb +13 -7
- data/test/misc/testing_a_gtk_frame.rb +3 -2
- data/test/misc/testing_gtk4_simplifications.rb +2 -4
- data/test/misc/testing_gtk_paradise_runner.rb +3 -4
- data/test/misc/testing_numbered_lines.rb +2 -0
- data/test/misc/testing_the_gtk_classes.rb +1 -1
- metadata +234 -236
- data/lib/gtk_paradise/app/app.rb +0 -239
- data/lib/gtk_paradise/base_module/class_methods/class_methods.rb +0 -0
- data/lib/gtk_paradise/base_module/colours.rb +0 -125
- data/lib/gtk_paradise/base_module/css.rb +0 -487
- data/lib/gtk_paradise/base_module/html_support.rb +0 -255
- data/lib/gtk_paradise/base_module/these_methods_work_for_gtk3_and_gtk4.rb +0 -171
- data/lib/gtk_paradise/examples/gtk3/063_examples_with_css.rb +0 -261
- data/lib/gtk_paradise/examples/gtk4/009_text_view_example.rb +0 -30
- data/lib/gtk_paradise/requires/require_base_module.rb +0 -7
- data/lib/gtk_paradise/run_this_widget/run_this_widget.rb +0 -129
- data/lib/gtk_paradise/toplevel_methods/tokenizer.rb +0 -118
- data/lib/gtk_paradise/widgets/gtk3/ping_widget/ping_widget.rb +0 -513
- data/lib/gtk_paradise/widgets/shared_code/calculator/calculator_module.rb +0 -581
- data/lib/gtk_paradise/widgets/shared_code/simple_clock/simple_clock_module.rb +0 -255
- /data/lib/gtk_paradise/{css_files → cascading_style_sheets}/borders.css +0 -0
- /data/lib/gtk_paradise/{css_files → cascading_style_sheets}/themes/README.md +0 -0
- /data/lib/gtk_paradise/{css_files → cascading_style_sheets}/themes/rainbow_theme.css +0 -0
- /data/lib/gtk_paradise/examples/gdk/{001_gdk_screen_properties.rb → gdk_screen_properties.rb} +0 -0
- /data/lib/gtk_paradise/examples/gir_ffi/{001_hello_world.rb → gtk3/001_hello_world.rb} +0 -0
- /data/lib/gtk_paradise/examples/gir_ffi/{002_upgraded_hello_world.rb → gtk3/002_upgraded_hello_world.rb} +0 -0
- /data/lib/gtk_paradise/examples/gir_ffi/{003_gtk_application_example.rb → gtk3/003_gtk_application_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gir_ffi/{004_treeview_example.rb → gtk3/004_treeview_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{001_gtk_entry.rb → 002_gtk_entry.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{075_gtk_expander.rb → 004_gtk_expander.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{036_buttons_showcasing_the_relief.rb → 006_buttons_showcasing_the_relief.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{050_cell_renderer_pixbuf_example.rb → 008_cell_renderer_pixbuf_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{044_spin_button_example.rb → 011_spin_button_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{064_accel_group_example.rb → 012_accel_group_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{048_colour_choose_button.rb → 015_colour_choose_button.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{086_app_chooser_button_example.rb → 020_app_chooser_button_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{018_message_dialog_example.rb → 022_message_dialog_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{076_ten_vboxes_example.rb → 023_ten_vboxes_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{071_button_demo.rb → 025_button_demo.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{074_frame_example.rb → 026_frame_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{080_vertical_boxes.rb → 027_vertical_boxes.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{032_switcher_window.rb → 028_switcher_window.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{057_flowbox.rb → 029_flowbox.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{066_header_bar_example.rb → 030_header_bar_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{049_drag_and_drop_example.rb → 031_drag_and_drop_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{055_threads_example.rb → 033_threads_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{079_tooltips_example.rb → 035_tooltips_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{087_calendar_example.rb → 037_calendar_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{060_check_button.rb → 038_check_button.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{062_event_box_example.rb → 040_event_box_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{042_installation_assistant.rb → 044_installation_assistant.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{053_css_example_of_a_button_changing_the_background_colour_on_click_event.rb → 045_css_example_of_a_button_changing_the_background_colour_on_click_event.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{017_extensive_markup_example.rb → 046_extensive_markup_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{059_form_example.rb → 047_form_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{068_popover_example.rb → 048_popover_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{012_show_the_xid_example.rb → 049_show_the_xid_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{016_scrolling_example.rb → 050_scrolling_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{065_change_the_application_theme.rb → 051_change_the_application_theme.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{058_colourized_button_example.rb → 052_colourized_button_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{035_grid_example.rb → 053_grid_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{027_menubar_example.rb → 054_menubar_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{040_popup_example.rb → 056_popup_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{069_entry_completion.rb → 057_entry_completion.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{030_notebook_example.rb → 061_notebook_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{014_undecorated_window_example.rb → 064_undecorated_window_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{026_progress_bar_example.rb → 065_progress_bar_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{028_paned_widget_example.rb → 067_paned_widget_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{082_file_chooser_dialog.rb → 068_file_chooser_dialog.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{037_text_buffer_example.rb → 070_text_buffer_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{013_grab_pointer_forcefully.rb → 071_grab_pointer_forcefully.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{008_search_bar_example.rb → 074_search_bar_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{061_fixed_example.rb → 075_fixed_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{011_colour_chooser_example.rb → 077_colour_chooser_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{015_bottom_left_placement.rb → 078_bottom_left_placement.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{045_radio_menu_item_example.rb → 080_radio_menu_item_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{046_gtk_dialog_sample.rb → 081_gtk_dialog_sample.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{003_toggle_button_example.rb → 082_toggle_button_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{019_status_icon_example.rb → 083_status_icon_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{023_sorted_tree.rb → 084_sorted_tree.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{083_bindings.rb → 085_bindings.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{002_scrolled_window_example.rb → 086_scrolled_window_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{007_two_windows_example.rb → 087_two_windows_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk3/{070_svg_viewer.rb → 088_svg_viewer.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk4/{001_gtk_entry.rb → 002_gtk_entry.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk4/{005_spinner_example.rb → 017_spinner_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk4/{074_frame_example.rb → 026_frame_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk4/{006_text_view_example.rb → 034_text_view_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk4/{087_calendar_example.rb → 037_calendar_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk4/{027_menubar_example.rb → 054_menubar_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk4/{010_switch_example.rb → 062_switch_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk4/{008_search_bar_example.rb → 074_search_bar_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk4/{004_simple_dialog_example.rb → 079_simple_dialog_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk4/{003_toggle_button_example.rb → 082_toggle_button_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk4/{002_scrolled_window_example.rb → 086_scrolled_window_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk4/{101_actionbar_example.rb → 201_actionbar_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk4/{103_drawing_example.rb → 203_drawing_example.rb} +0 -0
- /data/lib/gtk_paradise/examples/gtk4/{104_quit_on_keypress_event.rb → 204_quit_on_keypress_event.rb} +0 -0
- /data/lib/gtk_paradise/widgets/gtk2/{status_icon_example.rb → status_icon_example/status_icon_example.rb} +0 -0
@@ -4,104 +4,159 @@
|
|
4
4
|
# =========================================================================== #
|
5
5
|
# === Gtk::Widget
|
6
6
|
# =========================================================================== #
|
7
|
-
# require 'gtk_paradise/
|
7
|
+
# require 'gtk_paradise/core_classes/widget.rb'
|
8
8
|
# =========================================================================== #
|
9
9
|
module Gtk
|
10
10
|
|
11
11
|
class Widget # === Gtk::Widget
|
12
12
|
|
13
13
|
require 'gtk_paradise/toplevel_methods/determine_which_gtk_version_is_in_use.rb'
|
14
|
+
require 'gtk_paradise/fonts/fonts.rb'
|
14
15
|
|
15
16
|
# ========================================================================= #
|
16
|
-
#
|
17
|
+
# === add_hsep
|
17
18
|
# ========================================================================= #
|
18
|
-
|
19
|
+
def add_hsep
|
20
|
+
_ = ::Gtk.horizontal_separator
|
21
|
+
add(_)
|
22
|
+
end
|
19
23
|
|
20
24
|
# ========================================================================= #
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# This method is just a little wrapper over .set_size_request().
|
25
|
+
# Next, call in gdk-specific modifications.
|
24
26
|
# ========================================================================= #
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
require 'gtk_paradise/gdk/event_crossing.rb'
|
28
|
+
|
29
|
+
if Gtk.do_we_use_gtk4?
|
30
|
+
# ======================================================================= #
|
31
|
+
# === set_border_width
|
32
|
+
# ======================================================================= #
|
33
|
+
def set_border_width(i = 5)
|
34
|
+
css_class("pad#{i}px")
|
35
|
+
end
|
30
36
|
end
|
31
37
|
|
32
38
|
# ========================================================================= #
|
33
|
-
# ===
|
39
|
+
# === on_hover (on_hover tag)
|
40
|
+
#
|
41
|
+
# This method can be used to modify the colour of a given widget, on
|
42
|
+
# a "on-hover" event.
|
43
|
+
#
|
44
|
+
# Usage examples:
|
45
|
+
#
|
46
|
+
# on_hover(:lightblue)
|
47
|
+
# on_hover(:tomato)
|
34
48
|
#
|
35
|
-
# This method can be used to group together several calls to
|
36
|
-
# .minimal(), along with proper padding.
|
37
49
|
# ========================================================================= #
|
38
|
-
def
|
39
|
-
|
40
|
-
|
50
|
+
def on_hover(
|
51
|
+
this_colour = :lightgreen,
|
52
|
+
&block
|
41
53
|
)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
54
|
+
# ======================================================================= #
|
55
|
+
# Next we have to sanitize the input a little bit:
|
56
|
+
# ======================================================================= #
|
57
|
+
if this_colour.to_s.include? 'on_hover_'
|
58
|
+
this_colour = this_colour.to_s.delete_prefix('on_hover_').to_sym
|
59
|
+
end
|
60
|
+
modify_background(
|
61
|
+
:on_hover,
|
62
|
+
this_colour,
|
63
|
+
&block
|
64
|
+
)
|
65
|
+
end; alias on_hover_colour on_hover # === on_hover_colour
|
66
|
+
alias hover on_hover # === hover
|
46
67
|
|
47
68
|
# ========================================================================= #
|
48
|
-
# ===
|
69
|
+
# === modify_background
|
49
70
|
#
|
50
|
-
# This method will
|
51
|
-
#
|
52
|
-
#
|
71
|
+
# This method will set the background colour for a widget in a
|
72
|
+
# particular state. All other style values are left untouched.
|
73
|
+
# See also Gtk::Widget#modify_style.
|
53
74
|
#
|
54
|
-
# Since as of
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
|
59
|
-
# if respond_to?(:xaling=)
|
60
|
-
self.xalign = 0.5
|
61
|
-
# else
|
62
|
-
# self.halign = ::Gtk::Alignment.new(0.5, 0.5, 1.0, 1.0)
|
63
|
-
# end
|
64
|
-
end; alias align_to_the_center align_to_center # === align_to_the_center
|
65
|
-
alias center align_to_center # === center
|
66
|
-
alias do_center align_to_center # === do_center
|
67
|
-
alias to_center align_to_center # === to_center
|
68
|
-
alias to_the_middle align_to_center # === to_the_middle
|
69
|
-
alias align_into_the_middle align_to_center # === align_into_the_middle
|
70
|
-
alias center_align align_to_center # === center_align
|
71
|
-
|
72
|
-
# ========================================================================= #
|
73
|
-
# === scroll_up?
|
75
|
+
# Since as of November 2023, the gtk2-specific variant has been
|
76
|
+
# removed. For reference purposes, the old variant ::Gtk::STATE_NORMAL
|
77
|
+
# available in ruby-gtk2 was replaced via :normal in ruby-gtk3.
|
78
|
+
# Prelight would be ::GTK::STATE_PRELIGHT in ruby-gtk2, but is
|
79
|
+
# now :prelight in ruby-gtk3.
|
74
80
|
#
|
75
|
-
#
|
76
|
-
# button) is going upwards.
|
77
|
-
# ========================================================================= #
|
78
|
-
def scroll_up?(event)
|
79
|
-
(event.event_type.name == 'GDK_SCROLL') and
|
80
|
-
(event.direction == Gdk::ScrollDirection::UP)
|
81
|
-
end; alias scroll_up_event? scroll_up? # === scroll_up_event?
|
82
|
-
|
83
|
-
# ========================================================================= #
|
84
|
-
# === scroll_down?
|
81
|
+
# For ruby-gtk2 we also would then call modify_bg(state, colour).
|
85
82
|
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
# ========================================================================= #
|
95
|
-
# === on_scroll_event
|
83
|
+
# The arguments to this method are:
|
84
|
+
#
|
85
|
+
# state: the state(GtkStateType) for which to set the
|
86
|
+
# background color.
|
87
|
+
#
|
88
|
+
# colour: the Gdk::Color to assign (does not need to
|
89
|
+
# be allocated).
|
96
90
|
#
|
97
|
-
# This is the event that occurs when the mouse-scroll-wheel is clicked.
|
98
91
|
# ========================================================================= #
|
99
|
-
def
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
92
|
+
def modify_background(
|
93
|
+
state,
|
94
|
+
colour = nil,
|
95
|
+
&block
|
96
|
+
)
|
97
|
+
# ======================================================================= #
|
98
|
+
# === Handle Hashes first, for the variable state
|
99
|
+
# ======================================================================= #
|
100
|
+
if colour.is_a? Hash
|
101
|
+
if colour.has_key? :colour
|
102
|
+
colour = colour.delete(:colour)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
case state
|
106
|
+
# ======================================================================= #
|
107
|
+
# === :prelight
|
108
|
+
#
|
109
|
+
# This is synonymous with :on_hover.
|
110
|
+
# ======================================================================= #
|
111
|
+
when :prelight,
|
112
|
+
:hover,
|
113
|
+
:on_hover
|
114
|
+
state = :prelight
|
115
|
+
# ======================================================================= #
|
116
|
+
# === :normal
|
117
|
+
#
|
118
|
+
# This entry point is the default entry point.
|
119
|
+
# ======================================================================= #
|
120
|
+
when :normal,
|
121
|
+
:default
|
122
|
+
state = :normal
|
123
|
+
# ======================================================================= #
|
124
|
+
# === :active
|
125
|
+
# ======================================================================= #
|
126
|
+
when :active
|
127
|
+
state = :active
|
128
|
+
end
|
129
|
+
# ======================================================================= #
|
130
|
+
# === Handle blocks next
|
131
|
+
# ======================================================================= #
|
132
|
+
if block_given?
|
133
|
+
yielded = yield
|
134
|
+
if yielded.is_a?(Symbol)
|
135
|
+
colour = yielded
|
136
|
+
end
|
137
|
+
end
|
138
|
+
if colour.is_a? Symbol
|
139
|
+
# ===================================================================== #
|
140
|
+
# Convert it into a Gtk::Colours representation. We could check if it
|
141
|
+
# is a valid html-colour, but for the time being we do not do this.
|
142
|
+
# ===================================================================== #
|
143
|
+
if Gtk.do_we_use_gtk2? # This is retained for now, until we change it to ruby-gtk3.
|
144
|
+
colour = ::Gtk.colour_parse(colour)
|
145
|
+
# =================================================================== #
|
146
|
+
# gtk3 now uses RGBA rather than Gdk.parse().
|
147
|
+
# RGBA stands for red, green, blue and alpha.
|
148
|
+
# The values go from 0.0 to 1.0. However had, it seems as if
|
149
|
+
# ruby-gtk3 also supports HTML colours directly, so no need
|
150
|
+
# to convert them.
|
151
|
+
# =================================================================== #
|
152
|
+
end
|
153
|
+
end
|
154
|
+
_ = "hover_effect_#{colour}"
|
155
|
+
css_class(_)
|
156
|
+
# else # else assume ruby-gtk3 here.
|
157
|
+
# override_background_color(state, colour)
|
158
|
+
# end
|
159
|
+
end
|
105
160
|
|
106
161
|
# ========================================================================= #
|
107
162
|
# === yellow_background
|
@@ -111,7 +166,7 @@ class Widget # === Gtk::Widget
|
|
111
166
|
# thus, ruby-gtk2 does not work with this method.
|
112
167
|
# ========================================================================= #
|
113
168
|
def yellow_background
|
114
|
-
|
169
|
+
add_css_class('BG_light_yellow')
|
115
170
|
end; alias light_yellow_background yellow_background # === light_yellow_background
|
116
171
|
alias light_yellowish_background yellow_background # === light_yellowish_background
|
117
172
|
alias yellowish_background yellow_background # === yellowish_background
|
@@ -126,7 +181,7 @@ class Widget # === Gtk::Widget
|
|
126
181
|
# This depends on CSS, so it will not work on ruby-gtk2.
|
127
182
|
# ========================================================================= #
|
128
183
|
def very_light_yellowish_background
|
129
|
-
|
184
|
+
add_css_class('BG_very_light_yellowish')
|
130
185
|
end; alias yellowish_background2 very_light_yellowish_background # === yellowish_background2
|
131
186
|
alias background_yellow2 very_light_yellowish_background # === background_yellow2
|
132
187
|
alias very_light_yellow_background_colour very_light_yellowish_background # === very_light_yellow_background_colour
|
@@ -135,75 +190,10 @@ class Widget # === Gtk::Widget
|
|
135
190
|
alias yello very_light_yellowish_background # === yello
|
136
191
|
|
137
192
|
# ========================================================================= #
|
138
|
-
# ===
|
139
|
-
#
|
140
|
-
# This method will clear the background.
|
141
|
-
# ========================================================================= #
|
142
|
-
def clear_background
|
143
|
-
css_class('clear_background')
|
144
|
-
end; alias clear_border clear_background # === clear_border
|
145
|
-
alias remove_background clear_background # === remove_background
|
146
|
-
|
147
|
-
# ========================================================================= #
|
148
|
-
# === pretty_tooltip
|
149
|
-
# ========================================================================= #
|
150
|
-
def pretty_tooltip(i)
|
151
|
-
if i and i.include?('&')
|
152
|
-
i = i.dup if i.frozen?
|
153
|
-
# ===================================================================== #
|
154
|
-
# Oddly enough, ruby-gtk2 complains about this character.
|
155
|
-
#
|
156
|
-
# The warning was: "Gtk-WARNING **: Failed to set text from
|
157
|
-
# markup due to error parsing markup" [...] Entity did not
|
158
|
-
# end with a semicolon; most likely you used an ampersand
|
159
|
-
# character without intending to start an entity - escape
|
160
|
-
# ampersand as &"
|
161
|
-
# So we do this ^^^.
|
162
|
-
# ===================================================================== #
|
163
|
-
i.gsub!(/&/, '&')
|
164
|
-
end
|
165
|
-
set_tooltip_markup(i)
|
166
|
-
end; alias pretty_tooltip= pretty_tooltip # === pretty_tooltip=
|
167
|
-
alias fancy_tooltip= pretty_tooltip # === fancy_tooltip=
|
168
|
-
alias fancy_tooltips= pretty_tooltip # === fancy_tooltips=
|
169
|
-
alias hint= pretty_tooltip # === hint=
|
170
|
-
alias info pretty_tooltip # === info
|
171
|
-
alias popup_hint pretty_tooltip # === popup_hint
|
172
|
-
alias fancy_tip pretty_tooltip # === fancy_tip
|
173
|
-
alias fancy_hint pretty_tooltip # === fancy_hint
|
174
|
-
alias fancy_hint= pretty_tooltip # === fancy_hint=
|
175
|
-
alias set_hovertip pretty_tooltip # === set_hovertip
|
176
|
-
|
177
|
-
# ========================================================================= #
|
178
|
-
# === add_or_append
|
179
|
-
# ========================================================================= #
|
180
|
-
def add_or_append(i)
|
181
|
-
if Gtk.do_we_use_gtk3?
|
182
|
-
add(i)
|
183
|
-
elsif Gtk.do_we_use_gtk4?
|
184
|
-
append(i)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
# ========================================================================= #
|
189
|
-
# === remove_css_class
|
190
|
-
#
|
191
|
-
# This method can be used to remove a particular CSS class from a
|
192
|
-
# widget.
|
193
|
+
# === on_hover_lightblue
|
193
194
|
# ========================================================================= #
|
194
|
-
def
|
195
|
-
|
196
|
-
context.remove_class(this_css_class)
|
197
|
-
end; alias remove_this_css_class remove_css_class # === remove_this_css_class
|
198
|
-
alias remove_CSS_class remove_css_class # === remove_CSS_class
|
199
|
-
|
200
|
-
if Gtk.do_we_use_gtk4?
|
201
|
-
# ======================================================================= #
|
202
|
-
# === set_border_width
|
203
|
-
# ======================================================================= #
|
204
|
-
def set_border_width(i = 5)
|
205
|
-
css_class("pad#{i}px")
|
206
|
-
end
|
195
|
+
def on_hover_lightblue
|
196
|
+
on_hover(__method__)
|
207
197
|
end
|
208
198
|
|
209
199
|
# ========================================================================= #
|
@@ -214,148 +204,85 @@ class Widget # === Gtk::Widget
|
|
214
204
|
end
|
215
205
|
|
216
206
|
# ========================================================================= #
|
217
|
-
# ===
|
218
|
-
# ========================================================================= #
|
219
|
-
def limegreen
|
220
|
-
on_hover(__method__)
|
221
|
-
end; alias mediumaquamarine limegreen # === mediumaquamarine
|
222
|
-
alias khaki limegreen # === khaki
|
223
|
-
|
224
|
-
# ========================================================================= #
|
225
|
-
# === lightgreen
|
207
|
+
# === on_hover_tomato
|
226
208
|
# ========================================================================= #
|
227
|
-
def
|
209
|
+
def on_hover_tomato
|
228
210
|
on_hover(__method__)
|
229
211
|
end
|
230
212
|
|
231
213
|
# ========================================================================= #
|
232
|
-
# ===
|
214
|
+
# === on_hover_lightgreen
|
233
215
|
# ========================================================================= #
|
234
|
-
def
|
216
|
+
def on_hover_lightgreen
|
235
217
|
on_hover(__method__)
|
236
218
|
end
|
237
219
|
|
238
220
|
# ========================================================================= #
|
239
|
-
# ===
|
221
|
+
# === on_hover_paleturquoise
|
240
222
|
# ========================================================================= #
|
241
|
-
def
|
223
|
+
def on_hover_paleturquoise
|
242
224
|
on_hover(__method__)
|
243
225
|
end
|
244
226
|
|
245
227
|
# ========================================================================= #
|
246
|
-
# ===
|
228
|
+
# === on_hover_skyblue
|
247
229
|
# ========================================================================= #
|
248
230
|
def skyblue
|
249
231
|
on_hover(__method__)
|
250
232
|
end
|
251
233
|
|
252
234
|
# ========================================================================= #
|
253
|
-
# ===
|
235
|
+
# === on_hover_lightpink
|
254
236
|
# ========================================================================= #
|
255
237
|
def lightpink
|
256
238
|
on_hover(__method__)
|
257
239
|
end
|
258
240
|
|
259
241
|
# ========================================================================= #
|
260
|
-
# ===
|
242
|
+
# === on_hover_darkmagenta
|
261
243
|
# ========================================================================= #
|
262
|
-
def
|
244
|
+
def on_hover_darkmagenta
|
263
245
|
on_hover(__method__)
|
264
246
|
end
|
265
247
|
|
266
248
|
# ========================================================================= #
|
267
|
-
# ===
|
249
|
+
# === on_hover_limegreen
|
268
250
|
# ========================================================================= #
|
269
|
-
def
|
270
|
-
|
271
|
-
end
|
251
|
+
def on_hover_limegreen
|
252
|
+
on_hover(__method__)
|
253
|
+
end; alias mediumaquamarine on_hover_limegreen # === mediumaquamarine
|
254
|
+
alias khaki on_hover_limegreen # === khaki
|
272
255
|
|
273
256
|
# ========================================================================= #
|
274
|
-
# ===
|
257
|
+
# === lightskyblue_background
|
275
258
|
# ========================================================================= #
|
276
|
-
def
|
277
|
-
add_css_class(
|
278
|
-
end
|
259
|
+
def lightskyblue_background
|
260
|
+
add_css_class('BG_lightskyblue')
|
261
|
+
end; alias bg_lightblue lightskyblue_background # === bg_lightblue
|
262
|
+
alias lightblue_background lightskyblue_background # === lightblue_background
|
263
|
+
alias light_blue_background lightskyblue_background # === light_blue_background
|
279
264
|
|
280
265
|
# ========================================================================= #
|
281
|
-
# ===
|
266
|
+
# === light_pink_background
|
282
267
|
# ========================================================================= #
|
283
|
-
def
|
284
|
-
add_css_class(
|
285
|
-
end
|
268
|
+
def light_pink_background
|
269
|
+
add_css_class('BG_lightpink')
|
270
|
+
end; alias lightpink_background light_pink_background # === lightpink_background
|
286
271
|
|
287
272
|
# ========================================================================= #
|
288
|
-
# ===
|
289
|
-
#
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
#
|
295
|
-
#
|
296
|
-
# ========================================================================= #
|
297
|
-
def light_green_background
|
298
|
-
css_class('BG_light_green')
|
299
|
-
end; alias lightgreen_background light_green_background # === lightgreen_background
|
300
|
-
|
301
|
-
# ========================================================================= #
|
302
|
-
# === azure_background
|
303
|
-
# ========================================================================= #
|
304
|
-
def azure_background
|
305
|
-
css_class('BG_azure')
|
306
|
-
end; alias bg_azure azure_background # === bg_azure
|
307
|
-
|
308
|
-
# ========================================================================= #
|
309
|
-
# === steelblue
|
310
|
-
# ========================================================================= #
|
311
|
-
def steelblue
|
312
|
-
css_class(__method__.to_s)
|
313
|
-
end
|
314
|
-
|
315
|
-
# ========================================================================= #
|
316
|
-
# === royalblue
|
317
|
-
# ========================================================================= #
|
318
|
-
def royalblue
|
319
|
-
css_class(__method__.to_s)
|
320
|
-
end
|
321
|
-
|
322
|
-
# ========================================================================= #
|
323
|
-
# === slateblue
|
324
|
-
# ========================================================================= #
|
325
|
-
def slateblue
|
326
|
-
css_class(__method__.to_s)
|
327
|
-
end
|
328
|
-
|
329
|
-
# ========================================================================= #
|
330
|
-
# === lightskyblue_background
|
331
|
-
# ========================================================================= #
|
332
|
-
def lightskyblue_background
|
333
|
-
css_class('BG_lightskyblue')
|
334
|
-
end; alias bg_lightblue lightskyblue_background # === bg_lightblue
|
335
|
-
alias lightblue_background lightskyblue_background # === lightblue_background
|
336
|
-
alias light_blue_background lightskyblue_background # === light_blue_background
|
337
|
-
|
338
|
-
# ========================================================================= #
|
339
|
-
# === light_pink_background
|
340
|
-
# ========================================================================= #
|
341
|
-
def light_pink_background
|
342
|
-
css_class('BG_lightpink')
|
343
|
-
end; alias lightpink_background light_pink_background # === lightpink_background
|
344
|
-
|
345
|
-
# ========================================================================= #
|
346
|
-
# === modify_to_this_font
|
347
|
-
#
|
348
|
-
# This will modify the font for that particular widget at hand.
|
349
|
-
#
|
350
|
-
# Usage example:
|
351
|
-
#
|
352
|
-
# modify_this_font(:liberation)
|
353
|
-
#
|
273
|
+
# === modify_to_this_font
|
274
|
+
#
|
275
|
+
# This will modify the font for that particular widget at hand.
|
276
|
+
#
|
277
|
+
# Usage example:
|
278
|
+
#
|
279
|
+
# modify_this_font(:liberation)
|
280
|
+
#
|
354
281
|
# ========================================================================= #
|
355
282
|
def modify_to_this_font(
|
356
283
|
this_font = 'Sans 20'
|
357
284
|
)
|
358
|
-
this_font = ::Gtk.expand_this_font(this_font)
|
285
|
+
this_font = ::Gtk.expand_this_font(this_font) # This is part of gtk_paradise/fonts/fonts.rb.
|
359
286
|
_ = Pango::FontDescription.new(this_font)
|
360
287
|
# if Gtk.are_we_using_gtk2?
|
361
288
|
# modify_font(_)
|
@@ -366,160 +293,42 @@ class Widget # === Gtk::Widget
|
|
366
293
|
alias font_to_use= modify_to_this_font # === font_to_use=
|
367
294
|
|
368
295
|
# ========================================================================= #
|
369
|
-
# ===
|
370
|
-
# ========================================================================= #
|
371
|
-
def complex_font(
|
372
|
-
this_font = 'Calibre 32'
|
373
|
-
)
|
374
|
-
this_font = ::Gtk.expand_this_font(this_font)
|
375
|
-
_ = Pango::FontDescription.new(this_font)
|
376
|
-
override_font(_)
|
377
|
-
end
|
378
|
-
|
379
|
-
# ========================================================================= #
|
380
|
-
# === bsteelblue1
|
381
|
-
# ========================================================================= #
|
382
|
-
def bsteelblue1
|
383
|
-
css_class(__method__.to_s)
|
384
|
-
end
|
385
|
-
|
386
|
-
# ========================================================================= #
|
387
|
-
# === make_bold_font
|
296
|
+
# === use_these_css_classes
|
388
297
|
#
|
389
|
-
# This
|
390
|
-
#
|
391
|
-
# ========================================================================= #
|
392
|
-
def make_bold_font
|
393
|
-
css_class 'bold_font'
|
394
|
-
end
|
395
|
-
|
396
|
-
# ========================================================================= #
|
397
|
-
# === bnavy1
|
298
|
+
# This method allows for some convenience in regards to using CSS
|
299
|
+
# classes. You can pass several CSS classes into this method.
|
398
300
|
#
|
399
|
-
#
|
400
|
-
#
|
401
|
-
def bnavy1
|
402
|
-
css_class(__method__.to_s)
|
403
|
-
end
|
404
|
-
|
405
|
-
# ========================================================================= #
|
406
|
-
# === bindigo1
|
407
|
-
# ========================================================================= #
|
408
|
-
def bindigo1
|
409
|
-
css_class(__method__.to_s)
|
410
|
-
end
|
411
|
-
|
412
|
-
# ========================================================================= #
|
413
|
-
# === bdarkorchid1
|
414
|
-
# ========================================================================= #
|
415
|
-
def bdarkorchid1
|
416
|
-
css_class(__method__.to_s)
|
417
|
-
end
|
418
|
-
|
419
|
-
# ========================================================================= #
|
420
|
-
# === blightgreen1
|
421
|
-
# ========================================================================= #
|
422
|
-
def blightgreen1
|
423
|
-
css_class(__method__.to_s)
|
424
|
-
end
|
425
|
-
|
426
|
-
# ========================================================================= #
|
427
|
-
# === bblack1px
|
428
|
-
# ========================================================================= #
|
429
|
-
def bblack1px
|
430
|
-
css_class('bblack1')
|
431
|
-
end; alias bblack1 bblack1px # === bblack1
|
432
|
-
|
433
|
-
# ========================================================================= #
|
434
|
-
# === bblack2px
|
435
|
-
# ========================================================================= #
|
436
|
-
def bblack2px
|
437
|
-
css_class('bblack2')
|
438
|
-
end; alias bblack2 bblack2px # === bblack2
|
439
|
-
|
440
|
-
# ========================================================================= #
|
441
|
-
# === bblack3px
|
442
|
-
# ========================================================================= #
|
443
|
-
def bblack3px
|
444
|
-
css_class('bblack3')
|
445
|
-
end; alias bblack3 bblack3px # === bblack3
|
446
|
-
|
447
|
-
# ========================================================================= #
|
448
|
-
# === bblack4px
|
449
|
-
# ========================================================================= #
|
450
|
-
def bblack4px
|
451
|
-
css_class('bblack4')
|
452
|
-
end; alias bblack4 bblack4px # === bblack4
|
453
|
-
|
454
|
-
# ========================================================================= #
|
455
|
-
# === bblack5px
|
456
|
-
# ========================================================================= #
|
457
|
-
def bblack5px
|
458
|
-
css_class('bblack5')
|
459
|
-
end; alias bblack5 bblack5px # === bblack5
|
460
|
-
|
461
|
-
# ========================================================================= #
|
462
|
-
# === hcenter
|
301
|
+
# It is important to separate these CSS classes via a
|
302
|
+
# ' ' character specifically.
|
463
303
|
#
|
464
|
-
#
|
304
|
+
# Specific usage example:
|
305
|
+
#
|
306
|
+
# @frame.use_these_css_classes('no_box_shadow bblack2 BG_black pad0px mar0px')
|
465
307
|
#
|
466
|
-
# This variant has been confirmed to work for the gtk-hbox widget, in
|
467
|
-
# July 2022.
|
468
308
|
# ========================================================================= #
|
469
|
-
def
|
470
|
-
i = :center
|
471
|
-
)
|
472
|
-
case i
|
309
|
+
def use_these_css_classes(i)
|
473
310
|
# ======================================================================= #
|
474
|
-
#
|
311
|
+
# The input has to have a ' ' character, if this method is to work.
|
475
312
|
# ======================================================================= #
|
476
|
-
|
477
|
-
i
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
alias hjustify hcenter # === hjustify
|
483
|
-
alias center_this_widget hcenter # === center_this_widget
|
484
|
-
alias clever_center hcenter # === clever_center
|
485
|
-
alias center_into_the_middle hcenter # === center_into_the_middle
|
486
|
-
alias centered_container hcenter # === centered_container
|
487
|
-
|
488
|
-
require 'gtk_paradise/fonts/fonts.rb'
|
489
|
-
# ========================================================================= #
|
490
|
-
# === use_this_font=
|
491
|
-
# ========================================================================= #
|
492
|
-
def use_this_font=(
|
493
|
-
i = 'EmojiOne Color 22'
|
494
|
-
)
|
495
|
-
if i.is_a?(String) or i.is_a?(Symbol)
|
496
|
-
i = ::Gtk.expand_this_font(i)
|
497
|
-
i = Pango::FontDescription.new(i.to_s)
|
498
|
-
end
|
499
|
-
if ::Gtk.use_gtk2?
|
500
|
-
modify_font(i)
|
501
|
-
elsif ::Gtk.use_gtk3?
|
502
|
-
override_font(i)
|
503
|
-
elsif ::Gtk.use_gtk4?
|
504
|
-
puts 'override_font() has not yet been ported to ruby-gtk4 '\
|
505
|
-
'and the gtk_paradise gem.'
|
313
|
+
if i and i.include?(' ')
|
314
|
+
i.split(' ').each {|this_css_class|
|
315
|
+
css_class(this_css_class)
|
316
|
+
}
|
317
|
+
else
|
318
|
+
e 'The given input (`'+i.to_s+'`) does not have a " " character.'
|
506
319
|
end
|
507
|
-
end; alias
|
508
|
-
alias
|
509
|
-
alias try_to_use_this_font use_this_font= # === try_to_use_this_font
|
510
|
-
alias fonty use_this_font= # === fonty
|
511
|
-
alias font= use_this_font= # === font=
|
320
|
+
end; alias use_these_CSS_classes use_these_css_classes # === use_these_CSS_classes
|
321
|
+
alias css_classes use_these_css_classes # === css_classes
|
512
322
|
|
513
323
|
# ========================================================================= #
|
514
|
-
# ===
|
324
|
+
# === add_to_the_CSS_style_context
|
515
325
|
#
|
516
|
-
# This
|
517
|
-
#
|
326
|
+
# This method must be guaranteed to work on style_context. Thus, it can
|
327
|
+
# only work properly if style_context() actually returns something useful.
|
518
328
|
# ========================================================================= #
|
519
|
-
def
|
520
|
-
|
521
|
-
end
|
522
|
-
alias do_select do_focus # === do_select
|
329
|
+
def add_to_the_CSS_style_context(i)
|
330
|
+
style_context.add_class(i)
|
331
|
+
end
|
523
332
|
|
524
333
|
# ========================================================================= #
|
525
334
|
# === deselect
|
@@ -539,8 +348,10 @@ class Widget # === Gtk::Widget
|
|
539
348
|
#
|
540
349
|
# This method will remove all child-widgets from a container.
|
541
350
|
# ========================================================================= #
|
542
|
-
def remove_widgets
|
543
|
-
|
351
|
+
def remove_widgets(
|
352
|
+
i = children
|
353
|
+
)
|
354
|
+
i.each {|this_child_widget|
|
544
355
|
remove(this_child_widget)
|
545
356
|
}
|
546
357
|
end
|
@@ -554,34 +365,34 @@ class Widget # === Gtk::Widget
|
|
554
365
|
def set_background_colour(
|
555
366
|
i = :whitesmoke
|
556
367
|
)
|
557
|
-
if ::Gtk.use_gtk2?
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
else
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
end
|
569
|
-
i = ::Colours.convert_hex_code_to_RGBA_array(i)
|
570
|
-
i = Gdk::RGBA.new(*i)
|
571
|
-
elsif i.is_a? Gdk::Color
|
572
|
-
# =================================================================== #
|
573
|
-
# Convert it into RGB values next.
|
574
|
-
# =================================================================== #
|
575
|
-
array = [
|
576
|
-
(i.red * 100.0 / 65535) / 100,
|
577
|
-
(i.green * 100.0 / 65535) / 100,
|
578
|
-
(i.blue * 100.0 / 65535) / 100,
|
579
|
-
1.0
|
580
|
-
]
|
581
|
-
i = Gdk::RGBA.new(*array)
|
368
|
+
# if ::Gtk.use_gtk2?
|
369
|
+
# modify_bg(
|
370
|
+
# ::Gtk::STATE_NORMAL,
|
371
|
+
# Gdk::Color.parse(i.to_s)
|
372
|
+
# )
|
373
|
+
# else
|
374
|
+
if i.is_a?(String) and i.start_with?('#') # Assume a hex-code in this event.
|
375
|
+
unless Object.const_defined?(:Colours)
|
376
|
+
begin
|
377
|
+
require 'colours'
|
378
|
+
rescue LoadError; end
|
582
379
|
end
|
583
|
-
|
380
|
+
i = ::Colours.convert_hex_code_to_RGBA_array(i)
|
381
|
+
i = Gdk::RGBA.new(*i)
|
382
|
+
elsif i.is_a? Gdk::Color
|
383
|
+
# =================================================================== #
|
384
|
+
# Convert it into RGB values next.
|
385
|
+
# =================================================================== #
|
386
|
+
array = [
|
387
|
+
(i.red * 100.0 / 65535) / 100,
|
388
|
+
(i.green * 100.0 / 65535) / 100,
|
389
|
+
(i.blue * 100.0 / 65535) / 100,
|
390
|
+
1.0
|
391
|
+
]
|
392
|
+
i = Gdk::RGBA.new(*array)
|
584
393
|
end
|
394
|
+
override_background_color(:normal, i)
|
395
|
+
#end
|
585
396
|
@background_colour = i
|
586
397
|
end; alias set_background_color set_background_colour # === set_background_color
|
587
398
|
alias bg_colour set_background_colour # === bg_colour
|
@@ -599,139 +410,65 @@ class Widget # === Gtk::Widget
|
|
599
410
|
alias change_background_color_to set_background_colour # === change_background_color_to
|
600
411
|
|
601
412
|
# ========================================================================= #
|
602
|
-
# ===
|
413
|
+
# === add_css_class
|
603
414
|
#
|
604
|
-
# This method can be used to
|
605
|
-
#
|
415
|
+
# This method can be used to quickly add a CSS class to a particular
|
416
|
+
# gtk-widget.
|
606
417
|
#
|
607
|
-
# Usage example:
|
418
|
+
# Usage example how to use it via the gtk_paradise gem:
|
608
419
|
#
|
609
|
-
#
|
420
|
+
# label = create_label('This is a test')
|
421
|
+
# label.add_css_class('BG_black')
|
422
|
+
# label.add_css_class('yellow')
|
423
|
+
# label.css_class('bblack2') # This variant is shorter.
|
610
424
|
#
|
611
425
|
# ========================================================================= #
|
612
|
-
def
|
613
|
-
|
614
|
-
)
|
615
|
-
modify_background(
|
616
|
-
:on_hover, this_colour, &block
|
426
|
+
def add_css_class(
|
427
|
+
i
|
617
428
|
)
|
618
|
-
|
429
|
+
if respond_to? :style_context
|
430
|
+
i = i.to_s if i.is_a? Symbol
|
431
|
+
add_to_the_CSS_style_context(i)
|
432
|
+
# ===================================================================== #
|
433
|
+
# Always register it after it was added.
|
434
|
+
# No, this can not be done - we need to add CSS rules elsewhere.
|
435
|
+
# ===================================================================== #
|
436
|
+
# ::Gtk.append_these_css_rules(i)
|
437
|
+
end
|
438
|
+
end; alias set_class add_css_class # === set_class
|
439
|
+
alias set_css_class add_css_class # === set_css_class
|
440
|
+
alias css_class add_css_class # === css_class
|
441
|
+
alias css add_css_class # === css
|
442
|
+
alias add_this_css_class add_css_class # === add_this_css_class
|
443
|
+
alias add_css add_css_class # === add_this_css_class
|
444
|
+
alias add_class add_css_class # === add_class
|
619
445
|
|
620
446
|
# ========================================================================= #
|
621
|
-
# ===
|
622
|
-
#
|
623
|
-
|
624
|
-
|
625
|
-
|
447
|
+
# === add_or_append
|
448
|
+
# ========================================================================= #
|
449
|
+
def add_or_append(i)
|
450
|
+
if Gtk.do_we_use_gtk3? # For gtk3.
|
451
|
+
add(i)
|
452
|
+
elsif Gtk.do_we_use_gtk4? # For gtk4.
|
453
|
+
append(i)
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
# ========================================================================= #
|
458
|
+
# === enable_scroll_events
|
626
459
|
#
|
627
|
-
#
|
628
|
-
#
|
629
|
-
# state: the state(GtkStateType) for which to set the
|
630
|
-
# background color.
|
631
|
-
#
|
632
|
-
# colour: the Gdk::Color to assign (does not need to
|
633
|
-
# be allocated).
|
634
|
-
#
|
635
|
-
# ========================================================================= #
|
636
|
-
def modify_background(
|
637
|
-
state,
|
638
|
-
colour = nil,
|
639
|
-
&block
|
640
|
-
)
|
641
|
-
# ======================================================================= #
|
642
|
-
# === Handle Hashes first, for the variable state
|
643
|
-
# ======================================================================= #
|
644
|
-
if colour.is_a? Hash
|
645
|
-
if colour.has_key? :colour
|
646
|
-
colour = colour.delete(:colour)
|
647
|
-
end
|
648
|
-
end
|
649
|
-
case state
|
650
|
-
# ======================================================================= #
|
651
|
-
# === :normal
|
652
|
-
#
|
653
|
-
# This entry point is the default entry point.
|
654
|
-
# ======================================================================= #
|
655
|
-
when :normal,
|
656
|
-
:default
|
657
|
-
if Gtk.do_we_use_gtk2?
|
658
|
-
state = ::Gtk::STATE_NORMAL
|
659
|
-
else
|
660
|
-
state = :normal
|
661
|
-
end
|
662
|
-
# ======================================================================= #
|
663
|
-
# === :active
|
664
|
-
# ======================================================================= #
|
665
|
-
when :active
|
666
|
-
if Gtk.do_we_use_gtk2?
|
667
|
-
state = ::Gtk::STATE_ACTIVE
|
668
|
-
else
|
669
|
-
state = :active
|
670
|
-
end
|
671
|
-
# ======================================================================= #
|
672
|
-
# === :prelight
|
673
|
-
# ======================================================================= #
|
674
|
-
when :prelight,
|
675
|
-
:hover,
|
676
|
-
:on_hover
|
677
|
-
if Gtk.do_we_use_gtk2?
|
678
|
-
state = ::Gtk::STATE_PRELIGHT
|
679
|
-
else
|
680
|
-
state = :prelight
|
681
|
-
end
|
682
|
-
end
|
683
|
-
# ======================================================================= #
|
684
|
-
# === Handle blocks next
|
685
|
-
# ======================================================================= #
|
686
|
-
if block_given?
|
687
|
-
yielded = yield
|
688
|
-
if yielded.is_a?(Symbol)
|
689
|
-
colour = yielded
|
690
|
-
end
|
691
|
-
end
|
692
|
-
if colour.is_a? Symbol
|
693
|
-
# ===================================================================== #
|
694
|
-
# Convert it into a Gtk::Colours representation. We could check if it
|
695
|
-
# is a valid html-colour, but for the time being we do not do this.
|
696
|
-
# ===================================================================== #
|
697
|
-
if Gtk.do_we_use_gtk2?
|
698
|
-
colour = ::Gtk.colour_parse(colour)
|
699
|
-
# =================================================================== #
|
700
|
-
# gtk3 now uses RGBA rather than Gdk.parse().
|
701
|
-
# RGBA stands for red, green, blue and alpha.
|
702
|
-
# The values go from 0.0 to 1.0. However had, it seems as if
|
703
|
-
# ruby-gtk3 also supports HTML colours directly, so no need
|
704
|
-
# to convert them.
|
705
|
-
# =================================================================== #
|
706
|
-
end
|
707
|
-
end
|
708
|
-
if Gtk.do_we_use_gtk2?
|
709
|
-
modify_bg(state, colour) # Delegate to the original method here.
|
710
|
-
# ======================================================================= #
|
711
|
-
# === Handle ruby-gtk4 next
|
712
|
-
# ======================================================================= #
|
713
|
-
elsif Gtk.do_we_use_gtk4?
|
714
|
-
css_class("hover_effect_#{colour}")
|
715
|
-
else # else assume ruby-gtk3 here.
|
716
|
-
override_background_color(state, colour)
|
717
|
-
end
|
718
|
-
end
|
719
|
-
|
720
|
-
# ========================================================================= #
|
721
|
-
# === enable_scroll_events
|
722
|
-
#
|
723
|
-
# This method will enable scroll-events for a particular widget, such
|
724
|
-
# as a Gtk::Entry instance.
|
460
|
+
# This method will enable scroll-events for a particular widget, such
|
461
|
+
# as a Gtk::Entry instance.
|
725
462
|
#
|
726
463
|
# Note that set_events() is less flexible as it can not be used on
|
727
464
|
# widgets that have already been realized.
|
728
465
|
# ========================================================================= #
|
729
466
|
def enable_scroll_events
|
730
|
-
if ::Gtk.use_gtk2? # assume ruby-gtk2 here.
|
731
|
-
|
732
|
-
else
|
467
|
+
# if ::Gtk.use_gtk2? # assume ruby-gtk2 here.
|
468
|
+
# add_events(Gdk::EventMask::SCROLL_MASK)
|
469
|
+
# else
|
733
470
|
add_events(:scroll_mask)
|
734
|
-
end
|
471
|
+
# end
|
735
472
|
end; alias add_scroll_event enable_scroll_events # === add_scroll_event
|
736
473
|
|
737
474
|
# ========================================================================= #
|
@@ -774,6 +511,7 @@ class Widget # === Gtk::Widget
|
|
774
511
|
::Gtk.add_to_the_toplevel_CSS_string(css_rules_to_apply)
|
775
512
|
_ = "#{use_this_CSS_name}#{i.to_s.delete('px')}".delete('.')
|
776
513
|
css_class(_)
|
514
|
+
return css_rules_to_apply # And return it as well, just in case.
|
777
515
|
end
|
778
516
|
|
779
517
|
# ========================================================================= #
|
@@ -810,6 +548,59 @@ class Widget # === Gtk::Widget
|
|
810
548
|
do_markify
|
811
549
|
end
|
812
550
|
|
551
|
+
# ========================================================================= #
|
552
|
+
# === focus_in_event
|
553
|
+
# ========================================================================= #
|
554
|
+
def focus_in_event(&block)
|
555
|
+
signal_connect(:focus_in_event, &block)
|
556
|
+
end; alias on_focus_in_event focus_in_event # === on_focus_in_event
|
557
|
+
|
558
|
+
# ========================================================================= #
|
559
|
+
# === grey_out
|
560
|
+
#
|
561
|
+
# This is typically used for gtk-button, to "grey" out the button, thus
|
562
|
+
# make it no longer sensitive to user-input change.
|
563
|
+
# ========================================================================= #
|
564
|
+
def grey_out
|
565
|
+
set_sensitive(false)
|
566
|
+
end; alias not_sensitive grey_out # === not_sensitive
|
567
|
+
alias is_insensitive grey_out # === is_insensitive
|
568
|
+
|
569
|
+
require 'gtk_paradise/toplevel_methods/determine_which_gtk_version_is_in_use.rb'
|
570
|
+
# ========================================================================= #
|
571
|
+
# === grey_in
|
572
|
+
# ========================================================================= #
|
573
|
+
def grey_in
|
574
|
+
set_sensitive(true)
|
575
|
+
end; alias is_sensitive_again grey_in # === is_sensitive_again
|
576
|
+
unless respond_to?(:is_sensitive) or ::Gtk.use_gtk2? # This check is required for ruby-gtk2.
|
577
|
+
alias is_sensitive grey_in # === is_sensitive
|
578
|
+
end
|
579
|
+
|
580
|
+
# ========================================================================= #
|
581
|
+
# === children?
|
582
|
+
# ========================================================================= #
|
583
|
+
def children?
|
584
|
+
children
|
585
|
+
end
|
586
|
+
|
587
|
+
# ========================================================================= #
|
588
|
+
# === transition_change_background_to
|
589
|
+
#
|
590
|
+
# The first argument should be the target colour.
|
591
|
+
# ========================================================================= #
|
592
|
+
def transition_change_background_to(
|
593
|
+
to_this_colour = :lightgreen,
|
594
|
+
delay_in_n_seconds = 3
|
595
|
+
)
|
596
|
+
old_name = name.to_s
|
597
|
+
set_name("BG_#{to_this_colour}")
|
598
|
+
Thread.new {
|
599
|
+
sleep(delay_in_n_seconds) # Reinstate the old colour after n seconds.
|
600
|
+
set_name(old_name)
|
601
|
+
}
|
602
|
+
end
|
603
|
+
|
813
604
|
# ========================================================================= #
|
814
605
|
# === align_into_the_center
|
815
606
|
# ========================================================================= #
|
@@ -817,286 +608,236 @@ class Widget # === Gtk::Widget
|
|
817
608
|
set_halign(::Gtk::Align::CENTER)
|
818
609
|
end
|
819
610
|
|
611
|
+
# ========================================================================= #
|
612
|
+
# === override_background_colour
|
613
|
+
# ========================================================================= #
|
614
|
+
def override_background_colour(i)
|
615
|
+
override_background_color(:normal, i)
|
616
|
+
end
|
617
|
+
|
618
|
+
# ========================================================================= #
|
619
|
+
# === do_not_expand
|
620
|
+
#
|
621
|
+
# This method can be used to force a button to stay at its original
|
622
|
+
# size.
|
623
|
+
# ========================================================================= #
|
624
|
+
def do_not_expand
|
625
|
+
set_hexpand(false) if respond_to? :set_hexpand
|
626
|
+
set_vexpand(false) if respond_to? :set_vexpand
|
627
|
+
end; alias dont_expand do_not_expand # === dont_expand
|
628
|
+
alias retain_the_original_size do_not_expand # === retain_the_original_size
|
629
|
+
alias disallow_resizing do_not_expand # === disallow_resizing
|
630
|
+
alias do_not_resize do_not_expand # === do_not_resize
|
631
|
+
|
632
|
+
# ========================================================================= #
|
633
|
+
# === rpack
|
634
|
+
#
|
635
|
+
# rpack stands for "right pack". This is ultimately just a wrapper over
|
636
|
+
# .pack_end().
|
637
|
+
# ========================================================================= #
|
638
|
+
def rpack(
|
639
|
+
widget,
|
640
|
+
padding_to_use = 0
|
641
|
+
)
|
642
|
+
pack_end(
|
643
|
+
widget,
|
644
|
+
fill: true,
|
645
|
+
expand: true,
|
646
|
+
padding: padding_to_use
|
647
|
+
)
|
648
|
+
end
|
649
|
+
|
820
650
|
# ========================================================================= #
|
821
651
|
# === add_button_press_events
|
822
652
|
# ========================================================================= #
|
823
653
|
def add_button_press_events
|
824
|
-
if ::Gtk.use_gtk2?
|
825
|
-
|
826
|
-
|
654
|
+
# if ::Gtk.use_gtk2?
|
655
|
+
# add_events(Gdk::Event::BUTTON_PRESS_MASK)
|
656
|
+
if ::Gtk.use_gtk3? # else for ruby-gtk3
|
827
657
|
add_events(Gdk::EventMask::BUTTON_PRESS_MASK)
|
828
658
|
elsif ::Gtk.use_gtk4?
|
829
|
-
e '.add_events() has to be changed for ruby-gtk4.'
|
659
|
+
e '.add_events() has to be changed for ruby-gtk4. '\
|
660
|
+
'It is currently not working.'
|
830
661
|
end
|
831
662
|
end; alias enable_context_menu_on_button_click_events add_button_press_events # === enable_context_menu_on_button_click_events
|
832
663
|
alias enable_context_menu add_button_press_events # === enable_context_menu
|
833
664
|
|
834
665
|
# ========================================================================= #
|
835
|
-
# ===
|
836
|
-
#
|
837
|
-
# This method can be used to quickly add a CSS class to a particular
|
838
|
-
# gtk-widget.
|
839
|
-
#
|
840
|
-
# Example how to use it via the gtk_paradise gem:
|
841
|
-
#
|
842
|
-
# label = gtk_label('This is a test')
|
843
|
-
# label.add_css_class('BG_black')
|
844
|
-
# label.add_css_class('yellow')
|
845
|
-
# label.css_class('bblack2')
|
666
|
+
# === remove_css_class
|
846
667
|
#
|
668
|
+
# This method can be used to remove a particular CSS class from a
|
669
|
+
# widget.
|
847
670
|
# ========================================================================= #
|
848
|
-
def
|
849
|
-
|
671
|
+
def remove_css_class(
|
672
|
+
this_CSS_class
|
850
673
|
)
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
#
|
855
|
-
# Always register it after it was added.
|
856
|
-
# No, this can not be done - we need to add CSS rules elsewhere.
|
857
|
-
# ===================================================================== #
|
858
|
-
# ::Gtk.append_these_css_rules(i)
|
859
|
-
end
|
860
|
-
end; alias set_class add_css_class # === set_class
|
861
|
-
alias set_css_class add_css_class # === set_css_class
|
862
|
-
alias css_class add_css_class # === css_class
|
863
|
-
alias css add_css_class # === css
|
864
|
-
alias add_this_css_class add_css_class # === add_this_css_class
|
865
|
-
alias add_css add_css_class # === add_this_css_class
|
866
|
-
alias add_class add_css_class # === add_class
|
674
|
+
context = style_context
|
675
|
+
context.remove_class(this_CSS_class) # Remove the CSS class here.
|
676
|
+
end; alias remove_this_css_class remove_css_class # === remove_this_css_class
|
677
|
+
alias remove_CSS_class remove_css_class # === remove_CSS_class
|
867
678
|
|
868
679
|
# ========================================================================= #
|
869
|
-
# ===
|
680
|
+
# === clear_background
|
870
681
|
#
|
871
|
-
# This method
|
872
|
-
# only work properly if style_context() actually returns something useful.
|
682
|
+
# This method will clear the background.
|
873
683
|
# ========================================================================= #
|
874
|
-
def
|
875
|
-
|
876
|
-
end
|
684
|
+
def clear_background
|
685
|
+
add_css_class('clear_background')
|
686
|
+
end; alias clear_border clear_background # === clear_border
|
687
|
+
alias remove_background clear_background # === remove_background
|
877
688
|
|
878
689
|
# ========================================================================= #
|
879
|
-
# ===
|
880
|
-
#
|
881
|
-
|
882
|
-
|
883
|
-
#
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
#
|
888
|
-
#
|
889
|
-
# @frame.use_these_css_classes('no_box_shadow bblack2 BG_black pad0px mar0px')
|
690
|
+
# === enable_markup
|
691
|
+
# ========================================================================= #
|
692
|
+
def enable_markup
|
693
|
+
set_use_markup(true)
|
694
|
+
end; alias markify enable_markup # === markify
|
695
|
+
alias do_markify enable_markup # === do_markify
|
696
|
+
alias parse_markup enable_markup # === parse_markup
|
697
|
+
|
698
|
+
# ========================================================================= #
|
699
|
+
# === same_minimal
|
890
700
|
#
|
701
|
+
# This method can be used to group together several calls to
|
702
|
+
# .minimal(), along with proper padding. In fact, the same padding
|
703
|
+
# will be applied to each invocation of minimal(), which explains
|
704
|
+
# the name chosen for this method.
|
891
705
|
# ========================================================================= #
|
892
|
-
def
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
else
|
901
|
-
e 'The given input (`'+i.to_s+'`) does not have a " " character.'
|
902
|
-
end
|
903
|
-
end; alias use_these_CSS_classes use_these_css_classes # === use_these_CSS_classes
|
904
|
-
alias css_classes use_these_css_classes # === css_classes
|
706
|
+
def same_minimal(
|
707
|
+
padding_to_use = 0,
|
708
|
+
*these_widgets
|
709
|
+
)
|
710
|
+
these_widgets.flatten.each {|this_widget|
|
711
|
+
minimal(this_widget, padding_to_use)
|
712
|
+
}
|
713
|
+
end
|
905
714
|
|
906
715
|
# ========================================================================= #
|
907
|
-
# ===
|
716
|
+
# === align_to_center
|
908
717
|
#
|
909
|
-
# This
|
910
|
-
#
|
718
|
+
# This method will align towards the center. Note that not all widgets
|
719
|
+
# respond to this naturally; it is best to use this for gtk-entry
|
720
|
+
# widgets and perhaps gtk-label and similar widgets.
|
911
721
|
#
|
912
|
-
#
|
913
|
-
#
|
914
|
-
#
|
915
|
-
#
|
722
|
+
# Since as of May 2023 another approach is used: if the widget does
|
723
|
+
# not respond to .xalign= then another method will be called
|
724
|
+
# automatically. Unfortunately this does not work, so it had to be
|
725
|
+
# reverted ...
|
726
|
+
# ========================================================================= #
|
727
|
+
def align_to_center
|
728
|
+
# if respond_to?(:xaling=)
|
729
|
+
self.xalign = 0.5
|
730
|
+
# else
|
731
|
+
# self.halign = ::Gtk::Alignment.new(0.5, 0.5, 1.0, 1.0)
|
732
|
+
# end
|
733
|
+
end; alias align_to_the_center align_to_center # === align_to_the_center
|
734
|
+
alias center align_to_center # === center
|
735
|
+
alias do_center align_to_center # === do_center
|
736
|
+
alias to_center align_to_center # === to_center
|
737
|
+
alias to_the_middle align_to_center # === to_the_middle
|
738
|
+
alias align_into_the_middle align_to_center # === align_into_the_middle
|
739
|
+
alias center_align align_to_center # === center_align
|
740
|
+
|
741
|
+
# ========================================================================= #
|
742
|
+
# === make_bold
|
916
743
|
#
|
744
|
+
# This method can be used to make a widget bold. In ruby-gtk4 this has
|
745
|
+
# changed, though. I am not 100% positive yet, but I think it has
|
746
|
+
# changed.
|
917
747
|
# ========================================================================= #
|
918
|
-
def
|
919
|
-
if
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
when :highlight_text,
|
926
|
-
:select_everything,
|
927
|
-
:select_text
|
928
|
-
on_button_press_event { |widget, event|
|
929
|
-
set_focus(true)
|
930
|
-
select_region(0, -1)
|
931
|
-
}
|
932
|
-
# ===================================================================== #
|
933
|
-
# === :deselect_text
|
934
|
-
#
|
935
|
-
# This will deselect any selection on a gtk-entry. It is not as
|
936
|
-
# useful as the :highlight_text functionality, but I wanted to
|
937
|
-
# provide both, simply to quickly show how it is done.
|
938
|
-
# ===================================================================== #
|
939
|
-
when :deselect_text
|
940
|
-
on_button_press_event { |widget, event|
|
941
|
-
set_focus(true)
|
942
|
-
select_region(0, 0)
|
943
|
-
}
|
944
|
-
end
|
945
|
-
end
|
946
|
-
end
|
748
|
+
def make_bold
|
749
|
+
# if use_gtk3?
|
750
|
+
override_font(
|
751
|
+
Pango::FontDescription.new('bold')
|
752
|
+
)
|
753
|
+
#end
|
754
|
+
end; alias bold make_bold # === bold
|
947
755
|
|
948
756
|
# ========================================================================= #
|
949
|
-
# ===
|
757
|
+
# === on_key_press_event
|
950
758
|
# ========================================================================= #
|
951
|
-
def
|
952
|
-
|
759
|
+
def on_key_press_event(&block)
|
760
|
+
signal_connect(:key_press_event, &block)
|
953
761
|
end
|
954
762
|
|
955
763
|
# ========================================================================= #
|
956
|
-
# ===
|
764
|
+
# === tooltip=
|
957
765
|
# ========================================================================= #
|
958
|
-
def
|
959
|
-
|
766
|
+
def tooltip=(i)
|
767
|
+
::Gtk.tooltip_for(self, i)
|
960
768
|
end
|
961
769
|
|
962
770
|
# ========================================================================= #
|
963
|
-
# ===
|
771
|
+
# === on_value_changed
|
964
772
|
# ========================================================================= #
|
965
|
-
def
|
966
|
-
|
967
|
-
end
|
968
|
-
alias parse_markup enable_markup # === parse_markup
|
969
|
-
alias markify enable_markup # === markify
|
773
|
+
def on_value_changed(&block)
|
774
|
+
signal_connect(:value_changed, &block)
|
775
|
+
end
|
970
776
|
|
971
777
|
# ========================================================================= #
|
972
|
-
# ===
|
973
|
-
#
|
974
|
-
# This can be used for quick debugging, when you have a widget that is
|
975
|
-
# not responding to some events, to simply turn them all on.
|
778
|
+
# === tooltip
|
976
779
|
#
|
977
|
-
#
|
978
|
-
# it for ruby-gtk2 as well.
|
780
|
+
# Attach a small tooltip to the button at hand.
|
979
781
|
#
|
980
|
-
#
|
981
|
-
#
|
982
|
-
# 2021 was because it is simpler to "implement".
|
782
|
+
# The argument to this method should be a String, denoting which
|
783
|
+
# text should be displayed.
|
983
784
|
# ========================================================================= #
|
984
|
-
def
|
985
|
-
|
785
|
+
def tooltip(
|
786
|
+
text_for_the_tooltip = ''
|
986
787
|
)
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
# ========================================================================= #
|
994
|
-
# === on_mouse_button_clicked
|
995
|
-
# ========================================================================= #
|
996
|
-
def on_mouse_button_clicked(&block)
|
997
|
-
signal_connect(:event) {|widget, event|
|
998
|
-
if event.is_a?(Gdk::EventButton) and
|
999
|
-
(event.event_type.name == 'GDK_BUTTON_PRESS')# and
|
1000
|
-
case event.button
|
1001
|
-
when 1,2,3 # These are all left-mouse-button events.
|
1002
|
-
yield if block_given?
|
1003
|
-
end
|
788
|
+
# if ::Gtk.use_gtk2?
|
789
|
+
# ::Gtk::Tooltips.new.set_tip(self, text_for_the_tooltip, nil)
|
790
|
+
# else # else assume ruby-gtk3 or ruby-gtk4.
|
791
|
+
if text_for_the_tooltip.is_a? String
|
792
|
+
text_for_the_tooltip = { text: text_for_the_tooltip }
|
1004
793
|
end
|
1005
|
-
|
1006
|
-
|
794
|
+
::Gtk::Tooltip.new(text_for_the_tooltip)
|
795
|
+
# end
|
796
|
+
end; alias use_this_tooltip tooltip # === use_this_tooltip
|
797
|
+
# alias tooltip= tooltip # === tooltip=
|
1007
798
|
|
1008
799
|
# ========================================================================= #
|
1009
|
-
# ===
|
1010
|
-
#
|
1011
|
-
# This is currently (January 2021) unfinished. One day we want to
|
1012
|
-
# respond to double-click events.
|
800
|
+
# === read_only
|
1013
801
|
# ========================================================================= #
|
1014
|
-
def
|
1015
|
-
|
1016
|
-
|
1017
|
-
# ======================================================================= #
|
1018
|
-
# Assume ruby-gtk2 here:
|
1019
|
-
# ======================================================================= #
|
1020
|
-
if ::Gtk.use_gtk2? and
|
1021
|
-
(event.event_type == Gdk::Event::BUTTON2_PRESS) and
|
1022
|
-
(event.button == 1)
|
1023
|
-
signal_connect(:button_press_event, &block)
|
1024
|
-
# ======================================================================= #
|
1025
|
-
# assume ruby-gtk3 here.
|
1026
|
-
# ======================================================================= #
|
1027
|
-
elsif is_a_mouse_double_click_event?(event)
|
1028
|
-
signal_connect(:button_press_event, &block)
|
1029
|
-
end
|
1030
|
-
end; alias on_double_click on_mouse_double_click_event_UNFINISHED_METHOD # === on_double_click
|
802
|
+
def read_only
|
803
|
+
set_property('editable', false)
|
804
|
+
end; alias it_can_not_be_edited read_only # === it_can_not_be_edited
|
1031
805
|
|
1032
806
|
# ========================================================================= #
|
1033
|
-
# ===
|
1034
|
-
#
|
1035
|
-
# This method allows you to easily respond to mouse-double-click events.
|
807
|
+
# === set_width_request
|
1036
808
|
# ========================================================================= #
|
1037
|
-
def
|
1038
|
-
|
1039
|
-
if is_a_mouse_double_click_event?(event)
|
1040
|
-
yield
|
1041
|
-
end
|
1042
|
-
}
|
809
|
+
def set_width_request(i = 85)
|
810
|
+
set_property('width-request', i)
|
1043
811
|
end
|
1044
812
|
|
1045
813
|
# ========================================================================= #
|
1046
|
-
# ===
|
814
|
+
# === set_height_request
|
1047
815
|
# ========================================================================= #
|
1048
|
-
def
|
1049
|
-
|
1050
|
-
case event.event_type.name
|
1051
|
-
when 'GDK_2BUTTON_PRESS' # Double-click event here.
|
1052
|
-
return true
|
1053
|
-
when 'GDK_BUTTON_PRESS'
|
1054
|
-
if event.button == 1
|
1055
|
-
return false # Could be true, though.
|
1056
|
-
else
|
1057
|
-
return false
|
1058
|
-
end
|
1059
|
-
end
|
1060
|
-
else
|
1061
|
-
false
|
1062
|
-
end
|
816
|
+
def set_height_request(i = 85)
|
817
|
+
set_property('height-request', i)
|
1063
818
|
end
|
1064
819
|
|
1065
820
|
# ========================================================================= #
|
1066
|
-
# ===
|
1067
|
-
#
|
1068
|
-
# This is the event when the right mouse button is clicked.
|
821
|
+
# === red
|
1069
822
|
# ========================================================================= #
|
1070
|
-
def
|
1071
|
-
|
1072
|
-
|
1073
|
-
(event.event_type.name == 'GDK_BUTTON_PRESS') and
|
1074
|
-
(event.button == 3)
|
1075
|
-
yield if block_given?
|
1076
|
-
end
|
1077
|
-
}
|
1078
|
-
end; alias on_right_mouse_button_click on_right_mouse_button_clicked # === on_right_mouse_button_click
|
1079
|
-
alias on_right_mouse_button_click_event on_right_mouse_button_clicked # === on_right_mouse_button_click_event
|
823
|
+
def red
|
824
|
+
modify_foreground(__method__)
|
825
|
+
end
|
1080
826
|
|
1081
827
|
# ========================================================================= #
|
1082
|
-
# ===
|
828
|
+
# === is_padded
|
829
|
+
#
|
830
|
+
# This method uses a hardcoded value for the "padding" in use.
|
1083
831
|
# ========================================================================= #
|
1084
|
-
def
|
832
|
+
def is_padded(i = 8)
|
1085
833
|
set_border_width(i)
|
1086
|
-
end
|
834
|
+
end
|
1087
835
|
|
1088
836
|
# ========================================================================= #
|
1089
|
-
# ===
|
1090
|
-
#
|
1091
|
-
# Whenever the gtk-entry changes, we connect a change to another widget,
|
1092
|
-
# which is usually some spinner. This method can be used to achieve
|
1093
|
-
# precisely this.
|
837
|
+
# === on_button_press_event
|
1094
838
|
# ========================================================================= #
|
1095
|
-
def
|
1096
|
-
|
1097
|
-
signal_connect(:value_changed) {|widget, event|
|
1098
|
-
this_widget.set_text(text?)
|
1099
|
-
}
|
839
|
+
def on_button_press_event(&block)
|
840
|
+
signal_connect(:button_press_event, &block)
|
1100
841
|
end
|
1101
842
|
|
1102
843
|
# ========================================================================= #
|
@@ -1338,336 +1079,406 @@ class Widget # === Gtk::Widget
|
|
1338
1079
|
css_class('mar10px')
|
1339
1080
|
end
|
1340
1081
|
|
1341
|
-
require 'gtk_paradise/colours/parse.rb'
|
1342
1082
|
# ========================================================================= #
|
1343
|
-
# ===
|
1083
|
+
# === width_height
|
1344
1084
|
#
|
1345
|
-
# This method
|
1085
|
+
# This method is just a little wrapper over .set_size_request().
|
1346
1086
|
# ========================================================================= #
|
1347
|
-
def
|
1348
|
-
|
1349
|
-
|
1087
|
+
def width_height(
|
1088
|
+
width = 560,
|
1089
|
+
height = 160
|
1350
1090
|
)
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
)
|
1361
|
-
else
|
1091
|
+
set_size_request(width, height)
|
1092
|
+
end
|
1093
|
+
|
1094
|
+
# ========================================================================= #
|
1095
|
+
# === pretty_tooltip
|
1096
|
+
# ========================================================================= #
|
1097
|
+
def pretty_tooltip(i)
|
1098
|
+
if i and i.include?('&')
|
1099
|
+
i = i.dup if i.frozen?
|
1362
1100
|
# ===================================================================== #
|
1363
|
-
#
|
1364
|
-
#
|
1365
|
-
# state: the state for which to set the color
|
1101
|
+
# Oddly enough, ruby-gtk2 complains about this character.
|
1366
1102
|
#
|
1367
|
-
#
|
1368
|
-
#
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
#
|
1374
|
-
# The available StateFlags constants are:
|
1375
|
-
#
|
1376
|
-
# [:ACTIVE, :INCONSISTENT, :PRELIGHT, :BACKDROP, :VISITED,
|
1377
|
-
# :CHECKED, :LINK, :FOCUSED, :INSENSITIVE, :DROP_ACTIVE,
|
1378
|
-
# :SELECTED, :NORMAL, :DIR_LTR, :DIR_RTL]
|
1379
|
-
#
|
1380
|
-
# =================================================================== #
|
1381
|
-
case state.inspect.to_s
|
1382
|
-
when /prelight/
|
1383
|
-
state = :PRELIGHT
|
1384
|
-
when /active/
|
1385
|
-
state = :ACTIVE
|
1386
|
-
when /normal/
|
1387
|
-
state = :NORMAL
|
1388
|
-
else
|
1389
|
-
puts 'Not yet registered state: '+state.inspect.to_s
|
1390
|
-
end
|
1391
|
-
end
|
1392
|
-
# ===================================================================== #
|
1393
|
-
# ruby-gtk3 wants Gdk::RGBA rather than Gdk::Color. So we must
|
1394
|
-
# convert this next.
|
1103
|
+
# The warning was: "Gtk-WARNING **: Failed to set text from
|
1104
|
+
# markup due to error parsing markup" [...] Entity did not
|
1105
|
+
# end with a semicolon; most likely you used an ampersand
|
1106
|
+
# character without intending to start an entity - escape
|
1107
|
+
# ampersand as &"
|
1108
|
+
# So we do this ^^^.
|
1395
1109
|
# ===================================================================== #
|
1396
|
-
|
1397
|
-
colour = ::Gtk.convert_gdk_colour_to_gdk_rgba_colour(colour)
|
1398
|
-
# =================================================================== #
|
1399
|
-
# Or:
|
1400
|
-
# colour = Gdk::RGBA.new(*array)
|
1401
|
-
# colour.parse(colour.to_s).to_s # (*array)
|
1402
|
-
# =================================================================== #
|
1403
|
-
end
|
1404
|
-
override_color(
|
1405
|
-
state, colour
|
1406
|
-
)
|
1110
|
+
i.gsub!(/&/, '&')
|
1407
1111
|
end
|
1408
|
-
|
1409
|
-
|
1410
|
-
alias
|
1411
|
-
alias
|
1412
|
-
alias
|
1413
|
-
alias
|
1414
|
-
alias
|
1415
|
-
alias
|
1112
|
+
set_tooltip_markup(i)
|
1113
|
+
end; alias pretty_tooltip= pretty_tooltip # === pretty_tooltip=
|
1114
|
+
alias fancy_tooltip= pretty_tooltip # === fancy_tooltip=
|
1115
|
+
alias fancy_tooltips= pretty_tooltip # === fancy_tooltips=
|
1116
|
+
alias hint= pretty_tooltip # === hint=
|
1117
|
+
alias info pretty_tooltip # === info
|
1118
|
+
alias popup_hint pretty_tooltip # === popup_hint
|
1119
|
+
alias fancy_tip pretty_tooltip # === fancy_tip
|
1120
|
+
alias fancy_hint pretty_tooltip # === fancy_hint
|
1121
|
+
alias fancy_hint= pretty_tooltip # === fancy_hint=
|
1122
|
+
alias set_hovertip pretty_tooltip # === set_hovertip
|
1416
1123
|
|
1417
1124
|
# ========================================================================= #
|
1418
|
-
# ===
|
1125
|
+
# === on_scroll_event
|
1126
|
+
#
|
1127
|
+
# This is the event that occurs when the mouse-scroll-wheel is clicked.
|
1419
1128
|
# ========================================================================= #
|
1420
|
-
def
|
1421
|
-
|
1422
|
-
end
|
1129
|
+
def on_scroll_event(&block)
|
1130
|
+
signal_connect(:scroll_event, &block)
|
1131
|
+
end; alias on_scrolled on_scroll_event # === on_scrolled
|
1132
|
+
alias on_scrolling on_scroll_event # === on_scrolling
|
1133
|
+
alias on_scrolling_event on_scroll_event # === on_scrolling_event
|
1134
|
+
alias on_mouse_scroll_event on_scroll_event # === on_mouse_scroll_event
|
1423
1135
|
|
1424
1136
|
# ========================================================================= #
|
1425
|
-
# ===
|
1137
|
+
# === make_bold_font
|
1426
1138
|
#
|
1427
|
-
# This
|
1428
|
-
#
|
1139
|
+
# This makes use of CSS rules, so it will not work for ruby-gtk2 by
|
1140
|
+
# default.
|
1429
1141
|
# ========================================================================= #
|
1430
|
-
def
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1142
|
+
def make_bold_font
|
1143
|
+
add_css_class 'bold_font'
|
1144
|
+
end
|
1145
|
+
|
1146
|
+
# ========================================================================= #
|
1147
|
+
# Next we will define some colour-CSS clases:
|
1148
|
+
# ========================================================================= #
|
1149
|
+
%w(
|
1150
|
+
bindigo1
|
1151
|
+
bdarkorchid1
|
1152
|
+
blightgreen1
|
1153
|
+
bnavy1
|
1154
|
+
bsteelblue1
|
1155
|
+
darkblue
|
1156
|
+
darkgreen
|
1157
|
+
royalblue
|
1158
|
+
slateblue
|
1159
|
+
steelblue
|
1160
|
+
tomato
|
1161
|
+
).each {|this_colour_method|
|
1162
|
+
define_method(this_colour_method.to_sym) {
|
1163
|
+
add_css_class(__method__.to_s)
|
1164
|
+
}
|
1165
|
+
}
|
1437
1166
|
|
1438
1167
|
# ========================================================================= #
|
1439
|
-
# ===
|
1440
|
-
#
|
1441
|
-
# rpack stands for "right pack". This is ultimately just a wrapper over
|
1442
|
-
# .pack_end().
|
1168
|
+
# === khaki_background
|
1443
1169
|
# ========================================================================= #
|
1444
|
-
def
|
1445
|
-
|
1446
|
-
padding_to_use = 0
|
1447
|
-
)
|
1448
|
-
if ::Gtk.use_gtk2?
|
1449
|
-
pack_end(widget, true, true, padding_to_use)
|
1450
|
-
else
|
1451
|
-
pack_end(
|
1452
|
-
widget,
|
1453
|
-
fill: true,
|
1454
|
-
expand: true,
|
1455
|
-
padding: padding_to_use
|
1456
|
-
)
|
1457
|
-
end
|
1170
|
+
def khaki_background
|
1171
|
+
add_css_class('BG_khaki')
|
1458
1172
|
end
|
1459
1173
|
|
1460
1174
|
# ========================================================================= #
|
1461
|
-
# ===
|
1462
|
-
#
|
1463
|
-
# This method can be used to sync-connect two different widgets. This
|
1464
|
-
# is usually done to connect a combo-box to an entry, so whenever the
|
1465
|
-
# user changes the combo-box, the entry is also updated.
|
1466
|
-
#
|
1467
|
-
# Make sure that you pass the correct widgets to this method - I
|
1468
|
-
# accidentally passed the same widget into both arguments, which
|
1469
|
-
# of course leads to a failure.
|
1175
|
+
# === light_green_background
|
1470
1176
|
# ========================================================================= #
|
1471
|
-
def
|
1472
|
-
|
1473
|
-
|
1474
|
-
widget1.on_changed {
|
1475
|
-
text = widget1.text?.to_s
|
1476
|
-
widget2.set_text(text)
|
1477
|
-
}
|
1478
|
-
end
|
1177
|
+
def light_green_background
|
1178
|
+
add_css_class('BG_light_green')
|
1179
|
+
end; alias lightgreen_background light_green_background # === lightgreen_background
|
1479
1180
|
|
1480
1181
|
# ========================================================================= #
|
1481
|
-
# ===
|
1482
|
-
#
|
1483
|
-
# This method simplified the .pack_start() method.
|
1182
|
+
# === azure_background
|
1484
1183
|
# ========================================================================= #
|
1485
|
-
def
|
1486
|
-
|
1487
|
-
|
1488
|
-
)
|
1489
|
-
if ::Gtk.use_gtk2?
|
1490
|
-
pack_start(widget, true, true, padding_to_use)
|
1491
|
-
elsif ::Gtk.use_gtk4?
|
1492
|
-
append(widget)
|
1493
|
-
if padding_to_use
|
1494
|
-
css_class(
|
1495
|
-
'pad'+padding_to_use.to_s+'px'
|
1496
|
-
)
|
1497
|
-
end
|
1498
|
-
else
|
1499
|
-
pack_start(widget, expand: true, fill: true, padding: padding_to_use)
|
1500
|
-
end
|
1501
|
-
end; alias pack_with_expand pack_and_expand # === pack_with_expand
|
1502
|
-
alias pack_maximal pack_and_expand # === pack_maximal
|
1503
|
-
alias maximal pack_and_expand # === maximal
|
1184
|
+
def azure_background
|
1185
|
+
add_css_class('BG_azure')
|
1186
|
+
end; alias bg_azure azure_background # === bg_azure
|
1504
1187
|
|
1505
1188
|
# ========================================================================= #
|
1506
|
-
# ===
|
1189
|
+
# === bblack1px
|
1507
1190
|
# ========================================================================= #
|
1508
|
-
def
|
1509
|
-
|
1510
|
-
|
1511
|
-
)
|
1512
|
-
signal_connect(:event) {|widget, event|
|
1513
|
-
if event_left_mouse_button_click?(event)
|
1514
|
-
old_name = name # Keep track of the original colour.
|
1515
|
-
set_name(use_this_colour.to_s)
|
1516
|
-
Thread.new {
|
1517
|
-
duration = hash[:duration]
|
1518
|
-
sleep duration
|
1519
|
-
set_name(old_name)
|
1520
|
-
}
|
1521
|
-
end
|
1522
|
-
}
|
1523
|
-
end
|
1191
|
+
def bblack1px
|
1192
|
+
css_class('bblack1')
|
1193
|
+
end; alias bblack1 bblack1px # === bblack1
|
1524
1194
|
|
1525
1195
|
# ========================================================================= #
|
1526
|
-
# ===
|
1527
|
-
#
|
1528
|
-
# This is mostly an ad-hoc method to enable the default CSS files to
|
1529
|
-
# work on toplevel-created widgets. It was added in September 2021.
|
1196
|
+
# === bblack2px
|
1530
1197
|
# ========================================================================= #
|
1531
|
-
def
|
1532
|
-
|
1533
|
-
end; alias
|
1198
|
+
def bblack2px
|
1199
|
+
css_class('bblack2')
|
1200
|
+
end; alias bblack2 bblack2px # === bblack2
|
1534
1201
|
|
1535
1202
|
# ========================================================================= #
|
1536
|
-
# ===
|
1537
|
-
#
|
1538
|
-
# This method uses a hardcoded value for the "padding" in use.
|
1203
|
+
# === bblack3px
|
1539
1204
|
# ========================================================================= #
|
1540
|
-
def
|
1541
|
-
|
1542
|
-
end
|
1205
|
+
def bblack3px
|
1206
|
+
css_class('bblack3')
|
1207
|
+
end; alias bblack3 bblack3px # === bblack3
|
1543
1208
|
|
1544
1209
|
# ========================================================================= #
|
1545
|
-
# ===
|
1210
|
+
# === bblack4px
|
1546
1211
|
# ========================================================================= #
|
1547
|
-
def
|
1548
|
-
|
1549
|
-
end
|
1212
|
+
def bblack4px
|
1213
|
+
css_class('bblack4')
|
1214
|
+
end; alias bblack4 bblack4px # === bblack4
|
1550
1215
|
|
1551
1216
|
# ========================================================================= #
|
1552
|
-
# ===
|
1217
|
+
# === bblack5px
|
1218
|
+
# ========================================================================= #
|
1219
|
+
def bblack5px
|
1220
|
+
css_class('bblack5')
|
1221
|
+
end; alias bblack5 bblack5px # === bblack5
|
1222
|
+
|
1223
|
+
# ========================================================================= #
|
1224
|
+
# === hcenter
|
1553
1225
|
#
|
1554
|
-
#
|
1555
|
-
#
|
1226
|
+
# The name "hcenter" is an abbreviation for "horizontal center" position.
|
1227
|
+
#
|
1228
|
+
# This variant has been confirmed to work for the gtk-hbox widget, in
|
1229
|
+
# July 2022.
|
1556
1230
|
# ========================================================================= #
|
1557
|
-
def
|
1558
|
-
|
1231
|
+
def hcenter(
|
1232
|
+
i = :center
|
1559
1233
|
)
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
alias
|
1570
|
-
alias
|
1234
|
+
case i
|
1235
|
+
# ======================================================================= #
|
1236
|
+
# === :center
|
1237
|
+
# ======================================================================= #
|
1238
|
+
when :center
|
1239
|
+
i = ::Gtk::Align::CENTER
|
1240
|
+
end
|
1241
|
+
set_halign(i) # Or Gtk::Align::CENTER
|
1242
|
+
end; alias horizontal_center hcenter # === horizontal_center
|
1243
|
+
alias halign_center hcenter # === halign_center
|
1244
|
+
alias hjustify hcenter # === hjustify
|
1245
|
+
alias center_this_widget hcenter # === center_this_widget
|
1246
|
+
alias clever_center hcenter # === clever_center
|
1247
|
+
alias center_into_the_middle hcenter # === center_into_the_middle
|
1248
|
+
alias centered_container hcenter # === centered_container
|
1571
1249
|
|
1572
1250
|
# ========================================================================= #
|
1573
1251
|
# === do_focus
|
1252
|
+
#
|
1253
|
+
# This variant is a slightly nicer-looking variant compared to the
|
1254
|
+
# .set_focus(true) variant.
|
1574
1255
|
# ========================================================================= #
|
1575
1256
|
def do_focus
|
1576
1257
|
set_focus(true)
|
1577
|
-
end
|
1258
|
+
end; alias do_focus_on_it do_focus # === do_focus_on_it
|
1259
|
+
alias do_select do_focus # === do_select
|
1578
1260
|
|
1579
1261
|
# ========================================================================= #
|
1580
|
-
# ===
|
1262
|
+
# === on_click_event
|
1263
|
+
#
|
1264
|
+
# This is a shortcut to respond to an on-click event, which is the
|
1265
|
+
# left mouse click normally.
|
1266
|
+
#
|
1267
|
+
# You can enable this in your code by doing:
|
1268
|
+
#
|
1269
|
+
# .on_click_event { :highlight_text }
|
1270
|
+
# .on_click_event { :deselect_text }
|
1271
|
+
#
|
1581
1272
|
# ========================================================================= #
|
1582
|
-
def
|
1583
|
-
|
1273
|
+
def on_click_event
|
1274
|
+
if block_given?
|
1275
|
+
yielded = yield
|
1276
|
+
case yielded
|
1277
|
+
# ===================================================================== #
|
1278
|
+
# === :highlight_text
|
1279
|
+
# ===================================================================== #
|
1280
|
+
when :highlight_text,
|
1281
|
+
:select_everything,
|
1282
|
+
:select_text
|
1283
|
+
on_button_press_event { |widget, event|
|
1284
|
+
set_focus(true)
|
1285
|
+
select_region(0, -1)
|
1286
|
+
}
|
1287
|
+
# ===================================================================== #
|
1288
|
+
# === :deselect_text
|
1289
|
+
#
|
1290
|
+
# This will deselect any selection on a gtk-entry. It is not as
|
1291
|
+
# useful as the :highlight_text functionality, but I wanted to
|
1292
|
+
# provide both, simply to quickly show how it is done.
|
1293
|
+
# ===================================================================== #
|
1294
|
+
when :deselect_text
|
1295
|
+
on_button_press_event { |widget, event|
|
1296
|
+
set_focus(true)
|
1297
|
+
select_region(0, 0)
|
1298
|
+
}
|
1299
|
+
end
|
1300
|
+
end
|
1584
1301
|
end
|
1585
1302
|
|
1586
1303
|
# ========================================================================= #
|
1587
|
-
# ===
|
1304
|
+
# === shadow_type_etched_in
|
1588
1305
|
# ========================================================================= #
|
1589
|
-
def
|
1590
|
-
|
1591
|
-
i.flatten.each_slice(2).each {|text_to_display, colour_to_use|
|
1592
|
-
if colour_to_use
|
1593
|
-
_ << '<span weight="bold" foreground="'+colour_to_use.to_s+'">'+
|
1594
|
-
text_to_display.to_s+'</span>'
|
1595
|
-
else
|
1596
|
-
_ << text_to_display.to_s
|
1597
|
-
end
|
1598
|
-
}
|
1599
|
-
set_markup(_)
|
1306
|
+
def shadow_type_etched_in
|
1307
|
+
set_shadow_type(::Gtk::SHADOW_ETCHED_IN)
|
1600
1308
|
end
|
1601
1309
|
|
1602
1310
|
# ========================================================================= #
|
1603
|
-
# ===
|
1311
|
+
# === align_to_right
|
1604
1312
|
# ========================================================================= #
|
1605
|
-
def
|
1606
|
-
|
1607
|
-
end
|
1313
|
+
def align_to_right
|
1314
|
+
set_halign(:end) # halign=Gtk.Align.END
|
1315
|
+
end
|
1608
1316
|
|
1609
1317
|
# ========================================================================= #
|
1610
|
-
# ===
|
1318
|
+
# === enable_all_events
|
1611
1319
|
#
|
1612
|
-
# This
|
1613
|
-
#
|
1320
|
+
# This can be used for quick debugging, when you have a widget that is
|
1321
|
+
# not responding to some events, to simply turn them all on.
|
1322
|
+
#
|
1323
|
+
# This currently only works for ruby-gtk3. Not sure if we should enable
|
1324
|
+
# it for ruby-gtk2 as well.
|
1325
|
+
#
|
1326
|
+
# Note that the method-alias called "enable_enter_event" is, strictly
|
1327
|
+
# speaking, a misnomer. The reason why this was added still in August
|
1328
|
+
# 2021 was because it is simpler to "implement".
|
1614
1329
|
# ========================================================================= #
|
1615
|
-
def
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1330
|
+
def enable_all_events(
|
1331
|
+
i = Gdk::EventMask::ALL_EVENTS_MASK
|
1332
|
+
)
|
1333
|
+
set_events(i)
|
1334
|
+
end; alias all_events enable_all_events # === all_events
|
1335
|
+
alias enable_events enable_all_events # === enable_events
|
1336
|
+
alias enable_enter_event enable_all_events # === enable_enter_event
|
1337
|
+
alias respond_to_enter_event enable_all_events # === respond_to_enter_event
|
1619
1338
|
|
1620
1339
|
# ========================================================================= #
|
1621
|
-
# ===
|
1340
|
+
# === on_mouse_button_clicked
|
1622
1341
|
# ========================================================================= #
|
1623
|
-
def
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1342
|
+
def on_mouse_button_clicked(&block)
|
1343
|
+
signal_connect(:event) {|widget, event|
|
1344
|
+
if event.is_a?(Gdk::EventButton) and
|
1345
|
+
(event.event_type.name == 'GDK_BUTTON_PRESS')# and
|
1346
|
+
case event.button
|
1347
|
+
when 1,2,3 # These are all left-mouse-button events.
|
1348
|
+
yield if block_given?
|
1349
|
+
end
|
1350
|
+
end
|
1351
|
+
}
|
1352
|
+
end; alias on_mouse_click on_mouse_button_clicked # === on_mouse_click
|
1627
1353
|
|
1628
1354
|
# ========================================================================= #
|
1629
|
-
# ===
|
1355
|
+
# === sync_connect
|
1356
|
+
#
|
1357
|
+
# This method can be used to sync-connect two different widgets. This
|
1358
|
+
# is usually done to connect a combo-box to an entry, so whenever the
|
1359
|
+
# user changes the combo-box, the entry is also updated.
|
1360
|
+
#
|
1361
|
+
# Make sure that you pass the correct widgets to this method - I
|
1362
|
+
# accidentally passed the same widget into both arguments, which
|
1363
|
+
# of course leads to a failure.
|
1364
|
+
#
|
1365
|
+
# This method may have to be extended in the future, if we need
|
1366
|
+
# to combine other widgets more easily so.
|
1630
1367
|
# ========================================================================= #
|
1631
|
-
def
|
1632
|
-
|
1368
|
+
def sync_connect(
|
1369
|
+
widget1,
|
1370
|
+
widget2
|
1371
|
+
)
|
1372
|
+
widget1.on_changed {
|
1373
|
+
text = widget1.text?.to_s
|
1374
|
+
widget2.set_text(text)
|
1375
|
+
}
|
1633
1376
|
end
|
1634
1377
|
|
1635
1378
|
# ========================================================================= #
|
1636
|
-
# ===
|
1379
|
+
# === on_key_pressed
|
1637
1380
|
#
|
1638
|
-
#
|
1381
|
+
# When the user hits the enter key, we will do an action supplied
|
1382
|
+
# in via the yield method.
|
1639
1383
|
# ========================================================================= #
|
1640
|
-
def
|
1641
|
-
|
1642
|
-
delay_in_n_seconds = 3
|
1384
|
+
def on_key_pressed(
|
1385
|
+
this_key = :enter
|
1643
1386
|
)
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1387
|
+
signal_connect(:key_press_event) {|widget, event|
|
1388
|
+
if ::Gtk.enter_key?(event) # Handle the enter-key here.
|
1389
|
+
yield if block_given?
|
1390
|
+
end
|
1391
|
+
}
|
1392
|
+
end; alias click_event_when_enter_key_was_pressed on_key_pressed # === click_event_when_enter_key_was_pressed
|
1393
|
+
alias on_enter_key on_key_pressed # === on_enter_key
|
1394
|
+
alias on_enter_key_pressed on_key_pressed # === on_enter_key_pressed
|
1395
|
+
alias on_enter on_key_pressed # === on_enter
|
1396
|
+
alias on_enter_key_clicked on_key_pressed # === on_enter_key_clicked
|
1397
|
+
alias on_the_enter_key_was_pressed on_key_pressed # === on_the_enter_key_was_pressed
|
1651
1398
|
|
1652
1399
|
# ========================================================================= #
|
1653
|
-
# ===
|
1400
|
+
# === font?
|
1401
|
+
#
|
1402
|
+
# This adds experimental support for simply querying the font in use.
|
1654
1403
|
# ========================================================================= #
|
1655
|
-
def
|
1656
|
-
|
1404
|
+
def font?
|
1405
|
+
pango_context = self.pango_context
|
1406
|
+
font_description = pango_context.font_description
|
1407
|
+
font_in_use = font_description.to_s
|
1408
|
+
return font_in_use
|
1657
1409
|
end
|
1658
1410
|
|
1659
1411
|
# ========================================================================= #
|
1660
|
-
# ===
|
1412
|
+
# === set_font
|
1413
|
+
#
|
1414
|
+
# This is a slightly simpler way to set the font. We also allow for
|
1415
|
+
# Symbols here, such as :hack_25. This refers to the font called "Hack",
|
1416
|
+
# with a size of 25. Not all symbols are enabled, mind you - I only use
|
1417
|
+
# some, but may extend more over the coming months and years.
|
1661
1418
|
# ========================================================================= #
|
1662
|
-
def
|
1663
|
-
|
1664
|
-
|
1419
|
+
def set_font(
|
1420
|
+
i = :dejavu_condensed_50
|
1421
|
+
)
|
1422
|
+
if i.is_a? Symbol
|
1423
|
+
i = ::Gtk.expand_this_font(i)
|
1424
|
+
end
|
1425
|
+
i = Pango::FontDescription.new(i)
|
1426
|
+
# if ::Gtk.use_gtk2?
|
1427
|
+
# modify_font(i)
|
1428
|
+
if ::Gtk.use_gtk3?
|
1429
|
+
override_font(i)
|
1430
|
+
elsif ::Gtk.use_gtk4?
|
1431
|
+
# ===================================================================== #
|
1432
|
+
# Add it as a CSS rule next:
|
1433
|
+
# ===================================================================== #
|
1434
|
+
use_this_new_CSS_rule = '.font_'+i.to_s.downcase.tr(' ','_')+' {
|
1435
|
+
font-family: '+i.to_s+';
|
1436
|
+
}
|
1437
|
+
'
|
1438
|
+
css_class(use_this_new_CSS_rule)
|
1439
|
+
else
|
1440
|
+
e 'Unknown engine in use.'
|
1441
|
+
end
|
1442
|
+
end; alias font set_font # === font
|
1665
1443
|
|
1666
1444
|
# ========================================================================= #
|
1667
|
-
# ===
|
1445
|
+
# === increase_the_font_size_to
|
1446
|
+
#
|
1447
|
+
# The first argument has to be a percentage value for now. At a later
|
1448
|
+
# time this may change. The percentage value means a scaling factor,
|
1449
|
+
# such as "150%" meaning to upscale to 1.5 the former size.
|
1668
1450
|
# ========================================================================= #
|
1669
|
-
def
|
1670
|
-
|
1451
|
+
def increase_the_font_size_to(to = '150%')
|
1452
|
+
# ======================================================================= #
|
1453
|
+
# First, obtain the old font size that is currently in use by the
|
1454
|
+
# widget at hand.
|
1455
|
+
# ======================================================================= #
|
1456
|
+
#old_font = ::Gtk::Settings.default.gtk_font_name
|
1457
|
+
pango_context = self.pango_context
|
1458
|
+
font_description = pango_context.font_description
|
1459
|
+
old_font = font_description.to_s
|
1460
|
+
# ======================================================================= #
|
1461
|
+
# Next, scale it up. The assumed value in old_font should look like
|
1462
|
+
# this:
|
1463
|
+
#
|
1464
|
+
# "Noto Sans Bold 10"
|
1465
|
+
#
|
1466
|
+
# ======================================================================= #
|
1467
|
+
if old_font.include?(' ')
|
1468
|
+
splitted = old_font.split(' ')
|
1469
|
+
last_element = splitted.last # This should represent the font size at hand.
|
1470
|
+
scaled_up_last_element = last_element.to_f * (to.to_s.delete('%').to_f / 100.0)
|
1471
|
+
splitted[-1] = scaled_up_last_element.to_s
|
1472
|
+
new_font = splitted.join(' ')
|
1473
|
+
new_pango_font = Pango::FontDescription.new(new_font)
|
1474
|
+
# if ::Gtk.use_gtk2?
|
1475
|
+
# modify_font(new_pango_font)
|
1476
|
+
# else # else assume gtk3
|
1477
|
+
override_font(new_pango_font)
|
1478
|
+
# end
|
1479
|
+
else
|
1480
|
+
e "#{old_font} does not contain any \" \" tokens."
|
1481
|
+
end
|
1671
1482
|
end
|
1672
1483
|
|
1673
1484
|
# ========================================================================= #
|
@@ -1691,121 +1502,159 @@ class Widget # === Gtk::Widget
|
|
1691
1502
|
# ^^^ this alias would lead to the following error: "rbgobj_signal.c:939: warning: previous definition of activate was here"
|
1692
1503
|
|
1693
1504
|
# ========================================================================= #
|
1694
|
-
# ===
|
1505
|
+
# === do_focus
|
1695
1506
|
# ========================================================================= #
|
1696
|
-
def
|
1697
|
-
|
1507
|
+
def do_focus
|
1508
|
+
set_focus(true)
|
1698
1509
|
end
|
1699
1510
|
|
1700
1511
|
# ========================================================================= #
|
1701
|
-
# ===
|
1512
|
+
# === background_colour?
|
1702
1513
|
# ========================================================================= #
|
1703
|
-
def
|
1704
|
-
|
1514
|
+
def background_colour?
|
1515
|
+
return @background_colour
|
1516
|
+
end
|
1517
|
+
|
1518
|
+
# ========================================================================= #
|
1519
|
+
# === simple_markup
|
1520
|
+
# ========================================================================= #
|
1521
|
+
def simple_markup(*i)
|
1522
|
+
_ = ''.dup
|
1523
|
+
i.flatten.each_slice(2).each {|text_to_display, colour_to_use|
|
1524
|
+
if colour_to_use
|
1525
|
+
_ << '<span weight="bold" foreground="'+colour_to_use.to_s+'">'+
|
1526
|
+
text_to_display.to_s+'</span>'
|
1527
|
+
else
|
1528
|
+
_ << text_to_display.to_s
|
1529
|
+
end
|
1530
|
+
}
|
1531
|
+
set_markup(_)
|
1532
|
+
end
|
1533
|
+
|
1534
|
+
# ========================================================================= #
|
1535
|
+
# === pack_and_expand
|
1536
|
+
#
|
1537
|
+
# This method simplified the .pack_start() method.
|
1538
|
+
# ========================================================================= #
|
1539
|
+
def pack_and_expand(
|
1540
|
+
widget,
|
1541
|
+
padding_to_use = 0
|
1542
|
+
)
|
1543
|
+
# if ::Gtk.use_gtk2?
|
1544
|
+
# pack_start(widget, true, true, padding_to_use)
|
1545
|
+
if ::Gtk.use_gtk4?
|
1546
|
+
append(widget)
|
1547
|
+
if padding_to_use
|
1548
|
+
css_class(
|
1549
|
+
'pad'+padding_to_use.to_s+'px'
|
1550
|
+
)
|
1551
|
+
end
|
1552
|
+
else
|
1553
|
+
pack_start(widget, expand: true, fill: true, padding: padding_to_use)
|
1554
|
+
end
|
1555
|
+
end; alias pack_with_expand pack_and_expand # === pack_with_expand
|
1556
|
+
alias pack_maximal pack_and_expand # === pack_maximal
|
1557
|
+
alias maximal pack_and_expand # === maximal
|
1558
|
+
|
1559
|
+
# ========================================================================= #
|
1560
|
+
# === on_click_colour_change_to_this_colour
|
1561
|
+
# ========================================================================= #
|
1562
|
+
def on_click_colour_change_to_this_colour(
|
1563
|
+
use_this_colour = :mintcream,
|
1564
|
+
hash = {}
|
1565
|
+
)
|
1566
|
+
signal_connect(:event) {|widget, event|
|
1567
|
+
if event_left_mouse_button_click?(event)
|
1568
|
+
old_name = name # Keep track of the original colour.
|
1569
|
+
set_name(use_this_colour.to_s)
|
1570
|
+
Thread.new {
|
1571
|
+
duration = hash[:duration]
|
1572
|
+
sleep duration
|
1573
|
+
set_name(old_name)
|
1574
|
+
}
|
1575
|
+
end
|
1576
|
+
}
|
1705
1577
|
end
|
1706
1578
|
|
1707
1579
|
# ========================================================================= #
|
1708
|
-
# ===
|
1580
|
+
# === try_to_add_default_CSS_rules
|
1581
|
+
#
|
1582
|
+
# This is mostly an ad-hoc method to enable the default CSS files to
|
1583
|
+
# work on toplevel-created widgets. It was added in September 2021.
|
1709
1584
|
# ========================================================================= #
|
1710
|
-
def
|
1711
|
-
|
1712
|
-
end
|
1585
|
+
def try_to_add_default_CSS_rules
|
1586
|
+
::Gtk.initialize_default_css_provider
|
1587
|
+
end; alias enable_free_form_css try_to_add_default_CSS_rules # === enable_free_form_css
|
1713
1588
|
|
1714
1589
|
# ========================================================================= #
|
1715
|
-
# ===
|
1716
|
-
#
|
1717
|
-
# Attach a small tooltip to the button at hand.
|
1590
|
+
# === on_mouse_double_click_event
|
1718
1591
|
#
|
1719
|
-
#
|
1720
|
-
# text should be displayed.
|
1592
|
+
# This method allows you to easily respond to mouse-double-click events.
|
1721
1593
|
# ========================================================================= #
|
1722
|
-
def
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
::Gtk::Tooltips.new.set_tip(self, text_for_the_tooltip, nil)
|
1727
|
-
else # else assume ruby-gtk3 or ruby-gtk4.
|
1728
|
-
if text_for_the_tooltip.is_a? String
|
1729
|
-
text_for_the_tooltip = { text: text_for_the_tooltip }
|
1594
|
+
def on_mouse_double_click_event(&block)
|
1595
|
+
signal_connect(:button_press_event) {|widget, event|
|
1596
|
+
if is_a_mouse_double_click_event?(event)
|
1597
|
+
yield
|
1730
1598
|
end
|
1731
|
-
|
1732
|
-
|
1733
|
-
end; alias use_this_tooltip tooltip # === use_this_tooltip
|
1734
|
-
# alias tooltip= tooltip # === tooltip=
|
1599
|
+
}
|
1600
|
+
end
|
1735
1601
|
|
1736
1602
|
# ========================================================================= #
|
1737
|
-
# ===
|
1603
|
+
# === is_a_mouse_double_click_event?
|
1738
1604
|
# ========================================================================= #
|
1739
|
-
def
|
1740
|
-
|
1741
|
-
|
1605
|
+
def is_a_mouse_double_click_event?(event)
|
1606
|
+
if ::Gtk.use_gtk3?
|
1607
|
+
case event.event_type.name
|
1608
|
+
when 'GDK_2BUTTON_PRESS' # Double-click event here.
|
1609
|
+
return true
|
1610
|
+
when 'GDK_BUTTON_PRESS'
|
1611
|
+
if event.button == 1
|
1612
|
+
return false # Could be true, though.
|
1613
|
+
else
|
1614
|
+
return false
|
1615
|
+
end
|
1616
|
+
end
|
1617
|
+
else
|
1618
|
+
false
|
1619
|
+
end
|
1620
|
+
end
|
1742
1621
|
|
1743
1622
|
# ========================================================================= #
|
1744
|
-
# ===
|
1623
|
+
# === on_right_mouse_button_clicked
|
1745
1624
|
#
|
1746
|
-
# This
|
1625
|
+
# This is the event when the right mouse button is clicked.
|
1747
1626
|
# ========================================================================= #
|
1748
|
-
def
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1627
|
+
def on_right_mouse_button_clicked(&block)
|
1628
|
+
signal_connect(:event) {|widget, event|
|
1629
|
+
if event.is_a?(Gdk::EventButton) and
|
1630
|
+
(event.event_type.name == 'GDK_BUTTON_PRESS') and
|
1631
|
+
(event.button == 3)
|
1632
|
+
yield if block_given?
|
1633
|
+
end
|
1634
|
+
}
|
1635
|
+
end; alias on_right_mouse_button_click on_right_mouse_button_clicked # === on_right_mouse_button_click
|
1636
|
+
alias on_right_mouse_button_click_event on_right_mouse_button_clicked # === on_right_mouse_button_click_event
|
1754
1637
|
|
1755
1638
|
# ========================================================================= #
|
1756
|
-
# ===
|
1757
|
-
#
|
1758
|
-
# The first argument has to be a percentage value for now. At a later
|
1759
|
-
# time this may change. The percentage value means a scaling factor,
|
1760
|
-
# such as "150%" meaning to upscale to 1.5 the former size.
|
1639
|
+
# === padding=
|
1761
1640
|
# ========================================================================= #
|
1762
|
-
def
|
1763
|
-
|
1764
|
-
|
1765
|
-
# widget at hand.
|
1766
|
-
# ======================================================================= #
|
1767
|
-
#old_font = ::Gtk::Settings.default.gtk_font_name
|
1768
|
-
pango_context = self.pango_context
|
1769
|
-
font_description = pango_context.font_description
|
1770
|
-
old_font = font_description.to_s
|
1771
|
-
# ======================================================================= #
|
1772
|
-
# Next, scale it up. The assumed value in old_font should look like
|
1773
|
-
# this:
|
1774
|
-
#
|
1775
|
-
# "Noto Sans Bold 10"
|
1776
|
-
#
|
1777
|
-
# ======================================================================= #
|
1778
|
-
if old_font.include?(' ')
|
1779
|
-
splitted = old_font.split(' ')
|
1780
|
-
last_element = splitted.last # This should represent the font size at hand.
|
1781
|
-
scaled_up_last_element = last_element.to_f * (to.to_s.delete('%').to_f / 100.0)
|
1782
|
-
splitted[-1] = scaled_up_last_element.to_s
|
1783
|
-
new_font = splitted.join(' ')
|
1784
|
-
new_pango_font = Pango::FontDescription.new(new_font)
|
1785
|
-
if ::Gtk.use_gtk2?
|
1786
|
-
modify_font(new_pango_font)
|
1787
|
-
else # else assume gtk3
|
1788
|
-
override_font(new_pango_font)
|
1789
|
-
end
|
1790
|
-
else
|
1791
|
-
e "#{old_font} does not contain any \" \" tokens."
|
1792
|
-
end
|
1793
|
-
end
|
1641
|
+
def padding=(i)
|
1642
|
+
set_border_width(i)
|
1643
|
+
end; alias padding padding= # === padding
|
1794
1644
|
|
1795
1645
|
# ========================================================================= #
|
1796
|
-
# ===
|
1646
|
+
# === connect_to
|
1797
1647
|
#
|
1798
|
-
#
|
1799
|
-
#
|
1800
|
-
#
|
1648
|
+
# Whenever the gtk-entry changes, we connect a change to another widget,
|
1649
|
+
# which is usually some spinner. This method can be used to achieve
|
1650
|
+
# precisely this.
|
1801
1651
|
# ========================================================================= #
|
1802
|
-
def
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
end; alias bold make_bold # === bold
|
1652
|
+
def connect_to(this_widget)
|
1653
|
+
this_widget.enable_scroll_events
|
1654
|
+
signal_connect(:value_changed) {|widget, event|
|
1655
|
+
this_widget.set_text(text?)
|
1656
|
+
}
|
1657
|
+
end
|
1809
1658
|
|
1810
1659
|
# ========================================================================= #
|
1811
1660
|
# === on_toggled
|
@@ -1853,22 +1702,22 @@ class Widget # === Gtk::Widget
|
|
1853
1702
|
# ======================================================================= #
|
1854
1703
|
# === Handle ruby-gtk2 first
|
1855
1704
|
# ======================================================================= #
|
1856
|
-
if ::Gtk.use_gtk2?
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1705
|
+
# if ::Gtk.use_gtk2?
|
1706
|
+
# begin
|
1707
|
+
# pack_start(
|
1708
|
+
# widget,
|
1709
|
+
# false,
|
1710
|
+
# false,
|
1711
|
+
# padding_to_use
|
1712
|
+
# )
|
1713
|
+
# rescue ArgumentError => error
|
1714
|
+
# puts 'An error happened in '+__FILE__+' (method: pack_without_expand())'
|
1715
|
+
# pp error
|
1716
|
+
# puts 'caller() was:'
|
1717
|
+
# pp caller()
|
1718
|
+
# exit
|
1719
|
+
# end
|
1720
|
+
if ::Gtk.use_gtk4?
|
1872
1721
|
# ===================================================================== #
|
1873
1722
|
# === Handle ruby-gtk4 here
|
1874
1723
|
# ===================================================================== #
|
@@ -1876,8 +1725,8 @@ class Widget # === Gtk::Widget
|
|
1876
1725
|
widget
|
1877
1726
|
)
|
1878
1727
|
if padding_to_use
|
1879
|
-
|
1880
|
-
|
1728
|
+
add_css_class(
|
1729
|
+
"pad#{padding_to_use}px"
|
1881
1730
|
)
|
1882
1731
|
end
|
1883
1732
|
else # else handle ruby-gtk3
|
@@ -1899,36 +1748,162 @@ class Widget # === Gtk::Widget
|
|
1899
1748
|
end
|
1900
1749
|
|
1901
1750
|
# ========================================================================= #
|
1902
|
-
# ===
|
1751
|
+
# === scroll_up?
|
1903
1752
|
#
|
1904
|
-
# This
|
1905
|
-
#
|
1906
|
-
# with a size of 25. Not all symbols are enabled, mind you - I only use
|
1907
|
-
# some, but may extend more over the coming months and years.
|
1753
|
+
# This method returns true if the scroll-event (of the middle mouse
|
1754
|
+
# button) is going upwards.
|
1908
1755
|
# ========================================================================= #
|
1909
|
-
def
|
1910
|
-
|
1756
|
+
def scroll_up?(event)
|
1757
|
+
(event.event_type.name == 'GDK_SCROLL') and
|
1758
|
+
(event.direction == Gdk::ScrollDirection::UP)
|
1759
|
+
end; alias scroll_up_event? scroll_up? # === scroll_up_event?
|
1760
|
+
|
1761
|
+
# ========================================================================= #
|
1762
|
+
# === scroll_down?
|
1763
|
+
#
|
1764
|
+
# This method returns true if the scroll-event (of the middle mouse
|
1765
|
+
# button) is going downwards.
|
1766
|
+
# ========================================================================= #
|
1767
|
+
def scroll_down?(event)
|
1768
|
+
(event.event_type.name == 'GDK_SCROLL') and
|
1769
|
+
(event.direction == Gdk::ScrollDirection::DOWN)
|
1770
|
+
end; alias scroll_down_event? scroll_down? # === scroll_down_event?
|
1771
|
+
|
1772
|
+
# ========================================================================= #
|
1773
|
+
# === on_mouse_double_click_event
|
1774
|
+
#
|
1775
|
+
# This is currently (January 2021) unfinished. One day we want to
|
1776
|
+
# respond to double-click events.
|
1777
|
+
# ========================================================================= #
|
1778
|
+
def on_mouse_double_click_event_UNFINISHED_METHOD(
|
1779
|
+
event,
|
1780
|
+
&block
|
1911
1781
|
)
|
1912
|
-
|
1782
|
+
# ======================================================================= #
|
1783
|
+
# Assume ruby-gtk2 here:
|
1784
|
+
# ======================================================================= #
|
1785
|
+
#if ::Gtk.use_gtk2? and
|
1786
|
+
# (event.event_type == Gdk::Event::BUTTON2_PRESS) and
|
1787
|
+
# (event.button == 1)
|
1788
|
+
# signal_connect(:button_press_event, &block)
|
1789
|
+
# ======================================================================= #
|
1790
|
+
# assume ruby-gtk3 here.
|
1791
|
+
# ======================================================================= #
|
1792
|
+
# elsif is_a_mouse_double_click_event?(event)
|
1793
|
+
if is_a_mouse_double_click_event?(event)
|
1794
|
+
signal_connect(:button_press_event, &block)
|
1795
|
+
end
|
1796
|
+
end; alias on_double_click on_mouse_double_click_event_UNFINISHED_METHOD # === on_double_click
|
1797
|
+
|
1798
|
+
# ========================================================================= #
|
1799
|
+
# === complex_font
|
1800
|
+
# ========================================================================= #
|
1801
|
+
def complex_font(
|
1802
|
+
this_font = 'Calibre 32'
|
1803
|
+
)
|
1804
|
+
this_font = ::Gtk.expand_this_font(this_font)
|
1805
|
+
_ = Pango::FontDescription.new(this_font)
|
1806
|
+
override_font(_)
|
1807
|
+
end
|
1808
|
+
|
1809
|
+
# ========================================================================= #
|
1810
|
+
# === use_this_font=
|
1811
|
+
# ========================================================================= #
|
1812
|
+
def use_this_font=(
|
1813
|
+
i = 'EmojiOne Color 22'
|
1814
|
+
)
|
1815
|
+
if i.is_a?(String) or i.is_a?(Symbol)
|
1913
1816
|
i = ::Gtk.expand_this_font(i)
|
1817
|
+
i = Pango::FontDescription.new(i.to_s)
|
1914
1818
|
end
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
elsif ::Gtk.use_gtk3?
|
1819
|
+
# if ::Gtk.use_gtk2?
|
1820
|
+
# modify_font(i)
|
1821
|
+
if ::Gtk.use_gtk3?
|
1919
1822
|
override_font(i)
|
1920
1823
|
elsif ::Gtk.use_gtk4?
|
1824
|
+
puts 'override_font() has not yet been ported to ruby-gtk4 '\
|
1825
|
+
'and the gtk_paradise gem.'
|
1826
|
+
end
|
1827
|
+
end; alias use_this_font use_this_font= # === use_this_font
|
1828
|
+
alias set_use_this_font use_this_font= # === set_use_this_font
|
1829
|
+
alias try_to_use_this_font use_this_font= # === try_to_use_this_font
|
1830
|
+
alias fonty use_this_font= # === fonty
|
1831
|
+
alias font= use_this_font= # === font=
|
1832
|
+
|
1833
|
+
require 'gtk_paradise/colours/parse.rb'
|
1834
|
+
# ========================================================================= #
|
1835
|
+
# === modify_foreground
|
1836
|
+
#
|
1837
|
+
# This method will modify (change) the foreground colour.
|
1838
|
+
# ========================================================================= #
|
1839
|
+
def modify_foreground(
|
1840
|
+
colour = :steelblue,
|
1841
|
+
state = ::Gtk::StateType::NORMAL
|
1842
|
+
)
|
1843
|
+
if colour.is_a? Symbol
|
1921
1844
|
# ===================================================================== #
|
1922
|
-
#
|
1845
|
+
# Convert it into a Gtk::Colours representation.
|
1923
1846
|
# ===================================================================== #
|
1924
|
-
|
1925
|
-
font-family: '+i.to_s+';
|
1926
|
-
}
|
1927
|
-
'
|
1928
|
-
css_class(use_this_new_CSS_rule)
|
1929
|
-
else
|
1930
|
-
e 'Unknown engine in use.'
|
1847
|
+
colour = ::Gtk.colour_parse(colour)
|
1931
1848
|
end
|
1932
|
-
|
1849
|
+
# if ::Gtk.use_gtk2?
|
1850
|
+
# modify_fg(
|
1851
|
+
# state, colour # Flip it here. This is deliberately different to modify_background.
|
1852
|
+
# )
|
1853
|
+
# else
|
1854
|
+
# ===================================================================== #
|
1855
|
+
# Else we assume ruby-gtk3 is in use.
|
1856
|
+
#
|
1857
|
+
# state: the state for which to set the color
|
1858
|
+
#
|
1859
|
+
# colour: the colour to assign
|
1860
|
+
# ===================================================================== #
|
1861
|
+
if state.is_a? ::Gtk::StateType
|
1862
|
+
# =================================================================== #
|
1863
|
+
# Must convert it into a StateFlag then.
|
1864
|
+
# For example, <Gtk::StateType normal> should be :NORMAL.
|
1865
|
+
#
|
1866
|
+
# The available StateFlags constants are:
|
1867
|
+
#
|
1868
|
+
# [:ACTIVE, :INCONSISTENT, :PRELIGHT, :BACKDROP, :VISITED,
|
1869
|
+
# :CHECKED, :LINK, :FOCUSED, :INSENSITIVE, :DROP_ACTIVE,
|
1870
|
+
# :SELECTED, :NORMAL, :DIR_LTR, :DIR_RTL]
|
1871
|
+
#
|
1872
|
+
# =================================================================== #
|
1873
|
+
case state.inspect.to_s
|
1874
|
+
when /prelight/
|
1875
|
+
state = :PRELIGHT
|
1876
|
+
when /active/
|
1877
|
+
state = :ACTIVE
|
1878
|
+
when /normal/
|
1879
|
+
state = :NORMAL
|
1880
|
+
else
|
1881
|
+
puts 'Not yet registered state: '+state.inspect.to_s
|
1882
|
+
end
|
1883
|
+
end
|
1884
|
+
# ===================================================================== #
|
1885
|
+
# ruby-gtk3 wants Gdk::RGBA rather than Gdk::Color. So we must
|
1886
|
+
# convert this next.
|
1887
|
+
# ===================================================================== #
|
1888
|
+
if colour.is_a? Gdk::Color
|
1889
|
+
colour = ::Gtk.convert_gdk_colour_to_gdk_rgba_colour(colour)
|
1890
|
+
# =================================================================== #
|
1891
|
+
# Or:
|
1892
|
+
# colour = Gdk::RGBA.new(*array)
|
1893
|
+
# colour.parse(colour.to_s).to_s # (*array)
|
1894
|
+
# =================================================================== #
|
1895
|
+
end
|
1896
|
+
override_color(
|
1897
|
+
state, colour
|
1898
|
+
)
|
1899
|
+
# end
|
1900
|
+
end; alias set_colour modify_foreground # === set_colour
|
1901
|
+
alias foreground_colour= modify_foreground # === foreground_colour=
|
1902
|
+
alias foreground_color= modify_foreground # === foreground_color=
|
1903
|
+
alias foreground_colour modify_foreground # === foreground_colour
|
1904
|
+
alias foreground_color modify_foreground # === foreground_color
|
1905
|
+
alias use_this_colour= modify_foreground # === use_this_colour=
|
1906
|
+
alias set_use_this_colour modify_foreground # === set_use_this_colour
|
1907
|
+
alias change_colour_to modify_foreground # === change_colour_to
|
1933
1908
|
|
1934
1909
|
end; end
|