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: Fri, 9 Apr 2010 16:26:05 -0700 (PDT)
You're changing the selection mode on the first update. By moving the $treeselect->set_mode('single') line
from update_line() to init(), i could no longer get the "first time it acts weird" behavior. Doubtless,
changing the mode causes the iter to be different.
Thank you for this, however I was hoping to also make it possible for the user to select and delete multiple
rows.
Any recommendations on how to provide this functionality while avoiding the first update behaviour?
I was also getting some warnings on stdout.
*** unhandled exception in callback:
*** variable not allowed to be undef where GtkTreeIter is wanted at main.pl line 262.
*** ignoring at main.pl line 66.
It's best not to ignore those. ;-)
Will make sure I chase these up in my main project. :)
After moving the tree selection setup to init, you may be interested in using the two-return form of
get_selection() and adding error checking:
my ($model, $iter) = $treeselection->get_selected;
return unless $iter;
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?
The lines
# Update the view
$tv_items->set_model($model);
are not actually necessary; if you were swapping out the model to freeze updates, then that would be
necessary, but you're not, so it's not. In fact, the set_value calls immediately above are enough to make
everything Just Work.
Oh, and in connect_signals(), you have each "clicked" handler getting $widget and $event off the stack; but
there's no $event parameter to the "clicked" signal.
Great stuff. Thanks very much for the feedback on the other code. Always like to improve it.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]