diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/irc/irc-bar-item.c | 45 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 4 |
2 files changed, 34 insertions, 15 deletions
diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c index dcfeb0420..1223c2893 100644 --- a/src/plugins/irc/irc-bar-item.c +++ b/src/plugins/irc/irc-bar-item.c @@ -33,6 +33,34 @@ /* + * irc_bar_item_away: bar item with away indicator + */ + +char * +irc_bar_item_away (void *data, struct t_gui_bar_item *item, + struct t_gui_window *window) +{ + struct t_gui_buffer *buffer; + struct t_irc_server *server; + + /* make C compiler happy */ + (void) data; + (void) item; + + buffer = weechat_window_get_pointer (window, "buffer"); + + if (buffer) + { + irc_buffer_get_server_channel (buffer, &server, NULL); + + if (server && server->is_away) + return strdup (_("away")); + } + + return NULL; +} + +/* * irc_bar_item_buffer_title: bar item with buffer title */ @@ -77,7 +105,7 @@ 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], away[128]; + char buf[512], buf_name[256], modes[128]; const char *name; int part_from_channel; struct t_gui_buffer *buffer; @@ -93,7 +121,6 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item, buf_name[0] = '\0'; modes[0] = '\0'; - away[0] = '\0'; buffer = weechat_window_get_pointer (window, "buffer"); @@ -154,14 +181,6 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item, } } } - if (server && server->is_away) - { - snprintf (away, sizeof (away), " %s(%s%s%s)", - IRC_COLOR_BAR_DELIM, - IRC_COLOR_BAR_FG, - _("away"), - IRC_COLOR_BAR_DELIM); - } } else { @@ -170,11 +189,10 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item, snprintf (buf_name, sizeof (buf_name), "%s", name); } - snprintf (buf, sizeof (buf), "%s%s%s%s", + snprintf (buf, sizeof (buf), "%s%s%s", IRC_COLOR_STATUS_NAME, buf_name, - modes, - away); + modes); return strdup (buf); } @@ -283,6 +301,7 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item, 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_name", &irc_bar_item_buffer_name, NULL); weechat_bar_item_new ("lag", &irc_bar_item_lag, NULL); diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 7fa8cb446..15e4cee62 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -2670,7 +2670,7 @@ irc_protocol_cmd_305 (struct t_irc_server *server, const char *command, server->is_away = 0; server->away_time = 0; - weechat_bar_item_update ("buffer_name"); + weechat_bar_item_update ("away"); return WEECHAT_RC_OK; } @@ -2704,7 +2704,7 @@ irc_protocol_cmd_306 (struct t_irc_server *server, const char *command, server->is_away = 1; server->away_time = time (NULL); - weechat_bar_item_update ("buffer_name"); + weechat_bar_item_update ("away"); return WEECHAT_RC_OK; } |