Strange window resizing behaviour in Gtk+-2.0



Hi,

In moving from Gtk+-1.2 to Gtk+-2.0 I have noticed what I believe to be an incompatiable change in window resizing behaviour. I am not sure if this change is intentional or a bug. When I resize a top level window using the mouse the widget inside the window is not resized. In 1.2 it would resize the widget to fill the window (I think this behaviour was inherited from GtkBin). Also if I set the size of the window programatically using gtk_widget_size_allocate it seems to change only the size of the child widget and not the window itself. This seems very weird behaviour to me. I have also noticed that the "size-allocate" signal is not called as the window's size changes as a result of the user resizing the window (it did in 1.2).

I am using KDE desktop so obviously kwm window manager. Don't know if this has something to do with it.

For example, here is a very simple test program which just has a button added to the window. I would have thought that as the size of the window is changed by the user the button would change size to fill the window but it does not in 2.0:

#include <gtk/gtk.h>

int
main (int argc, char *argv[])
{
 GtkWidget *window;
 GtkWidget *button;
 GtkAllocation bounds;

 gtk_init (&argc, &argv);

 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 button = gtk_button_new_with_label("Hello");
 gtk_widget_show(button);
 gtk_container_add(GTK_CONTAINER(window), button);
 gtk_widget_show (window);

/* Programatically change the size of the window. What actually happens is that the button is resized but not the window!*/

 bounds.x = 100;
 bounds.y = 100;
 bounds.width = 500;
 bounds.height = 500;
 gtk_widget_size_allocate(window, &bounds);

 gdk_threads_enter ();
 gtk_main ();
 gdk_threads_leave ();

 return 0;
}

--
Nick Allen
Software Engineer
Sun Microsystems Ireland Ltd
Hamilton House
East Point Business Park
Dublin 3

email: nicholas allen ireland sun com

The views expressed in this email are not necessarily the views of Sun Microsystems or its staff





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