Class: RuGUI::FrameworkAdapters::GTK::BaseView
- Inherits:
-
BaseFrameworkAdapter::BaseView
- Object
- BaseFrameworkAdapter::Base
- BaseFrameworkAdapter::BaseView
- RuGUI::FrameworkAdapters::GTK::BaseView
- Defined in:
- lib/rugui/framework_adapters/GTK.rb
Instance Attribute Summary
Attributes inherited from BaseFrameworkAdapter::Base
Class Method Summary collapse
-
.builder_file_extension ⇒ Object
Returns the builder file extension to be used for this view class.
Instance Method Summary collapse
-
#add_widget_to_container(widget, container_widget) ⇒ Object
Adds a widget to the given container widget.
-
#autoconnect_signals(other_target = nil) ⇒ Object
Autoconnects signals handlers for the view.
-
#build_widgets_from(filename) ⇒ Object
Builds widgets from the given filename, using the proper builder.
-
#connect_declared_signal(widget, signal, receiver, method) ⇒ Object
Connects the signal from the widget to the given receiver method.
-
#connect_declared_signal_block(widget, signal, receiver, block) ⇒ Object
Connects the signal from the widget to the given receiver block.
-
#queue(&block) ⇒ Object
Queues the block call, so that it is only gets executed in the main thread.
-
#register_widgets ⇒ Object
Registers widgets as attributes of the view class.
-
#remove_all_children(container_widget) ⇒ Object
Removes all children from the given container widget.
-
#remove_widget_from_container(widget, container_widget) ⇒ Object
Removes a widget from the given container widget.
-
#set_widget_name(widget, widget_name) ⇒ Object
Sets the widget name for the given widget if given.
Methods inherited from BaseFrameworkAdapter::Base
Constructor Details
This class inherits a constructor from RuGUI::FrameworkAdapters::BaseFrameworkAdapter::Base
Class Method Details
.builder_file_extension ⇒ Object
Returns the builder file extension to be used for this view class.
175 176 177 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 175 def builder_file_extension 'glade' end |
Instance Method Details
#add_widget_to_container(widget, container_widget) ⇒ Object
Adds a widget to the given container widget.
106 107 108 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 106 def (, ) .add() end |
#autoconnect_signals(other_target = nil) ⇒ Object
Autoconnects signals handlers for the view. If other_target
is given it is used instead of the view itself.
129 130 131 132 133 134 135 136 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 129 def autoconnect_signals(other_target = nil) if self.adapted_object.use_builder? self.adapted_object.glade.signal_autoconnect_full do |source, target, signal_name, handler_name, signal_data, after| target ||= other_target self.adapted_object.glade.connect(source, target, signal_name, handler_name, signal_data) if target.respond_to?(handler_name) end end end |
#build_widgets_from(filename) ⇒ Object
Builds widgets from the given filename, using the proper builder.
154 155 156 157 158 159 160 161 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 154 def (filename) self.adapted_object.glade = GladeXML.new(filename, self.adapted_object.root, nil, nil, GladeXML::FILE) self.adapted_object.glade..each do || self.adapted_object.send(:create_attribute_for_widget, ) unless self.adapted_object.glade[].nil? end self.adapted_object..show if self.adapted_object.display_root? and not self.adapted_object..nil? end |
#connect_declared_signal(widget, signal, receiver, method) ⇒ Object
Connects the signal from the widget to the given receiver method.
147 148 149 150 151 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 147 def connect_declared_signal(, signal, receiver, method) .signal_connect(signal) do |*args| receiver.send(method, *args) end end |
#connect_declared_signal_block(widget, signal, receiver, block) ⇒ Object
Connects the signal from the widget to the given receiver block. The block is executed in the context of the receiver.
140 141 142 143 144 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 140 def connect_declared_signal_block(, signal, receiver, block) .signal_connect(signal) do |*args| receiver.instance_exec(*args, &block) end end |
#queue(&block) ⇒ Object
Queues the block call, so that it is only gets executed in the main thread.
101 102 103 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 101 def queue(&block) Gtk.queue(&block) end |
#register_widgets ⇒ Object
Registers widgets as attributes of the view class.
164 165 166 167 168 169 170 171 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 164 def self.adapted_object.glade..each do || unless self.adapted_object.glade[].nil? self.adapted_object.send("#{}=".to_sym, self.adapted_object.glade[]) self.adapted_object.[] = self.adapted_object.glade[] end end end |
#remove_all_children(container_widget) ⇒ Object
Removes all children from the given container widget.
116 117 118 119 120 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 116 def remove_all_children() .children.each do |child| .remove(child) end end |
#remove_widget_from_container(widget, container_widget) ⇒ Object
Removes a widget from the given container widget.
111 112 113 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 111 def (, ) .remove() end |
#set_widget_name(widget, widget_name) ⇒ Object
Sets the widget name for the given widget if given.
123 124 125 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 123 def (, ) .name = .to_s unless .nil? end |