Module: Builder::Gtk::LayoutProxy

Included in:
BoxProxy, WindowProxy
Defined in:
lib/proxies/layout.rb

Overview

Base class for all widgets that can have children

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object

Handles constructing Gtk widgets

Example:

proxy.entry --> Gtk::Entry.new
proxy.vbox(true, 10) --> Gtk::VBox.new(true, 10)
proxy.drawing_area --> Gtk::DrawingArea.new

Parameters:

  • name

    The name of the widget in snake case

  • args

    The arguments to pass to the constructor of the Gtk widget

  • block

    A block that will be executed with the created widget or a proxy if one is available.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/proxies/layout.rb', line 24

def method_missing(name, *args, &block)
  if @widget.respond_to?(name)
    return @widget.__send__(name, *args, &block)
  end

  widget = _get_widget(name, args)
  proxy = _get_proxy(name, widget)
  block.call(proxy) if block
  _pack_widget(widget)
  return self
end

Instance Attribute Details

#widgetObject

The widget that is being proxied



9
10
11
# File 'lib/proxies/layout.rb', line 9

def widget
  @widget
end