Sha256: d919d0559a50fff666974a533c4bbf20ab47037287540b70b2a3fcd4ac2b4e67

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 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

4 entries across 4 versions & 1 rubygems

Version Path
knjrbfw-0.0.8 lib/knj/gtk2_tv.rb
knjrbfw-0.0.7 lib/knj/gtk2_tv.rb
knjrbfw-0.0.4 lib/knj/gtk2_tv.rb
knjrbfw-0.0.3 lib/knj/gtk2_tv.rb