Class: VR::Col::Ren::CellRendererText

Inherits:
Gtk::CellRendererText
  • Object
show all
Defined in:
lib/treeview/columns/CellRendererText.rb

Overview

This class is a helper to VR::ListView and VR::TreeView. When

colums are created, this class is used as the renderer because
it adds functionality to the Gtk Renderer.

When you call ListView#render(model_col) an instance of this class
will be returned.  It is a subclass of

{Gtk::CellRendererText}[http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3ACellRendererText]

So it has all the functionality of its parent, plus the methods listed here.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_col, column, view, model_sym) ⇒ CellRendererText

:nodoc:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/treeview/columns/CellRendererText.rb', line 19

def initialize(model_col, column, view, model_sym) # :nodoc:
  super()
  @column = column
  @model_sym = model_sym
  @model_col = model_col
  @view = view
  @validate_block = Proc.new { |text, model_sym, row, view| true }
  @edited_callback = nil
  self.signal_connect('edited') do |ren, path, text|
    next unless iter = @view.model.get_iter(path)
    if @validate_block.call(text, @model_sym, @view.vr_row(iter), @view)
      iter[@model_col] = (iter[@model_col].is_a? String) ? text : text.to_f
      @edited_callback.call(@model_sym, @view.vr_row(iter)) if @edited_callback
    end
  end 
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column



17
18
19
# File 'lib/treeview/columns/CellRendererText.rb', line 17

def column
  @column
end

#edited_callbackObject

Returns the value of attribute edited_callback



16
17
18
# File 'lib/treeview/columns/CellRendererText.rb', line 16

def edited_callback
  @edited_callback
end

#model_colObject (readonly)

Returns the value of attribute model_col



17
18
19
# File 'lib/treeview/columns/CellRendererText.rb', line 17

def model_col
  @model_col
end

#model_symObject (readonly)

Returns the value of attribute model_sym



17
18
19
# File 'lib/treeview/columns/CellRendererText.rb', line 17

def model_sym
  @model_sym
end

#validate_blockObject

Returns the value of attribute validate_block



16
17
18
# File 'lib/treeview/columns/CellRendererText.rb', line 16

def validate_block
  @validate_block
end