GtkApp:View - drfeelngood/rb-gtk_app GitHub Wiki
Method Missing
Many common view activities have been simplified by exercising Gtk::View#method_missing. The main helper is that the Gtk::View responds to widget names. This means for any widget that exists in the view, you can invoke @view.widget_name and the Gtk object is returned. In a addition to simplifying widget access, a few convenience methods are added to core widget classes. Below are code examples for each:
Gtk::TextView
# Set the text of the text buffer
@view.txtFoo = "Hello World!"
# Returns the text in the text buffer
@view.txtFoo! # => Hello Wold!
# Append text to the text buffer
@view.txtFoo << " Who farted?" # => Hello World! Who farted?.
Gtk::ComboBox
# Returns the active text
@view.cmbFoo!
# The following two examples show how to activate a combo box item by the text or position.
@view.cmbFoo = "Activate Selection"
@view.cmbFoo = 1
# Append an item the the combo box.
@view.cmbFoo << "Additional Selection"
Gtk::ToggleButton, Gtk::CheckButton
# Returns the value (Boolean) of the active property.
@view.chkFoo!
# Sets the widget active property.
@view.chkFoo = true
@view.chkFoo = false
Gtk::TreeView
# Return the Gtk::TreeIter of the current selected row
@view.listFoo!
# Append a row of data
@view.listFoo << %w(foo bar)