Sha256: a23954cac71860472374a7fb49c143db97910235b28900c0e694afcd9208f2ba

Contents?: true

Size: 1.2 KB

Versions: 27

Compression:

Stored size: 1.2 KB

Contents

module Knj::Gtk2::Tv
  def self.init(tv, columns)
    args = []
    columns.each do |pair|
      args << String
    end
    
    list_store = Gtk::ListStore.new(*args)
    tv.model = list_store
    
    count = 0
    columns.each do |col_title|
      renderer = Gtk::CellRendererText.new
      col = Gtk::TreeViewColumn.new(col_title, renderer, :text => count)
      tv.append_column(col)
      count += 1
    end
  end
  
  def self.append(tv, data)
    iter = tv.model.append
    
    count = 0
    data.each do |value|
      iter[count] = value.to_s
      count += 1
    end
  end
  
  def self.sel(tv)
    selected = tv.selection.selected_rows
    
    if !tv.model or selected.size <= 0
      return nil
    end
    
    iter = tv.model.get_iter(selected[0])
    returnval = []
    columns = tv.columns
    
    count = 0
    columns.each do |column|
      returnval[count] = iter[count]
      count += 1
    end
    
    return returnval
  end
end

class Gtk::TreeView
  def sel
    return Knj::Gtk2::Tv.sel(self)
  end
  
  def append(data)
    return Knj::Gtk2::Tv.append(self, data)
  end
  
  def init(cols)
    return Knj::Gtk2::Tv.init(self, cols)
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
knjrbfw-0.0.35 lib/knj/gtk2_tv.rb
knjrbfw-0.0.34 lib/knj/gtk2_tv.rb
knjrbfw-0.0.33 lib/knj/gtk2_tv.rb
knjrbfw-0.0.32 lib/knj/gtk2_tv.rb
knjrbfw-0.0.31 lib/knj/gtk2_tv.rb
knjrbfw-0.0.30 lib/knj/gtk2_tv.rb
knjrbfw-0.0.29 lib/knj/gtk2_tv.rb
knjrbfw-0.0.28 lib/knj/gtk2_tv.rb
knjrbfw-0.0.27 lib/knj/gtk2_tv.rb
knjrbfw-0.0.26 lib/knj/gtk2_tv.rb
knjrbfw-0.0.25 lib/knj/gtk2_tv.rb
knjrbfw-0.0.24 lib/knj/gtk2_tv.rb
knjrbfw-0.0.23 lib/knj/gtk2_tv.rb
knjrbfw-0.0.22 lib/knj/gtk2_tv.rb
knjrbfw-0.0.21 lib/knj/gtk2_tv.rb
knjrbfw-0.0.20 lib/knj/gtk2_tv.rb
knjrbfw-0.0.19 lib/knj/gtk2_tv.rb
knjrbfw-0.0.18 lib/knj/gtk2_tv.rb
knjrbfw-0.0.17 lib/knj/gtk2_tv.rb
knjrbfw-0.0.16 lib/knj/gtk2_tv.rb