summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2014-05-15 23:19:58 +0200
committerSébastien Helleu <flashcode@flashtux.org>2014-05-15 23:19:58 +0200
commit540abf0874dc9e38a3acde11c3c4c8705ad4c931 (patch)
treecc11be63985cc9272ed9f02400dfd96afcf83f55 /src
parent85b8e0d82bf99ca2c55a87482ee40b3043df14db (diff)
downloadweechat-540abf0874dc9e38a3acde11c3c4c8705ad4c931.zip
irc: add bar item "irc_nick_modes" (closes #71)
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-bar-item.c41
-rw-r--r--src/plugins/irc/irc-config.c18
-rw-r--r--src/plugins/irc/irc-mode.c4
-rw-r--r--src/plugins/irc/irc-server.c1
4 files changed, 63 insertions, 1 deletions
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;