qulogic/libgnt

Add accessors for GntButton members.
release-2.x.y
2019-04-06, Elliott Sales de Andrade
7dd03b1bd21f
Parents b3d988638ca1
Children 78bef0588dd6
Add accessors for GntButton members.
  • +16 -0
    gntbutton.c
  • +23 -0
    gntbutton.h
  • +3 -2
    gntcheckbox.c
  • --- a/gntbutton.c Sat Apr 06 06:05:21 2019 -0400
    +++ b/gntbutton.c Sat Apr 06 16:32:41 2019 -0400
    @@ -182,3 +182,19 @@
    return widget;
    }
    +const gchar *
    +gnt_button_get_text(GntButton *button)
    +{
    + g_return_val_if_fail(GNT_IS_BUTTON(button), NULL);
    +
    + return button->priv->text;
    +}
    +
    +void
    +gnt_button_set_text(GntButton *button, const gchar *text)
    +{
    + g_return_if_fail(GNT_IS_BUTTON(button));
    +
    + g_free(button->priv->text);
    + button->priv->text = g_strdup(text);
    +}
    --- a/gntbutton.h Sat Apr 06 06:05:21 2019 -0400
    +++ b/gntbutton.h Sat Apr 06 16:32:41 2019 -0400
    @@ -86,6 +86,29 @@
    */
    GntWidget * gnt_button_new(const char *text);
    +/**
    + * gnt_button_set_text:
    + * @button: The button.
    + * @text: The text for the button.
    + *
    + * Set the text of a button.
    + *
    + * Since: 2.9.0
    + */
    +void gnt_button_set_text(GntButton *button, const gchar *text);
    +
    +/**
    + * gnt_button_get_text:
    + * @button: The button.
    + *
    + * Get the text of a button.
    + *
    + * Returns: The text for the button.
    + *
    + * Since: 2.9.0
    + */
    +const gchar *gnt_button_get_text(GntButton *button);
    +
    G_END_DECLS
    #endif /* GNT_BUTTON_H */
    --- a/gntcheckbox.c Sat Apr 06 06:05:21 2019 -0400
    +++ b/gntcheckbox.c Sat Apr 06 16:32:41 2019 -0400
    @@ -51,7 +51,8 @@
    mvwaddch(widget->window, 0, 2, ']');
    wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_NORMAL));
    - mvwaddstr(widget->window, 0, 4, C_(GNT_BUTTON(cb)->priv->text));
    + mvwaddstr(widget->window, 0, 4,
    + C_(gnt_button_get_text(GNT_BUTTON(cb))));
    (void)wmove(widget->window, 0, 1);
    GNTDEBUG;
    @@ -156,7 +157,7 @@
    {
    GntWidget *widget = g_object_new(GNT_TYPE_CHECK_BOX, NULL);
    - GNT_BUTTON(widget)->priv->text = g_strdup(text);
    + gnt_button_set_text(GNT_BUTTON(widget), text);
    gnt_widget_set_take_focus(widget, TRUE);
    return widget;