mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 16:53:14 +02:00
Add new bar item "away" (now displayed by default in input bar)
This commit is contained in:
@@ -32,6 +32,34 @@
|
||||
#include "irc-channel.h"
|
||||
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user