Re: setting object data (how do I?)

On 06/25/01 Jim Edwards wrote:
I have a tree with two levels, call them branchs and leafs.

I don´t want the user to be able to select branchs, how can I turn that

You may connect to the select-child signal and unselect it if it's a branch.
Note however that the Gtk::Tree widget has lots of bugs and is deprecated:
if possible switch to Gtk::CTree.

When someone selects a child and clicks okay in the dialog, I want to
retreve the label of the leaf and it´s branch.  How can I retreve that
information given that I know how to get the selected TreeItem object?

One way I was trying to assign the info using gtk_object_set_data as

 foreach $item (@{$list->{$gridtype}}) {
    my $sleaf = new_with_label Gtk::TreeItem( $item );



But I get an error

Can't locate object method "gtk_object_set_data" via package
"Gtk::TreeItem" - which makes sense to me but how do i really do it?

If gtk_object_set_data() will be wrapped it would be available as
$object->set_data() anyway....
gtk_object_set_data() is not type safe and as such is not exported to
perl. Note, however, that every Gtk::Object is a hash reference and
you can use it to store data with the object itself:

        $object->{mydata} = "stuff";

That said, your problem can be easily solved in another way:
a Gtk::TreeItem is a Gtk::Item is a Gtk::Bin and contains a Gtk::Label,
so you can just use:

        # leaf item       get the Gtk::Label        get the text in the label
        $treeitem->       child->                   get();


lupus debian org                                     debian/rules
lupus ximian com                             Monkeys do it better

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]