diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2014-05-15 23:19:58 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2014-05-15 23:19:58 +0200 |
commit | 540abf0874dc9e38a3acde11c3c4c8705ad4c931 (patch) | |
tree | cc11be63985cc9272ed9f02400dfd96afcf83f55 | |
parent | 85b8e0d82bf99ca2c55a87482ee40b3043df14db (diff) | |
download | weechat-540abf0874dc9e38a3acde11c3c4c8705ad4c931.zip |
irc: add bar item "irc_nick_modes" (closes #71)
-rw-r--r-- | ChangeLog.asciidoc | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-bar-item.c | 41 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 18 | ||||
-rw-r--r-- | src/plugins/irc/irc-mode.c | 4 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 1 |
5 files changed, 64 insertions, 1 deletions
diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index 0f65f2e60..8f01838eb 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -104,6 +104,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] * alias: change default command for alias /beep to "/print -beep" * exec: add exec plugin: new command /exec and file exec.conf * guile: fix module used after unload of a script +* irc: add bar item "irc_nick_modes" (closes #71) * irc: make reason optional in command /kill * irc: add support of message 324 (channel modes) in option irc.look.display_join_message (closes #75) diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c index e98292d39..0e84023f8 100644 --- a/src/plugins/irc/irc-bar-item.c +++ b/src/plugins/irc/irc-bar-item.c @@ -504,6 +504,45 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item, } /* + * Returns content of bar item "nick_modes": bar item with nick modes. + */ + +char * +irc_bar_item_nick_modes (void *data, struct t_gui_bar_item *item, + struct t_gui_window *window, + struct t_gui_buffer *buffer, + struct t_hashtable *extra_info) +{ + struct t_irc_server *server; + char *buf; + int length; + + /* make C compiler happy */ + (void) data; + (void) item; + (void) window; + (void) extra_info; + + if (!buffer) + return NULL; + + irc_buffer_get_server_and_channel (buffer, &server, NULL); + if (!server || !server->nick_modes || !server->nick_modes[0]) + return NULL; + + length = 64 + strlen (server->nick_modes) + 1; + buf = malloc (length); + if (buf) + { + snprintf (buf, length, "%s%s", + IRC_COLOR_ITEM_NICK_MODES, + server->nick_modes); + } + + return buf; +} + +/* * Focus on nicklist. */ @@ -570,6 +609,7 @@ irc_bar_item_buffer_switch (void *data, const char *signal, weechat_bar_item_update ("irc_channel"); weechat_bar_item_update ("lag"); weechat_bar_item_update ("input_prompt"); + weechat_bar_item_update ("irc_nick_modes"); return WEECHAT_RC_OK; } @@ -589,6 +629,7 @@ irc_bar_item_init () weechat_bar_item_new ("irc_channel", &irc_bar_item_channel, NULL); weechat_bar_item_new ("lag", &irc_bar_item_lag, NULL); weechat_bar_item_new ("input_prompt", &irc_bar_item_input_prompt, NULL); + weechat_bar_item_new ("irc_nick_modes", &irc_bar_item_nick_modes, NULL); weechat_hook_focus ("buffer_nicklist", &irc_bar_item_focus_buffer_nicklist, NULL); weechat_hook_signal ("buffer_switch", diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index fe13a7671..5329063e1 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -719,6 +719,22 @@ irc_config_change_color_item_lag (void *data, } /* + * Callback for changes on option "irc.color.item_nick_modes". + */ + +void +irc_config_change_color_item_nick_modes (void *data, + struct t_config_option *option) +{ + /* make C compiler happy */ + (void) data; + (void) option; + + weechat_bar_item_update ("input_prompt"); + weechat_bar_item_update ("irc_nick_modes"); +} + +/* * Callback for changes on option "irc.color.mirc_remap". */ @@ -2714,7 +2730,7 @@ irc_config_init () "item_nick_modes", "color", N_("color for nick modes in bar item \"input_prompt\""), NULL, -1, 0, "default", NULL, 0, NULL, NULL, - &irc_config_change_bar_item_input_prompt, NULL, NULL, NULL); + &irc_config_change_color_item_nick_modes, NULL, NULL, NULL); irc_config_color_message_join = weechat_config_new_option ( irc_config_file, ptr_section, "message_join", "color", diff --git a/src/plugins/irc/irc-mode.c b/src/plugins/irc/irc-mode.c index 98a1936b3..b0b9230fb 100644 --- a/src/plugins/irc/irc-mode.c +++ b/src/plugins/irc/irc-mode.c @@ -503,6 +503,7 @@ irc_mode_user_add (struct t_irc_server *server, char mode) server->nick_modes = nick_modes2; strcat (server->nick_modes, str_mode); weechat_bar_item_update ("input_prompt"); + weechat_bar_item_update ("irc_nick_modes"); } } else @@ -510,6 +511,7 @@ irc_mode_user_add (struct t_irc_server *server, char mode) server->nick_modes = malloc (2); strcpy (server->nick_modes, str_mode); weechat_bar_item_update ("input_prompt"); + weechat_bar_item_update ("irc_nick_modes"); } } @@ -534,6 +536,7 @@ irc_mode_user_remove (struct t_irc_server *server, char mode) if (nick_modes2) server->nick_modes = nick_modes2; weechat_bar_item_update ("input_prompt"); + weechat_bar_item_update ("irc_nick_modes"); } } } @@ -586,4 +589,5 @@ irc_mode_user_set (struct t_irc_server *server, const char *modes, modes++; } weechat_bar_item_update ("input_prompt"); + weechat_bar_item_update ("irc_nick_modes"); } diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 84620e237..f94a7c01b 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -4333,6 +4333,7 @@ irc_server_disconnect (struct t_irc_server *server, int switch_address, free (server->nick_modes); server->nick_modes = NULL; weechat_bar_item_update ("input_prompt"); + weechat_bar_item_update ("irc_nick_modes"); } server->cap_away_notify = 0; server->is_away = 0; |