Class: Gtk::Widget

Inherits:
Object
  • Object
show all
Extended by:
GLib::Deprecatable
Defined in:
lib/gtk4/widget.rb,
lib/gtk4/deprecated.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.have_template?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/gtk4/widget.rb', line 20

def have_template?
  @have_template ||= false
end

.template_childrenObject



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, options={})
  internal_child = options[:internal_child]
  internal_child = false if internal_child.nil?
  bind_template_child_full(name, internal_child, 0)
  template_children << name
  attr_reader(name)
end

#childrenObject



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_rawObject



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
    options = args[0]
    raise ArgumentError, ":width is missing" unless options.key?(:width)
    width = options[:width]
    raise ArgumentError, ":height is missing" unless options.key?(:height)
    height = options[:height]
  when 2
    width, height = args
  else
    message = "wrong number of arguments (given #{args.size}, expected 1..2)"
    raise ArgumentError, message
  end
  set_size_request_raw(width, height)
end

#set_size_request_rawObject



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_rawObject



29
# File 'lib/gtk4/widget.rb', line 29

alias_method :set_template_raw, :set_template

#style_contextObject



82
83
84
# File 'lib/gtk4/widget.rb', line 82

def style_context
  @style_context ||= style_context_raw
end

#style_context_rawObject



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(widget, x, y)
  translated, x, y = translate_coordinates_raw(widget, x, y)
  if translated
    [x, y]
  else
    nil
  end
end

#translate_coordinates_rawObject



71
# File 'lib/gtk4/widget.rb', line 71

alias_method :translate_coordinates_raw, :translate_coordinates