1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 04:46:37 +02:00

Add option irc.look.item_display_server to display server with plugin or name in status bar

This commit is contained in:
Sebastien Helleu
2009-06-11 19:03:27 +02:00
parent ec5c3aa3cc
commit a06fa73ba8
13 changed files with 140 additions and 13 deletions
+63 -4
View File
@@ -109,6 +109,61 @@ irc_bar_item_buffer_title (void *data, struct t_gui_bar_item *item,
return NULL;
}
/*
* 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);
+25
View File
@@ -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;
@@ -268,6 +269,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",
+7
View File
@@ -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;