Re: Menu destruction

On Thu, 12 Apr 2007, Johannes Schmid wrote:


In the discussion about bug 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,


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