class Gtk::Widget

Public Class Methods

bind_template_child(name, options={}) click to toggle source
# File lib/gtk3/widget.rb, line 41
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
have_template?() click to toggle source
# File lib/gtk3/widget.rb, line 20
def have_template?
  @have_template ||= false
end
set_connect_func(&block) click to toggle source
# File lib/gtk3/widget.rb, line 51
def set_connect_func(&block)
  set_connect_func_raw do |*args|
    Builder.connect_signal(*args, &block)
  end
end
Also aliased as: set_connect_func_raw
set_connect_func_raw(&block)
Alias for: set_connect_func
set_template(template) click to toggle source
# File lib/gtk3/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
  @have_template = true
end
template_children() click to toggle source
# File lib/gtk3/widget.rb, line 24
def template_children
  @template_children ||= []
end

Public Instance Methods

__set_allocation__(*args)
Alias for: set_allocation
add_events(new_events) click to toggle source
# File lib/gtk3/widget.rb, line 64
def add_events(new_events)
  unless new_events.is_a?(Gdk::EventMask)
    new_events = Gdk::EventMask.new(new_events)
  end
  add_events_raw(new_events.to_i)
end
Also aliased as: add_events_raw
add_events_raw(new_events)
Alias for: add_events
drag_dest_set(flags, targets, actions) click to toggle source
# File lib/gtk3/widget.rb, line 107
def drag_dest_set(flags, targets, actions)
  targets = ensure_drag_targets(targets)
  drag_dest_set_raw(flags, targets, actions)
end
Also aliased as: drag_dest_set_raw
drag_dest_set_raw(flags, targets, actions)
Alias for: drag_dest_set
drag_source_set(flags, targets, actions) click to toggle source
# File lib/gtk3/widget.rb, line 101
def drag_source_set(flags, targets, actions)
  targets = ensure_drag_targets(targets)
  drag_source_set_raw(flags, targets, actions)
end
Also aliased as: drag_source_set_raw
drag_source_set_raw(flags, targets, actions)
Alias for: drag_source_set
events() click to toggle source
# File lib/gtk3/widget.rb, line 59
def events
  Gdk::EventMask.new(events_raw)
end
Also aliased as: events_raw
events=(new_events)
Also aliased as: events_raw=
Alias for: set_events
events_raw()
Alias for: events
events_raw=(new_events)
Alias for: events=
insert_action_group(name, group) click to toggle source
# File lib/gtk3/widget.rb, line 145
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
Also aliased as: insert_action_group_raw
insert_action_group_raw(name, group)
Alias for: insert_action_group
render_icon_pixbuf(stock_id, size) click to toggle source
# File lib/gtk3/widget.rb, line 124
def render_icon_pixbuf(stock_id, size)
  size = IconSize.new(size) unless size.is_a?(IconSize)
  render_icon_pixbuf_raw(stock_id, size)
end
Also aliased as: render_icon_pixbuf_raw
render_icon_pixbuf_raw(stock_id, size)
Alias for: render_icon_pixbuf
set_allocation(*args) click to toggle source
# File lib/gtk3/deprecated.rb, line 1084
def set_allocation(*args)
  case args.size
  when 1
    __set_allocation__(args.first)
  when 4
    warn "#{caller[0]}: '#{self.class}#set_allocation(x, y, width, height)' style has been deprecated. Use '#{self.class}#set_allocation(alloc)' style."
    __set_allocation__(Gtk::Allocation.new(*args))
  else
    raise ArgumentError.new("need 1 or 4 arguments.")
  end
end
Also aliased as: __set_allocation__
set_events(new_events) click to toggle source
# File lib/gtk3/widget.rb, line 72
def set_events(new_events)
  unless new_events.is_a?(Gdk::EventMask)
    new_events = Gdk::EventMask.new(new_events)
  end
  set_events_raw(new_events.to_i)
end
Also aliased as: set_events_raw, events=
set_events_raw(new_events)
Alias for: set_events
set_size_request(*args) click to toggle source
# File lib/gtk3/widget.rb, line 83
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
Also aliased as: set_size_request_raw
set_size_request_raw(*args)
Alias for: set_size_request
style_context() click to toggle source
# File lib/gtk3/widget.rb, line 140
def style_context
  @style_context ||= style_context_raw
end
Also aliased as: style_context_raw
style_context_raw()
Alias for: style_context
style_get_property(name) click to toggle source
# File lib/gtk3/widget.rb, line 113
def style_get_property(name)
  property = self.class.find_style_property(name)
  if property.nil?
    raise ArgumentError, "unknown style: #{name.inspect}"
  end
  value = GLib::Value.new(property.value_type)
  style_get_property_raw(name, value)
  value.value
end
Also aliased as: style_get_property_raw
style_get_property_raw(name)
Alias for: style_get_property
translate_coordinates(widget, x, y) click to toggle source
# File lib/gtk3/widget.rb, line 130
def translate_coordinates(widget, x, y)
  translated, x, y = translate_coordinates_raw(widget, x, y)
  if translated
    [x, y]
  else
    nil
  end
end
Also aliased as: translate_coordinates_raw
translate_coordinates_raw(widget, x, y)

Private Instance Methods

ensure_drag_targets(targets) click to toggle source
# File lib/gtk3/widget.rb, line 168
def ensure_drag_targets(targets)
  return targets unless targets.is_a?(Array)

  targets.collect do |target|
    case target
    when Array
      TargetEntry.new(*target)
    else
      target
    end
  end
end
initialize_template() click to toggle source
# File lib/gtk3/widget.rb, line 156
def initialize_template
  klass = self.class
  return unless klass.have_template?
  return unless respond_to?(:init_template)

  init_template
  gtype = klass.gtype
  klass.template_children.each do |name|
    instance_variable_set("@#{name}", get_template_child(gtype, name))
  end
end