RE: [gtk-list] Perl/Gtk: how to get the data from a Gtk::ListIte
- From: tile primenet com
- To: gtk-list redhat com
- Subject: RE: [gtk-list] Perl/Gtk: how to get the data from a Gtk::ListIte
- Date: Tue, 14 Apr 1998 15:15:00 -0000 (???)
On 14-Apr-98 Des Herriott wrote:
> @items = qw(one two three four);
> $l = new Gtk::List;
>
> for $item (@items) {
> my $li = new Gtk::ListItem($item);
> $list->add($li);
> $li->show;
> }
> $list->signal_connect('selection_changed' => \&sel_callback);
Change the first line of the for loop to:
my $li = new_with_label Gtk::ListItem ($item);
> sub sel_callback {
> my ($w) = @_;
> my @list = $w->selection;
> my $item = $list[0];
> # now what?
> }
>
> This gives me back a Gtk::ListItem, but how do I get the original data
> from it? It seems that in C I would use gtk_object_get_data() - is this
> right? Is this missing from the Perl binding or should I be using
> something else?
Gtk::ListItems are containers, and since we are now using new_with_label you
can just use Gtk::Container::children to grab the label and use Gtk::Label::get
to get the actual label string.
That is:
sub sel_callback {
my $item = shift->selection;
return unless $item;
print STDERR $item->children->get, "\n";
}
I just wish there was more documentation on the Perl binding... It took me
a couple hours of poking around with sym tables and such to find this out.
Hope this helps.
--
tile
tile@primenet.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]