Gtk.Widget.get_ancestor

### Method

# Gtk Widgetget_ancestor

#### Declaration [src]

    GtkWidget*
    gtk_widget_get_ancestor (
      GtkWidget* widget,
      GType widget_type
    )

#### Description [src]

Gets the first ancestor of `widget` with type `widget_type`.

For example, `gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)` gets the first `GtkBox` that’s an ancestor of `widget`. No reference will be added to the returned widget; it should not be unreferenced.

Note that unlike `gtk_widget_is_ancestor()`, this function considers `widget` to be an ancestor of itself.

#### Parameters

`widget_type`

  Type: `GType`

  Ancestor type.

#### Return value

Type: `GtkWidget`

The ancestor widget.

The data is owned by the instance.
The return value can be `NULL`.