Re: [PATCH] fix GtkOptionMenu initial sizing



On Wed, 2001-12-12 at 18:44, Owen Taylor wrote:
> 
> jacob berkman <jacob ximian com> writes:
> 
> > i have fixed the bug where GtkOptionMenu will initially be too big.
> > 
> > this screenshot shows the bug:
> > 
> > http://primates.ximian.com/~jacob/gnome2/optionmenu.png
> > 
> > the top one had an item selected in it; if you were to select an item in
> > the bottom one it would snap to the correct size.
> > 
> > the patch is pretty obvious when you read it.
> > 
> > ok to commit, or is there a bug # i should attach it to?  i found a
> > couple of gtkoptionmenu bugs but none seemed to be this one.
> 
> The fix looks correct, but maybe you could investigate a bit why it
> it is necessary. In general, option_menu->height is supposed to be the
> max of all the child items, so I wouldn't expect the MAX() to be needed
> in the normal case.

ok, i've found out what's going on, and it explains why it sometimes
works right, and lends another obvious potential fix.

gtk_option_menu_calc_size() gets called when the menu is set on the
option menu and on size_request of this menu.

however, if the menuitems aren't added to the menu until after
_set_menu() is called, _calc_size() will not get called with menu
containing any children until you click on it.

in gtk 1.2, gtk_menu_shell_insert() called gtk_widget_queue_resize() on
items added, and in 2.0 it doesn't (although this may get triggered
somewhere else, i am not sure).

so, connecting to the add/remove signals of the menu to _calc_size()
indeed fixes it (although this is probably a worse solution).

which fix would you like to go in, or is there another solution which is
better?

jacob
-- 
"In fact, can you imagine anything more terrifying than a zombie clown?"
	-- moby
Index: gtkoptionmenu.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkoptionmenu.c,v
retrieving revision 1.58
diff -u -r1.58 gtkoptionmenu.c
--- gtkoptionmenu.c	2001/12/04 03:27:29	1.58
+++ gtkoptionmenu.c	2001/12/13 18:47:27
@@ -279,6 +279,13 @@
       gtk_signal_connect_object (GTK_OBJECT (option_menu->menu), "size_request",
 				 (GtkSignalFunc) gtk_option_menu_calc_size,
 				 GTK_OBJECT (option_menu));
+      gtk_signal_connect_object (GTK_OBJECT (option_menu->menu), "add",
+				 G_CALLBACK (gtk_option_menu_calc_size),
+				 GTK_OBJECT (option_menu));
+      gtk_signal_connect_object (GTK_OBJECT (option_menu->menu), "remove",
+				 G_CALLBACK (gtk_option_menu_calc_size),
+				 GTK_OBJECT (option_menu));
+      gtk_widget_size_request (menu, NULL);
 
       if (GTK_WIDGET (option_menu)->parent)
 	gtk_widget_queue_resize (GTK_WIDGET (option_menu));


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