Re: [gtk-list] Re: gtk_widget_show_all [or "much ado about foreach and forall]



Thomas Mailund Jensen wrote:
> 
> >>>>> "J" == J A M Molenaar <Klem.Prod@net.HCC.nl> writes:
> 
>  J> Sascha Ziemann wrote:
>  >>  Sascha Ziemann <szi@aibon.ping.de> writes:
>  >>
>  >> | gtk_widget_show_all does not show tree items.  Is that intended?
>  >>
>  >> sorry: it shows items but doesn't show subtrees.
> 
>  J> Yes, I had the same problem a while ago... It had something to do
>  J> with a TRUE value that had to be FALSE or visa versa... If you
>  J> can't figure it out give a sample of the code you have written
> 
> hmm...this kind of made me curious, since I couldn't find anything in
> the header files[1] like a flag to modify this kind of behavior...and
> since the only alternative to examining this was getting some real
> work done, I decided to track the show_all stuff...
> 

Thanx for your analysis :-) 

My function went wrong when I wanted to use all elements in the CTree
not as leaves (forgot the other word...). The place marked with "(1)"
normally should return FALSE. This wil not let the upper node expand if
requested. (I can't verify it due to an Segmentation Fault while
executing my own program, sorry)
The code just builds a tree with different icons according to the
contents of the gnode->data field.

gboolean
gnode2ctree (GtkCTree     *ctree,
             guint         depth,
             GNode        *gnode,
             GtkCTreeNode *cnode,
             GmeTreeView  *tree_view)
{
  if (!cnode || !gnode || !GME_IS_DATA (gnode->data) || !tree_view)
    return TRUE;  // (1)

  if (GME_IS_CLASS (gnode->data) && tree_view->show_classes) 
    {
      GtkCTreeRow *crow = GTK_CTREE_ROW (cnode);
      crow->row.data = gnode;
      gtk_ctree_set_node_info (ctree, cnode, 
			       gme_data_get_name (GME_DATA (gnode->data)), 2,
			       tree_view->xpm_class, 
			       tree_view->xbm_class, 
			       tree_view->xpm_class, 
			       tree_view->xbm_class,
			       !tree_view->allow_subclasses, depth < 2);
    }
  else if (GME_IS_PACKAGE (gnode->data) && tree_view->show_packages) 
    {
      GtkCTreeRow *crow = GTK_CTREE_ROW (cnode);
      crow->row.data = gnode;
      gtk_ctree_set_node_info (ctree, cnode, 
			       gme_data_get_name (GME_DATA (gnode->data)), 2,
			       tree_view->xpm_package, 
			       tree_view->xbm_package, 
			       tree_view->xpm_package, 
			       tree_view->xbm_package,
			       FALSE, depth < 2);
      //gtk_ctree_set_show_stub (ctree, depth >= 2);
    }
  else if (tree_view->show_other)
    {
      GtkCTreeRow *crow = GTK_CTREE_ROW (cnode);
      crow->row.data = gnode;
      gtk_ctree_set_node_info (ctree, cnode, 
			       gme_data_get_name (GME_DATA (gnode->data)), 2,
			       NULL, NULL, NULL, NULL,
			       FALSE, depth < 2);
      //gtk_ctree_set_show_stub (ctree, depth >= 2);
    }
  else
    return FALSE;

  return TRUE;
}



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