Re: Gtk_CTree : Help please



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()
  
> -- 
> Florent DEVIN
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-list
> 

 Best regards,
  -Vlad





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