Class: Gtk::ListView

Inherits:
TreeView
  • Object
show all
Defined in:
lib/merrol/gtk/list_view.rb

Instance Method Summary collapse

Constructor Details

#initializeListView

Returns a new instance of ListView.



3
4
5
6
7
8
# File 'lib/merrol/gtk/list_view.rb', line 3

def initialize
  super
  self.headers_visible = false
  self.append_column(Gtk::TreeViewColumn.new('Name', Gtk::CellRendererText.new, "text" => 0))
  self.model = Gtk::ListStore.new String
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/merrol/gtk/list_view.rb', line 38

def empty?
  self.model.iter_first.nil?
end

#list=(items) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/merrol/gtk/list_view.rb', line 10

def list= items
  items.each do |item|
    iter = self.model.append
    self.model.set_value iter, 0, item
  end
  selection.select_iter(self.model.iter_first) if items.any?
end

#nextObject



28
29
30
31
32
# File 'lib/merrol/gtk/list_view.rb', line 28

def next
  iter = selection.selected
  iter.next!
  selection.select_iter iter
end

#prepend(item) ⇒ Object



18
19
20
21
22
# File 'lib/merrol/gtk/list_view.rb', line 18

def prepend item
  iter = self.model.prepend
  self.model.set_value iter, 0, item
  selection.select_iter iter
end

#selectedObject



24
25
26
# File 'lib/merrol/gtk/list_view.rb', line 24

def selected
  selection.selected[0] if selection.selected
end

#selected_to_topObject



34
35
36
# File 'lib/merrol/gtk/list_view.rb', line 34

def selected_to_top
  self.model.move_before selection.selected, self.model.iter_first
end