class Interphase::Widget

A basic GTK widget wrapper.

Attributes

gtk_instance[RW]
name[RW]
parent[RW]

Public Class Methods

new(gtk_instance, **options, &block) click to toggle source

Creates a new widget.

gtk_instance

The GTK widget instance this is wrapping.

name:

This widgets name, allowing it to be referred to after being created.

# File lib/interphase/widgets/basic_widgets.rb, line 14
def initialize(gtk_instance, **options, &block)
  @gtk_instance = gtk_instance
  @parent = nil
  @name = options[:name]

  instance_eval(&block) if block_given?
end

Public Instance Methods

destroy() click to toggle source

Destroy this widget.

# File lib/interphase/widgets/basic_widgets.rb, line 43
def destroy
  gtk_instance.destroy
end
method_missing(requested, *args, &block) click to toggle source

Respond to lookups by name. TODO IMPLEMENT RESPONDS_TO

Calls superclass method
# File lib/interphase/widgets/basic_widgets.rb, line 49
def method_missing(requested, *args, &block)
  # If any arguments or a block have been given, then this isn't an attr
  if !args.empty? || block_given?
    super
    return
  end

  return self if requested.to_s == name

  super
end
on(name, &block) click to toggle source

Associates a block with a signal. The block is invoked whenever the signal occurs.

name

The name of the signal.

# File lib/interphase/widgets/basic_widgets.rb, line 38
def on(name, &block)
  gtk_instance.signal_connect(name, &block)
end
respond_to_missing?() click to toggle source
# File lib/interphase/widgets/basic_widgets.rb, line 61
def respond_to_missing?
  true
end
show() click to toggle source

Shows this widget.

# File lib/interphase/widgets/basic_widgets.rb, line 31
def show
  gtk_instance.show
end
size(width, height) click to toggle source

Requests that this widget is resized. Note that this is a method, rather than a 'size=' setter, because the request is not guaranteed, and indeed in many cases will not. Only some containers allow their child widgets to be resized.

# File lib/interphase/widgets/basic_widgets.rb, line 26
def size(width, height)
  gtk_instance.set_size_request(width, height)
end