[619] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

[gtk-list] [patch] optionmenu with no items

daemon@ATHENA.MIT.EDU (Owen Taylor)
Fri Aug 1 16:17:55 1997

From: Owen Taylor <owt1@cornell.edu>
To: gtk-list@redhat.com
Date: Fri, 01 Aug 1997 16:19:18 -0400
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com


Here is a patch to keep the optionmenu widget from crashing when
it's associated menu has no items. (OK, that's a pretty useless
situation...)

diff -c -r -P -X patch-exclude gtk+owt-071997/gtk/gtkoptionmenu.c gtk+/gtk/gtkoptionmenu.c
*** gtk+owt-071997/gtk/gtkoptionmenu.c	Fri Jun  6 03:01:53 1997
--- gtk+/gtk/gtkoptionmenu.c	Sun Jul 27 02:47:37 1997
***************
*** 370,375 ****
--- 370,377 ----
  	    return FALSE;
  	  gtk_option_menu_update_contents (GTK_OPTION_MENU (widget));
  	  child = GTK_BUTTON (widget)->child;
+ 	  if (!child)
+ 	    return FALSE;
  	  remove_child = TRUE;
  	}
  
***************
*** 534,540 ****
    children = GTK_MENU_SHELL (option_menu->menu)->children;
    gdk_window_get_origin (GTK_WIDGET (option_menu)->window, &menu_xpos, &menu_ypos);
  
!   menu_ypos += (GTK_WIDGET (option_menu)->allocation.height - active->requisition.height) / 2 - 2;
  
    while (children)
      {
--- 536,545 ----
    children = GTK_MENU_SHELL (option_menu->menu)->children;
    gdk_window_get_origin (GTK_WIDGET (option_menu)->window, &menu_xpos, &menu_ypos);
  
!   menu_ypos += GTK_WIDGET (option_menu)->allocation.height / 2 - 2;
!   
!   if (active != NULL)
!     menu_ypos -= active->requisition.height / 2;
  
    while (children)
      {

--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post