libgnt/libgnt

Add an accessor for the widget visibility flag.

2019-04-08, Elliott Sales de Andrade
c8ca009d57a9
Parents e000a7bfaccd
Children fff4afb7fb1e
Add an accessor for the widget visibility flag.
  • +9 -7
    gntbox.c
  • +8 -0
    gntwidget.c
  • +12 -0
    gntwidget.h
  • +2 -2
    gntwm.c
  • --- a/gntbox.c Mon Apr 08 03:51:46 2019 -0400
    +++ b/gntbox.c Mon Apr 08 03:57:00 2019 -0400
    @@ -121,7 +121,7 @@
    for (iter = box->list; iter; iter = iter->next)
    {
    - if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(iter->data), GNT_WIDGET_INVISIBLE))
    + if (!gnt_widget_get_visible(GNT_WIDGET(iter->data)))
    continue;
    gnt_widget_set_position(GNT_WIDGET(iter->data), curx, cury);
    gnt_widget_get_size(GNT_WIDGET(iter->data), &w, &h);
    @@ -273,9 +273,11 @@
    box->active = iter->next->data;
    else if (box->focus)
    box->active = box->focus->data;
    - if (!GNT_WIDGET_IS_FLAG_SET(box->active, GNT_WIDGET_INVISIBLE) &&
    - GNT_WIDGET_IS_FLAG_SET(box->active, GNT_WIDGET_CAN_TAKE_FOCUS))
    + if (gnt_widget_get_visible(box->active) &&
    + GNT_WIDGET_IS_FLAG_SET(box->active,
    + GNT_WIDGET_CAN_TAKE_FOCUS)) {
    break;
    + }
    } while (box->active != last);
    }
    @@ -296,7 +298,7 @@
    box->active = g_list_last(box->focus)->data;
    else
    box->active = iter->prev->data;
    - if (!GNT_WIDGET_IS_FLAG_SET(box->active, GNT_WIDGET_INVISIBLE))
    + if (gnt_widget_get_visible(box->active))
    break;
    } while (box->active != last);
    }
    @@ -421,8 +423,8 @@
    gnt_widget_get_size(wid, &w, &h);
    if (wid != last && !child && w > 0 && h > 0 &&
    - !GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_INVISIBLE) &&
    - gnt_widget_confirm_size(wid, w - wchange, h - hchange)) {
    + gnt_widget_get_visible(wid) &&
    + gnt_widget_confirm_size(wid, w - wchange, h - hchange)) {
    child = wid;
    break;
    }
    @@ -706,7 +708,7 @@
    continue;
    }
    - if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_INVISIBLE))
    + if (!gnt_widget_get_visible(w))
    continue;
    if (GNT_IS_BOX(w))
    --- a/gntwidget.c Mon Apr 08 03:51:46 2019 -0400
    +++ b/gntwidget.c Mon Apr 08 03:57:00 2019 -0400
    @@ -561,6 +561,14 @@
    GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_INVISIBLE);
    }
    +gboolean
    +gnt_widget_get_visible(GntWidget *widget)
    +{
    + g_return_val_if_fail(GNT_IS_WIDGET(widget), FALSE);
    +
    + return !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_INVISIBLE);
    +}
    +
    gboolean gnt_widget_has_shadow(GntWidget *widget)
    {
    return (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_SHADOW) &&
    --- a/gntwidget.h Mon Apr 08 03:51:46 2019 -0400
    +++ b/gntwidget.h Mon Apr 08 03:57:00 2019 -0400
    @@ -346,6 +346,18 @@
    void gnt_widget_set_visible(GntWidget *widget, gboolean set);
    /**
    + * gnt_widget_get_visible:
    + * @widget: The widget.
    + *
    + * Get the visibility of a widget.
    + *
    + * Returns: Whether the widget is visible or not.
    + *
    + * Since: 2.9.0
    + */
    +gboolean gnt_widget_get_visible(GntWidget *widget);
    +
    +/**
    * gnt_widget_has_shadow:
    * @widget: The widget.
    *
    --- a/gntwm.c Mon Apr 08 03:51:46 2019 -0400
    +++ b/gntwm.c Mon Apr 08 03:57:00 2019 -0400
    @@ -1826,8 +1826,8 @@
    while (widget->parent)
    widget = widget->parent;
    - if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_INVISIBLE) ||
    - g_hash_table_lookup(wm->nodes, widget)) {
    + if (!gnt_widget_get_visible(widget) ||
    + g_hash_table_lookup(wm->nodes, widget)) {
    update_screen(wm);
    return;
    }