Class: Gtk::Widget
- Inherits:
-
Object
- Object
- Gtk::Widget
- Extended by:
- GLib::Deprecatable
- Defined in:
- lib/gtk4/widget.rb,
lib/gtk4/deprecated.rb
Class Method Summary collapse
Instance Method Summary collapse
- #bind_template_child(name, options = {}) ⇒ Object
- #children ⇒ Object
- #insert_action_group(name, group) ⇒ Object
- #insert_action_group_raw ⇒ Object
- #set_size_request(*args) ⇒ Object
- #set_size_request_raw ⇒ Object
- #set_template(template) ⇒ Object
- #set_template_raw ⇒ Object
- #style_context ⇒ Object
- #style_context_raw ⇒ Object
- #translate_coordinates(widget, x, y) ⇒ Object
- #translate_coordinates_raw ⇒ Object
Class Method Details
.have_template? ⇒ Boolean
20 21 22 |
# File 'lib/gtk4/widget.rb', line 20 def have_template? @have_template ||= false end |
.template_children ⇒ Object
24 25 26 |
# File 'lib/gtk4/widget.rb', line 24 def template_children @template_children ||= [] end |
Instance Method Details
#bind_template_child(name, options = {}) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/gtk4/widget.rb', line 43 def bind_template_child(name, ={}) internal_child = [:internal_child] internal_child = false if internal_child.nil? bind_template_child_full(name, internal_child, 0) template_children << name attr_reader(name) end |
#children ⇒ Object
97 98 99 100 101 102 103 104 105 |
# File 'lib/gtk4/widget.rb', line 97 def children _children = [] child = first_child while child _children << child child = child.next_sibling end _children end |
#insert_action_group(name, group) ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/gtk4/widget.rb', line 87 def insert_action_group(name, group) insert_action_group_raw(name, group) @action_groups ||= {} if group.nil? @action_groups.delete(name) else @action_groups[name] = group end end |
#insert_action_group_raw ⇒ Object
86 |
# File 'lib/gtk4/widget.rb', line 86 alias_method :insert_action_group_raw, :insert_action_group |
#set_size_request(*args) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/gtk4/widget.rb', line 54 def set_size_request(*args) case args.size when 1 = args[0] raise ArgumentError, ":width is missing" unless .key?(:width) width = [:width] raise ArgumentError, ":height is missing" unless .key?(:height) height = [:height] when 2 width, height = args else = "wrong number of arguments (given #{args.size}, expected 1..2)" raise ArgumentError, end set_size_request_raw(width, height) end |
#set_size_request_raw ⇒ Object
53 |
# File 'lib/gtk4/widget.rb', line 53 alias_method :set_size_request_raw, :set_size_request |
#set_template(template) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gtk4/widget.rb', line 30 def set_template(template) resource = template[:resource] data = template[:data] if resource set_template_from_resource(resource) else set_template_raw(data) end @scope = Gtk::RubyBuilderScope.new set_template_scope(@scope) @have_template = true end |
#set_template_raw ⇒ Object
29 |
# File 'lib/gtk4/widget.rb', line 29 alias_method :set_template_raw, :set_template |
#style_context ⇒ Object
82 83 84 |
# File 'lib/gtk4/widget.rb', line 82 def style_context @style_context ||= style_context_raw end |
#style_context_raw ⇒ Object
81 |
# File 'lib/gtk4/widget.rb', line 81 alias_method :style_context_raw, :style_context |
#translate_coordinates(widget, x, y) ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/gtk4/widget.rb', line 72 def translate_coordinates(, x, y) translated, x, y = translate_coordinates_raw(, x, y) if translated [x, y] else nil end end |
#translate_coordinates_raw ⇒ Object
71 |
# File 'lib/gtk4/widget.rb', line 71 alias_method :translate_coordinates_raw, :translate_coordinates |