Class: Interphase::SimpleListView

Inherits:
ListView show all
Defined in:
lib/interphase/widgets/simple_list_view.rb

Overview

A simple list view which displays an Array.

Instance Attribute Summary collapse

Attributes inherited from ListView

#rows

Attributes inherited from Widget

#gtk_instance, #name, #parent

Instance Method Summary collapse

Methods inherited from ListView

#refresh_rows

Methods inherited from Widget

#destroy, #method_missing, #on, #respond_to_missing?, #show, #size

Constructor Details

#initialize(items = [], **options, &block) ⇒ SimpleListView


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/interphase/widgets/simple_list_view.rb', line 11

def initialize(items = [], **options, &block)
  super(['Column'], options, &block)

  gtk_instance.headers_visible = false

  @items = Interphase::Helpers::Observable.new(items) do
    refresh_items
  end

  refresh_items
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Interphase::Widget

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items


9
10
11
# File 'lib/interphase/widgets/simple_list_view.rb', line 9

def items
  @items
end

Instance Method Details

#refresh_itemsObject

Copies #items into #rows, where each item is one row.


24
25
26
27
28
# File 'lib/interphase/widgets/simple_list_view.rb', line 24

def refresh_items
  items.each do |item|
    rows << [item]
  end
end