Author image Kevin Ryde
and 1 contributors


Glib::Ex::ConnectProperties::Element::tree_selection -- TreeSelection rows


 Glib::Ex::ConnectProperties->new([$treesel, 'tree-selection#width'],
                                  [$another, 'something']);


This element class implements ConnectProperties access to rows selected in a Gtk2::TreeSelection.

    tree-selection#empty           boolean, read-only
    tree-selection#not-empty       boolean, read-only
    tree-selection#count           integer, read-only
    tree-selection#selected-path   Gtk2::TreePath or undef

A Gtk2::TreeSelection is normally used by Gtk2::TreeView. The target object for ConnectProperties should be the TreeSelection, as obtained from the TreeView with

    $treeselection = $treeview->get_selection();

For example tree-selection#not-empty might be connected up to make a delete button sensitive only when the user has selected one or more rows,

    my $treeselection = $treeview->get_selection;
      ([$treeselection, 'tree-selection#not-empty'],
       [$button,        'sensitive', write_only => 1]);

tree-selection#selected-path is the first selected row. It's intended for use with "single" selection mode so there's at most one row selected. Writing to the property does select_path() and in single mode will switch from any existing selected row to just the new one. This could be used to synchronise the selected item in two TreeViews.

Rows in a Gtk2::TreeSelection and items in a Gtk2::IconView are similar but not quite the same and so are kept as separate tree-selection# and iconview-selection#.

For reference a selected-iter of type Gtk2::TreeIter might mostly work, but not sure about comparing on storing. Would prefer an equal() or compare() method on Gtk2::TreeIter rather than going via the model. (Perl-Gtk2's to_arrayref() access only suits Perl code models.)


Glib::Ex::ConnectProperties, Glib::Ex::ConnectProperties::Element::iconview_selection, Glib::Ex::ConnectProperties::Element::model_rows, Glib::Ex::ConnectProperties::Element::combobox_active, Gtk2::TreeSelection, Gtk2::TreeView, Gtk2::TreePath



Copyright 2010, 2011, 2012 Kevin Ryde

Glib-Ex-ConnectProperties is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Glib-Ex-ConnectProperties is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Glib-Ex-ConnectProperties. If not, see