This function returns the topmost widget in the container hierarchy
widget is a part of. If widget has no parent widgets, it will be
returned as the topmost widget. No reference will be added to the
returned widget; it should not be unreferenced.
Note the difference in behavior vs. gtk_widget_get_ancestor();
gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW)
would return
NULL if widget wasn't inside a toplevel window, and if the
window was inside a GtkWindow-derived widget which was in turn
inside the toplevel GtkWindow. While the second case may
seem unlikely, it actually happens when a GtkPlug is embedded
inside a GtkSocket within the same application.
To reliably find the toplevel GtkWindow, use
gtk_widget_get_toplevel() and check if the TOPLEVEL flags
is set on the result.
This function returns the topmost widget in the container hierarchy widget is a part of. If widget has no parent widgets, it will be returned as the topmost widget. No reference will be added to the returned widget; it should not be unreferenced. Note the difference in behavior vs. gtk_widget_get_ancestor(); gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW) would return NULL if widget wasn't inside a toplevel window, and if the window was inside a GtkWindow-derived widget which was in turn inside the toplevel GtkWindow. While the second case may seem unlikely, it actually happens when a GtkPlug is embedded inside a GtkSocket within the same application. To reliably find the toplevel GtkWindow, use gtk_widget_get_toplevel() and check if the TOPLEVEL flags is set on the result.