Gtk.Widget.prototype.get_ancestor

function get_ancestor(widget_type:GType):Gtk.Widget {
    // Gjs wrapper for gtk_widget_get_ancestor()
}

Gets the first ancestor of widget with type widget_type. For example, <literal>gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)</literal> gets the first Gtk.Box that's an ancestor of widget. No reference will be added to the returned widget; it should not be unreferenced. See note about checking for a toplevel Gtk.Window in the docs for Gtk.get_toplevel.

Note that unlike Gtk.is_ancestor, Gtk.Widget.prototype.get_ancestor considers widget to be an ancestor of itself.

widget_type

ancestor type

Returns

the ancestor widget, or null if not found