class Gtk::Widget - gtk3-3.1.1 Documentation

# class Gtk::Widget

### Public Class Methods

bind_template_child(name, options={}) click to toggle source

    # File lib/gtk3/widget.rb, line 44
    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 23
    def have_template?
      @have_template ||= false
    end

init() click to toggle source

    # File lib/gtk3/widget.rb, line 20
    def init
    end

set_connect_func(&block) click to toggle source

    # File lib/gtk3/widget.rb, line 54
    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 33
    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 27
    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 67
    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 92
    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 86
    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 62
    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=
render_icon_pixbuf(stock_id, size) click to toggle source

    # File lib/gtk3/widget.rb, line 106
    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 1078
    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 75
    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
style_get_property(name) click to toggle source

    # File lib/gtk3/widget.rb, line 98
    def style_get_property(name)
      property = self.class.find_style_property(name)
      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 112
    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)
Alias for: translate_coordinates

### Private Instance Methods

ensure_drag_targets(targets) click to toggle source

    # File lib/gtk3/widget.rb, line 134
    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_post() click to toggle source

    # File lib/gtk3/widget.rb, line 122
    def initialize_post
      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