Re: Gtk_CTree : Help please



Vlad Harchev a écrit :
> 
> On Thu, 3 Aug 2000, Florent. Devin wrote:
> 
>  Hi,
> 
> > Hi,
> > I was using gtk_tree to figure a tree structure from a program.
> > In this tree, I set for each item a key (with this key I had access to
> > the
> > program and something).
> >       gtk_object_set_data (GTK_OBJECT (item), "key", key);
> > And also for each kind of item I set a drop destination and drag
> > source.
> > When I want to do the same thing with a Gnome MDI environnement, Havoc
> > says
> > that I have to use Gtk_CTree because Gtk_Tree was obsolete/deprecated.
> > So I change my tree to a ctree one. Now it work fine but :
> >
> > How can I set a key for an item in a gtk_ctree ?
> > I can't use gtk_object_set_data (GTK_OBJECT (item),...) because Gtk
> > can't
> > convert a GtkCTreeNode to an GtkObject (the GtkCTreeNode is opaque...).
> > And a second question which is the same thing I think.
> > How can I set a drag source and a dest drop for a specific item ?
> >
> > I've got this warning when I run my program.
> > Gtk-WARNING **: invalid cast from `(unknown)' to `GtkObject'
> >
> > Gtk-CRITICAL **: file gtkobject.c: line 1034 (gtk_object_set_data):
> > assertion `GTK_IS_OBJECT (object)' failed.
> >
> > This warning is done by this code :
> >       noeud = gtk_ctree_insert_node (GTK_CTREE (root_tree), tree, NULL,
> >               texte, 8,
> >               image->pixmap, image->mask,
> >               image->pixmap, image->mask,
> >               FALSE, FALSE);
> >       gtk_object_set_data (GTK_OBJECT (noeud), "nom", key);
> 
>   It looks like node is not an ancestor of GtkObject. What I would do, is to
> gtk_ctree_node_set_row_data_full(GTK_CTREE(root_tree),noeud,
>         g_hash_table_new(g_str_hash,g_str_equal),g_hash_table_destroy);
> 
>  And then use the following:
> 
> g_hash_table_insert((GHashTable*)
>         gtk_ctree_node_get_row_data(GTK_CTREE(root_tree),noeud)),"nom",key);
> 
>  instead of gtk_object_set_data().
>  The hash will be destoyed automatically when the node dies.
> 
>  Or you can try to represent all data you wish to associate with a node via a
> single pointer and use gtk_ctree_node_{s,g}et_row_data()
> 
This is a good way to do what I want and it feet great. I try it, I run
it,
I like it... Thanks
But with this method, I can not still handle signal for different
gtk_ctree_node ? If I can not handle signal, I can not do drag and drop
from
another widget to a particular node.
There is one function that may help me but I do not know what it is for
: 
gtk_ctree_set_drag_compare_func
Or is there a way to handle drag and drop signal ?
Is there a way to handle at least signal from gtk_widget ?

-- 
Florent DEVIN




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