qulogic/libgnt

Use gnt_widget_get_parent more.

2019-04-22, Elliott Sales de Andrade
0cd1b7b7f1d1
Parents ea3a1a528401
Children d808614e672c
Use gnt_widget_get_parent more.
  • +9 -6
    gntbox.c
  • +16 -8
    gntcombobox.c
  • +3 -3
    gntentry.c
  • --- a/gntbox.c Mon Apr 22 03:07:09 2019 -0400
    +++ b/gntbox.c Mon Apr 22 03:20:47 2019 -0400
    @@ -77,8 +77,9 @@
    {
    GntBox *box = GNT_BOX(widget);
    - if (box->focus == NULL && widget->parent == NULL)
    + if (box->focus == NULL && gnt_widget_get_parent(widget) == NULL) {
    g_list_foreach(box->list, add_to_focus, box);
    + }
    g_list_foreach(box->list, (GFunc)gnt_widget_draw, NULL);
    @@ -253,8 +254,10 @@
    find_focusable_widget(GntBox *box)
    {
    /* XXX: Make sure the widget is visible? */
    - if (box->focus == NULL && GNT_WIDGET(box)->parent == NULL)
    + if (box->focus == NULL &&
    + gnt_widget_get_parent(GNT_WIDGET(box)) == NULL) {
    g_list_foreach(box->list, add_to_focus, box);
    + }
    if (box->active == NULL && box->focus)
    box->active = box->focus->data;
    @@ -764,7 +767,7 @@
    {
    box->list = g_list_remove(box->list, widget);
    if (gnt_widget_get_take_focus(widget) &&
    - GNT_WIDGET(box)->parent == NULL && box->focus) {
    + gnt_widget_get_parent(GNT_WIDGET(box)) == NULL && box->focus) {
    if (widget == box->active)
    {
    find_next_focus(box);
    @@ -794,8 +797,9 @@
    GntWidget *wid;
    int width, height;
    - if (GNT_WIDGET(box)->parent != NULL)
    + if (gnt_widget_get_parent(GNT_WIDGET(box)) != NULL) {
    return;
    + }
    for (iter = box->list; iter; iter = iter->next)
    {
    @@ -821,8 +825,7 @@
    wid->priv.width = 0;
    wid->priv.height = 0;
    - if (wid->parent == NULL)
    - {
    + if (gnt_widget_get_parent(wid) == NULL) {
    g_list_free(box->focus);
    box->focus = NULL;
    box->active = NULL;
    --- a/gntcombobox.c Mon Apr 22 03:07:09 2019 -0400
    +++ b/gntcombobox.c Mon Apr 22 03:20:47 2019 -0400
    @@ -73,7 +73,7 @@
    set_selection(box, gnt_tree_get_selection_data(GNT_TREE(box->dropdown)));
    else
    gnt_tree_set_selected(GNT_TREE(box->dropdown), box->selected);
    - gnt_widget_hide(box->dropdown->parent);
    + gnt_widget_hide(gnt_widget_get_parent(box->dropdown));
    }
    static void
    @@ -133,7 +133,7 @@
    popup_dropdown(GntComboBox *box)
    {
    GntWidget *widget = GNT_WIDGET(box);
    - GntWidget *parent = box->dropdown->parent;
    + GntWidget *parent = gnt_widget_get_parent(box->dropdown);
    int height = g_list_length(GNT_TREE(box->dropdown)->list);
    int y = widget->priv.y + widget->priv.height - 1;
    gnt_widget_set_size(box->dropdown, widget->priv.width, height + 2);
    @@ -157,7 +157,9 @@
    gnt_combo_box_key_pressed(GntWidget *widget, const char *text)
    {
    GntComboBox *box = GNT_COMBO_BOX(widget);
    - gboolean showing = gnt_widget_get_mapped(box->dropdown->parent);
    + gboolean showing;
    +
    + showing = gnt_widget_get_mapped(gnt_widget_get_parent(box->dropdown));
    if (showing) {
    if (text[1] == 0) {
    @@ -215,15 +217,17 @@
    static void
    gnt_combo_box_destroy(GntWidget *widget)
    {
    - gnt_widget_destroy(GNT_COMBO_BOX(widget)->dropdown->parent);
    + GntComboBox *combo = GNT_COMBO_BOX(widget);
    + gnt_widget_destroy(gnt_widget_get_parent(combo->dropdown));
    }
    static void
    gnt_combo_box_lost_focus(GntWidget *widget)
    {
    GntComboBox *combo = GNT_COMBO_BOX(widget);
    - if (gnt_widget_get_mapped(combo->dropdown->parent))
    + if (gnt_widget_get_mapped(gnt_widget_get_parent(combo->dropdown))) {
    hide_popup(combo, FALSE);
    + }
    widget_lost_focus(widget);
    }
    @@ -232,7 +236,9 @@
    G_GNUC_UNUSED int x, G_GNUC_UNUSED int y)
    {
    GntComboBox *box = GNT_COMBO_BOX(widget);
    - gboolean dshowing = gnt_widget_get_mapped(box->dropdown->parent);
    + gboolean dshowing;
    +
    + dshowing = gnt_widget_get_mapped(gnt_widget_get_parent(box->dropdown));
    if (event == GNT_MOUSE_SCROLL_UP) {
    if (dshowing)
    @@ -262,9 +268,11 @@
    static gboolean
    dropdown_menu(GntBindable *b, G_GNUC_UNUSED GList *params)
    {
    - if (gnt_widget_get_mapped(GNT_COMBO_BOX(b)->dropdown->parent))
    + GntComboBox *combo = GNT_COMBO_BOX(b);
    + if (gnt_widget_get_mapped(gnt_widget_get_parent(combo->dropdown))) {
    return FALSE;
    - popup_dropdown(GNT_COMBO_BOX(b));
    + }
    + popup_dropdown(combo);
    return TRUE;
    }
    --- a/gntentry.c Mon Apr 22 03:07:09 2019 -0400
    +++ b/gntentry.c Mon Apr 22 03:20:47 2019 -0400
    @@ -154,7 +154,7 @@
    destroy_suggest(GntEntryPrivate *priv)
    {
    if (priv->ddown) {
    - gnt_widget_destroy(priv->ddown->parent);
    + gnt_widget_destroy(gnt_widget_get_parent(priv->ddown));
    priv->ddown = NULL;
    }
    }
    @@ -299,7 +299,7 @@
    priv->ddown = ddown;
    }
    }
    - gnt_widget_draw(priv->ddown->parent);
    + gnt_widget_draw(gnt_widget_get_parent(priv->ddown));
    }
    return TRUE;
    @@ -1021,7 +1021,7 @@
    }
    if (priv->ddown) {
    - gnt_widget_destroy(priv->ddown->parent);
    + gnt_widget_destroy(gnt_widget_get_parent(priv->ddown));
    }
    g_free(priv->search->needle);