Sha256: 023a57f57bf9a7072cbd57ffd641497e954057b51bcaca893b7400377699b2c7

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 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)
      col.resizable = true
      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

6 entries across 6 versions & 1 rubygems

Version Path
knjrbfw-0.0.41 lib/knj/gtk2_tv.rb
knjrbfw-0.0.40 lib/knj/gtk2_tv.rb
knjrbfw-0.0.39 lib/knj/gtk2_tv.rb
knjrbfw-0.0.38 lib/knj/gtk2_tv.rb
knjrbfw-0.0.37 lib/knj/gtk2_tv.rb
knjrbfw-0.0.36 lib/knj/gtk2_tv.rb