Re: Possible row selection interfering with Update
- From: Zettai Muri <zettaimuri ymail com>
- To: muppet <scott asofyet org>
- Cc: gtk-perl-list gnome org
- Subject: Re: Possible row selection interfering with Update
- Date: Thu, 15 Apr 2010 05:07:50 -0700 (PDT)
Leave the view in multiple selection mode, and use this instead of get_selected():
@paths = $selection->get_selected_rows
Returns the Gtk2::TreePath of each selected row, or an empty list if no
rows are selected. The model is not returned, as documented in the C
API reference. To get the model, try
"$selection->get_tree_view->get_model".
So your selection changed code would be
my @paths = $selection->get_selected_rows ();
if (@paths == 1) {
# exactly one selected, display it
display_row (...);
} else {
# either multiple rows selected, or nothing selected.
# clear the display.
undisplay (...);
}
# or you might want to allow modifying multiple elements
# at once, so you'd treat @path == 0 and @path > 1 differently
and then the delete key handler would look like this (untested!):
my $model = $selection->get_tree_view->get_model;
foreach my $path (reverse $selection->get_selected_rows ()) {
$model->remove ($model->get_iter ($path));
}
Thank you so much for all your help on this! It works like a charm!
In update_line() I have done the following:
# Get selected line number
my ($model, $iter) = $treeselection->get_selected;
return unless $iter;
#my $model = $tv_items->get_model;
#my $iter = $treeselection->get_selected;
However, now no update occurs. How should I be implementing this?
Did you set the selection mode at initialization?
Yes, prior to changing the code to using the paths I had:
$treeselection->set_mode('single');
in my init().
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]