Re: gtk2-perl tree signals



Jens Wilke <jens wilke org> writes:

If a iter is selected using  $selection->get_selected(), it returns the 
"label" and or some scalar values, which differ each click.

I'm not sure to see exactly what you're looking for.

One solution to react on user selecting a leaf row is:

$treeview->get_selection->signal_connect(changed => sub {
    my ($model, $iter) = $_[0]->get_selected;
    $model && $iter or return;  #- no current selection

    if (!$model->iter_has_child($iter)) {
        my $column_0_contents = $model->get($iter, 0);
        ....
    }
    0;
});

If there are childs of differend parents, which have the same name, the app 
might run in trouble.
Is it possible to add user data to each iter?

I'm not authoritative but I'd say no, since a TreeIter is not a
GObject.

Remember that GtkTreeView has a model-view concept. It means that
you can associate data with each row (you have data in the model)
but not necessarily show all of them (you display some data in
the view).

I've never done so, but I suppose the key is to create a model
with, say, 3 columns, and then append only 2 renderers to the
view. You may use the non-displayed column for storing a unique
id or something of the like.

I found gtk_tree_selection_get_user_data () in the API reference but trying to 
use it 
        my @u= $selection->get_user_data();
results: 
      Is gtk2-perl missing Gtk2::TreeSelection::get_user_data ?

And i didn't find any set_user_data, as it was in Gtk::Tree.

gtk_object_set_data and gtk_object_set_user_data are deprecated
in favor of g_object_set_data

since GtkTreeSelection inherits GObject, you may use
$treeselection->set_data (and get_data).
 
Or is there any other solution for this Problem?
Is it possible to get the parent of an iter?

Are you looking at the API doc? This list is not here for looking
the API doc for you...

http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeModel.html#gtk-tree-model-iter-parent

-- 
Guillaume Cottenceau - http://people.mandrakesoft.com/~gc/



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