gtkmm 4.16.0
|
Typedefed as Gtk::TreeView::Selection. More...
#include <gtkmm/treeselection.h>
Public Types | |
using | SlotSelect = sigc::slot< bool(const Glib::RefPtr< TreeModel > &, const TreeModel::Path &, bool)> |
For instance, bool on_select_function(const Glib::RefPtr<TreeModel>& model, const TreeModel::Path& path, bool path_currently_selected);. | |
using | SlotForeachIter = sigc::slot< void(const TreeModel::const_iterator &)> |
For example, void on_foreach(const Gtk::TreeModel::const_iterator& iter);. | |
using | SlotForeachPath = sigc::slot< void(const TreeModel::Path &)> |
For example, void on_foreach(const Gtk::TreeModel::Path& path);. | |
using | SlotForeachPathAndIter = sigc::slot< void(const TreeModel::Path &, const TreeModel::const_iterator &)> |
For example, void on_foreach(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::const_iterator& iter);. | |
Public Member Functions | |
TreeSelection (TreeSelection &&src) noexcept | |
TreeSelection & | operator= (TreeSelection &&src) noexcept |
~TreeSelection () noexcept override | |
GtkTreeSelection * | gobj () |
Provides access to the underlying C GObject. | |
const GtkTreeSelection * | gobj () const |
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. | |
void | set_mode (SelectionMode type) |
Sets the selection mode of the selection. | |
SelectionMode | get_mode () const |
Gets the selection mode for selection. | |
void | set_select_function (const SlotSelect &slot) |
Sets the selection callback slot. | |
TreeView * | get_tree_view () |
Returns the tree view associated with selection. | |
const TreeView * | get_tree_view () const |
Returns the tree view associated with selection. | |
Glib::RefPtr< TreeModel > | get_model () |
Shortcut for get_tree_view()->get_model(). | |
Glib::RefPtr< const TreeModel > | get_model () const |
TreeModel::iterator | get_selected () |
Get the currently selected row. | |
TreeModel::const_iterator | get_selected () const |
Get the currently selected row. | |
TreeModel::iterator | get_selected (Glib::RefPtr< TreeModel > &model) |
Get the currently selected row. | |
TreeModel::const_iterator | get_selected (Glib::RefPtr< const TreeModel > &model) const |
Get the currently selected row. | |
std::vector< TreeModel::Path > | get_selected_rows () const |
Creates a vector of paths of all selected rows. | |
std::vector< TreeModel::Path > | get_selected_rows (Glib::RefPtr< TreeModel > &model) |
Creates a list of paths of all selected rows. | |
int | count_selected_rows () const |
Returns the number of rows that have been selected in tree. | |
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 | selected_foreach (const SlotForeachPathAndIter &slot) const |
Calls a callback slot for each selected node. | |
void | select (const TreeModel::Path & path) |
Select the row at path. | |
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::const_iterator &iter) |
Selects the specified iterator. | |
void | unselect (const TreeModel::Path & path) |
Unselects the row at path. | |
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::const_iterator &iter) |
Unselects the specified iterator. | |
bool | is_selected (const TreeModel::Path & path) const |
Returns true if the row pointed to by path is currently selected. | |
bool | is_selected (const TreeModel::const_iterator &iter) const |
Returns true if the row at iter is currently selected. | |
void | select_all () |
Selects all the nodes. | |
void | unselect_all () |
Unselects all the nodes. | |
Glib::PropertyProxy< SelectionMode > | property_mode () |
Selection mode. | |
Glib::PropertyProxy_ReadOnly< SelectionMode > | property_mode () const |
Selection mode. | |
Glib::SignalProxy< void()> | signal_changed () |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gtk::TreeSelection > | wrap (GtkTreeSelection *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
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.
using Gtk::TreeSelection::SlotForeachIter = sigc::slot<void(const TreeModel::const_iterator&)> |
For example, void on_foreach(const Gtk::TreeModel::const_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.
using Gtk::TreeSelection::SlotForeachPath = sigc::slot<void(const TreeModel::Path&)> |
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.
using Gtk::TreeSelection::SlotForeachPathAndIter = sigc::slot<void(const TreeModel::Path&, const TreeModel::const_iterator&)> |
For example, void on_foreach(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::const_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.
using Gtk::TreeSelection::SlotSelect = sigc::slot<bool(const Glib::RefPtr<TreeModel>&, const TreeModel::Path&, bool)> |
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.
|
noexcept |
|
overridenoexcept |
int Gtk::TreeSelection::count_selected_rows | ( | ) | const |
Returns the number of rows that have been selected in tree.
Deprecated: 4.10: Use GtkListView or GtkColumnView
SelectionMode Gtk::TreeSelection::get_mode | ( | ) | const |
Gets the selection mode for selection.
See set_mode().
Deprecated: 4.10: Use GtkListView or GtkColumnView
Glib::RefPtr< TreeModel > Gtk::TreeSelection::get_model | ( | ) |
Shortcut for get_tree_view()->get_model().
TreeModel::iterator Gtk::TreeSelection::get_selected | ( | ) |
Get the currently selected row.
Gtk::SelectionMode::MULTIPLE
. Use get_selected_rows() for multiple selections. TreeModel::const_iterator Gtk::TreeSelection::get_selected | ( | ) | const |
Get the currently selected row.
Gtk::SelectionMode::MULTIPLE
. Use get_selected_rows() for multiple selections.TreeModel::const_iterator Gtk::TreeSelection::get_selected | ( | Glib::RefPtr< const TreeModel > & | model | ) | const |
Get the currently selected row.
[out] | model | The current TreeModel. |
Gtk::SelectionMode::MULTIPLE
. Use get_selected_rows() for multiple selections.TreeModel::iterator Gtk::TreeSelection::get_selected | ( | Glib::RefPtr< TreeModel > & | model | ) |
Get the currently selected row.
[out] | model | The current TreeModel. |
Gtk::SelectionMode::MULTIPLE
. Use get_selected_rows() for multiple selections. std::vector< TreeModel::Path > Gtk::TreeSelection::get_selected_rows | ( | ) | const |
Creates a vector 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.
std::vector< TreeModel::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.
[out] | model | The current TreeModel. |
TreeView * Gtk::TreeSelection::get_tree_view | ( | ) |
Returns the tree view associated with selection.
Deprecated: 4.10: Use GtkListView or GtkColumnView
Gtk::TreeView
. Returns the tree view associated with selection.
Deprecated: 4.10: Use GtkListView or GtkColumnView
Gtk::TreeView
.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
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.
bool Gtk::TreeSelection::is_selected | ( | const TreeModel::const_iterator & | iter | ) | const |
Returns true
if the row at iter is currently selected.
Deprecated: 4.10: Use GtkListView or GtkColumnView
iter | A valid Gtk::TreeIter . |
true
, if iter is selected. 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
Deprecated: 4.10: Use GtkListView or GtkColumnView
path | A Gtk::TreePath to check selection on. |
true
if path is selected.
|
noexcept |
Glib::PropertyProxy< SelectionMode > Gtk::TreeSelection::property_mode | ( | ) |
Selection mode.
See Gtk::TreeSelection::set_mode() for more information on this property.
Default value: Gtk::SelectionMode::SINGLE
Glib::PropertyProxy_ReadOnly< SelectionMode > Gtk::TreeSelection::property_mode | ( | ) | const |
Selection mode.
See Gtk::TreeSelection::set_mode() for more information on this property.
Default value: Gtk::SelectionMode::SINGLE
void Gtk::TreeSelection::select | ( | const TreeModel::const_iterator & | iter | ) |
Selects the specified iterator.
Deprecated: 4.10: Use GtkListView or GtkColumnView
iter | The Gtk::TreeIter to be selected. |
void Gtk::TreeSelection::select | ( | const TreeModel::Path & | path | ) |
Select the row at path.
Deprecated: 4.10: Use GtkListView or GtkColumnView
path | The Gtk::TreePath to be selected. |
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::SelectionMode::MULTIPLE mode.
Deprecated: 4.10: Use GtkListView or GtkColumnView
start_path | The initial node of the range. |
end_path | The final node of the range. |
void Gtk::TreeSelection::select_all | ( | ) |
Selects all the nodes.
selection must be set to Gtk::SelectionMode::MULTIPLE mode.
Deprecated: 4.10: Use GtkListView or GtkColumnView
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.
slot | The function to call for each selected node. |
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.
slot | The function to call for each selected node. |
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.
slot | The function to call for each selected node. |
void Gtk::TreeSelection::set_mode | ( | SelectionMode | type | ) |
Sets the selection mode of the selection.
If the previous type was Gtk::SelectionMode::MULTIPLE, then the anchor is kept selected, if it was previously selected.
Deprecated: 4.10: Use GtkListView or GtkColumnView
type | The selection mode. |
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.
slot | The selection function. |
Glib::SignalProxy< void()> Gtk::TreeSelection::signal_changed | ( | ) |
void on_my_changed()
Flags: Run First
Emitted whenever the selection has (possibly) changed. Please note that this signal is mostly a hint. It may only be emitted once when a range of rows are selected, and it may occasionally be emitted when nothing has happened.
void Gtk::TreeSelection::unselect | ( | const TreeModel::const_iterator & | iter | ) |
Unselects the specified iterator.
Deprecated: 4.10: Use GtkListView or GtkColumnView
iter | The Gtk::TreeIter to be unselected. |
void Gtk::TreeSelection::unselect | ( | const TreeModel::Path & | path | ) |
Unselects the row at path.
Deprecated: 4.10: Use GtkListView or GtkColumnView
path | The Gtk::TreePath to be unselected. |
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.
Deprecated: 4.10: Use GtkListView or GtkColumnView
start_path | The initial node of the range. |
end_path | The initial node of the range. |
void Gtk::TreeSelection::unselect_all | ( | ) |
Unselects all the nodes.
Deprecated: 4.10: Use GtkListView or GtkColumnView
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |