From 2eebde035a79eacd8696b79910fd469e635b6f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Thu, 18 May 2017 20:34:25 +0200 Subject: buflist: add option "bar" in command /buflist, do not automatically add the bar when buflist is disabled (closes #994) --- src/plugins/buflist/buflist-command.c | 13 ++++++++++--- src/plugins/buflist/buflist.c | 21 ++++++++++++++++----- src/plugins/buflist/buflist.h | 1 + 3 files changed, 27 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/plugins/buflist/buflist-command.c b/src/plugins/buflist/buflist-command.c index 8a006a34b..b3256170f 100644 --- a/src/plugins/buflist/buflist-command.c +++ b/src/plugins/buflist/buflist-command.c @@ -45,6 +45,12 @@ buflist_command_buflist (const void *pointer, void *data, if (argc == 1) return WEECHAT_RC_OK; + if (weechat_strcasecmp (argv[1], "bar") == 0) + { + buflist_add_bar (); + return WEECHAT_RC_OK; + } + if (weechat_strcasecmp (argv[1], "refresh") == 0) { buflist_bar_item_update (); @@ -64,8 +70,9 @@ buflist_command_init () weechat_hook_command ( "buflist", N_("bar item with list of buffers"), - "refresh", - N_("refresh: force the refresh of the \"buflist\" bar item\n" + "bar || refresh", + N_("bar: add the \"buflist\" bar\n" + "refresh: force the refresh of the \"buflist\" bar item\n" "\n" "The lines with buffers are displayed using string evaluation " "(see /help eval for the format), with these options:\n" @@ -115,6 +122,6 @@ buflist_command_init () " - ${hotlist}: the raw hotlist\n" " - ${format_lag}: the lag for an IRC server buffer, empty if " "there's no lag (evaluation of option buflist.format.lag)"), - "refresh", + "bar || refresh", &buflist_command_buflist, NULL, NULL); } diff --git a/src/plugins/buflist/buflist.c b/src/plugins/buflist/buflist.c index 7c98cc7e0..666b8ea64 100644 --- a/src/plugins/buflist/buflist.c +++ b/src/plugins/buflist/buflist.c @@ -45,7 +45,20 @@ struct t_hdata *buflist_hdata_hotlist = NULL; /* - * Get IRC server and channel pointers for a buffer. + * Adds the buflist bar. + */ + +void +buflist_add_bar () +{ + weechat_bar_new (BUFLIST_BAR_NAME, "off", "0", "root", "", "left", + "columns_vertical", "vertical", "0", "0", + "default", "default", "default", "on", + BUFLIST_BAR_ITEM_NAME); +} + +/* + * Gets IRC server and channel pointers for a buffer. * * According to buffer: * - non IRC buffer: both are NULL @@ -443,10 +456,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) buflist_command_init (); - weechat_bar_new (BUFLIST_BAR_NAME, "off", "0", "root", "", "left", - "columns_vertical", "vertical", "0", "0", - "default", "default", "default", "on", - BUFLIST_BAR_ITEM_NAME); + if (weechat_config_boolean (buflist_config_look_enabled)) + buflist_add_bar (); buflist_bar_item_update (); diff --git a/src/plugins/buflist/buflist.h b/src/plugins/buflist/buflist.h index a998dfed4..94dc7bd33 100644 --- a/src/plugins/buflist/buflist.h +++ b/src/plugins/buflist/buflist.h @@ -33,6 +33,7 @@ extern struct t_weechat_plugin *weechat_buflist_plugin; extern struct t_hdata *buflist_hdata_buffer; extern struct t_hdata *buflist_hdata_hotlist; +extern void buflist_add_bar (); extern void buflist_buffer_get_irc_pointers(struct t_gui_buffer *buffer, struct t_irc_server **server, struct t_irc_channel **channel); -- cgit v1.2.3