GNOME Bugzilla – Bug 534979
GtkImageMenuItem is a bin but has two children.
Last modified: 2008-11-02 16:16:17 UTC
Please describe the problem: GtkImageMenuItem is a GtkBin, but gtk_container_foreach on a GtkImageMenuItem iterates over the GtkImage. The image should be an internal child; as it is already exposed in "image" property. Steps to reproduce: static void _callback(GtkWidget * widget, gpointer data){ g_message("Child widget: type = %s", G_OBJECT_TYPE_NAME(widget)); } int main(int argc, char* argv){ gtk_init(&argc, &argv); { GtkImageMenuItem * item = gtk_image_menu_item_new_from_stock(GTK_STOCK_OK,NULL); gtk_container_foreach(item, _callback, NULL); } return NULL; } Actual results: GtkImage GtkAccelLabel Expected results: GtkAccelLabel Does this happen every time? Yes Other information: A patch follows
Created attachment 111569 [details] [review] patch gtkimagemenuitem.c The image should be an internal child.
Looks good to me. Ping?
Echo from the reporter.
Thanks for the patch. Committed in r20985: 2008-08-04 Björn Lindqvist <bjourne@gmail.com> Bug 534979 – GtkImageMenuItem is a bin but has two children. * gtk/gtkimagemenuitem.c (gtk_image_menu_item_forall): Do not include the image widget when iterating over non-internal children. Patch by rainwoodman.
This is patch is wrong. It breaks the contract of gtk_container_forall: * Invokes @callback on each child of @container, including children * that are considered "internal" There is a ton of code out there that assumes that one can use forall recursively to iterate over all widgets in a hierarchy.
Actually, nevermind, you do the include_internals thing
yes I did.