qulogic/libgnt

Use widget focus flag accessors.

2019-04-08, Elliott Sales de Andrade
fff4afb7fb1e
Parents c8ca009d57a9
Children 9c8fc70af8eb
Use widget focus flag accessors.

Also, add a getter for can-take-focus.
  • +5 -7
    gntbox.c
  • +1 -1
    gntfilesel.c
  • +10 -2
    gntwidget.c
  • +12 -0
    gntwidget.h
  • +3 -2
    gntwm.c
  • --- a/gntbox.c Mon Apr 08 03:57:00 2019 -0400
    +++ b/gntbox.c Mon Apr 08 04:20:38 2019 -0400
    @@ -54,7 +54,7 @@
    if (GNT_IS_BOX(w))
    g_list_foreach(GNT_BOX(w)->list, add_to_focus, box);
    - else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_CAN_TAKE_FOCUS))
    + else if (gnt_widget_get_take_focus(w))
    box->focus = g_list_append(box->focus, w);
    }
    @@ -274,8 +274,7 @@
    else if (box->focus)
    box->active = box->focus->data;
    if (gnt_widget_get_visible(box->active) &&
    - GNT_WIDGET_IS_FLAG_SET(box->active,
    - GNT_WIDGET_CAN_TAKE_FOCUS)) {
    + gnt_widget_get_take_focus(box->active)) {
    break;
    }
    } while (box->active != last);
    @@ -520,7 +519,7 @@
    if (cx >= x && cx < x + w && cy >= y && cy < y + h) {
    if (event <= GNT_MIDDLE_MOUSE_DOWN &&
    - GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_CAN_TAKE_FOCUS)) {
    + gnt_widget_get_take_focus(wid)) {
    while (widget->parent)
    widget = widget->parent;
    gnt_box_give_focus_to_child(GNT_BOX(widget), wid);
    @@ -757,9 +756,8 @@
    void gnt_box_remove(GntBox *box, GntWidget *widget)
    {
    box->list = g_list_remove(box->list, widget);
    - if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)
    - && GNT_WIDGET(box)->parent == NULL && box->focus)
    - {
    + if (gnt_widget_get_take_focus(widget) &&
    + GNT_WIDGET(box)->parent == NULL && box->focus) {
    if (widget == box->active)
    {
    find_next_focus(box);
    --- a/gntfilesel.c Mon Apr 08 03:57:00 2019 -0400
    +++ b/gntfilesel.c Mon Apr 08 04:20:38 2019 -0400
    @@ -314,7 +314,7 @@
    file_sel_changed(GntWidget *widget, G_GNUC_UNUSED gpointer old,
    G_GNUC_UNUSED gpointer current, GntFileSel *sel)
    {
    - if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_HAS_FOCUS)) {
    + if (gnt_widget_get_has_focus(widget)) {
    g_free(sel->suggest);
    sel->suggest = NULL;
    update_location(sel);
    --- a/gntwidget.c Mon Apr 08 03:57:00 2019 -0400
    +++ b/gntwidget.c Mon Apr 08 04:20:38 2019 -0400
    @@ -265,6 +265,14 @@
    GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS);
    }
    +gboolean
    +gnt_widget_get_take_focus(GntWidget *widget)
    +{
    + g_return_val_if_fail(GNT_IS_WIDGET(widget), FALSE);
    +
    + return GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS);
    +}
    +
    void
    gnt_widget_destroy(GntWidget *widget)
    {
    @@ -316,7 +324,7 @@
    gnt_widget_key_pressed(GntWidget *widget, const char *keys)
    {
    gboolean ret;
    - if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS))
    + if (!gnt_widget_get_take_focus(widget))
    return FALSE;
    if (!gnt_widget_get_disable_actions(widget) &&
    @@ -485,7 +493,7 @@
    gboolean
    gnt_widget_set_focus(GntWidget *widget, gboolean set)
    {
    - if (!(GNT_WIDGET_FLAGS(widget) & GNT_WIDGET_CAN_TAKE_FOCUS))
    + if (!gnt_widget_get_take_focus(widget))
    return FALSE;
    if (set && !gnt_widget_get_has_focus(widget)) {
    --- a/gntwidget.h Mon Apr 08 03:57:00 2019 -0400
    +++ b/gntwidget.h Mon Apr 08 04:20:38 2019 -0400
    @@ -337,6 +337,18 @@
    void gnt_widget_set_take_focus(GntWidget *widget, gboolean set);
    /**
    + * gnt_widget_get_take_focus:
    + * @widget: The widget.
    + *
    + * Get whether a widget can take focus or not.
    + *
    + * Returns: %TRUE if the widget can take focus.
    + *
    + * Since: 2.9.0
    + */
    +gboolean gnt_widget_get_take_focus(GntWidget *widget);
    +
    +/**
    * gnt_widget_set_visible:
    * @widget: The widget.
    * @set: Whether the widget is visible or not.
    --- a/gntwm.c Mon Apr 08 03:57:00 2019 -0400
    +++ b/gntwm.c Mon Apr 08 04:20:38 2019 -0400
    @@ -1846,8 +1846,9 @@
    g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget);
    if (wm->windows && !gnt_widget_get_transient(widget)) {
    - if ((GNT_IS_BOX(widget) && GNT_BOX(widget)->title) && wm->_list.window != widget
    - && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)) {
    + if ((GNT_IS_BOX(widget) && GNT_BOX(widget)->title) &&
    + wm->_list.window != widget &&
    + gnt_widget_get_take_focus(widget)) {
    gnt_tree_add_row_last(GNT_TREE(wm->windows->tree), widget,
    gnt_tree_create_row(GNT_TREE(wm->windows->tree), GNT_BOX(widget)->title),
    g_object_get_data(G_OBJECT(wm->windows->tree), "workspace") ? wm->cws : NULL);