Hi Owen,
Yeah I figured that must be what is going on.
So right now if I want to trace up the tree to find the top level
window, I check if it is a GtkMenu and if so use
gtk_menu_get_attach_widget (GTK_MENU (widget)), otherwise just use
widget->parent. Here is an example of the code from glade's support.c:-
GtkWidget*
lookup_widget (GtkWidget *widget,
const gchar *widget_name)
{
GtkWidget *parent, *found_widget;
for (;;)
{
if (GTK_IS_MENU (widget))
parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
else
parent = widget->parent;
if (parent == NULL)
break;
widget = parent;
}
found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget),
widget_name);
if (!found_widget)
g_warning ("Widget not found: %s", widget_name);
return found_widget;
}
So my question is should user-land progs be concerned with figuring out
the widget types, or could we provide a library function to do the same
thing? That way all the intricacies of how each widget behaves around
parenting can be hidden.
I am happy to write a function to do this. However if that is
acceptable, I am unclear about which .c file it should live in.
Damian
On Mon, 2001-10-29 at 01:02, Owen Taylor wrote:
>
> Damian Ivereigh <damian cisco com> writes:
>
> > Can anyone think of good reason why GtkMenu objects don't have a parent.
> > I would expect them to be parented by the Widget that they are attached
> > to - e.g. in the case of the menu bar at the top, the drop down menu
> > when you hit file is not parented by the "File" menu item.
> >
> > If it was it would make tracing up the tree (to find the top level
> > window) that much easier.
> >
> > Or am I misunderstanding something here.
>
> Parent/child relationships in GTK+ refer to physical containership -
> that is,
>
> widget->window is always a child of window owned by the parent
> widget->allocation is contained completely within widget->parent->allocation.
>
> Now, there is an ugly exception to that for GtkHandleBox because
> of it's reparenting nature, but we don't want to extend that
> exception elsewhere.
>
> So, we use GtkMenuShell->parent_menu_shell instead to handle this.
>
> Regards,
> Owen
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
>
--
Damian Ivereigh
CEPS Team Lead
http://wwwin-print.cisco.com
Desk: +61 2 8446 6344
Mob: +61 418 217 582
Attachment:
pgpugBd3BKtch.pgp
Description: PGP signature