summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2013-03-09 17:57:06 -0500
committerTingPing <tingping@tingping.se>2013-03-09 17:57:06 -0500
commit6bd96564168c66eda4d1b198e62c7bd20549205e (patch)
tree96d8e6b9024b5ea55768bc1aecee6648d22be2d4 /src
parentc76dedd9b9f7a15deaac01783bab2f2da225ebd6 (diff)
Add option to color nicknames in the userlist to match the chat
Diffstat (limited to 'src')
-rw-r--r--src/common/cfgfiles.c1
-rw-r--r--src/common/hexchat.h1
-rw-r--r--src/common/text.c6
-rw-r--r--src/common/text.h1
-rw-r--r--src/fe-gtk/setup.c3
-rw-r--r--src/fe-gtk/userlistgui.c25
6 files changed, 21 insertions, 16 deletions
diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c
index 9aac5a4f..243371b0 100644
--- a/src/common/cfgfiles.c
+++ b/src/common/cfgfiles.c
@@ -466,6 +466,7 @@ const struct prefs vars[] =
 	{"gui_tray_minimize", P_OFFINT (hex_gui_tray_minimize), TYPE_BOOL},
 	{"gui_tray_quiet", P_OFFINT (hex_gui_tray_quiet), TYPE_BOOL},
 	{"gui_ulist_buttons", P_OFFINT (hex_gui_ulist_buttons), TYPE_BOOL},
+	{"gui_ulist_color", P_OFFINT (hex_gui_ulist_color), TYPE_BOOL},
 	{"gui_ulist_count", P_OFFINT (hex_gui_ulist_count), TYPE_BOOL},
 	{"gui_ulist_doubleclick", P_OFFSET (hex_gui_ulist_doubleclick), TYPE_STR},
 	{"gui_ulist_hide", P_OFFINT (hex_gui_ulist_hide), TYPE_BOOL},
diff --git a/src/common/hexchat.h b/src/common/hexchat.h
index dfd2fd5a..fad61938 100644
--- a/src/common/hexchat.h
+++ b/src/common/hexchat.h
@@ -158,6 +158,7 @@ struct hexchatprefs
 	unsigned int hex_gui_tray_minimize;
 	unsigned int hex_gui_tray_quiet;
 	unsigned int hex_gui_ulist_buttons;
+	unsigned int hex_gui_ulist_color;
 	unsigned int hex_gui_ulist_count;
 	unsigned int hex_gui_ulist_hide;
 	unsigned int hex_gui_ulist_icons;
diff --git a/src/common/text.c b/src/common/text.c
index 0bef377c..fdf08b90 100644
--- a/src/common/text.c
+++ b/src/common/text.c
@@ -2081,8 +2081,8 @@ pevt_build_string (const char *input, char **output, int *max_arg)
 
 static char rcolors[] = { 19, 20, 22, 24, 25, 26, 27, 28, 29 };
 
-static int
-color_of (char *name)
+int
+text_color_of (char *name)
 {
 	int i = 0, sum = 0;
 
@@ -2105,7 +2105,7 @@ text_emit (int index, session *sess, char *a, char *b, char *c, char *d)
 
 	if (prefs.hex_text_color_nicks && (index == XP_TE_CHANACTION || index == XP_TE_CHANMSG))
 	{
-		snprintf (tbuf, sizeof (tbuf), "\003%d%s", color_of (a), a);
+		snprintf (tbuf, sizeof (tbuf), "\003%d%s", text_color_of (a), a);
 		a = tbuf;
 		stripcolor_args &= ~ARG_FLAG(1);	/* don't strip color from this argument */
 	}
diff --git a/src/common/text.h b/src/common/text.h
index ccbae785..e018c769 100644
--- a/src/common/text.h
+++ b/src/common/text.h
@@ -26,6 +26,7 @@ void pevent_save (char *fn);
 int pevt_build_string (const char *input, char **output, int *max_arg);
 int pevent_load (char *filename);
 void pevent_make_pntevts (void);
+int text_color_of (char *name);
 void text_emit (int index, session *sess, char *a, char *b, char *c, char *d);
 int text_emit_by_name (char *name, session *sess, char *a, char *b, char *c, char *d);
 #ifdef WIN32
diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c
index f02bc3d7..71162792 100644
--- a/src/fe-gtk/setup.c
+++ b/src/fe-gtk/setup.c
@@ -287,6 +287,7 @@ static const setting userlist_settings[] =
 	{ST_TOGGLE, N_("Show hostnames in user list"), P_OFFINTNL(hex_gui_ulist_show_hosts), 0, 0, 0},
 	{ST_TOGGLE, N_("Use the Text box font and colors"), P_OFFINTNL(hex_gui_ulist_style),0,0,0},
 	{ST_TOGGLE, N_("Show icons for user modes"), P_OFFINTNL(hex_gui_ulist_icons), N_("Use graphical icons instead of text symbols in the user list."), 0, 0},
+	{ST_TOGGLE, N_("Color nicknames in userlist"), P_OFFINTNL(hex_gui_ulist_color), N_("Will color nicknames the same as in chat."), 0, 0},
 	{ST_TOGGLE, N_("Show user count in channels"), P_OFFINTNL(hex_gui_ulist_count), 0, 0, 0},
 /*	{ST_TOGGLE, N_("Resizable user list"), P_OFFINTNL(hex_gui_ulist_resizable),0,0,0},*/
 	{ST_MENU,	N_("User list sorted by:"), P_OFFINTNL(hex_gui_ulist_sort), 0, ulmenutext, 0},
@@ -2253,7 +2254,7 @@ setup_apply (struct hexchatprefs *pr)
 	if (DIFF (hex_gui_tab_layout))
 		do_layout = TRUE;
 
-	if (color_change || (DIFF (hex_away_size_max)) || (DIFF (hex_away_track)))
+	if (color_change || (DIFF (hex_gui_ulist_color)) || (DIFF (hex_away_size_max)) || (DIFF (hex_away_track)))
 		do_ulist = TRUE;
 
 	if ((pr->hex_gui_tab_pos == 5 || pr->hex_gui_tab_pos == 6) &&
diff --git a/src/fe-gtk/userlistgui.c b/src/fe-gtk/userlistgui.c
index 8405695b..75281a0c 100644
--- a/src/fe-gtk/userlistgui.c
+++ b/src/fe-gtk/userlistgui.c
@@ -38,6 +38,7 @@
 #include "../common/util.h"
 #include "../common/userlist.h"
 #include "../common/modes.h"
+#include "../common/text.h"
 #include "../common/notify.h"
 #include "../common/hexchatc.h"
 #include "../common/fe.h"
@@ -327,21 +328,21 @@ fe_userlist_rehash (session *sess, struct User *user)
 {
 	GtkTreeIter *iter;
 	int sel;
-	int do_away = TRUE;
+	int nick_color = NULL;
 
 	iter = find_row (GTK_TREE_VIEW (sess->gui->user_tree),
 						  sess->res->user_model, user, &sel);
 	if (!iter)
 		return;
 
-	if (prefs.hex_away_size_max < 1 || !prefs.hex_away_track)
-		do_away = FALSE;
+	if (prefs.hex_away_track && prefs.hex_away_size_max && user->away)
+		nick_color = COL_AWAY;
+	else if (prefs.hex_gui_ulist_color)
+		nick_color = text_color_of(user->nick);
 
 	gtk_list_store_set (GTK_LIST_STORE (sess->res->user_model), iter,
 							  COL_HOST, user->hostname,
-							  COL_GDKCOLOR, (do_away)
-									?	(user->away ? &colors[COL_AWAY] : NULL)
-									:	(NULL),
+							  COL_GDKCOLOR, nick_color ? &colors[nick_color] : NULL,
 							  -1);
 }
 
@@ -351,11 +352,13 @@ fe_userlist_insert (session *sess, struct User *newuser, int row, int sel)
 	GtkTreeModel *model = sess->res->user_model;
 	GdkPixbuf *pix = get_user_icon (sess->server, newuser);
 	GtkTreeIter iter;
-	int do_away = TRUE;
 	char *nick;
+	int nick_color = NULL;
 
-	if (prefs.hex_away_size_max < 1 || !prefs.hex_away_track)
-		do_away = FALSE;
+	if (prefs.hex_away_track && prefs.hex_away_size_max && user->away)
+		nick_color = COL_AWAY;
+	else if (prefs.hex_gui_ulist_color)
+		nick_color = text_color_of(newuser->nick);
 
 	nick = newuser->nick;
 	if (!prefs.hex_gui_ulist_icons)
@@ -374,9 +377,7 @@ fe_userlist_insert (session *sess, struct User *newuser, int row, int sel)
 									COL_NICK, nick,
 									COL_HOST, newuser->hostname,
 									COL_USER, newuser,
-									COL_GDKCOLOR, (do_away)
-										?	(newuser->away ? &colors[COL_AWAY] : NULL)
-										:	(NULL),
+									COL_GDKCOLOR, nick_color ? &colors[nick_color] : NULL,
 								  -1);
 
 	if (!prefs.hex_gui_ulist_icons)