Class: VR::Col::Ren::CellRendererToggle

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

Overview

This renderer has a slightly different validate_block than the others. Its validate_block will be called with three

parameters:

 @view.renderer(:name).validate_block = Proc.new { | model_sym, row, view |
   (row[:name].length < 3)
 }

Also, you can use the VR::Col::Ren::CellRendererToggle#edited= method to allow editing.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of CellRendererToggle



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

def initialize(model_col, column, view, model_sym)
  super()
  @model_col = model_col
  @model_sym = model_sym
  @column = column
  @view = view
  @edited_callback = nil
  @validate_block = Proc.new { |model_sym, row, view | true }
  self.signal_connect('toggled') do |ren, path|
    @view.model.each { |mod, path, iter| iter[@model_col] = false } if self.radio?
    next unless iter = @view.model.get_iter(path)
    if @validate_block.call(@model_sym, @view.vr_row(iter), @view)
      iter[model_col] = !iter[model_col]
      @edited_callback.call(@model_col, 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/CellRendererToggle.rb', line 17

def column
  @column
end

#edited_callbackObject

Returns the value of attribute edited_callback



16
17
18
# File 'lib/treeview/columns/CellRendererToggle.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/CellRendererToggle.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/CellRendererToggle.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/CellRendererToggle.rb', line 16

def validate_block
  @validate_block
end

Instance Method Details

#editable=(is_editable) ⇒ Object



37
38
39
# File 'lib/treeview/columns/CellRendererToggle.rb', line 37

def editable=(is_editable)
  self.sensitive = is_editable
end

#set_editable(is_editable) ⇒ Object



41
42
43
# File 'lib/treeview/columns/CellRendererToggle.rb', line 41

def set_editable(is_editable)
  self.sensitive = is_editable
end