summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-10-12 08:31:12 +0200
committerSebastien Helleu <flashcode@flashtux.org>2010-10-12 08:31:12 +0200
commit6e695ebe65f1dd6304b0a2b8b25c5b285d60a251 (patch)
tree28ae1e06f7f75f003b1cdbc8c37cd149bfda1ea9 /src/plugins
parent000a222378eb5ec9134ba9b8c19f5bddb2f50c0f (diff)
downloadweechat-6e695ebe65f1dd6304b0a2b8b25c5b285d60a251.zip
Add new option irc.look.item_away_message
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/irc/irc-bar-item.c32
-rw-r--r--src/plugins/irc/irc-config.c23
-rw-r--r--src/plugins/irc/irc-config.h1
3 files changed, 47 insertions, 9 deletions
diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c
index 78a890822..1deec1b6f 100644
--- a/src/plugins/irc/irc-bar-item.c
+++ b/src/plugins/irc/irc-bar-item.c
@@ -45,13 +45,15 @@ irc_bar_item_away (void *data, struct t_gui_bar_item *item,
{
struct t_gui_buffer *buffer;
struct t_irc_server *server;
- char *buf;
+ char *buf, *message;
int length;
/* make C compiler happy */
(void) data;
(void) item;
+ buf = NULL;
+
buffer = weechat_window_get_pointer (window, "buffer");
if (buffer)
@@ -60,19 +62,31 @@ irc_bar_item_away (void *data, struct t_gui_bar_item *item,
if (server && server->is_away)
{
- length = strlen (_("away")) + 64 + 1;
- buf = malloc (length);
- if (buf)
+ if (weechat_config_boolean (irc_config_look_item_away_message)
+ && server->away_message && server->away_message[0])
{
- snprintf (buf, length, "%s%s",
- IRC_COLOR_ITEM_AWAY,
- _("away"));
- return buf;
+ message = strdup (server->away_message);
+ }
+ else
+ {
+ message = strdup (_("away"));
+ }
+ if (message)
+ {
+ length = strlen (message) + 64 + 1;
+ buf = malloc (length);
+ if (buf)
+ {
+ snprintf (buf, length, "%s%s",
+ IRC_COLOR_ITEM_AWAY,
+ message);
+ }
+ free (message);
}
}
}
- return NULL;
+ return buf;
}
/*
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index 2b99e9b46..f5122d908 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -67,6 +67,7 @@ struct t_config_option *irc_config_look_display_host_quit;
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;
@@ -242,6 +243,22 @@ irc_config_change_look_server_buffer (void *data,
}
/*
+ * irc_config_change_look_item_away_message: called when the "item
+ * away message" option is changed
+ */
+
+void
+irc_config_change_look_item_away_message (void *data,
+ struct t_config_option *option)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) option;
+
+ weechat_bar_item_update ("away");
+}
+
+/*
* irc_config_change_look_item_channel_modes: called when the "display
* channel modes" option is changed
*/
@@ -1701,6 +1718,12 @@ irc_config_init ()
N_("display a message in private when user is back (after quit on "
"server)"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_look_item_away_message = weechat_config_new_option (
+ irc_config_file, ptr_section,
+ "item_away_message", "boolean",
+ 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",
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index e83bd8b1b..89310215c 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -93,6 +93,7 @@ extern struct t_config_option *irc_config_look_display_host_quit;
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;