changeset 28983:8356e2f2486a

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.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 20 Nov 2009 16:46:58 +0000
parents a169c5c81ef5
children a18f421696dc
files finch/libgnt/gntcheckbox.c
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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;