W Wrapl, The Programming Language




Inherits from:

A T is a tree model which wraps another tree model, and can do the following things:

  • Filter specific rows, based on data from a "visible column", a column storing booleans indicating whether the row should be filtered or not, or based on the return value of a "visible function", which gets a model, iter and user_data and returns a boolean indicating whether the row should be filtered or not.

  • Modify the "appearance" of the model, using a modify function. This is extremely powerful and allows for just changing some values and also for creating a completely different model based on the given child model.

  • Set a different root node, also known as a "virtual root". You can pass in a Gtk.Gtk.TreePath.T indicating the root node for the filter at construction time.


Nil : T


GetType() : Gtk.GObject.Type.T

New(child_model @ Gtk.Gtk.TreeModel.T, root @ Gtk.Gtk.TreePath.T) : Gtk.Gtk.TreeModelFilter.T

Creates a new Gtk.Gtk.TreeModel.T, with child_model as the child_model and root as the virtual root.

child_model A Gtk.Gtk.TreeModel.T.
root A Gtk.Gtk.TreePath.T or NULL. [allow-none]
Returns A new Gtk.Gtk.TreeModel.T. [transfer full]


:ClearCache(self @ T) : Std.Object.T

This function should almost never be called. It clears the filter of any cached iterators that haven't been reffed with Gtk.Gtk.TreeModel.RefNode. This might be useful if the child model being filtered is static (and doesn't change often) and there has been a lot of unreffed access to nodes. As a side effect of this function, all unreffed iters will be invalid.

filter A T.

:ConvertChildIterToIter(self @ T, filter_iter @ Gtk.Gtk.TreeIter.T, child_iter @ Gtk.Gtk.TreeIter.T) : Std.Symbol.T

Sets filter_iter to point to the row in filter that corresponds to the row pointed at by child_iter. If filter_iter was not set, FALSE is returned.

filter A T.
filter_iter An uninitialized Gtk.Gtk.TreeIter.T. [out]
child_iter A valid Gtk.Gtk.TreeIter.T pointing to a row on the child model.
Returns TRUE, if filter_iter was set, i.e. if child_iter is a valid iterator pointing to a visible row in child model.

:ConvertChildPathToPath(self @ T, child_path @ Gtk.Gtk.TreePath.T) : Gtk.Gtk.TreePath.T

Converts child_path to a path relative to filter. That is, child_path points to a path in the child model. The rerturned path will point to the same row in the filtered model. If child_path isn't a valid path on the child model or points to a row which is not visible in filter, then NULL is returned.

filter A T.
child_path A Gtk.Gtk.TreePath.T to convert.
Returns A newly allocated Gtk.Gtk.TreePath.T, or NULL.

:ConvertIterToChildIter(self @ T, child_iter @ Gtk.Gtk.TreeIter.T, filter_iter @ Gtk.Gtk.TreeIter.T) : Std.Object.T

Sets child_iter to point to the row pointed to by filter_iter.

filter A T.
child_iter An uninitialized Gtk.Gtk.TreeIter.T. [out]
filter_iter A valid Gtk.Gtk.TreeIter.T pointing to a row on filter.

:ConvertPathToChildPath(self @ T, filter_path @ Gtk.Gtk.TreePath.T) : Gtk.Gtk.TreePath.T

Converts filter_path to a path on the child model of filter. That is, filter_path points to a location in filter. The returned path will point to the same location in the model not being filtered. If filter_path does not point to a location in the child model, NULL is returned.

filter A T.
filter_path A Gtk.Gtk.TreePath.T to convert.
Returns A newly allocated Gtk.Gtk.TreePath.T, or NULL.

:GetModel(self @ T) : Gtk.Gtk.TreeModel.T

Returns a pointer to the child model of filter.

filter A T.
Returns A pointer to a Gtk.Gtk.TreeModel.T. [transfer none]

:Refilter(self @ T) : Std.Object.T

Emits ::row_changed for each row in the child model, which causes the filter to re-evaluate whether a row is visible or not.

filter A T.

:SetModifyFunc(self @ T, n_columns @ Std.Integer.SmallT, types @ Std.Object.T, func @ Std.Function.T, data @ Std.Address.T, destroy @ Std.Function.T) : Std.Object.T

With the n_columns and types parameters, you give an array of column types for this model (which will be exposed to the parent model/view). The func, data and destroy parameters are for specifying the modify function. The modify function will get called for each data access, the goal of the modify function is to return the data which should be displayed at the location specified using the parameters of the modify function.

filter A T.
n_columns The number of columns in the filter model.
types The GTypes of the columns. [array length=n_columns]
func A Gtk.Gtk.TreeModelFilterModifyFunc
data User data to pass to the modify function, or NULL. [allow-none]
destroy Destroy notifier of data, or NULL. [allow-none]

:SetVisibleColumn(self @ T, column @ Std.Integer.SmallT) : Std.Object.T

Sets column of the child_model to be the column where filter should look for visibility information. columns should be a column of type G_TYPE_BOOLEAN, where TRUE means that a row is visible, and FALSE if not.

filter A T.
column A gint which is the column containing the visible information.

:SetVisibleFunc(self @ T, func @ Std.Function.T, data @ Std.Address.T, destroy @ Std.Function.T) : Std.Object.T

Sets the visible function used when filtering the filter to be func. The function should return TRUE if the given row should be visible and FALSE otherwise.

If the condition calculated by the function changes over time (e.g. because it depends on some global parameters), you must call Refilter to keep the visibility information of the model uptodate.

Note that func is called whenever a row is inserted, when it may still be empty. The visible function should therefore take special care of empty rows, like in the example below.

static gboolean
visible_func (GtkTreeModel *model,
              GtkTreeIter  *iter,
              gpointer      data)
  /* Visible if row is non-empty and first column is "HI" */
  gchar *str;
  gboolean visible = FALSE;

  gtk_tree_model_get (model, iter, 0, &str, -1);
  if (str && strcmp (str, "HI") == 0)
    visible = TRUE;
  g_free (str);

  return visible;