Crea  Modifica  FrontPage  Indici  Cerca  Ultime modifiche  History  RSS  Login

Gtk::TreeSelection

class Gtk::TreeSelection

The Gtk::TreeSelection object is a helper object to manage the selection for a Gtk::TreeView widget. The Gtk::TreeSelection object is automatically created when a new Gtk::TreeView widget is created, and cannot exist independentally of this widget. The primary reason the Gtk::TreeSelection objects 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 methods.

The Gtk::TreeSelection object is gotten from a Gtk::TreeView by calling Gtk::TreeView#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 "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 (mostly as a result of programmers calling select_row on an already selected row).

Instance Methods

mode
Gets the selection mode for selection. See Gtk::TreeSelection#mode=.
  • Returns: the current selection mode
mode=(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.
set_mode(type)
Same as Gtk::TreeSelection#mode=.
set_select_function {|selection, model, path, path_currentry_selected| ... }
Sets the selection block. If set, this block is called before any node is selected or unselected, giving some control over which nodes are selected. The select block should return true if the state of the node may be toggled, and false if the state of the node should be left unchanged.
  • {|selection, model, path, path_currentry_selected| ... }: the selection block
    • selection: A Gtk::TreeSelection
    • model: A Gtk::TreeModel being viewed
    • path: The Gtk::TreePath of the row in question
    • path_currently_selected: true, if the path is currently selected
    • Returns : true, if the selection state of the row can be toggled
  • Returns: self
tree_view
Returns the tree view associated with selection.
selected
Gets iter to the currently selected node if selection is set to Gtk::SELECTION_SINGLE or Gtk::SELECTION_BROWSE. iter may be nil if you just want to test if selection has any selected nodes. This method will not work if you use selection is Gtk::SELECTION_MULTIPLE.
selected_each {|model, path, iter| ... }
Calls a block for each selected node.
  • {|model, path, iter| ... }: The block to call for each selected node.

data : user data to pass to the function.

  • Returns: self
select_path(path)
Select the row at path.
unselect_path(path)
Unselects the row at path.
path_is_selected?
Returns true if the row pointed to by path is currently selected. If path does not point to a valid location, false is returned.
  • path: A Gtk::TreePath to check selection on.
  • Returns: true if path is selected.
select_iter(iter)
Selects the specified iterator.
unselect_iter(iter)
Unselects the specified iterator.
iter_is_selected?(iter)
Returns true if the row pointed to by path is currently selected.
select_all
Selects all the nodes. selection is must be set to Gtk::SELECTION_MULTIPLE mode.
  • Returns: self
unselect_all
Unselects all the nodes.
  • Returns: self
select_range(start_path, end_path)
Selects a range of nodes, determined by start_path and end_path inclusive.
  • start_path: The initial node of the range.
  • end_path: The final node of the range.
  • Returns: self

Signals

changed: self
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.
Ultima modifica:2005/11/17 02:43:41
Parola chiave:
Referenze:[Gtk::TreeView] [Gtk::TreeSelection] [Gtk::TreeViewColumn]