Class: MittensUi::ListBox
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Attributes inherited from Core
Instance Method Summary collapse
- #get_selected_value ⇒ Object (also: #selected_value)
-
#initialize(options = {}) ⇒ ListBox
constructor
A new instance of ListBox.
- #render ⇒ Object
- #set_selected_value(value) ⇒ Object (also: #set_value)
Methods inherited from Core
#hidden?, #hide, #remove, #show
Methods included from Helpers
#icon_map, #list_system_icons, #set_margin_from_opts_for
Constructor Details
#initialize(options = {}) ⇒ ListBox
Returns a new instance of ListBox.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mittens_ui/listbox.rb', line 7 def initialize(={}) @items = [:items] list_store = Gtk::ListStore.new(String) @items.each do |i| iter = list_store.append iter[0] = i end renderer = Gtk::CellRendererText.new @gtk_combobox = Gtk::ComboBox.new(model: list_store) @gtk_combobox.pack_start(renderer, true) @gtk_combobox.set_attributes(renderer, "text" => 0) @gtk_combobox.set_cell_data_func(renderer) do |_layout, _cell_renderer, _model, iter| set_selected_value(iter[0]) end @gtk_combobox.set_active(0) super(@gtk_combobox) end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
5 6 7 |
# File 'lib/mittens_ui/listbox.rb', line 5 def items @items end |
Instance Method Details
#get_selected_value ⇒ Object Also known as: selected_value
36 37 38 |
# File 'lib/mittens_ui/listbox.rb', line 36 def get_selected_value @selected_value end |
#render ⇒ Object
41 42 43 44 |
# File 'lib/mittens_ui/listbox.rb', line 41 def render $vertical_box.pack_start(@gtk_combobox) return self end |
#set_selected_value(value) ⇒ Object Also known as: set_value
31 32 33 |
# File 'lib/mittens_ui/listbox.rb', line 31 def set_selected_value(value) @selected_value = value end |