# HG changeset patch # User Sadrul Habib Chowdhury # Date 1258735618 0 # Node ID 8356e2f2486a89a30d6781eb294a24389a4413dd # Parent a169c5c81ef5bdfb37d67a3e3f968423c2ba1677 Underline the selection in a checkbox. This makes it easier to notice when a checkbox has a focus when the color selection is not great. Also, don't allocate memory when not necessary. diff -r a169c5c81ef5 -r 8356e2f2486a finch/libgnt/gntcheckbox.c --- a/finch/libgnt/gntcheckbox.c Fri Nov 20 09:11:10 2009 +0000 +++ b/finch/libgnt/gntcheckbox.c Fri Nov 20 16:46:58 2009 +0000 @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "gntinternal.h" #include "gntcheckbox.h" enum @@ -36,21 +37,21 @@ { GntCheckBox *cb = GNT_CHECK_BOX(widget); GntColorType type; - char *text; + gboolean focus = gnt_widget_has_focus(widget); - if (gnt_widget_has_focus(widget)) + if (focus) type = GNT_COLOR_HIGHLIGHT; else type = GNT_COLOR_NORMAL; wbkgdset(widget->window, '\0' | gnt_color_pair(type)); - text = g_strdup_printf("[%c]", cb->checked ? 'X' : ' '); - mvwaddstr(widget->window, 0, 0, text); - g_free(text); + mvwaddch(widget->window, 0, 0, '['); + mvwaddch(widget->window, 0, 1, (cb->checked ? 'X' : ' ') | (focus ? A_UNDERLINE : A_NORMAL)); + mvwaddch(widget->window, 0, 2, ']'); wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_NORMAL)); - mvwaddstr(widget->window, 0, 4, GNT_BUTTON(cb)->priv->text); + mvwaddstr(widget->window, 0, 4, (GNT_BUTTON(cb)->priv->text)); wmove(widget->window, 0, 1); GNTDEBUG;