Package: gtk
Function gtk:widget-toplevel
Lambda Listgtk:widget-toplevel (widget) ArgumentsReturn ValueThe topmost ancestor of widget, or widget itself if there is no ancestor. Details
This function returns the topmost widget in the container hierarchy
the widget is a part of.
If the widget has no parent widgets, it will be returned as the topmost
widget. Note the difference in behavior versus the gtk:widget-ancestor function. The call (gtk:widget-ancestor widget "GtkWindow") would return nil if the widget was not inside a toplevel window, and if the window was inside a gtk:window derived widget which was in turn inside the toplevel gtk:window widget. While the second case may seem unlikely, it actually happens when a gtk:plug widget is embedded inside a gtk:socket widget within the same application. To reliably find the toplevel gtk:window widget, use the gtk:widget-toplevel function and check the type of the result to be of "GtkWindow" type. For instance, to get the title of the toplevel window of the widget, one might use: (defun get-widget-toplevel-title (widget) (let ((toplevel (gtk:widget-toplevel widget))) (when (eq (gtype "GtkWindow") (g:type-from-instance toplevel)) (gtk:window-title toplevel)))) | See also |
#2023-3-8