VBox child problem



Hi,

This code displays "Hi" in a window:

  GtkWidget *table=table_new();            // empty table
  GtkWidget *label=gtk_label_new("Hi");
  gtk_box_pack_start(GTK_BOX(table),label,FALSE,FALSE,0);

  gtk_container_add(GTK_CONTAINER(window),table);
  gtk_widget_show_all(window);
  gtk_main ();


This code gives an error:

  GtkWidget *table=table_new();            // empty table
  GtkWidget *label=gtk_label_new("Hi");
  gtk_box_pack_start(GTK_BOX(table),label,FALSE,FALSE,0);
  label=gtk_label_new("Hi2");
  gtk_box_pack_start(GTK_BOX(table),label,FALSE,FALSE,0);

  gtk_container_add(GTK_CONTAINER(window),table);
  gtk_widget_show_all(window);
  gtk_main ();

error:

  (db:3452): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate
                             widget with width 18 and height -19714


It seems that more than one item packed into "table" causes the error.
I have commented out all the things in "Table" except the basic creation
of the table object. "Table" is my own widget derived from GtkVBox:
(Gtk 2.2.4)

GType
table_get_type(void)
{
    static GType table_type=0;

    if(!table_type){
        static const GTypeInfo table_info={
            sizeof(TableClass),
            NULL, /* base_init */
            NULL, /* base_finalize */
            (GClassInitFunc)table_class_init,
            NULL, /* class_finalize */
            NULL, /* class_data */
            sizeof(Table),
            0,    /* n_preallocs */
            (GInstanceInitFunc)table_init,
            0   /* value table */
        };

        table_type=g_type_register_static(
                GTK_TYPE_VBOX,
                "Table",
                &table_info,
                0);
    }
    return table_type;
}



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