gtkmm: Gtk::TreeSortable Class Reference

#include <gtkmm/treesortable.h>

Inheritance diagram for Gtk::TreeSortable:

Public Types

enum  {

  DEFAULT_SORT_COLUMN_ID = -1,

  DEFAULT_UNSORTED_COLUMN_ID = -2

}
 
typedef sigc::slot< int(const Gtk::TreeModel::const_iterator&, const Gtk::TreeModel::const_iterator&)> SlotCompare
 This callback should return -1 if a compares before b, 0 if they compare equal, 1 if a compares after b. More...

 
- Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify func_destroy_notify
 
- Public Types inherited from sigc::notifiable
typedef internal::func_destroy_notify func_destroy_notify
 

Public Member Functions

 TreeSortable (TreeSortable&& src) noexcept
 
TreeSortableoperator= (TreeSortable&& src) noexcept
 
 ~TreeSortable () noexcept override
 
GtkTreeSortable* gobj ()
 Provides access to the underlying C GObject. More...

 
const GtkTreeSortable* gobj () const
 Provides access to the underlying C GObject. More...

 
bool get_sort_column_id (int& sort_column_id, SortType& order) const
 Fills in sort_column_id and order with the current sort column and the order. More...

 
void set_sort_column (const TreeModelColumnBase& sort_column_id, SortType order)
 Sets the current sort column to be sort_column_id. More...

 
void set_sort_column (int sort_column_id, SortType order)
 Sets the current sort column to be sort_column_id. More...

 
void set_sort_func (const TreeModelColumnBase& sort_column, const SlotCompare& slot)
 Sets the comparison function used when sorting a certain column. More...

 
void set_sort_func (int sort_column_id, const SlotCompare& slot)
 Sets the comparison function used when sorting a certain column. More...

 
void set_default_sort_func (const SlotCompare& slot)
 Sets the default comparison function used when sorting. More...

 
void unset_default_sort_func ()
 Sets the default comparison function used when sorting. More...

 
bool has_default_sort_func () const
 Returns true if the model has a default sort function. More...

 
void sort_column_changed ()
 Emits a Gtk::TreeSortable::signal_sort_column_changed() signal on sortable. More...

 
Glib::SignalProxy< void()> signal_sort_column_changed ()
 
- Public Member Functions inherited from Glib::Interface
 Interface ()
 
 Interface (Interface &&src) noexcept
 
Interfaceoperator= (Interface &&src) noexcept
 
 Interface (const Glib::Interface_Class &interface_class)
 
 Interface (GObject *castitem)
 
 ~Interface () noexcept override
 
 Interface (const Interface &)=delete
 
Interfaceoperator= (const Interface &)=delete
 
GObject * gobj ()
 
const GObject * gobj () const
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
void set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
 
void get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
 
void set_property (const Glib::ustring &property_name, const PropertyType &value)
 
void get_property (const Glib::ustring &property_name, PropertyType &value) const
 
PropertyType get_property (const Glib::ustring &property_name) const
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot)
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot)
 
void freeze_notify ()
 
void thaw_notify ()
 
virtual void reference () const
 
virtual void unreference () const
 
GObject * gobj ()
 
const GObject * gobj () const
 
GObject * gobj_copy () const
 
- Public Member Functions inherited from sigc::trackable
 trackable () noexcept
 
 trackable (const trackable &src) noexcept
 
 trackable (trackable &&src) noexcept
 
 ~trackable ()
 
void add_destroy_notify_callback (notifiable *data, func_destroy_notify func) const
 
void notify_callbacks ()
 
trackableoperator= (const trackable &src)
 
trackableoperator= (trackable &&src) noexcept
 
void remove_destroy_notify_callback (notifiable *data) const
 

Static Public Member Functions

static void add_interface (GType gtype_implementer)
 
static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...

 

Protected Member Functions

 TreeSortable ()
 You should derive from this class to use it. More...

 
virtual bool get_sort_column_id_vfunc (int* sort_column_id, SortType* order) const
 
virtual void set_sort_column_id_vfunc (int sort_column_id, SortType order)
 
virtual void set_sort_func_vfunc (int sort_column_id, GtkTreeIterCompareFunc func, void* data, GDestroyNotify destroy)
 
virtual void set_default_sort_func_vfunc (GtkTreeIterCompareFunc func, void* data, GDestroyNotify destroy)
 
virtual bool has_default_sort_func_vfunc () const
 
virtual void sort_column_changed_vfunc () const
 
virtual void on_sort_column_changed ()
 This is a default handler for the signal signal_sort_column_changed(). More...

 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 
 ObjectBase (const char *custom_type_name)
 
 ObjectBase (const std::type_info &custom_type_info)
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::TreeSortablewrap (GtkTreeSortable* object, bool take_copy=false)
 A Glib::wrap() method for this object. More...

 

Member Typedef Documentation

This callback should return -1 if a compares before b, 0 if they compare equal, 1 if a compares after b.

For instance, int on_sort_compare(const Gtk::TreeModel::const_iterator& a, const Gtk::TreeModel::const_iterator& b);

Member Enumeration Documentation

anonymous enum
Enumerator
DEFAULT_SORT_COLUMN_ID 

See set_default_sort_func() and set_sort_column().

DEFAULT_UNSORTED_COLUMN_ID 

Constructor & Destructor Documentation

Gtk::TreeSortable::TreeSortable ( )
protected

You should derive from this class to use it.

Gtk::TreeSortable::TreeSortable ( TreeSortable&&  src)
noexcept
Gtk::TreeSortable::~TreeSortable ( )
overridenoexcept

Member Function Documentation

static void Gtk::TreeSortable::add_interface ( GType  gtype_implementer)
static
bool Gtk::TreeSortable::get_sort_column_id ( int &  sort_column_id,
SortType order 
) const

Fills in sort_column_id and order with the current sort column and the order.

It returns true unless the sort_column_id is GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID or GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.

Parameters
sort_column_idThe sort column id to be filled in.
orderThe Gtk::SortType to be filled in.
Returns
true if the sort column is not one of the special sort column ids.
virtual bool Gtk::TreeSortable::get_sort_column_id_vfunc ( int *  sort_column_id,
SortType order 
) const
protectedvirtual
static GType Gtk::TreeSortable::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

GtkTreeSortable* Gtk::TreeSortable::gobj ( )
inline

Provides access to the underlying C GObject.

const GtkTreeSortable* Gtk::TreeSortable::gobj ( ) const
inline

Provides access to the underlying C GObject.

bool Gtk::TreeSortable::has_default_sort_func ( ) const

Returns true if the model has a default sort function.

This is used primarily by GtkTreeViewColumns in order to determine if a model can go back to the default state, or not.

Returns
true, if the model has a default sort function.
virtual bool Gtk::TreeSortable::has_default_sort_func_vfunc ( ) const
protectedvirtual
virtual void Gtk::TreeSortable::on_sort_column_changed ( )
protectedvirtual

This is a default handler for the signal signal_sort_column_changed().

TreeSortable& Gtk::TreeSortable::operator= ( TreeSortable&&  src)
noexcept
void Gtk::TreeSortable::set_default_sort_func ( const SlotCompare slot)

Sets the default comparison function used when sorting.

If the current sort column id of sortable is DEFAULT_SORT_COLUMN_ID, then the model will sort using this function. See also unset_default_sort_func().

Parameters
slotThe sorting function
virtual void Gtk::TreeSortable::set_default_sort_func_vfunc ( GtkTreeIterCompareFunc  func,
void *  data,
GDestroyNotify  destroy 
)
protectedvirtual
void Gtk::TreeSortable::set_sort_column ( const TreeModelColumnBase sort_column_id,
SortType  order 
)

Sets the current sort column to be sort_column_id.

The sortable will resort itself to reflect this change, after emitting a Gtk::TreeSortable::signal_sort_column_changed() signal. sort_column_id may either be a regular column id, or one of the following special values:

  • GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID: the default sort function will be used, if it is set
  • GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID: no sorting will occur
Parameters
sort_column_idThe sort column id to set.
orderThe sort order of the column.
void Gtk::TreeSortable::set_sort_column ( int  sort_column_id,
SortType  order 
)

Sets the current sort column to be sort_column_id.

The sortable will resort itself to reflect this change, after emitting a Gtk::TreeSortable::signal_sort_column_changed() signal. sort_column_id may either be a regular column id, or one of the following special values:

  • GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID: the default sort function will be used, if it is set
  • GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID: no sorting will occur
Parameters
sort_column_idThe sort column id to set.
orderThe sort order of the column.
virtual void Gtk::TreeSortable::set_sort_column_id_vfunc ( int  sort_column_id,
SortType  order 
)
protectedvirtual
void Gtk::TreeSortable::set_sort_func ( const TreeModelColumnBase sort_column,
const SlotCompare slot 
)

Sets the comparison function used when sorting a certain column.

If the current sort column is the same as sort_column, then the model will sort using this function.

Parameters
sort_columnthe sort column to set the function for
slotThe sorting slot callback.
void Gtk::TreeSortable::set_sort_func ( int  sort_column_id,
const SlotCompare slot 
)

Sets the comparison function used when sorting a certain column.

If the current sort column id is the same as sort_column_id, then the model will sort using this function.

Parameters
sort_column_idthe sort column id to set the function for
slotThe sorting slot callback.
virtual void Gtk::TreeSortable::set_sort_func_vfunc ( int  sort_column_id,
GtkTreeIterCompareFunc  func,
void *  data,
GDestroyNotify  destroy 
)
protectedvirtual
Glib::SignalProxy<void()> Gtk::TreeSortable::signal_sort_column_changed ( )
Slot Prototype:
void on_my_sort_column_changed()

Flags: Run Last

The signal_sort_column_changed() signal is emitted when the sort column or sort order of sortable is changed. The signal is emitted before the contents of sortable are resorted.

void Gtk::TreeSortable::sort_column_changed ( )
virtual void Gtk::TreeSortable::sort_column_changed_vfunc ( ) const
protectedvirtual
void Gtk::TreeSortable::unset_default_sort_func ( )

Sets the default comparison function used when sorting.

See set_default_sort_func().

After calling this method there will be no default comparison function. This means that once the model has been sorted, it can't go back to the default state. In this case, when the current sort column id of sortable is DEFAULT_SORT_COLUMN_ID, the model will be unsorted.

Friends And Related Function Documentation

Glib::RefPtr< Gtk::TreeSortable > wrap ( GtkTreeSortable *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.