Ardour  9.0-pre0-582-g084a23a80d
Gtk::TreeSelection Class Reference

#include <treeselection.h>

Inheritance diagram for Gtk::TreeSelection:
[legend]

Public Types

typedef sigc::slot< bool, const Glib::RefPtr< TreeModel > &, const TreeModel::Path &, bool > SlotSelect
 
typedef Glib::ListHandle< TreeModel::Path, TreePath_Traits > ListHandle_Path
 
typedef sigc::slot< void, const TreeModel::iterator & > SlotForeachIter
 
typedef sigc::slot< void, const TreeModel::Path & > SlotForeachPath
 
typedef sigc::slot< void, const TreeModel::Path &, const TreeModel::iterator & > SlotForeachPathAndIter
 

Public Member Functions

virtual ~TreeSelection ()
 
GtkTreeSelectiongobj ()
 Provides access to the underlying C GObject. More...
 
const GtkTreeSelectiongobj () const
 Provides access to the underlying C GObject. More...
 
GtkTreeSelectiongobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
void set_mode (SelectionMode type)
 
SelectionMode get_mode () const
 
void set_select_function (const SlotSelect &slot)
 
TreeViewget_tree_view ()
 
const TreeViewget_tree_view () const
 
Glib::RefPtr< TreeModelget_model ()
 
Glib::RefPtr< const TreeModelget_model () const
 
TreeModel::iterator get_selected ()
 
TreeModel::iterator get_selected (Glib::RefPtr< TreeModel > &model)
 
ListHandle_Path get_selected_rows () const
 
ListHandle_Path get_selected_rows (Glib::RefPtr< TreeModel > &model)
 
int count_selected_rows () const
 
void selected_foreach_iter (const SlotForeachIter &slot) const
 
void selected_foreach_path (const SlotForeachPath &slot) const
 
void selected_foreach (const SlotForeachPathAndIter &slot) const
 
void select (const TreeModel::Path &path)
 
void select (const TreeModel::iterator &iter)
 
void select (const TreeModel::Row &row)
 
void select (const TreeModel::Path &start_path, const TreeModel::Path &end_path)
 
void unselect (const TreeModel::Path &path)
 
void unselect (const TreeModel::Path &start_path, const TreeModel::Path &end_path)
 
void unselect (const TreeModel::iterator &iter)
 
bool is_selected (const TreeModel::Path &path) const
 
bool is_selected (const TreeModel::iterator &iter) const
 
void select_all ()
 
void unselect_all ()
 
Glib::SignalProxy0< void > signal_changed ()
 

Static Public Member Functions

static GType get_type () G_GNUC_CONST
 

Protected Member Functions

virtual void on_changed ()
 This is a default handler for the signal signal_changed(). More...
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::TreeSelectionwrap (GtkTreeSelection *object, bool take_copy=false)
 

Detailed Description

Typedefed as Gtk::TreeView::Selection. This is a helper object to manage the selection for a Gtk::TreeView widget.

It is automatically created when a new Gtk::TreeView widget is created, and cannot exist independently of this widget. The primary reason this class exists is for cleanliness of code and API. That is, there is no conceptual reason all these methods could not be methods on the Gtk::TreeView widget instead of a separate class.

The Gtk::TreeSelection object can be obtained from a Gtk::TreeView by calling Gtk::TreeView::get_selection(). It can be manipulated to check the selection status of the tree, as well as to select and deselect individual rows. Selection is done completely view-side. As a result, multiple views of the same model can have completely different selections. Additionally, you cannot change the selection of a row on the model that is not currently displayed by the view without expanding its parents first.

When monitoring the selection of a view, it's important to remember that the "changed" signal is mostly a hint. That is, it may only emit one signal when a range of rows is selected. Additionally, it may on occasion emit a "changed" signal when nothing has happened.

Definition at line 79 of file treeselection.h.

Member Typedef Documentation

◆ ListHandle_Path

typedef Glib::ListHandle<TreeModel::Path, TreePath_Traits> Gtk::TreeSelection::ListHandle_Path

Definition at line 206 of file treeselection.h.

◆ SlotForeachIter

typedef sigc::slot<void, const TreeModel::iterator&> Gtk::TreeSelection::SlotForeachIter

For example, void on_foreach(const Gtk::TreeModel::iterator& iter);

Note that you cannot modify the tree or selection from within the callback function. As a result, get_selected_rows() might be more useful.

Definition at line 241 of file treeselection.h.

◆ SlotForeachPath

typedef sigc::slot<void, const TreeModel::Path&> Gtk::TreeSelection::SlotForeachPath

For example, void on_foreach(const Gtk::TreeModel::Path& path);

Note that you cannot modify the tree or selection from within the callback function. As a result, get_selected_rows() might be more useful.

Definition at line 257 of file treeselection.h.

◆ SlotForeachPathAndIter

For example, void on_foreach(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter);

Note that you cannot modify the tree or selection from within the callback function. As a result, get_selected_rows() might be more useful.

Definition at line 274 of file treeselection.h.

◆ SlotSelect

typedef sigc::slot<bool, const Glib::RefPtr<TreeModel>&, const TreeModel::Path&, bool> Gtk::TreeSelection::SlotSelect

For instance, bool on_select_function(const Glib::RefPtr<TreeModel>& model, const TreeModel::Path& path, bool path_currently_selected) The select function should return true if the state of the node may be toggled, and false if the state of the node should be left unchanged.

Definition at line 153 of file treeselection.h.

Constructor & Destructor Documentation

◆ ~TreeSelection()

virtual Gtk::TreeSelection::~TreeSelection ( )
virtual

Member Function Documentation

◆ count_selected_rows()

int Gtk::TreeSelection::count_selected_rows ( ) const

Returns the number of rows that have been selected in tree.

Returns
The number of rows selected.

◆ get_mode()

SelectionMode Gtk::TreeSelection::get_mode ( ) const

Gets the selection mode for selection. See set_mode().

Returns
The current selection mode.

◆ get_model() [1/2]

Glib::RefPtr<TreeModel> Gtk::TreeSelection::get_model ( )

Shortcut for get_tree_view()->get_model().

Returns
The TreeModel associated with this TreeSelection.

◆ get_model() [2/2]

Glib::RefPtr<const TreeModel> Gtk::TreeSelection::get_model ( ) const

◆ get_selected() [1/2]

TreeModel::iterator Gtk::TreeSelection::get_selected ( )

Get the currently selected row.

Returns
The currently selected row.
Note
This method won't work if the selection mode is Gtk::SELECTION_MULTIPLE. Use get_selected_rows() for multiple selections.

◆ get_selected() [2/2]

TreeModel::iterator Gtk::TreeSelection::get_selected ( Glib::RefPtr< TreeModel > &  model)

Get the currently selected row.

Returns
The currently selected row. Or end() if no rows were selected.
Return values
modelThe current TreeModel.
Note
This method won't work if the selection mode is Gtk::SELECTION_MULTIPLE. Use get_selected_rows() for multiple selections.

◆ get_selected_rows() [1/2]

ListHandle_Path Gtk::TreeSelection::get_selected_rows ( ) const

Creates a list of paths of all selected rows. Additionally, if you are planning on modifying the model after calling this function, you may want to convert the returned list into a list of GtkTreeRowReferences.

Returns
a standard container containing a Gtk::Model::Path for each selected row.

◆ get_selected_rows() [2/2]

ListHandle_Path Gtk::TreeSelection::get_selected_rows ( Glib::RefPtr< TreeModel > &  model)

Creates a list of paths of all selected rows. Additionally, if you are planning on modifying the model after calling this function, you may want to convert the returned list into a list of GtkTreeRowReferences.

Return values
modelThe current TreeModel.
Returns
a standard container containing a Gtk::Model::Path for each selected row.

◆ get_tree_view() [1/2]

TreeView* Gtk::TreeSelection::get_tree_view ( )

Returns the tree view associated with selection.

Returns
A Gtk::TreeView.

◆ get_tree_view() [2/2]

const TreeView* Gtk::TreeSelection::get_tree_view ( ) const

Returns the tree view associated with selection.

Returns
A Gtk::TreeView.

◆ get_type()

static GType Gtk::TreeSelection::get_type ( )
static

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

◆ gobj() [1/2]

GtkTreeSelection* Gtk::TreeSelection::gobj ( )
inline

Provides access to the underlying C GObject.

Definition at line 118 of file treeselection.h.

◆ gobj() [2/2]

const GtkTreeSelection* Gtk::TreeSelection::gobj ( ) const
inline

Provides access to the underlying C GObject.

Definition at line 121 of file treeselection.h.

◆ gobj_copy()

GtkTreeSelection* Gtk::TreeSelection::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

◆ is_selected() [1/2]

bool Gtk::TreeSelection::is_selected ( const TreeModel::iterator iter) const

Returns true if the row at iter is currently selected.

Parameters
iterA valid Gtk::TreeIter.
Returns
true, if iter is selected.

◆ is_selected() [2/2]

bool Gtk::TreeSelection::is_selected ( const TreeModel::Path path) const

Returns true if the row pointed to by path is currently selected. If path does not point to a valid location, false is returned

Parameters
pathA Gtk::TreePath to check selection on.
Returns
true if path is selected.

◆ on_changed()

virtual void Gtk::TreeSelection::on_changed ( )
protectedvirtual

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

◆ select() [1/4]

void Gtk::TreeSelection::select ( const TreeModel::iterator iter)

Selects the specified iterator.

Parameters
iterThe Gtk::TreeIter to be selected.

◆ select() [2/4]

void Gtk::TreeSelection::select ( const TreeModel::Path path)

Select the row at path.

Parameters
pathThe Gtk::TreePath to be selected.

◆ select() [3/4]

void Gtk::TreeSelection::select ( const TreeModel::Path start_path,
const TreeModel::Path end_path 
)

Selects a range of nodes, determined by start_path and end_path inclusive. selection must be set to Gtk::SELECTION_MULTIPLE mode.

Parameters
start_pathThe initial node of the range.
end_pathThe final node of the range.

◆ select() [4/4]

void Gtk::TreeSelection::select ( const TreeModel::Row row)

Selects the specified iterator.

Parameters
rowThe Gtk::TreeModel::Row to be selected.

◆ select_all()

void Gtk::TreeSelection::select_all ( )

Selects all the nodes. selection must be set to Gtk::SELECTION_MULTIPLE mode.

◆ selected_foreach()

void Gtk::TreeSelection::selected_foreach ( const SlotForeachPathAndIter slot) const

Calls a callback slot for each selected node. Note that you cannot modify the tree or selection from within the callback function. As a result, get_selected_rows() might be more useful.

Parameters
slotThe function to call for each selected node.

◆ selected_foreach_iter()

void Gtk::TreeSelection::selected_foreach_iter ( const SlotForeachIter slot) const

Calls a callback slot for each selected node. Note that you cannot modify the tree or selection from within the callback function. As a result, get_selected_rows() might be more useful.

Parameters
slotThe function to call for each selected node.

◆ selected_foreach_path()

void Gtk::TreeSelection::selected_foreach_path ( const SlotForeachPath slot) const

Calls a callback slot for each selected node. Note that you cannot modify the tree or selection from within the callback function. As a result, get_selected_rows() might be more useful.

Parameters
slotThe function to call for each selected node.

◆ set_mode()

void Gtk::TreeSelection::set_mode ( SelectionMode  type)

Sets the selection mode of the selection. If the previous type was Gtk::SELECTION_MULTIPLE, then the anchor is kept selected, if it was previously selected.

Parameters
typeThe selection mode.

◆ set_select_function()

void Gtk::TreeSelection::set_select_function ( const SlotSelect slot)

Sets the selection callback slot. If set, this function is called before any node is selected or unselected, giving some control over which nodes are selected.

The select function should return true if the state of the node may be toggled, and FALSE if the state of the node should be left unchanged.

Parameters
slotThe selection function.

◆ signal_changed()

Glib::SignalProxy0< void > Gtk::TreeSelection::signal_changed ( )
Slot Prototype:
void on_my_changed()

◆ unselect() [1/3]

void Gtk::TreeSelection::unselect ( const TreeModel::iterator iter)

Unselects the specified iterator.

Parameters
iterThe Gtk::TreeIter to be unselected.

◆ unselect() [2/3]

void Gtk::TreeSelection::unselect ( const TreeModel::Path path)

Unselects the row at path.

Parameters
pathThe Gtk::TreePath to be unselected.

◆ unselect() [3/3]

void Gtk::TreeSelection::unselect ( const TreeModel::Path start_path,
const TreeModel::Path end_path 
)

Unselects a range of nodes, determined by start_path and end_path inclusive.

Parameters
start_pathThe initial node of the range.
end_pathThe initial node of the range.

◆ unselect_all()

void Gtk::TreeSelection::unselect_all ( )

Unselects all the nodes.

Friends And Related Function Documentation

◆ wrap()

Glib::RefPtr< Gtk::TreeSelection > wrap ( GtkTreeSelection 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.

The documentation for this class was generated from the following file: