class Interphase::Container
A widget which may contain other widgets.
Attributes
children[RW]
Public Instance Methods
add(child, should_add = true, &block)
click to toggle source
Add a widget as a child of this one. Accepts a block which is executed on the child.
child
-
The new child widget.
should_add
-
(Optional) Whether to actually add the element, or just to register it as added by adding it to
children
. You probably shouldn't change this.
# File lib/interphase/widgets/basic_widgets.rb, line 76 def add(child, should_add = true, &block) child.instance_eval(&block) if block_given? raise 'Widget already has a parent' unless child.parent.nil? gtk_instance.add(child.gtk_instance) if should_add child.parent = self # Ensure a children array exists, and add the new child to it @children ||= [] children << child end
method_missing(requested, *args, &block)
click to toggle source
Allows child named widgets to be looked up like an attribute. TODO IMPLEMENT RESPONDS_TO
Calls superclass method
Interphase::Widget#method_missing
# File lib/interphase/widgets/basic_widgets.rb, line 96 def method_missing(requested, *args, &block) (children || []).each do |child| # An exception simply means that wasn't the child we were looking for begin return child.send(requested) rescue StandardError next end end super end
respond_to_missing?(*)
click to toggle source
# File lib/interphase/widgets/basic_widgets.rb, line 109 def respond_to_missing?(*) true end
show_all()
click to toggle source
Show this widget and all of its children.
# File lib/interphase/widgets/basic_widgets.rb, line 90 def show_all gtk_instance.show_all end