1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 15:26:37 +02:00

Add new bar item "away" (now displayed by default in input bar)

This commit is contained in:
Sebastien Helleu
2009-03-26 18:58:00 +01:00
parent 5046e49747
commit 6e7b62be97
3 changed files with 38 additions and 17 deletions
+4 -2
View File
@@ -1878,7 +1878,9 @@ gui_bar_create_default_input ()
+ strlen (gui_bar_item_names[GUI_BAR_ITEM_INPUT_PASTE])
+ 3 /* "],[" */
+ strlen (gui_bar_item_names[GUI_BAR_ITEM_INPUT_PROMPT])
+ 3 /* "],[" */
+ 3 /* "]+(" */
+ 4 /* "away" */
+ 3 /* "),[" */
+ strlen (gui_bar_item_names[GUI_BAR_ITEM_INPUT_SEARCH])
+ 2 /* "]," */
+ strlen (gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT])
@@ -1886,7 +1888,7 @@ gui_bar_create_default_input ()
buf = malloc (length);
if (buf)
{
snprintf (buf, length, "[%s],[%s],[%s],%s",
snprintf (buf, length, "[%s],[%s]+(away),[%s],%s",
gui_bar_item_names[GUI_BAR_ITEM_INPUT_PASTE],
gui_bar_item_names[GUI_BAR_ITEM_INPUT_PROMPT],
gui_bar_item_names[GUI_BAR_ITEM_INPUT_SEARCH],
+32 -13
View File
@@ -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);
+2 -2
View File
@@ -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;
}