TreeSelection issues

2 views
Skip to first unread message

darkbob

unread,
Jun 9, 2010, 5:16:17 PM6/9/10
to camelbox
Hi-

I'm having a problem with a callback on a TreeView widget's selection;
this works
correctly on unix, but in the camelbox Gtk2 distribution it doesn't
work. Here is
the code for the callback assignment, as well as what I was trying to
do in the callback:

$treeview->get_selection->signal_connect('changed'=>
\&handleSelectionChange);

and then the callback:

sub handleSelectionChange {
my $selection = shift;

if ($selection) {
my ($model,$iter) = $selection->get_selected;
if ($model) {
my $name = $model->get($iter, NAME_COL);
my $text = $crypt_info->{$name}->{'Card Text'};
$ct_label->set_text($text);
}
}
return 0;
}

Like I said, this works fine on unix. The help files that I could
find say that the get_selected
method of TreeSelection should return the model and the iterator when
called in list
context, and just the iterator in scalar context. I'm not sure if
this is a windows issue
in general, or if it is just with the camelbox distribution (camelbox
is the first windows
perl gtk2 distribution that I managed to get working), but it's
definitely returning just
the iterator, even when called in list context as above.

I managed a workaround by replacing:

my ($model,$iter) = $selection->get_selected;

with:

my $tv = $selection->get_tree_view();
my $model = $tv->get_model();
my $iter = $selection->get_selected;

but I shouldn't have to do that, since that method is supposed to
return the model
and the iterator.

Any ideas what the problem might be?

Brian Manning

unread,
Jun 9, 2010, 7:38:05 PM6/9/10
to came...@googlegroups.com
On Wed, Jun 9, 2010 at 2:16 PM, darkbob <dark...@gmail.com> wrote:
> Hi-
>
> I'm having a problem with a callback on a TreeView widget's selection;
> this works
> correctly on unix, but in the camelbox Gtk2 distribution it doesn't
> work.

Can you post:

1) the version of libgtk and Gtk2-Perl that you're using in *nix,
along with your distro/version information?

and

2) a complete example program that demonstrates the problem?

Thanks,

Brian

Bob Joseph

unread,
Jun 11, 2010, 2:02:07 PM6/11/10
to came...@googlegroups.com
On Wed, Jun 9, 2010 at 7:38 PM, Brian Manning <elspi...@gmail.com> wrote:
> On Wed, Jun 9, 2010 at 2:16 PM, darkbob <dark...@gmail.com> wrote:
>> Hi-
>>
>> I'm having a problem with a callback on a TreeView widget's selection;
>> this works
>> correctly on unix, but in the camelbox Gtk2 distribution it doesn't
>> work.
>
> Can you post:
>
> 1) the version of libgtk and Gtk2-Perl that you're using in *nix,
> along with your distro/version information?

yes- it works correctly on ubuntu 8.10 with libgth2.0 (the ubuntu
package version
is 2.14.4-0ubuntu1) and the Gtk2.pm file says $VERSION = '1.183'.

It also works correctly on a redhat 5 system with libgtk.so =
libgtk-x11-2.0.so.0.1000.4
and version 1.221.

>
> and
>
> 2) a complete example program that demonstrates the problem?

Yes- I'll attach that here. I got it down to a main window with a treeview
with one column and one item, and a quit button. I put both versions of
the callback- one of which uses the get_selected() method as described
in the perldoc page (it's suppose to return model and iter), and the second
version handleSelectionChange2 shows the workaround I made to get it
to work in both places. It just seems silly to have to do that when the
documentation says the method is stupposed to return both items in
list context (and the C function seems to take both of those items as
parameters to be filled in as well).

If you want to try the second version yourself, just change the signal_conmect
call for $treeview. The callbacks both print out the model and
iterator, as well
as the text of the line that was selected.

Thanks for looking into this.

--
Bob Joseph
http://www.cse.ohio-state.edu/~joseph

tvtest.pl

Brian Manning

unread,
Jun 11, 2010, 3:27:34 PM6/11/10
to came...@googlegroups.com
On Fri, Jun 11, 2010 at 11:02 AM, Bob Joseph <dark...@gmail.com> wrote:
> On Wed, Jun 9, 2010 at 7:38 PM, Brian Manning <elspi...@gmail.com> wrote:
>> Can you post:
>>
>> 1) the version of libgtk and Gtk2-Perl that you're using in *nix,
>> along with your distro/version information?
>
> yes- it works correctly on ubuntu 8.10 with libgth2.0 (the ubuntu
> package version
> is 2.14.4-0ubuntu1) and the Gtk2.pm file says $VERSION = '1.183'.
>
> It also works correctly on a redhat 5 system with libgtk.so =
> libgtk-x11-2.0.so.0.1000.4
> and version 1.221.

rpm -qa | grep gtk2 will show you the gtk2 library version number.

>> 2) a complete example program that demonstrates the problem?
>
> Yes- I'll attach that here.  I got it down to a main window with a treeview
> with one column and one item, and a quit button.  I put both versions of
> the callback- one of which uses the get_selected() method as described
> in the perldoc page (it's suppose to return model and iter), and the second
> version handleSelectionChange2 shows the workaround I made to get it
> to work in both places.  It just seems silly to have to do that when the
> documentation says the method is stupposed to return both items in
> list context (and the C function seems to take both of those items as
> parameters to be filled in as well).

I can reproduce your issue, but I can't offer any suggestions as to
why it's working the way it is, and I lack the skills to debug down to
the library level on Windows. I don't really have any other
suggestions beyond keeping your workaround, or possibly building a new
Gtk2-Perl stack on Windows using an updated version of libgtk+.
What's in camelbox-2009.167.2132Z-tahi.exe (I'm guessing that's the
version of Camelbox that you're running) is 2.16.7, which is 2 major
revs down from current stable.

Thanks,

Brian

Reply all
Reply to author
Forward
0 new messages