Re: [gtk-list] Cosmetic bug in gtkoptionmenu




"Jason P." <jasonp@pobox.com> writes:

> Hi,
> 
> There's a small bug in the way gtk_option_menus of very small size get
> drawn when the have the focus. See the time popups in gnomecal for an
> example -- once you have popped the menu, and selected an item or opened
> a submenu in the menu, when the optionmenu 'button' gets focus, it draws
> the selected item in the button, even though there isn't enough space.
> 
> I made patch to fix this, which changes gtkoptionmenu so that it only
> draws its child when the child is totally within the child_area (as
> opposed to now, when it draws if the the child just intersects the
> child_area). I don't know if this is the best way to fix the problem...
> but it works for me.
> 
> Should I send the patch to the list, or is there a specific person,
> or... ?

There are a couple of things going on here:

 1) A bug in gtkoptionmenu's size allocation code which caused
    the child to get the wrong allocation, which defeated
    clipping code in GtkLabel. Patch below, for the curious.

 2) A known deficiency in OptionMenus. The size of an
    OptionMenu is calculated at the time of 
    gtk_option_menu_set_menu(), and will not be changed
    if the menu is later modified.

    The problem is that there is no way for an OptionMenu
    to know when the potential size of the Menu's
    contents change. (Connecting to "size_allocate" works
    badly, since that won't be called until the menu
    is popped up for the first time).

Actually, GnomeDataEdit is actually depending on the
latter deficiency. Without it, the option menu
popdown would display the selected menu item, or a big
empty space, instead of the current popdown tab.

Regards,
                                        Owen

Index: gtkoptionmenu.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkoptionmenu.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- gtkoptionmenu.c	1999/01/25 19:05:52	1.23
+++ gtkoptionmenu.c	1999/02/01 21:55:49	1.24
@@ -307,11 +307,11 @@
 			    GTK_WIDGET (widget)->style->klass->xthickness) + 1;
       child_allocation.y = (GTK_CONTAINER (widget)->border_width +
 			    GTK_WIDGET (widget)->style->klass->ythickness) + 1;
-      child_allocation.width = (allocation->width - child_allocation.x * 2 -
-				OPTION_INDICATOR_WIDTH - OPTION_INDICATOR_SPACING * 5 -
-				CHILD_LEFT_SPACING - CHILD_RIGHT_SPACING) - 2;
-      child_allocation.height = (allocation->height - child_allocation.y * 2 -
-				 CHILD_TOP_SPACING - CHILD_BOTTOM_SPACING) - 2;
+      child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2 -
+				    OPTION_INDICATOR_WIDTH - OPTION_INDICATOR_SPACING * 5 -
+				    CHILD_LEFT_SPACING - CHILD_RIGHT_SPACING - 2);
+      child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2 -
+				     CHILD_TOP_SPACING - CHILD_BOTTOM_SPACING - 2);
       child_allocation.x += CHILD_LEFT_SPACING;
       child_allocation.y += CHILD_RIGHT_SPACING;
 



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