Class: Gtk::TreeModelFilter

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#child_modelGtk::TreeModel

Returns child-model.

Returns:

#child_model=(child_model) ⇒ Gtk::TreeModel

Parameters:

Returns:

#clear_cachenil

This function should almost never be called. It clears the filter of any cached iterators that haven’t been reffed with gtk_tree_model_ref_node(). 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.

Returns:

  • (nil)

#convert_child_iter_to_iter(filter_iter, child_iter) ⇒ TrueClass

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. valid iterator pointing to a visible row in child model.

Parameters:

  • filter_iter (Gtk::TreeIter)

    An uninitialized Gtk::TreeIter.

  • child_iter (Gtk::TreeIter)

    A valid Gtk::TreeIter pointing to a row on the child model.

Returns:

  • (TrueClass)

    true, if filter_iter was set, i.e. if child_iter is a

#convert_child_path_to_path(child_path) ⇒ Gtk::TreePath

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 nil is returned.

Parameters:

  • child_path (Gtk::TreePath)

    A Gtk::TreePath to convert.

Returns:

  • (Gtk::TreePath)

    A newly allocated Gtk::TreePath, or nil.

#convert_iter_to_child_iter(child_iter, filter_iter) ⇒ nil

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

Parameters:

  • child_iter (Gtk::TreeIter)

    An uninitialized Gtk::TreeIter.

  • filter_iter (Gtk::TreeIter)

    A valid Gtk::TreeIter pointing to a row on filter.

Returns:

  • (nil)

#convert_path_to_child_path(filter_path) ⇒ Gtk::TreePath

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, nil is returned.

Parameters:

  • filter_path (Gtk::TreePath)

    A Gtk::TreePath to convert.

Returns:

  • (Gtk::TreePath)

    A newly allocated Gtk::TreePath, or nil.

#modelGtk::TreeModel

Returns a pointer to the child model of filter.

Returns:

#refilternil

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

Returns:

  • (nil)

#set_modify_func(n_columns, types, func, data, destroy) ⇒ nil

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.

Note that gtk_tree_model_filter_set_modify_func() can only be called once for a given filter model.

Parameters:

  • n_columns (Integer)

    The number of columns in the filter model.

  • types (Array<GLib::Type>)

    The #GTypes of the columns.

  • func (Gtk::TreeModelFilterModifyFunc)

    A Gtk::TreeModelFilterModifyFunc

  • data (GObject)

    User data to pass to the modify function, or nil.

  • destroy (GLib::DestroyNotify)

    Destroy notifier of data, or nil.

Returns:

  • (nil)

#set_visible_func(func, data, destroy) ⇒ nil

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 gtk_tree_model_filter_refilter() to keep the visibility information of the model up-to-date.

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;
}

Note that gtk_tree_model_filter_set_visible_func() or gtk_tree_model_filter_set_visible_column() can only be called once for a given filter model.

Parameters:

  • func (Gtk::TreeModelFilterVisibleFunc)

    A Gtk::TreeModelFilterVisibleFunc, the visible function

  • data (GObject)

    User data to pass to the visible function, or nil

  • destroy (GLib::DestroyNotify)

    Destroy notifier of data, or nil

Returns:

  • (nil)

#virtual_rootGtk::TreePath

Returns virtual-root.

Returns:

  • (Gtk::TreePath)

    virtual-root

#virtual_root=(virtual_root) ⇒ Gtk::TreePath

Parameters:

  • virtual_root (Gtk::TreePath)

Returns:

  • (Gtk::TreePath)

    virtual-root

  • (Gtk::TreePath)

    virtual-root

#visible_column=(column) ⇒ nil

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.

Note that gtk_tree_model_filter_set_visible_func() or gtk_tree_model_filter_set_visible_column() can only be called once for a given filter model.

Parameters:

  • column (Integer)

    A #gint which is the column containing the visible information

Returns:

  • (nil)