CTree bug or programmer error?



I created a sample app which just creates a simple CTree(1.1.12).  The bug
I am seeing is that gtk_clist_columns_autosize does not set the width
of the column wide enough to see the entire label.  Is this a bug or
did I just make a stupid programming error?  Does a gtk_ctree_columns_autosize
function exist which does better (I don't see one in the gtkctree.h file)?

Sample app attached below.

Andy L.

--CUT HERE--
#include <stdio.h>

#include <gtk/gtk.h>

int main (int argc, char *argv[])
{
  GtkWindow *tl_window;
  GtkVBox *tl_vbox;
  GtkLabel *label;
  GdkFont *default_font;
  GtkCTree *ctree;
  GtkCTreeNode *ctreetemp,*ctreenode0,*ctreenode1,*ctreenode2;

  int i;

  char *title[3];

  char title0[80] = "Simname";
  char title1[80] = "Signals";
  char title2[80] = "Type";

  title[0] = title0;
  title[1] = title1;
  title[2] = title2;

  /* Initiate Gtk stuff below here */

  gtk_set_locale();

  gtk_init(&argc,&argv);


  default_font = gdk_font_load("-adobe-courier-medium-r-normal-*-18-*-*-*-m-*-*-*"); 

  tl_window = GTK_WINDOW(gtk_window_new (GTK_WINDOW_TOPLEVEL));
  gtk_window_set_title (tl_window, "CTree test example");
  gtk_container_set_border_width (GTK_CONTAINER (tl_window), 0);
  
  gtk_signal_connect (GTK_OBJECT (tl_window), "destroy",
		      GTK_SIGNAL_FUNC(gtk_widget_destroyed),
		      &tl_window);
  gtk_signal_connect (GTK_OBJECT (tl_window), "delete-event",
		      GTK_SIGNAL_FUNC (gtk_true),
		      NULL);
  
  /* Create a top level vbox to hold everything to start */

  tl_vbox = GTK_VBOX(gtk_vbox_new (FALSE, 0));
  gtk_container_add (GTK_CONTAINER (tl_window), GTK_WIDGET(tl_vbox));

  
  /* Add a label in order to give the window some extent */
  label = GTK_LABEL(gtk_label_new("Label to make a window\n"));
  gtk_box_pack_start(GTK_BOX(tl_vbox),GTK_WIDGET(label),FALSE,TRUE,FALSE);


  /* Now, attempt to create the ctree */
  ctree = GTK_CTREE(gtk_ctree_new_with_titles(3,0,title));
  gtk_box_pack_start(GTK_BOX(tl_vbox),GTK_WIDGET(ctree),TRUE,TRUE,FALSE);

  gtk_clist_set_selection_mode (GTK_CLIST(ctree), GTK_SELECTION_EXTENDED);

  sprintf(title0,"Simname0");
  sprintf(title1,"Signals");
  sprintf(title2,"Type");
  ctreenode0 = gtk_ctree_insert_node(ctree,NULL,NULL,title,5,
				     NULL,NULL,NULL,NULL,FALSE,TRUE);

  for(i=0;i<5;i++)
    {
      sprintf(title0,"\0");
      sprintf(title1,"Signal %d",i);
      sprintf(title2,"Type");

      ctreetemp = gtk_ctree_insert_node(ctree,ctreenode0,NULL,title,5,
					NULL,NULL,NULL,NULL,TRUE,FALSE);
    }

  sprintf(title0,"Simname1");
  sprintf(title1,"Signals");
  sprintf(title2,"Type");
  ctreenode1 = gtk_ctree_insert_node(ctree,NULL,NULL,title,5,
				     NULL,NULL,NULL,NULL,FALSE,TRUE);

  for(i=0;i<5;i++)
    {
      sprintf(title0,"\0");
      sprintf(title1,"Signal %d",i);
      sprintf(title2,"Type");

      ctreetemp = gtk_ctree_insert_node(ctree,ctreenode1,NULL,title,5,
					NULL,NULL,NULL,NULL,TRUE,FALSE);
    }

  sprintf(title0,"Simname2");
  sprintf(title1,"Signals");
  sprintf(title2,"Type");
  ctreenode2 = gtk_ctree_insert_node(ctree,NULL,NULL,title,5,
				     NULL,NULL,NULL,NULL,FALSE,TRUE);

  for(i=0;i<5;i++)
    {
      sprintf(title0,"\0");
      sprintf(title1,"Signal %d",i);
      sprintf(title2,"Type");

      ctreetemp = gtk_ctree_insert_node(ctree,ctreenode2,NULL,title,5,
					NULL,NULL,NULL,NULL,TRUE,FALSE);
    }

  gtk_clist_columns_autosize(GTK_CLIST(ctree));

  gtk_widget_show_all(GTK_WIDGET(tl_window));

  gtk_main();

  return 0;
}





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