Gtk2::TreeSortable(3)

NAME
Gtk2::TreeSortable

HIERARCHY
  Glib::Interface
  +----Gtk2::TreeSortable

METHODS

  $sortable->set_default_sort_func ($sort_func, $user_data=undef)

•   $sort_func (scalar)

•   $user_data (scalar)

  boolean = $sortable->has_default_sort_func

  $sortable->sort_column_changed

  (sort_column_id, order) = $sortable->get_sort_column_id
Returns sort_column_id, an integer and order, a Gtk2::SortType.

  $sortable->set_sort_column_id ($sort_column_id, $order)

•   $sort_column_id (integer)

•   $order (Gtk2::SortType)

  $sortable->set_sort_func ($sort_column_id, $sort_func, $user_data=undef)

•   $sort_column_id (integer)

•   $sort_func (scalar)

•   $user_data (scalar)

IMPLEMENTING THE GtkTreeSortable INTERACE
If you want your custom tree model to be sortable, you need to implement the GtkTreeSortable interface. Just like with other interfaces, this boils down to announcing that your subclass implements the interface and providing a few virtual methods. The former is achieved by adding "Gtk2::TreeSortable" to the "interfaces" key. For example:

  package MyModel;
  use Gtk2;
  use Glib::Object::Subclass
      Glib::Object::,
      interfaces => [ Gtk2::TreeModel::, Gtk2::TreeSortable:: ],
      ;

The virtual methods you need to implement are listed below.

  VIRTUAL METHODS
These virtual methods are called by perl when gtk+ attempts to modify the sorting behavior of your model. Implement them in your model's package. Note that we don't provide a wrapper for sort_column_changed because there is a signal for it, which means you can use the normal signal overriding mechanism documented in Glib::Object::Subclass.

(is_not_special, id, order) = GET_SORT_COLUMN_ID ($model)
    Returns a boolean indicating whether the column is a special or normal one, its id and its sorting order.

SET_SORT_COLUMN_ID ($list, $id, $order)
    Sets the sort column to the one specified by $id and the sorting order to $order.

SET_SORT_FUNC ($list, $id, $func, $data)
    Sets the function that is to be used for sorting the column $id.

SET_DEFAULT_SORT_FUNC ($list, $func, $data)
    Sets the function that is to be used for sorting columns that don't have a sorting function attached to them.

    The $func and $data arguments passed to these two methods should be treated as blackboxes. They are generic containers for some callback that is to be invoked whenever you want to compare two tree iters. When you call them, make sure to always pass $data. For example:

      $retval = $func->($list, $a, $b, $data);

bool = HAS_DEFAULT_SORT_FUNC ($list)
    Returns a bool indicating whether $list has a default sorting function.

SIGNALS

sort-column-changed (Gtk2::TreeSortable)

ENUMS AND FLAGS

  enum Gtk2::SortType
•   'ascending' / 'GTK_SORT_ASCENDING'

•   'descending' / 'GTK_SORT_DESCENDING'

SEE ALSO
Gtk2, Glib::Interface

COPYRIGHT
Copyright (C) 2003-2008 by the gtk2-perl team.

This software is licensed under the LGPL. See Gtk2 for a full notice.