1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 19:23:13 +02:00

Add new option irc.look.item_away_message

This commit is contained in:
Sebastien Helleu
2010-10-12 08:31:12 +02:00
parent 000a222378
commit 6e695ebe65
17 changed files with 124 additions and 20 deletions
+23 -9
View File
@@ -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;
}
/*
+23
View File
@@ -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;
@@ -241,6 +242,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",
+1
View File
@@ -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;