Class: VR::Col::Ren::CellRendererText
- Inherits:
-
Gtk::CellRendererText
- Object
- Gtk::CellRendererText
- VR::Col::Ren::CellRendererText
- 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
So it has all the functionality of its parent, plus the methods listed here.
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#edited_callback ⇒ Object
Returns the value of attribute edited_callback.
-
#model_col ⇒ Object
readonly
Returns the value of attribute model_col.
-
#model_sym ⇒ Object
readonly
Returns the value of attribute model_sym.
-
#validate_block ⇒ Object
Returns the value of attribute validate_block.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Instance Method Summary collapse
-
#initialize(model_col, column, view, model_sym) ⇒ CellRendererText
constructor
:nodoc:.
Constructor Details
#initialize(model_col, column, view, model_sym) ⇒ CellRendererText
:nodoc:
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/treeview/columns/CellRendererText.rb', line 17 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
#column ⇒ Object (readonly)
Returns the value of attribute column.
15 16 17 |
# File 'lib/treeview/columns/CellRendererText.rb', line 15 def column @column end |
#edited_callback ⇒ Object
Returns the value of attribute edited_callback.
14 15 16 |
# File 'lib/treeview/columns/CellRendererText.rb', line 14 def edited_callback @edited_callback end |
#model_col ⇒ Object (readonly)
Returns the value of attribute model_col.
15 16 17 |
# File 'lib/treeview/columns/CellRendererText.rb', line 15 def model_col @model_col end |
#model_sym ⇒ Object (readonly)
Returns the value of attribute model_sym.
15 16 17 |
# File 'lib/treeview/columns/CellRendererText.rb', line 15 def model_sym @model_sym end |
#validate_block ⇒ Object
Returns the value of attribute validate_block.
14 15 16 |
# File 'lib/treeview/columns/CellRendererText.rb', line 14 def validate_block @validate_block end |
#view ⇒ Object (readonly)
Returns the value of attribute view.
15 16 17 |
# File 'lib/treeview/columns/CellRendererText.rb', line 15 def view @view end |