diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/irc/irc-bar-item.c | 98 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 42 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.h | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-mode.c | 2 |
4 files changed, 78 insertions, 65 deletions
diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c index 3c2490de5..48f647d63 100644 --- a/src/plugins/irc/irc-bar-item.c +++ b/src/plugins/irc/irc-bar-item.c @@ -192,8 +192,8 @@ char * irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item, struct t_gui_window *window) { - char buf[512], buf_name[256], modes[128], *modes_without_args; - const char *name, *pos_space, *pos_key; + char buf[512], buf_name[256], modes[128]; + const char *name; int part_from_channel, display_server; struct t_gui_buffer *buffer; struct t_irc_server *server; @@ -245,34 +245,6 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item, channel->name, (part_from_channel) ? IRC_COLOR_BAR_DELIM : "", (part_from_channel) ? ")" : ""); - if (!part_from_channel - && weechat_config_boolean (irc_config_look_item_channel_modes) - && channel->modes && channel->modes[0] - && (strcmp (channel->modes, "+") != 0)) - { - modes_without_args = NULL; - if (weechat_config_boolean (irc_config_look_item_channel_modes_hide_key)) - { - pos_space = strchr(channel->modes, ' '); - if (pos_space) - { - pos_key = strchr(channel->modes, 'k'); - if (pos_key && (pos_key < pos_space)) - { - modes_without_args = weechat_strndup(channel->modes, - pos_space - channel->modes); - } - } - } - snprintf (modes, sizeof (modes), - "%s(%s%s%s)", - IRC_COLOR_BAR_DELIM, - IRC_COLOR_ITEM_CHANNEL_MODES, - (modes_without_args) ? modes_without_args : channel->modes, - IRC_COLOR_BAR_DELIM); - if (modes_without_args) - free (modes_without_args); - } } } } @@ -294,6 +266,70 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item, } /* + * irc_bar_item_buffer_modes: bar item with buffer modes + */ + +char * +irc_bar_item_buffer_modes (void *data, struct t_gui_bar_item *item, + struct t_gui_window *window) +{ + char modes[128], *modes_without_args; + const char *pos_space, *pos_key; + int part_from_channel; + struct t_gui_buffer *buffer; + struct t_irc_server *server; + struct t_irc_channel *channel; + + /* make C compiler happy */ + (void) data; + (void) item; + + if (!window) + window = weechat_current_window (); + + modes[0] = '\0'; + + buffer = weechat_window_get_pointer (window, "buffer"); + if (!buffer) + return NULL; + + irc_buffer_get_server_and_channel (buffer, &server, &channel); + if (!channel) + return NULL; + + part_from_channel = ((channel->type == IRC_CHANNEL_TYPE_CHANNEL) + && !channel->nicks); + if (!part_from_channel + && channel->modes && channel->modes[0] + && (strcmp (channel->modes, "+") != 0)) + { + modes_without_args = NULL; + if (weechat_config_boolean (irc_config_look_item_channel_modes_hide_key)) + { + pos_space = strchr(channel->modes, ' '); + if (pos_space) + { + pos_key = strchr(channel->modes, 'k'); + if (pos_key && (pos_key < pos_space)) + { + modes_without_args = weechat_strndup (channel->modes, + pos_space - channel->modes); + } + } + } + snprintf (modes, sizeof (modes), + "%s%s", + IRC_COLOR_ITEM_CHANNEL_MODES, + (modes_without_args) ? modes_without_args : channel->modes); + if (modes_without_args) + free (modes_without_args); + return strdup (modes); + } + + return NULL; +} + +/* * irc_bar_item_channel: bar item with channel name (without modes) */ @@ -562,6 +598,7 @@ irc_bar_item_buffer_switch (void *data, const char *signal, weechat_bar_item_update ("away"); weechat_bar_item_update ("buffer_title"); weechat_bar_item_update ("buffer_name"); + weechat_bar_item_update ("buffer_modes"); weechat_bar_item_update ("irc_channel"); weechat_bar_item_update ("lag"); weechat_bar_item_update ("input_prompt"); @@ -580,6 +617,7 @@ irc_bar_item_init () 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_modes", &irc_bar_item_buffer_modes, NULL); weechat_bar_item_new ("irc_channel", &irc_bar_item_channel, NULL); weechat_bar_item_new ("lag", &irc_bar_item_lag, NULL); weechat_bar_item_new ("input_prompt", &irc_bar_item_input_prompt, NULL); diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 4e695140f..046c21ee5 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -76,7 +76,6 @@ struct t_config_option *irc_config_look_display_old_topic; struct t_config_option *irc_config_look_display_pv_away_once; struct t_config_option *irc_config_look_display_pv_back; struct t_config_option *irc_config_look_item_away_message; -struct t_config_option *irc_config_look_item_channel_modes; struct t_config_option *irc_config_look_item_channel_modes_hide_key; struct t_config_option *irc_config_look_item_nick_modes; struct t_config_option *irc_config_look_item_nick_prefix; @@ -334,22 +333,6 @@ irc_config_change_look_item_away_message (void *data, } /* - * irc_config_change_look_item_channel_modes: called when the "display - * channel modes" option is changed - */ - -void -irc_config_change_look_item_channel_modes (void *data, - struct t_config_option *option) -{ - /* make C compiler happy */ - (void) data; - (void) option; - - weechat_bar_item_update ("buffer_name"); -} - -/* * irc_config_change_look_item_channel_modes_hide_key: called when the * "display channel modes * hide key" option is @@ -364,7 +347,7 @@ irc_config_change_look_item_channel_modes_hide_key (void *data, (void) data; (void) option; - weechat_bar_item_update ("buffer_name"); + weechat_bar_item_update ("buffer_modes"); } /* @@ -566,19 +549,19 @@ irc_config_change_color_item_away (void *data, } /* - * irc_config_change_color_item_buffer_name: called when the color of buffer - * name is changed + * irc_config_change_color_item_buffer_modes: called when the color of buffer + * modes is changed */ void -irc_config_change_color_item_buffer_name (void *data, - struct t_config_option *option) +irc_config_change_color_item_buffer_modes (void *data, + struct t_config_option *option) { /* make C compiler happy */ (void) data; (void) option; - weechat_bar_item_update ("buffer_name"); + weechat_bar_item_update ("buffer_modes"); } /* @@ -2181,18 +2164,11 @@ irc_config_init () N_("display server away message in away bar item"), NULL, 0, 0, "on", NULL, 0, NULL, NULL, &irc_config_change_look_item_away_message, NULL, NULL, NULL); - irc_config_look_item_channel_modes = weechat_config_new_option ( - irc_config_file, ptr_section, - "item_channel_modes", "boolean", - N_("display channel modes in \"buffer_name\" bar item"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, - &irc_config_change_look_item_channel_modes, NULL, NULL, NULL); irc_config_look_item_channel_modes_hide_key = weechat_config_new_option ( irc_config_file, ptr_section, "item_channel_modes_hide_key", "boolean", - N_("hide channel key if modes are displayed in \"buffer_name\" bar " - "item (this will hide all channel modes arguments if mode +k is " - "set on channel)"), + N_("hide channel key in channel modes (this will hide all channel modes " + "arguments if mode +k is set on channel)"), NULL, 0, 0, "off", NULL, 0, NULL, NULL, &irc_config_change_look_item_channel_modes_hide_key, NULL, NULL, NULL); irc_config_look_item_nick_modes = weechat_config_new_option ( @@ -2428,7 +2404,7 @@ irc_config_init () "item_channel_modes", "color", N_("color for channel modes, near channel name"), NULL, -1, 0, "default", NULL, 0, NULL, NULL, - &irc_config_change_color_item_buffer_name, NULL, NULL, NULL); + &irc_config_change_color_item_buffer_modes, NULL, NULL, NULL); irc_config_color_item_lag_counting = weechat_config_new_option ( irc_config_file, ptr_section, "item_lag_counting", "color", diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index 213ddb9c8..1d03a8b37 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -101,7 +101,6 @@ extern struct t_config_option *irc_config_look_display_old_topic; extern struct t_config_option *irc_config_look_display_pv_away_once; extern struct t_config_option *irc_config_look_display_pv_back; extern struct t_config_option *irc_config_look_item_away_message; -extern struct t_config_option *irc_config_look_item_channel_modes; extern struct t_config_option *irc_config_look_item_channel_modes_hide_key; extern struct t_config_option *irc_config_look_item_nick_modes; extern struct t_config_option *irc_config_look_item_nick_prefix; diff --git a/src/plugins/irc/irc-mode.c b/src/plugins/irc/irc-mode.c index 29970ea3e..5e97fac77 100644 --- a/src/plugins/irc/irc-mode.c +++ b/src/plugins/irc/irc-mode.c @@ -396,7 +396,7 @@ irc_mode_channel_set (struct t_irc_server *server, weechat_string_free_split (argv); if (channel_modes_updated) - weechat_bar_item_update ("buffer_name"); + weechat_bar_item_update ("buffer_modes"); } /* |