Re: Remove Multiple Rows from Gtk2::ListStore
- From: Zettai Muri <zettaimuri ymail com>
- To: gtk-perl-list gnome org
- Subject: Re: Remove Multiple Rows from Gtk2::ListStore
- Date: Fri, 18 Dec 2009 18:25:40 -0800 (PST)
Not sure if it is the "right" way to do it but it works for me.
Actually doesn't work unless I disconnect the model from the tree view before and after the removal.
So now I'm using the following:
my $model = $tv_sources->get_model;
my $selection = $tv_sources->get_selection;
my @paths = $selection->get_selected_rows;
# Disconnect tree view from data model.
$tv_sources->set_model(undef);
# Convert paths to row references
my @rowrefs;
foreach my $p (@paths)
{
my $treerowreference = Gtk2::TreeRowReference->new ($model, $p);
push (@rowrefs, $treerowreference);
}
# Remove rows based on row references
for (my $i = 0; $i < scalar(@paths); $i++)
{
my $treerowreference = Gtk2::TreeRowReference->new ($model, $paths[$i]);
my $path = $rowrefs[$i]->get_path;
my ($iter) = $model->get_iter($path);
$model->remove($iter);
}
$tv_sources->set_model($model);
Prior to this removing 2 of the 3 rows in the treeview was working. Adding 4 rows and then trying to remove
each alternate row was producing strange results until adding the set_model(undef/$model) lines.
Again possibly not the best way to do it but *now* it seems to work correctly.
__________________________________________________________________________________
See what's on at the movies in your area. Find out now: http://au.movies.yahoo.com/session-times/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]