summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-06-11 19:03:27 +0200
committerSebastien Helleu <flashcode@flashtux.org>2009-06-11 19:03:27 +0200
commita06fa73ba82b9b7f69b5eb442087be39ea4dfd1e (patch)
tree1f0dcf51aeeb84a579055fe3a53171ecdf363c11 /src
parentec5c3aa3cc1970240f5d3afa05f50bcccc584744 (diff)
downloadweechat-a06fa73ba82b9b7f69b5eb442087be39ea4dfd1e.zip
Add option irc.look.item_display_server to display server with plugin or name in status bar
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-bar-item.c67
-rw-r--r--src/plugins/irc/irc-config.c25
-rw-r--r--src/plugins/irc/irc-config.h7
3 files changed, 95 insertions, 4 deletions
diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c
index 2292a6edd..fe32b1e76 100644
--- a/src/plugins/irc/irc-bar-item.c
+++ b/src/plugins/irc/irc-bar-item.c
@@ -110,6 +110,61 @@ irc_bar_item_buffer_title (void *data, struct t_gui_bar_item *item,
}
/*
+ * irc_bar_item_buffer_plugin: bar item with buffer plugin
+ */
+
+char *
+irc_bar_item_buffer_plugin (void *data, struct t_gui_bar_item *item,
+ struct t_gui_window *window)
+{
+ char buf[512];
+ struct t_gui_buffer *buffer;
+ struct t_weechat_plugin *ptr_plugin;
+ const char *name;
+ struct t_irc_server *server;
+ struct t_irc_channel *channel;
+
+ /* make C compiler happy */
+ (void) data;
+ (void) item;
+
+ if (!window)
+ window = weechat_current_window ();
+
+ buffer = weechat_window_get_pointer (window, "buffer");
+
+ if (buffer)
+ {
+ ptr_plugin = weechat_buffer_get_pointer (buffer, "plugin");
+ name = weechat_plugin_get_name (ptr_plugin);
+ if (ptr_plugin == weechat_irc_plugin)
+ {
+ irc_buffer_get_server_channel (buffer, &server, &channel);
+ if (server && channel
+ && (weechat_config_integer (irc_config_look_item_display_server) == IRC_CONFIG_LOOK_ITEM_DISPLAY_SERVER_PLUGIN))
+ {
+ snprintf (buf, sizeof (buf), "%s%s/%s%s",
+ name,
+ IRC_COLOR_BAR_DELIM,
+ IRC_COLOR_BAR_FG,
+ server->name);
+ }
+ else
+ {
+ snprintf (buf, sizeof (buf), "%s", name);
+ }
+ }
+ else
+ {
+ snprintf (buf, sizeof (buf), "%s", name);
+ }
+ return strdup (buf);
+ }
+
+ return NULL;
+}
+
+/*
* irc_bar_item_buffer_name: bar item with buffer name
*/
@@ -119,7 +174,7 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
{
char buf[512], buf_name[256], modes[128];
const char *name;
- int part_from_channel;
+ int part_from_channel, display_server;
struct t_gui_buffer *buffer;
struct t_irc_server *server;
struct t_irc_channel *channel;
@@ -134,6 +189,8 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
buf_name[0] = '\0';
modes[0] = '\0';
+ display_server = (weechat_config_integer (irc_config_look_item_display_server) == IRC_CONFIG_LOOK_ITEM_DISPLAY_SERVER_NAME);
+
buffer = weechat_window_get_pointer (window, "buffer");
if (buffer)
@@ -157,12 +214,13 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
part_from_channel = ((channel->type == IRC_CHANNEL_TYPE_CHANNEL)
&& !channel->nicks);
snprintf (buf_name, sizeof (buf_name),
- "%s%s%s%s%s/%s%s%s%s",
+ "%s%s%s%s%s%s%s%s%s%s",
(part_from_channel) ? IRC_COLOR_BAR_DELIM : "",
(part_from_channel) ? "(" : "",
IRC_COLOR_STATUS_NAME,
- server->name,
- IRC_COLOR_BAR_DELIM,
+ (display_server) ? server->name : "",
+ (display_server) ? IRC_COLOR_BAR_DELIM : "",
+ (display_server) ? "/" : "",
IRC_COLOR_STATUS_NAME,
channel->name,
(part_from_channel) ? IRC_COLOR_BAR_DELIM : "",
@@ -303,6 +361,7 @@ 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_plugin", &irc_bar_item_buffer_plugin, NULL);
weechat_bar_item_new ("buffer_name", &irc_bar_item_buffer_name, NULL);
weechat_bar_item_new ("lag", &irc_bar_item_lag, NULL);
weechat_bar_item_new ("input_prompt", &irc_bar_item_input_prompt, NULL);
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index b0fa3c072..b1f37aec7 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -54,6 +54,7 @@ struct t_config_option *irc_config_look_display_nick_modes;
struct t_config_option *irc_config_look_display_old_topic;
struct t_config_option *irc_config_look_hide_nickserv_pwd;
struct t_config_option *irc_config_look_highlight_tags;
+struct t_config_option *irc_config_look_item_display_server;
struct t_config_option *irc_config_look_notice_as_pv;
struct t_config_option *irc_config_look_raw_messages;
struct t_config_option *irc_config_look_show_away_once;
@@ -269,6 +270,24 @@ irc_config_change_look_highlight_tags (void *data,
}
/*
+ * irc_config_change_look_item_display_server: called when the
+ * "item_display_server" option is
+ * changed
+ */
+
+void
+irc_config_change_look_item_display_server (void *data,
+ struct t_config_option *option)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) option;
+
+ weechat_bar_item_update ("buffer_plugin");
+ weechat_bar_item_update ("buffer_name");
+}
+
+/*
* irc_config_change_look_topic_strip_colors: called when the "topic strip colors"
* option is changed
*/
@@ -1137,6 +1156,12 @@ irc_config_init ()
"messages,..)"),
NULL, 0, 0, "irc_privmsg,irc_notice", NULL, 0, NULL, NULL,
&irc_config_change_look_highlight_tags, NULL, NULL, NULL);
+ irc_config_look_item_display_server = weechat_config_new_option (
+ irc_config_file, ptr_section,
+ "item_display_server", "integer",
+ N_("name of bar item where IRC server is displayed (for status bar)"),
+ "buffer_plugin|buffer_name", 0, 0, "buffer_plugin", NULL, 0, NULL, NULL,
+ &irc_config_change_look_item_display_server, NULL, NULL, NULL);
irc_config_look_raw_messages = weechat_config_new_option (
irc_config_file, ptr_section,
"raw_messages", "integer",
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index d79e15b7b..2071824af 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -29,6 +29,12 @@ enum t_irc_config_look_server_buffer
IRC_CONFIG_LOOK_SERVER_BUFFER_INDEPENDENT,
};
+enum t_irc_config_look_item_display_server
+{
+ IRC_CONFIG_LOOK_ITEM_DISPLAY_SERVER_PLUGIN = 0,
+ IRC_CONFIG_LOOK_ITEM_DISPLAY_SERVER_NAME,
+};
+
enum t_irc_config_nick_completion
{
IRC_CONFIG_NICK_COMPLETION_SMART_OFF = 0,
@@ -59,6 +65,7 @@ extern struct t_config_option *irc_config_look_display_nick_modes;
extern struct t_config_option *irc_config_look_display_old_topic;
extern struct t_config_option *irc_config_look_hide_nickserv_pwd;
extern struct t_config_option *irc_config_look_highlight_tags;
+extern struct t_config_option *irc_config_look_item_display_server;
extern struct t_config_option *irc_config_look_notice_as_pv;
extern struct t_config_option *irc_config_look_raw_messages;
extern struct t_config_option *irc_config_look_show_away_once;