pidgin: 253167f4: Underline the selection in a checkbox.

sadrul at pidgin.im sadrul at pidgin.im
Fri Nov 20 17:51:49 EST 2009


-----------------------------------------------------------------
Revision: 253167f45b9ac9d02b9a70bc2a3469705175d008
Ancestor: e82b0d8f02e0a92cc7e4e5dab9ebcb49d0f180e6
Author: sadrul at pidgin.im
Date: 2009-11-20T16:46:58
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/253167f45b9ac9d02b9a70bc2a3469705175d008

Modified files:
        finch/libgnt/gntcheckbox.c

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- finch/libgnt/gntcheckbox.c	e69aa270183df03aa36e68e029244907cc58d98e
+++ finch/libgnt/gntcheckbox.c	a490038651a76e44b34ec3febed63df2164eb031
@@ -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 @@ gnt_check_box_draw(GntWidget *widget)
 {
 	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;


More information about the Commits mailing list