summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-03-26 18:58:00 +0100
committerSebastien Helleu <flashcode@flashtux.org>2009-03-26 18:58:00 +0100
commit6e7b62be9723205cb4f7dc69966ed80ed7119dd6 (patch)
tree9c27766e96d678446a6f3c4df47eb3f393ce856f
parent5046e49747444b6e3f218b80252d97f871f8bb0e (diff)
downloadweechat-6e7b62be9723205cb4f7dc69966ed80ed7119dd6.zip
Add new bar item "away" (now displayed by default in input bar)
-rw-r--r--src/gui/gui-bar.c6
-rw-r--r--src/plugins/irc/irc-bar-item.c45
-rw-r--r--src/plugins/irc/irc-protocol.c4
3 files changed, 38 insertions, 17 deletions
diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c
index c6c73c674..77a7db154 100644
--- a/src/gui/gui-bar.c
+++ b/src/gui/gui-bar.c
@@ -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],
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;
}