Class: Gtk::TreeIter

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/json/editor.rb

Overview

The Gtk::TreeIter class is reopened and some auxiliary methods are added.

Instance Method Summary collapse

Instance Method Details

#contentObject

Returns the content of this node.



194
195
196
# File 'lib/json/editor.rb', line 194

def content
  self[CONTENT_COL]
end

#content=(value) ⇒ Object

Sets the content of this node to value.



199
200
201
# File 'lib/json/editor.rb', line 199

def content=(value)
  self[CONTENT_COL] = value
end

#eachObject

Traverse each of this Gtk::TreeIter instance’s children and yield to them.



160
161
162
# File 'lib/json/editor.rb', line 160

def each
  n_children.times { |i| yield nth_child(i) }
end

#recursive_each {|_self| ... } ⇒ Object

Recursively traverse all nodes of this Gtk::TreeIter’s subtree (including self) and yield to them.

Yields:

  • (_self)

Yield Parameters:

  • _self (Gtk::TreeIter)

    the object that the method was called on



166
167
168
169
170
171
# File 'lib/json/editor.rb', line 166

def recursive_each(&block)
  yield self
  each do |i|
    i.recursive_each(&block)
  end
end

#remove_subtree(model) ⇒ Object

Remove the subtree of this Gtk::TreeIter instance from the model model.



175
176
177
178
179
# File 'lib/json/editor.rb', line 175

def remove_subtree(model)
  while current = first_child
    model.remove(current)
  end
end

#typeObject

Returns the type of this node.



182
183
184
# File 'lib/json/editor.rb', line 182

def type
  self[TYPE_COL]
end

#type=(value) ⇒ Object

Sets the type of this node to value. This implies setting the respective icon accordingly.



188
189
190
191
# File 'lib/json/editor.rb', line 188

def type=(value)
  self[TYPE_COL] = value
  self[ICON_COL] = Editor.fetch_icon(value)
end