Class: Interphase::Widget
- Inherits:
-
Object
- Object
- Interphase::Widget
- Defined in:
- lib/interphase/widgets/basic_widgets.rb
Overview
A basic GTK widget wrapper.
Instance Attribute Summary collapse
-
#gtk_instance ⇒ Object
Returns the value of attribute gtk_instance.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
-
#destroy ⇒ Object
Destroy this widget.
-
#initialize(gtk_instance, **options, &block) ⇒ Widget
constructor
Creates a new widget.
-
#method_missing(requested, *args, &block) ⇒ Object
Respond to lookups by name.
-
#on(name, &block) ⇒ Object
Associates a block with a signal.
- #respond_to_missing? ⇒ Boolean
-
#show ⇒ Object
Shows this widget.
-
#size(width, height) ⇒ Object
Requests that this widget is resized.
Constructor Details
#initialize(gtk_instance, **options, &block) ⇒ Widget
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.
14 15 16 17 18 19 20 |
# File 'lib/interphase/widgets/basic_widgets.rb', line 14 def initialize(gtk_instance, **, &block) @gtk_instance = gtk_instance @parent = nil @name = [:name] instance_eval(&block) if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(requested, *args, &block) ⇒ Object
Respond to lookups by name. TODO IMPLEMENT RESPONDS_TO
49 50 51 52 53 54 55 56 57 58 59 |
# 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 |
Instance Attribute Details
#gtk_instance ⇒ Object
Returns the value of attribute gtk_instance.
8 9 10 |
# File 'lib/interphase/widgets/basic_widgets.rb', line 8 def gtk_instance @gtk_instance end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/interphase/widgets/basic_widgets.rb', line 8 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
8 9 10 |
# File 'lib/interphase/widgets/basic_widgets.rb', line 8 def parent @parent end |
Instance Method Details
#destroy ⇒ Object
Destroy this widget.
43 44 45 |
# File 'lib/interphase/widgets/basic_widgets.rb', line 43 def destroy gtk_instance.destroy end |
#on(name, &block) ⇒ Object
Associates a block with a signal. The block is invoked whenever the signal occurs.
name
-
The name of the signal.
38 39 40 |
# File 'lib/interphase/widgets/basic_widgets.rb', line 38 def on(name, &block) gtk_instance.signal_connect(name, &block) end |
#respond_to_missing? ⇒ Boolean
61 62 63 |
# File 'lib/interphase/widgets/basic_widgets.rb', line 61 def respond_to_missing? true end |
#show ⇒ Object
Shows this widget.
31 32 33 |
# File 'lib/interphase/widgets/basic_widgets.rb', line 31 def show gtk_instance.show end |
#size(width, height) ⇒ Object
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.
26 27 28 |
# File 'lib/interphase/widgets/basic_widgets.rb', line 26 def size(width, height) gtk_instance.set_size_request(width, height) end |