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.



173
174
175
# File 'lib/json/editor.rb', line 173

def content
  self[CONTENT_COL]
end

#content=(value) ⇒ Object

Sets the content of this node to value.



178
179
180
# File 'lib/json/editor.rb', line 178

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

#eachObject

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



139
140
141
# File 'lib/json/editor.rb', line 139

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



145
146
147
148
149
150
# File 'lib/json/editor.rb', line 145

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.



154
155
156
157
158
# File 'lib/json/editor.rb', line 154

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

#typeObject

Returns the type of this node.



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

def type
  self[TYPE_COL]
end

#type=(value) ⇒ Object

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



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

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