From 706c966af81706d007d0ea93963497ab2a65bfff Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Fri, 21 Sep 2012 11:55:57 +0400 Subject: [PATCH] (groupbox_set_title): new function. Signed-off-by: Andrew Borodin --- lib/widget/groupbox.c | 18 +++++++++++++++++- lib/widget/groupbox.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/widget/groupbox.c b/lib/widget/groupbox.c index af592a733..96c67e539 100644 --- a/lib/widget/groupbox.c +++ b/lib/widget/groupbox.c @@ -109,6 +109,21 @@ groupbox_new (int y, int x, int height, int width, const char *title) widget_want_hotkey (w, FALSE); g->title = NULL; + groupbox_set_title (g, title); + + return g; +} + +/* --------------------------------------------------------------------------------------------- */ + +void +groupbox_set_title (WGroupbox *g, const char *title) +{ + Widget *w = WIDGET (g); + + g_free (g->title); + g->title = NULL; + /* Strip existing spaces, add one space before and after the title */ if (title != NULL && *title != '\0') { @@ -119,7 +134,8 @@ groupbox_new (int y, int x, int height, int width, const char *title) g_free (t); } - return g; + if (w->owner != NULL) + send_message (w, NULL, WIDGET_DRAW, 0, NULL); } /* --------------------------------------------------------------------------------------------- */ diff --git a/lib/widget/groupbox.h b/lib/widget/groupbox.h index ff53f347b..e6b792065 100644 --- a/lib/widget/groupbox.h +++ b/lib/widget/groupbox.h @@ -23,6 +23,7 @@ typedef struct WGroupbox /*** declarations of public functions ************************************************************/ WGroupbox *groupbox_new (int y, int x, int height, int width, const char *title); +void groupbox_set_title (WGroupbox *g, const char *title); /*** inline functions ****************************************************************************/ -- 2.11.4.GIT