Hi! Thanks for your help. Well, I think I found what the main difference is: gtk_container_add() sets widget->parent while gtk_menu_attach_to_widget() does not. As we check for widget->parent in the special case for GtkContainer we don't catch the menu case there. As there might be reasons why parent is not set by gtk_menu_attach_to_widget I will simply add another special case. Thanks, Johannes Tim Janik schrieb: > On Thu, 12 Apr 2007, Johannes Schmid wrote: > >> Hi! >> >> In the discussion about bug >> http://bugzilla.gnome.org/show_bug.cgi?id=339791 some questions about >> the destruction of GtkMenu and GtkMenuItem came up. >> >> Having a look at the source reveals that gtk_menu_attach_to_widget() is >> much like gtk_widget_set_parent(). Anyway, we would rather think that >> the GtkMenuItem => GtkMenu relation should be like a GtkContainer/GtkBin >> = Child. >> >> In gtk_menu_item_destroy() any submenu is destroyed absolutely >> unconditionally which is really bad when you want to use the submenu >> later and is also no documented. >> >> Is this the expected behaviour in GTK+ or should this be changed? > > this is *exactly* the same behavior that GtkContainer has: > > gtk_menu_item_destroy (GtkObject *object) > { > gtk_widget_destroy (menu_item->submenu); > } > gtk_container_destroy (GtkObject *object) > { > gtk_container_foreach (container, (GtkCallback) gtk_widget_destroy, > NULL); > } > > it is intentional and should not be changed. > if you want to reuse submenus, you can do that just like you > do it with container children. i.e. remove the menuitem's > submenu with gtk_menu_item_set_submenu(,NULL) before you destroy > it, just like you'd remove a child from its container. > >> Thanks and regards, >> Johannes > > --- > ciaoTJ >
Attachment:
signature.asc
Description: OpenPGP digital signature