class documentation

class GenericTreeModel(GObject.GObject, Gtk.TreeModel): (source)

Known subclasses: zim.plugins.pageindex.PageTreeStoreBase

View In Hierarchy

A base implementation of a Gtk.TreeModel for python.

The GenericTreeModel eases implementing the Gtk.TreeModel interface in Python. The class can be subclassed to provide a TreeModel implementation which works directly with Python objects instead of iterators.

All of the on_* methods should be overridden by subclasses to provide the underlying implementation a way to access custom model data. For the purposes of this API, all custom model data supplied or handed back through the overridable API will use the argument names: node, parent, and child in regards to user data python objects.

The create_tree_iter, set_user_data, invalidate_iters, iter_is_valid methods are available to help manage Gtk.TreeIter objects and their Python object references.

GenericTreeModel manages a pool of user data nodes that have been used with iters. This pool stores a references to user data nodes as a dictionary value with the key being the integer id of the data. This id is what the Gtk.TreeIter objects use to reference data in the pool. References will be removed from the pool when the model is deleted or explicitly by using the optional "node" argument to the "row_deleted" method when notifying the model of row deletion.

Method __init__ Initialize. Make sure to call this from derived classes if overridden.
Method create_tree_iter Create a Gtk.TreeIter instance with the given user_data specific for this model.
Method do_get_column_type Internal method.
Method do_get_flags Internal method.
Method do_get_iter Internal method.
Method do_get_n_columns Internal method.
Method do_get_path Internal method.
Method do_get_value Internal method.
Method do_iter_children Internal method.
Method do_iter_has_child Internal method.
Method do_iter_n_children Internal method.
Method do_iter_next Internal method.
Method do_iter_nth_child Internal method.
Method do_iter_parent Internal method.
Method do_ref_node Undocumented
Method do_unref_node Undocumented
Method get_user_data Get the user_data associated with the given TreeIter.
Method invalidate_iter Clear user data and its reference from the iter and this model.
Method invalidate_iters This method invalidates all TreeIter objects associated with this custom tree model and frees their locally pooled references.
Method iter_depth_first Depth-first iteration of the entire TreeModel yielding the python nodes.
Method iter_is_valid :Returns: True if the gtk.TreeIter specified by iter is valid for the custom tree model.
Method on_get_column_type Overridable.
Method on_get_flags Overridable.
Method on_get_iter Overridable.
Method on_get_n_columns Overridable.
Method on_get_path Overridable.
Method on_get_value Overridable.
Method on_iter_children Overridable.
Method on_iter_has_child Overridable.
Method on_iter_n_children Overridable.
Method on_iter_next Overridable.
Method on_iter_nth_child Overridable.
Method on_iter_parent Overridable.
Method on_ref_node Undocumented
Method on_unref_node Undocumented
Method row_deleted Notify the model a row has been deleted.
Method set_user_data Applies user_data and stamp to the given iter.
Class Variable leak_references Undocumented
Instance Variable stamp Undocumented
Method _create_tree_iter Internal creation of a (bool, TreeIter) pair for returning directly back to the view interfacing with this model.
Instance Variable _held_refs Undocumented
def __init__(self): (source)
Initialize. Make sure to call this from derived classes if overridden.
def create_tree_iter(self, user_data): (source)

Create a Gtk.TreeIter instance with the given user_data specific for this model.

Use this method to create Gtk.TreeIter instance instead of directly calling Gtk.Treeiter(), this will ensure proper reference managment of wrapped used_data.

@handle_exception(GObject.TYPE_INVALID)
def do_get_column_type(self, index): (source)
Internal method.
@handle_exception(0)
def do_get_flags(self): (source)
Internal method.
@handle_exception((False, None))
def do_get_iter(self, path): (source)
Internal method.
@handle_exception(0)
def do_get_n_columns(self): (source)
Internal method.
@handle_exception(None)
def do_get_path(self, iter): (source)
Internal method.
@handle_exception(None)
def do_get_value(self, iter, column): (source)
Internal method.
@handle_exception((False, None))
def do_iter_children(self, parent): (source)
Internal method.
@handle_exception(False)
def do_iter_has_child(self, parent): (source)
Internal method.
@handle_exception(0)
def do_iter_n_children(self, iter): (source)
Internal method.
@handle_exception(False)
def do_iter_next(self, iter): (source)
Internal method.
@handle_exception((False, None))
def do_iter_nth_child(self, parent, n): (source)
Internal method.
@handle_exception((False, None))
def do_iter_parent(self, child): (source)
Internal method.
@handle_exception(None)
def do_ref_node(self, iter): (source)

Undocumented

@handle_exception(None)
def do_unref_node(self, iter): (source)

Undocumented

def get_user_data(self, iter): (source)

Get the user_data associated with the given TreeIter.

GenericTreeModel stores arbitrary Python objects mapped to instances of Gtk.TreeIter. This method allows to retrieve the Python object held by the given iterator.

def invalidate_iter(self, iter): (source)
Clear user data and its reference from the iter and this model.
def invalidate_iters(self): (source)
This method invalidates all TreeIter objects associated with this custom tree model and frees their locally pooled references.
def iter_depth_first(self): (source)
Depth-first iteration of the entire TreeModel yielding the python nodes.
def iter_is_valid(self, iter): (source)
def on_get_column_type(self, index): (source)
def on_get_flags(self): (source)
def on_get_iter(self, path): (source)
def on_get_n_columns(self): (source)
def on_get_path(self, node): (source)
def on_get_value(self, node, column): (source)
def on_iter_children(self, parent): (source)
def on_iter_has_child(self, node): (source)
def on_iter_n_children(self, node): (source)
def on_iter_next(self, node): (source)
def on_iter_nth_child(self, parent, n): (source)
def on_iter_parent(self, child): (source)
def on_ref_node(self, node): (source)

Undocumented

def on_unref_node(self, node): (source)

Undocumented

def row_deleted(self, path, node=None): (source)
def set_user_data(self, iter, user_data): (source)

Applies user_data and stamp to the given iter.

If the models "leak_references" property is set, a reference to the user_data is stored with the model to ensure we don't run into bad memory problems with the TreeIter.

leak_references = (source)

Undocumented

stamp = (source)

Undocumented

def _create_tree_iter(self, data): (source)
Internal creation of a (bool, TreeIter) pair for returning directly back to the view interfacing with this model.
_held_refs = (source)

Undocumented