diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2014-10-31 07:48:46 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2014-10-31 07:48:46 +0100 |
commit | 013165209af818daba6b6c5869e822ec9cb86fc3 (patch) | |
tree | 049ac0139e14c43033d6c1ab9fcfe1988acd3359 /src | |
parent | 3d791fb806e6ef564f7623d1ca364693e08a495c (diff) | |
download | weechat-013165209af818daba6b6c5869e822ec9cb86fc3.zip |
irc: remove IRC color codes from buffer title in channels (closes #237)
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/irc/irc-bar-item.c | 35 | ||||
-rw-r--r-- | src/plugins/irc/irc-channel.c | 25 | ||||
-rw-r--r-- | src/plugins/irc/irc-channel.h | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 14 |
4 files changed, 36 insertions, 39 deletions
diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c index 3ac0d466f..26cbbd3e9 100644 --- a/src/plugins/irc/irc-bar-item.c +++ b/src/plugins/irc/irc-bar-item.c @@ -88,39 +88,6 @@ irc_bar_item_away (void *data, struct t_gui_bar_item *item, } /* - * Returns content of bar item "buffer_title": bar item with buffer title. - */ - -char * -irc_bar_item_buffer_title (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - struct t_gui_buffer *buffer, - struct t_hashtable *extra_info) -{ - const char *title; - char *title_color; - - /* make C compiler happy */ - (void) data; - (void) item; - (void) window; - (void) extra_info; - - if (!buffer) - return NULL; - - title = weechat_buffer_get_string (buffer, "title"); - if (!title) - return NULL; - - title_color = irc_color_decode (title, - (weechat_config_boolean (irc_config_look_topic_strip_colors)) ? - 0 : 1); - - return (title_color) ? title_color : strdup (title); -} - -/* * Returns content of bar item "buffer_plugin": bar item with buffer plugin. */ @@ -634,7 +601,6 @@ irc_bar_item_buffer_switch (void *data, const char *signal, (void) signal_data; weechat_bar_item_update ("away"); - weechat_bar_item_update ("buffer_title"); weechat_bar_item_update ("buffer_name"); weechat_bar_item_update ("buffer_short_name"); weechat_bar_item_update ("buffer_modes"); @@ -666,7 +632,6 @@ void irc_bar_item_init () { weechat_bar_item_new ("away", &irc_bar_item_away, NULL); - weechat_bar_item_new ("buffer_title", &irc_bar_item_buffer_title, NULL); weechat_bar_item_new ("buffer_plugin", &irc_bar_item_buffer_plugin, NULL); weechat_bar_item_new ("buffer_name", &irc_bar_item_buffer_name, NULL); weechat_bar_item_new ("buffer_short_name", &irc_bar_item_buffer_short_name, NULL); diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index 739e7cc80..ed6ffb848 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -389,6 +389,26 @@ irc_channel_add_nicklist_groups (struct t_irc_server *server, } /* + * Sets the buffer title with the channel topic. + */ + +void +irc_channel_set_buffer_title (struct t_irc_channel *channel) +{ + char *title_color; + + if (channel->topic) + { + title_color = irc_color_decode ( + channel->topic, + (weechat_config_boolean (irc_config_look_topic_strip_colors)) ? 0 : 1); + weechat_buffer_set (channel->buffer, "title", title_color); + } + else + weechat_buffer_set (channel->buffer, "title", ""); +} + +/* * Sets topic for a channel. */ @@ -397,10 +417,9 @@ irc_channel_set_topic (struct t_irc_channel *channel, const char *topic) { if (channel->topic) free (channel->topic); - channel->topic = (topic) ? strdup (topic) : NULL; - weechat_buffer_set (channel->buffer, "title", - (channel->topic) ? channel->topic : ""); + + irc_channel_set_buffer_title (channel); } /* diff --git a/src/plugins/irc/irc-channel.h b/src/plugins/irc/irc-channel.h index 65d319320..2d91e1907 100644 --- a/src/plugins/irc/irc-channel.h +++ b/src/plugins/irc/irc-channel.h @@ -85,6 +85,7 @@ extern struct t_irc_channel *irc_channel_new (struct t_irc_server *server, int auto_switch); extern void irc_channel_add_nicklist_groups (struct t_irc_server *server, struct t_irc_channel *channel); +extern void irc_channel_set_buffer_title (struct t_irc_channel *channel); extern void irc_channel_set_topic (struct t_irc_channel *channel, const char *topic); extern void irc_channel_set_modes (struct t_irc_channel *channel, diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index d8b91abaf..177be4b6a 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -652,11 +652,23 @@ void irc_config_change_look_topic_strip_colors (void *data, struct t_config_option *option) { + struct t_irc_server *ptr_server; + struct t_irc_channel *ptr_channel; + /* make C compiler happy */ (void) data; (void) option; - weechat_bar_item_update ("buffer_title"); + 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) + { + if (ptr_channel->buffer) + irc_channel_set_buffer_title (ptr_channel); + } + } } /* |