Class: Gtk::TreeSelection

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Overview

The selection object for GtkTreeView

The GtkTreeSelection object is a helper object to manage the selection for a GtkTreeView widget. The GtkTreeSelection object is automatically created when a new GtkTreeView widget is created, and cannot exist independently of this widget. The primary reason the GtkTreeSelection objects exists is for cleanliness of code and API. That is, there is no conceptual reason all these functions could not be methods on the GtkTreeView widget instead of a separate function.

The GtkTreeSelection object is gotten from a GtkTreeView by calling gtk_tree_view_get_selection(). It can be manipulated to check the selection status of the tree, as well as 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.

One of the important things to remember when monitoring the selection of a view is that the GtkTreeSelection::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 GtkTreeSelection::changed signal when nothing has happened (mostly as a result of programmers calling select_row on an already selected row).

Instance Method Summary collapse

Instance Method Details

#count_selected_rowsInteger

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

Returns:

  • (Integer)

    The number of rows selected.

#get_selected(model, iter) ⇒ Boolean

Sets iter to the currently selected node if selection is set to %GTK_SELECTION_SINGLE or %GTK_SELECTION_BROWSE. iter may be NULL if you just want to test if selection has any selected nodes. model is filled with the current model as a convenience. This function will not work if you use selection is %GTK_SELECTION_MULTIPLE.

Parameters:

  • model (Gtk::TreeModel)

    A pointer to set to the GtkTreeModel

  • iter (Gtk::TreeIter)

    The GtkTreeIter

Returns:

  • (Boolean)

    TRUE, if there is a selected node.

#get_selected_rows(model) ⇒ GLib::List<Gtk::TreePath>

Creates a list of path 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. To do this, you can use gtk_tree_row_reference_new().

To free the return value, use:

g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);

Parameters:

Returns:

  • (GLib::List<Gtk::TreePath>)

    A GList containing a GtkTreePath for each selected row.

#iter_is_selected(iter) ⇒ Boolean

Returns true if the row at iter is currently selected.

Parameters:

  • iter (Gtk::TreeIter)

    A valid GtkTreeIter

Returns:

  • (Boolean)

    true, if iter is selected

#modeGtk::SelectionMode

Selection mode. See gtk_tree_selection_set_mode() for more information on this property.

Returns:

#mode=(mode) ⇒ Gtk::SelectionMode

Selection mode. See gtk_tree_selection_set_mode() for more information on this property.

Parameters:

Returns:

#path_is_selected(path) ⇒ Boolean

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:

  • path (Gtk::TreePath)

    A GtkTreePath to check selection on.

Returns:

  • (Boolean)

    true if path is selected.

#select_allnil

Selects all the nodes. selection must be set to %GTK_SELECTION_MULTIPLE mode.

Returns:

  • (nil)

#select_functionGtk::TreeSelectionFunc

Returns the current selection function.

Returns:

  • (Gtk::TreeSelectionFunc)

    The function.

#select_iter(iter) ⇒ nil

Selects the specified iterator.

Parameters:

  • iter (Gtk::TreeIter)

    The GtkTreeIter to be selected.

Returns:

  • (nil)

#select_path(path) ⇒ nil

Select the row at path.

Parameters:

  • path (Gtk::TreePath)

    The GtkTreePath to be selected.

Returns:

  • (nil)

#select_range(start_path, end_path) ⇒ nil

Selects a range of nodes, determined by start_path and end_path inclusive. selection must be set to %GTK_SELECTION_MULTIPLE mode.

Parameters:

  • start_path (Gtk::TreePath)

    The initial node of the range.

  • end_path (Gtk::TreePath)

    The final node of the range.

Returns:

  • (nil)

#selected_foreach(func, data) ⇒ nil

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

Parameters:

  • func (Gtk::TreeSelectionForeachFunc)

    The function to call for each selected node.

  • data (GObject)

    user data to pass to the function.

Returns:

  • (nil)

#set_select_function(func, data, destroy) ⇒ nil

Sets the selection function.

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:

  • func (Gtk::TreeSelectionFunc)

    The selection function. May be nil

  • data (GObject)

    The selection function’s data. May be nil

  • destroy (GLib::DestroyNotify)

    The destroy function for user data. May be nil

Returns:

  • (nil)

#tree_viewGtk::TreeView

Returns the tree view associated with selection.

Returns:

#unselect_allnil

Unselects all the nodes.

Returns:

  • (nil)

#unselect_iter(iter) ⇒ nil

Unselects the specified iterator.

Parameters:

  • iter (Gtk::TreeIter)

    The GtkTreeIter to be unselected.

Returns:

  • (nil)

#unselect_path(path) ⇒ nil

Unselects the row at path.

Parameters:

  • path (Gtk::TreePath)

    The GtkTreePath to be unselected.

Returns:

  • (nil)

#unselect_range(start_path, end_path) ⇒ nil

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

Parameters:

  • start_path (Gtk::TreePath)

    The initial node of the range.

  • end_path (Gtk::TreePath)

    The initial node of the range.

Returns:

  • (nil)

#user_dataGObject

Returns the user data for the selection function.

Returns:

  • (GObject)

    The user data.