diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 83f60dfca..5ca9c97b6 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -321,37 +321,6 @@ config_change_color (void *data, struct t_config_option *option) } } -/* - * config_change_nicks_colors: called when number of nicks color changed - */ - -void -config_change_nicks_colors (void *data, struct t_config_option *option) -{ - /* make C compiler happy */ - (void) data; - (void) option; - - /* TODO: change nicks colors */ - /* - struct t_gui_buffer *ptr_buffer; - struct t_gui_nick *ptr_nick; - - for (ptr_buffer = gui_buffers; ptr_buffer; - ptr_buffer = ptr_buffer->next_buffer) - { - if (ptr_buffer->nicks) - { - for (ptr_nick = ptr_buffer->nicks; ptr_nick; - ptr_nick = ptr_nick->next_nick) - { - gui_nick_find_color (ptr_nick); - } - } - } - */ -} - /* * config_day_change_timer_cb: timer callback for displaying * "Day changed to xxx" message @@ -1099,7 +1068,7 @@ config_weechat_init () weechat_config_file, ptr_section, "color_nicks_number", "integer", N_("number of colors to use for nicks colors"), - NULL, 1, 10, "10", NULL, NULL, NULL, &config_change_nicks_colors, NULL, NULL, NULL); + NULL, 1, 10, "10", NULL, NULL, NULL, NULL, NULL, NULL, NULL); config_look_color_real_white = config_file_new_option ( weechat_config_file, ptr_section, "color_real_white", "boolean", diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index ec52f2af6..54b029c7c 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -31,6 +31,7 @@ #include "irc-config.h" #include "irc-buffer.h" #include "irc-ignore.h" +#include "irc-nick.h" #include "irc-server.h" #include "irc-channel.h" @@ -87,6 +88,8 @@ struct t_config_option *irc_config_network_send_unknown_commands; struct t_config_option *irc_config_server_default[IRC_CONFIG_NUM_SERVER_OPTIONS]; +struct t_hook *hook_config_color_nicks_number = NULL; + /* * irc_config_search_server_option: search a server option name @@ -139,6 +142,42 @@ irc_config_get_server_from_option_name (const char *name) return ptr_server; } +/* + * irc_config_change_look_color_nicks_number: called when the + * "weechat.look.color_nicks_number" + * option is changed + */ + +int +irc_config_change_look_color_nicks_number (void *data, const char *option, + const char *value) +{ + 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; + (void) value; + + 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) + { + ptr_nick->color = irc_nick_find_color (ptr_nick); + } + } + } + + return WEECHAT_RC_OK; +} + /* * irc_config_change_look_one_server_buffer: called when the "one server buffer" * option is changed @@ -1285,6 +1324,9 @@ irc_config_init () irc_config_section_server = ptr_section; + hook_config_color_nicks_number = weechat_hook_config ("weechat.look.color_nicks_number", + &irc_config_change_look_color_nicks_number, NULL); + return 1; } @@ -1324,4 +1366,10 @@ void irc_config_free () { weechat_config_free (irc_config_file); + + if (hook_config_color_nicks_number) + { + weechat_unhook (hook_config_color_nicks_number); + hook_config_color_nicks_number = NULL; + } } diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h index 34aebafa1..915fe221e 100644 --- a/src/plugins/irc/irc-nick.h +++ b/src/plugins/irc/irc-nick.h @@ -58,6 +58,7 @@ struct t_irc_nick extern int irc_nick_valid (struct t_irc_channel *channel, struct t_irc_nick *nick); +extern const char *irc_nick_find_color (struct t_irc_nick *nick); extern struct t_irc_nick *irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel, const char *nick_name, int is_chanowner,