1.1.12 and gtk_tree



[I know CTree is better, but ...]

Everything in this mail is about this small program digged from
tutorial:

#define CONST 2048

#include <gtk/gtk.h>

int main (int argc, char *argv[])
{

   GtkWidget *window, *scrolled_win, *tree;

   gint i;

   gtk_init (&argc, &argv);

       /* a generic toplevel window */
       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
       gtk_signal_connect (GTK_OBJECT(window), "delete_event",
                           GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
       gtk_container_border_width (GTK_CONTAINER(window), 5);

       /* A generic scrolled window */
       scrolled_win = gtk_scrolled_window_new (NULL, NULL);
       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
                                       GTK_POLICY_AUTOMATIC,
                                       GTK_POLICY_AUTOMATIC);
       gtk_widget_set_usize (scrolled_win, 150, 200);
       gtk_container_add (GTK_CONTAINER(window), scrolled_win);
       gtk_widget_show (scrolled_win);
       
       /* Create the root tree */
       tree = gtk_tree_new();

       gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_win), tree);

       gtk_widget_show (tree);

       {
         GtkWidget *subtree, *item;
         gint j;

         item = gtk_tree_item_new_with_label ("Tree");

         gtk_tree_append (GTK_TREE(tree), item);

         gtk_widget_show (item);

         subtree = gtk_tree_new();

         gtk_tree_item_set_subtree (GTK_TREE_ITEM(item), subtree);

         for (j = 1; j <= CONST; j++){
           GtkWidget *subitem;
           char Buf[100];

sprintf(Buf, "%d", j);

           subitem = gtk_tree_item_new_with_label (Buf);

           gtk_tree_append (GTK_TREE(subtree), subitem);
           gtk_widget_show (subitem);
         }
       }

       /* Show the window and loop endlessly */
       gtk_widget_show (window);
       gtk_main();
       return 0;
     }
     /* example-end */

It is very simple - creates gtk_tree and append CONST items to
it. Well. But:

if CONST is e.g. 50- it's ok. When the tree is expanded it's rolled
out, scrolled window gets scrollbar.

If CONST is 2047 then the tree is also expandable, but no more
scrolling bars...

If CONST is 2048+ then the tree is no more expandable and no more
scrollbars.

2048 is the problem (2^11). Can you explain it? Is it the limitation
of subitems or items in then scrolled_win or what? All my programs use
CTree now.
-- 
Pavel Janik ml.
Pavel.Janik@inet.cz



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