qulogic/libgnt

Add a shortcut accessor to the toplevel parent.
release-2.x.y
2019-04-19, Elliott Sales de Andrade
e59cae5434a0
Parents b1d6cdff79d5
Children 2ef05b12e0c1
Add a shortcut accessor to the toplevel parent.
  • +12 -0
    gntwidget.c
  • +13 -0
    gntwidget.h
  • --- a/gntwidget.c Thu Apr 11 04:39:24 2019 -0400
    +++ b/gntwidget.c Fri Apr 19 01:19:02 2019 -0400
    @@ -455,6 +455,18 @@
    return widget->parent;
    }
    +GntWidget *
    +gnt_widget_get_toplevel(GntWidget *widget)
    +{
    + g_return_val_if_fail(GNT_IS_WIDGET(widget), NULL);
    +
    + while (widget->parent) {
    + widget = widget->parent;
    + }
    +
    + return widget;
    +}
    +
    void
    gnt_widget_set_position(GntWidget *wid, int x, int y)
    {
    --- a/gntwidget.h Thu Apr 11 04:39:24 2019 -0400
    +++ b/gntwidget.h Fri Apr 19 01:19:02 2019 -0400
    @@ -269,6 +269,19 @@
    GntWidget *gnt_widget_get_parent(GntWidget *widget);
    /**
    + * gnt_widget_get_toplevel:
    + * @widget: The widget.
    + *
    + * Get the toplevel parent of a widget in the container hierarchy. If widget
    + * has no parent widgets, it will be returned as the topmost widget.
    + *
    + * Returns: (transfer none) (nullable): The toplevel parent widget.
    + *
    + * Since: 2.14.0
    + */
    +GntWidget *gnt_widget_get_toplevel(GntWidget *widget);
    +
    +/**
    * gnt_widget_get_position:
    * @widget: The widget.
    * @x: Location to store the x-coordinate of the widget.