a bug in the GtkOptionMenu widget (GTK-1.2.6)

Hi, folks,

There is a bug in the GtkOptionMenu widget. I've found it in GTK-1.2.6
but I think it's older.

When _first_ activated the GtkOptionMenu displays its popup GtkMenu not
always properly. Maybe you noticed when the GtkOptionMenu was at the
bottom of the screen its popup menu fell beneath the screen after the
first click. After the second click it was already positioned correctly.

The problem is because of using allocation.width and allocation.height
of the menu for its positioning. So before the first displaying the menu
those fields are equal to their initial values (i.e. 1 and 1). I've
patched the bug by getting requisitions (NOT allocations!) via
gtk_widget_size_request (widget, &requisition). Please, look at diff

But, nevertheless, help me, friends, to understand why in
gtk_option_menu_position() (and not only there) for getting sizes of
widgets allocation.width and allocation.height are used.
And what is more preferable in gtk_option_menu_position(): to use
requisition fields directly or via gtk_widget_size_request()?
--- gtkoptionmenu.c	Wed Feb 24 16:15:10 1999
+++ /usr/src/gtk-devel/gtkoptionmenu.c	Sun Jan 23 23:40:09 2000
@@ -614,6 +614,8 @@
 			  gint     *y,
 			  gpointer  user_data)
+  GtkWidget *widget;
+  GtkRequisition requisition;
   GtkOptionMenu *option_menu;
   GtkWidget *active;
   GtkWidget *child;
@@ -631,8 +633,12 @@
   option_menu = GTK_OPTION_MENU (user_data);
-  width = GTK_WIDGET (menu)->allocation.width;
-  height = GTK_WIDGET (menu)->allocation.height;
+  widget = GTK_WIDGET (menu);
+  gtk_widget_size_request (widget, &requisition);
+  width = requisition.width;
+  height = requisition.height;
   active = gtk_menu_get_active (GTK_MENU (option_menu->menu));
   children = GTK_MENU_SHELL (option_menu->menu)->children;

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