diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/irc/irc-config.c | 44 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.h | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-nick.c | 78 | ||||
-rw-r--r-- | src/plugins/irc/irc-nick.h | 5 |
4 files changed, 100 insertions, 28 deletions
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index d2c7989b0..945ba6bb9 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -50,6 +50,7 @@ struct t_config_section *irc_config_section_server = NULL; /* IRC config, look section */ +struct t_config_option *irc_config_look_color_nicks_in_nicklist; struct t_config_option *irc_config_look_color_nicks_in_server_messages; struct t_config_option *irc_config_look_color_pv_nick_like_channel; struct t_config_option *irc_config_look_server_buffer; @@ -230,6 +231,41 @@ irc_config_change_nick_colors_cb (void *data, const char *option, } /* + * irc_config_change_look_color_nicks_in_nicklist: called when the + * "color nicks in nicklist" + * option is changed + */ + +void +irc_config_change_look_color_nicks_in_nicklist (void *data, + struct t_config_option *option) +{ + struct t_irc_server *ptr_server; + struct t_irc_channel *ptr_channel; + struct t_irc_nick *ptr_nick; + + /* make C compiler happy */ + (void) data; + (void) option; + + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) + { + for (ptr_channel = ptr_server->channels; ptr_channel; + ptr_channel = ptr_channel->next_channel) + { + for (ptr_nick = ptr_channel->nicks; ptr_nick; + ptr_nick = ptr_nick->next_nick) + { + irc_nick_nicklist_set (ptr_channel, ptr_nick, "color", + irc_nick_get_color_for_nicklist (ptr_server, + ptr_nick)); + } + } + } +} + +/* * irc_config_change_look_server_buffer: called when the "one server buffer" * option is changed */ @@ -1765,7 +1801,13 @@ irc_config_init () weechat_config_free (irc_config_file); return 0; } - + + irc_config_look_color_nicks_in_nicklist = weechat_config_new_option ( + irc_config_file, ptr_section, + "color_nicks_in_nicklist", "boolean", + N_("use nick color in nicklist"), + NULL, 0, 0, "off", NULL, 0, NULL, NULL, + &irc_config_change_look_color_nicks_in_nicklist, NULL, NULL, NULL); irc_config_look_color_nicks_in_server_messages = weechat_config_new_option ( irc_config_file, ptr_section, "color_nicks_in_server_messages", "boolean", diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index b835f84e3..890617df3 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -75,6 +75,7 @@ extern struct t_config_section *irc_config_section_ctcp; extern struct t_config_section *irc_config_section_server_default; extern struct t_config_section *irc_config_section_server; +extern struct t_config_option *irc_config_look_color_nicks_in_nicklist; extern struct t_config_option *irc_config_look_color_nicks_in_server_messages; extern struct t_config_option *irc_config_look_color_pv_nick_like_channel; extern struct t_config_option *irc_config_look_server_buffer; diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index 6c69386e6..5419935f0 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -411,6 +411,54 @@ irc_nick_get_prefix_color (struct t_irc_server *server, } /* + * irc_nick_get_prefix_color_name: return name of color with a prefix number + */ + +const char * +irc_nick_get_prefix_color_name (int prefix_color) +{ + static char *color_for_prefix[] = { + "chat", + "irc.color.nick_prefix_op", + "irc.color.nick_prefix_halfop", + "irc.color.nick_prefix_voice", + "irc.color.nick_prefix_user", + }; + + if ((prefix_color >= 0) && (prefix_color <= 4)) + return color_for_prefix[prefix_color]; + + /* no color by default (should not happen) */ + return color_for_prefix[0]; +} + +/* + * irc_nick_get_color_for_nicklist: get nick color for nicklist + */ + +const char * +irc_nick_get_color_for_nicklist (struct t_irc_server *server, + struct t_irc_nick *nick) +{ + static char *nick_color_bar_fg = "bar_fg"; + static char *nick_color_self = "weechat.color.chat_nick_self"; + static char *nick_color_away = "weechat.color.nicklist_away"; + + if (nick->away) + return nick_color_away; + + if (weechat_config_boolean(irc_config_look_color_nicks_in_nicklist)) + { + if (weechat_strcasecmp (nick->name, server->nick) == 0) + return nick_color_self; + else + return irc_nick_find_color_name (nick->name); + } + + return nick_color_bar_fg; +} + +/* * irc_nick_nicklist_add: add nick to buffer nicklist */ @@ -421,13 +469,12 @@ irc_nick_nicklist_add (struct t_irc_server *server, { int prefix_color; struct t_gui_nick_group *ptr_group; - + ptr_group = irc_nick_get_nicklist_group (server, channel->buffer, nick); prefix_color = irc_nick_get_prefix_color (server, nick); weechat_nicklist_add_nick (channel->buffer, ptr_group, nick->name, - (nick->away) ? - "weechat.color.nicklist_away" : "bar_fg", + irc_nick_get_color_for_nicklist (server, nick), nick->prefix, irc_nick_get_prefix_color_name (prefix_color), 1); @@ -470,28 +517,6 @@ irc_nick_nicklist_set (struct t_irc_channel *channel, } /* - * irc_nick_get_prefix_color_name: return name of color with a prefix number - */ - -const char * -irc_nick_get_prefix_color_name (int prefix_color) -{ - static char *color_for_prefix[] = { - "chat", - "irc.color.nick_prefix_op", - "irc.color.nick_prefix_halfop", - "irc.color.nick_prefix_voice", - "irc.color.nick_prefix_user", - }; - - if ((prefix_color >= 0) && (prefix_color <= 4)) - return color_for_prefix[prefix_color]; - - /* no color by default (should not happen) */ - return color_for_prefix[0]; -} - -/* * irc_nick_new: allocate a new nick for a channel and add it to the nick list */ @@ -769,8 +794,7 @@ irc_nick_set_away (struct t_irc_server *server, struct t_irc_channel *channel, { nick->away = is_away; irc_nick_nicklist_set (channel, nick, "color", - (nick->away) ? - "weechat.color.nicklist_away" : "bar_fg"); + irc_nick_get_color_for_nicklist (server, nick)); } } } diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h index 53880c559..84cb61726 100644 --- a/src/plugins/irc/irc-nick.h +++ b/src/plugins/irc/irc-nick.h @@ -58,6 +58,11 @@ extern int irc_nick_has_prefix_mode (struct t_irc_server *server, extern int irc_nick_get_prefix_color (struct t_irc_server *server, struct t_irc_nick *nick); extern const char *irc_nick_get_prefix_color_name (int prefix_color); +extern const char *irc_nick_get_color_for_nicklist (struct t_irc_server *server, + struct t_irc_nick *nick); +extern void irc_nick_nicklist_set (struct t_irc_channel *channel, + struct t_irc_nick *nick, + const char *property, const char *value); extern struct t_irc_nick *irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel, const char *nickname, |