![]() |
![]() |
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.
Public Types | |
typedef Glib::ListHandle< TreeModel::Path, TreePath_Traits > | ListHandle_Path |
typedef sigc::slot< void, const TreeModel::iterator& > | SlotForeachIter |
For example, void on_foreach(const Gtk::TreeModel::iterator& iter);. | |
typedef sigc::slot< void, const TreeModel::Path& > | SlotForeachPath |
For example, void on_foreach(const Gtk::TreeModel::Path& path);. | |
typedef sigc::slot< void, const TreeModel::Path&, const TreeModel::iterator& > | SlotForeachPathAndIter |
For example, void on_foreach(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter);. | |
typedef sigc::slot< bool, const Glib::RefPtr<TreeModel>&, const TreeModel::Path&, bool > | 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. | |
Public Member Functions | |
int | count_selected_rows () const |
Returns the number of rows that have been selected in tree . | |
SelectionMode | get_mode () const |
Gets the selection mode for selection . | |
Glib::RefPtr<const TreeModel> | get_model () const |
Glib::RefPtr<TreeModel> | get_model () |
Shortcut for get_tree_view()->get_model(). | |
TreeModel::iterator | get_selected (Glib::RefPtr<TreeModel>& model) |
Get the currently selected row. | |
TreeModel::iterator | get_selected () |
Get the currently selected row. | |
ListHandle_Path | get_selected_rows (Glib::RefPtr<TreeModel>& model) |
Creates a list of paths of all selected rows. | |
ListHandle_Path | get_selected_rows () const |
Creates a list of paths of all selected rows. | |
const TreeView* | get_tree_view () const |
Returns the tree view associated with selection . | |
TreeView* | get_tree_view () |
Returns the tree view associated with selection . | |
const GtkTreeSelection* | gobj () const |
Provides access to the underlying C GObject. | |
GtkTreeSelection* | gobj () |
Provides access to the underlying C GObject. | |
GtkTreeSelection* | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
bool | is_selected (const TreeModel::iterator& iter) const |
Returns true if the row at iter is currently selected. | |
bool | is_selected (const TreeModel::Path& path) const |
Returns true if the row pointed to by path is currently selected. | |
void | select (const TreeModel::Path& start_path, const TreeModel::Path& end_path) |
Selects a range of nodes, determined by start_path and end_path inclusive. | |
void | select (const TreeModel::Row& row) |
Selects the specified iterator. | |
void | select (const TreeModel::iterator& iter) |
Selects the specified iterator. | |
void | select (const TreeModel::Path& path) |
Select the row at path . | |
void | select_all () |
Selects all the nodes. | |
void | selected_foreach (const SlotForeachPathAndIter& slot) const |
Calls a callback slot for each selected node. | |
void | selected_foreach_iter (const SlotForeachIter& slot) const |
Calls a callback slot for each selected node. | |
void | selected_foreach_path (const SlotForeachPath& slot) const |
Calls a callback slot for each selected node. | |
void | set_mode (SelectionMode type) |
Sets the selection mode of the selection . | |
void | set_select_function (const SlotSelect& slot) |
Sets the selection callback slot. | |
Glib::SignalProxy0<void> | signal_changed () |
void | unselect (const TreeModel::iterator& iter) |
Unselects the specified iterator. | |
void | unselect (const TreeModel::Path& start_path, const TreeModel::Path& end_path) |
Unselects a range of nodes, determined by start_path and end_path inclusive. | |
void | unselect (const TreeModel::Path& path) |
Unselects the row at path . | |
void | unselect_all () |
Unselects all the nodes. | |
virtual | ~TreeSelection () |
Protected Member Functions | |
virtual void | on_changed () |
Related Functions | |
(Note that these are not member functions.) | |
Glib::RefPtr<Gtk::TreeSelection> | wrap (GtkTreeSelection* object, bool take_copy=false) |
|
|
|
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. |
|
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. |
|
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. |
|
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.
|
|
|
|
Returns the number of rows that have been selected in tree .
|
|
Gets the selection mode for selection . See set_mode().
|
|
|
|
Shortcut for get_tree_view()->get_model().
|
|
Get the currently selected row.
|
|
Get the currently selected row.
|
|
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.
|
|
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 the tree view associated with selection .
|
|
Returns the tree view associated with selection .
|
|
Provides access to the underlying C GObject.
Reimplemented from Glib::ObjectBase. |
|
Provides access to the underlying C GObject.
Reimplemented from Glib::ObjectBase. |
|
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
|
|
Returns
|
|
Returns
If path does not point to a valid location,
|
|
|
|
Selects a range of nodes, determined by start_path and end_path inclusive. selection must be set to Gtk::SELECTION_MULTIPLE mode.
|
|
Selects the specified iterator.
|
|
Selects the specified iterator.
|
|
Select the row at path .
|
|
Selects all the nodes. selection must be set to Gtk::SELECTION_MULTIPLE mode. |
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
|
|
Unselects the specified iterator.
|
|
Unselects a range of nodes, determined by start_path and end_path inclusive.
|
|
Unselects the row at path .
|
|
Unselects all the nodes.
|
|
|