CTree confusion/bug



Hi,

I've run into some confusion while using the CTree widget.
What I wish to do is a gtk_ctree_post_recursive call on a node, which
will then refresh the pixmap of that node (leaving the text label
intact), according to some condition.

However, the result I get is that the pixmap is changed, but the labels
are for the most part completely garbled.

I have included a function below, which when called from a
gtk_ctree_post_recursive() shows the problem.
I can send the entire test program which demonstrates this, if required,
but I suspect the problem is more likely a misunderstanding on my part.

Here's a test function I'm using...

void pixmap_refresh (GtkCTree *tree, GtkCTreeNode *node) {
   extern int state;
   guint8 spaces;
   gchar *node_text;
   gboolean is_a_leaf, open;
   GdkBitmap *red_file_map, *orange_file_map;
   GdkPixmap *red_file, *orange_file;
   GtkStyle *style;
   style = gtk_widget_get_style (window1);

   /* Just creating 2 GdkPixmap's */
   orange_file = gdk_pixmap_create_from_xpm_d (window1->window,
					       &orange_file_map,
					       &style->bg[GTK_STATE_NORMAL],
					       (gchar **) orange_file_xpm);
   red_file = gdk_pixmap_create_from_xpm_d (window1->window,
					    &red_file_map,
					    &style->bg[GTK_STATE_NORMAL],
					    (gchar **) red_file_xpm);
   
   node_text = (gchar *) malloc (100);
   memset (node_text, 0, 100);
   
   
   /* Get everything about the node except the pixmaps */
   gtk_ctree_get_node_info (GTK_CTREE (tree),
			    GTK_CTREE_NODE (node),
			    &node_text, &spaces,
			    NULL, NULL, NULL, NULL,
			    &is_a_leaf, &open);
   /* printf shows the node label to have been grabbed correctly. */
   printf ("Node label is %s.\n", node_text);
   
   /* Dependant upon state, change the node's pixmap fields */
   if (state == 1) {
      gtk_ctree_set_node_info (GTK_CTREE (tree), 
			       GTK_CTREE_NODE (node),
			       node_text,
			       spaces, orange_file, orange_file_map,
			       orange_file, orange_file_map,
			       is_a_leaf, open);
   } else {
      gtk_ctree_set_node_info (GTK_CTREE (tree), 
			       GTK_CTREE_NODE (node),
			       node_text,
			       spaces, red_file, red_file_map,
			       red_file, red_file_map,
			       is_a_leaf, open);
   }
}

The printf shows the correct node label, but the label is set to
random(?) characters. Any advice would be appreciated.

Regards,

--
Lee.
http://atlas.cs.york.ac.uk/~lrpm100/



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