bug or feature



I have the following situation: The toplevel window contains a vbox with
two elements. The first element is another vbox, the second is the
'rest', with consists of a frame and a label inside.
The inner vbox also has two elements, the first one is a hbox with some
buttons, the second a 'data' widget.
The buttons can enlarge and shrink the data-widget, the 'rest'-widget in
the outer vbox should allways fill the rest of the top-level-window.

When i enlarge the data-widget, all works well, the rest-widget shrinks
as it should do.
But when I shrink the data widget, the rest isn't resized and I get some
vacuum above and below the data.

If I resize the top-level-window with the mouse or gtk_widget_set_usize
function, the rest-widget resizes and all is fine.

Is this a (known?) bug? I'm using GTK+ 1.2.8 on GNU/Linux.

In the attachment, you find a small programm that shows the effect. If
you uncomment the last two lines, that 'resize' the top-level-window to
it's current size, it works  as expected.

Gerhard
#include <gtk/gtk.h>

/* to keep the demo simple, we use global variables */

GtkWidget *window, *vboxi, *vboxo, *hbox, *smaller, *bigger, 
          *datalabel, *dataframe,
          *restlabel, *restframe;

extern void on_button_clicked (GtkWidget *, gpointer);


main(gint ac, gchar *av[])
{
  
    gtk_init(&ac,&av);
    
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_signal_connect(GTK_OBJECT(window),"delete_event",
                       GTK_SIGNAL_FUNC(gtk_main_quit),NULL);
    gtk_signal_connect(GTK_OBJECT(window),"destroy",
                       GTK_SIGNAL_FUNC(gtk_main_quit),NULL);

    vboxo = gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vboxo);
    
    vboxi = gtk_vbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vboxo),vboxi,FALSE,FALSE,0);
    
    hbox = gtk_hbox_new(TRUE,0);
    gtk_box_pack_start(GTK_BOX(vboxi),hbox,FALSE,FALSE,0);
    
    smaller = gtk_button_new_with_label("smaller");
    gtk_box_pack_start(GTK_BOX(hbox),smaller,TRUE,TRUE,0);

    bigger = gtk_button_new_with_label("bigger");
    gtk_box_pack_start(GTK_BOX(hbox),bigger,TRUE,TRUE,0);

    gtk_signal_connect(GTK_OBJECT(smaller),"clicked",
                       GTK_SIGNAL_FUNC(on_button_clicked),"smaller");
    gtk_signal_connect(GTK_OBJECT(bigger),"clicked",
                       GTK_SIGNAL_FUNC(on_button_clicked),"bigger");
    
    dataframe = gtk_frame_new(NULL);
    datalabel = gtk_label_new("Data");
    gtk_container_add(GTK_CONTAINER(dataframe),datalabel);

    gtk_widget_set_usize(dataframe,-2,50);
    gtk_box_pack_start(GTK_BOX(vboxi),dataframe,TRUE, FALSE, 0);


    restframe = gtk_frame_new(NULL);
    restlabel = gtk_label_new("Rest");
    gtk_container_add(GTK_CONTAINER(restframe),restlabel);

    gtk_box_pack_end(GTK_BOX(vboxo),restframe,TRUE,TRUE,0);
    

    gtk_widget_show(restlabel);
    gtk_widget_show(restframe);
    gtk_widget_show(datalabel);
    gtk_widget_show(dataframe);
    gtk_widget_show(bigger);
    gtk_widget_show(smaller);
    gtk_widget_show(hbox);
    gtk_widget_show(vboxi);
    gtk_widget_show(vboxo);
    gtk_widget_show(window);

    gtk_main();
}



void
on_button_clicked (GtkWidget *button, gpointer user_data)
{
    gchar *labeltext = (gchar *)user_data;
    gint  oldheight;

    oldheight = dataframe->allocation.height;
    if (*labeltext == 'b')
	gtk_widget_set_usize(dataframe,-2,(oldheight*3)/2);
    else
	gtk_widget_set_usize(dataframe,-2,(oldheight*2)/3);

    /* with this strange patch, it works fine 
    oldheight = window->allocation.height;
    gtk_widget_set_usize(window,-2,oldheight);
    */
}



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