mirror of
https://github.com/weechat/weechat.git
synced 2026-07-06 01:33:12 +02:00
buflist: add option buflist.look.enabled
This commit is contained in:
@@ -37,6 +37,17 @@ struct t_hashtable *buflist_hashtable_options_conditions = NULL;
|
||||
struct t_arraylist *buflist_list_buffers = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Updates buflist bar item if buflist is enabled.
|
||||
*/
|
||||
|
||||
void
|
||||
buflist_bar_item_update ()
|
||||
{
|
||||
if (weechat_config_boolean (buflist_config_look_enabled))
|
||||
weechat_bar_item_update (BUFLIST_BAR_ITEM_NAME);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns content of bar item "buffer_plugin": bar item with buffer plugin.
|
||||
*/
|
||||
@@ -79,6 +90,9 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
|
||||
(void) buffer;
|
||||
(void) extra_info;
|
||||
|
||||
if (!weechat_config_boolean (buflist_config_look_enabled))
|
||||
return NULL;
|
||||
|
||||
prev_number = -1;
|
||||
|
||||
buflist = weechat_string_dyn_alloc (256);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
extern struct t_arraylist *buflist_list_buffers;
|
||||
|
||||
extern void buflist_bar_item_update ();
|
||||
extern int buflist_bar_item_init ();
|
||||
extern void buflist_bar_item_end ();
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ buflist_command_buflist (const void *pointer, void *data,
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "refresh") == 0)
|
||||
{
|
||||
weechat_bar_item_update (BUFLIST_BAR_ITEM_NAME);
|
||||
buflist_bar_item_update ();
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ struct t_config_file *buflist_config_file = NULL;
|
||||
/* buflist config, look section */
|
||||
|
||||
struct t_config_option *buflist_config_look_display_conditions;
|
||||
struct t_config_option *buflist_config_look_enabled;
|
||||
struct t_config_option *buflist_config_look_mouse_jump_visited_buffer;
|
||||
struct t_config_option *buflist_config_look_mouse_move_buffer;
|
||||
struct t_config_option *buflist_config_look_mouse_wheel;
|
||||
@@ -60,29 +61,6 @@ char **buflist_config_sort_fields = NULL;
|
||||
int buflist_config_sort_fields_count = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Callback for changes on option "buflist.look.sort".
|
||||
*/
|
||||
|
||||
void
|
||||
buflist_config_change_sort (const void *pointer, void *data,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
if (buflist_config_sort_fields)
|
||||
weechat_string_free_split (buflist_config_sort_fields);
|
||||
|
||||
buflist_config_sort_fields = weechat_string_split (
|
||||
weechat_config_string (buflist_config_look_sort),
|
||||
",", 0, 0, &buflist_config_sort_fields_count);
|
||||
|
||||
weechat_bar_item_update (BUFLIST_BAR_ITEM_NAME);
|
||||
}
|
||||
|
||||
/*
|
||||
* Frees the signals hooked for refresh.
|
||||
*/
|
||||
@@ -106,27 +84,6 @@ buflist_config_free_signals_refresh ()
|
||||
buflist_config_num_signals_refresh = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for a signal on a buffer.
|
||||
*/
|
||||
|
||||
int
|
||||
buflist_config_signal_buffer_cb (const void *pointer, void *data,
|
||||
const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
(void) signal_data;
|
||||
|
||||
weechat_bar_item_update (BUFLIST_BAR_ITEM_NAME);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compares two signals to add them in the sorted arraylist.
|
||||
*
|
||||
@@ -148,26 +105,38 @@ buflist_config_compare_signals (void *data, struct t_arraylist *arraylist,
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for changes on option "buflist.look.signals_refresh".
|
||||
* Callback for a signal on a buffer.
|
||||
*/
|
||||
|
||||
int
|
||||
buflist_config_signal_buffer_cb (const void *pointer, void *data,
|
||||
const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
(void) signal_data;
|
||||
|
||||
buflist_bar_item_update ();
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Hooks the signals for refresh.
|
||||
*/
|
||||
|
||||
void
|
||||
buflist_config_change_signals_refresh (const void *pointer, void *data,
|
||||
struct t_config_option *option)
|
||||
buflist_config_hook_signals_refresh ()
|
||||
{
|
||||
char **all_signals, **signals;
|
||||
const char *ptr_signals_refresh;
|
||||
struct t_arraylist *signals_list;
|
||||
int count, i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
if (buflist_config_signals_refresh)
|
||||
buflist_config_free_signals_refresh ();
|
||||
|
||||
all_signals = weechat_string_dyn_alloc (256);
|
||||
if (!all_signals)
|
||||
return;
|
||||
@@ -232,6 +201,76 @@ buflist_config_change_signals_refresh (const void *pointer, void *data,
|
||||
weechat_string_dyn_free (all_signals, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for changes on option "buflist.look.enabled".
|
||||
*/
|
||||
|
||||
void
|
||||
buflist_config_change_enabled (const void *pointer, void *data,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
buflist_config_free_signals_refresh ();
|
||||
|
||||
if (weechat_config_boolean (buflist_config_look_enabled))
|
||||
{
|
||||
/* buflist enabled */
|
||||
buflist_config_hook_signals_refresh ();
|
||||
weechat_command (NULL, "/mute /bar show buflist");
|
||||
buflist_bar_item_update ();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* buflist disabled */
|
||||
weechat_command (NULL, "/mute /bar hide buflist");
|
||||
weechat_bar_item_update (BUFLIST_BAR_ITEM_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for changes on option "buflist.look.sort".
|
||||
*/
|
||||
|
||||
void
|
||||
buflist_config_change_sort (const void *pointer, void *data,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
if (buflist_config_sort_fields)
|
||||
weechat_string_free_split (buflist_config_sort_fields);
|
||||
|
||||
buflist_config_sort_fields = weechat_string_split (
|
||||
weechat_config_string (buflist_config_look_sort),
|
||||
",", 0, 0, &buflist_config_sort_fields_count);
|
||||
|
||||
buflist_bar_item_update ();
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for changes on option "buflist.look.signals_refresh".
|
||||
*/
|
||||
|
||||
void
|
||||
buflist_config_change_signals_refresh (const void *pointer, void *data,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
buflist_config_free_signals_refresh ();
|
||||
buflist_config_hook_signals_refresh ();
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for changes on option "buflist.look.nick_prefix".
|
||||
*/
|
||||
@@ -246,7 +285,7 @@ buflist_config_change_nick_prefix (const void *pointer, void *data,
|
||||
(void) option;
|
||||
|
||||
buflist_config_change_signals_refresh (NULL, NULL, NULL);
|
||||
weechat_bar_item_update (BUFLIST_BAR_ITEM_NAME);
|
||||
buflist_bar_item_update ();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -262,7 +301,7 @@ buflist_config_change_buflist (const void *pointer, void *data,
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
weechat_bar_item_update (BUFLIST_BAR_ITEM_NAME);
|
||||
buflist_bar_item_update ();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -309,6 +348,14 @@ buflist_config_init ()
|
||||
NULL, NULL, NULL,
|
||||
&buflist_config_change_buflist, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_look_enabled = weechat_config_new_option (
|
||||
buflist_config_file, ptr_section,
|
||||
"enabled", "boolean",
|
||||
N_("enable buflist"),
|
||||
NULL, 0, 0, "on", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&buflist_config_change_enabled, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_look_mouse_jump_visited_buffer = weechat_config_new_option (
|
||||
buflist_config_file, ptr_section,
|
||||
"mouse_jump_visited_buffer", "boolean",
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
extern struct t_config_file *buflist_config_file;
|
||||
|
||||
extern struct t_config_option *buflist_config_look_display_conditions;
|
||||
extern struct t_config_option *buflist_config_look_enabled;
|
||||
extern struct t_config_option *buflist_config_look_mouse_jump_visited_buffer;
|
||||
extern struct t_config_option *buflist_config_look_mouse_move_buffer;
|
||||
extern struct t_config_option *buflist_config_look_mouse_wheel;
|
||||
|
||||
@@ -448,7 +448,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
"default", "default", "default", "on",
|
||||
BUFLIST_BAR_ITEM_NAME);
|
||||
|
||||
weechat_bar_item_update (BUFLIST_BAR_ITEM_NAME);
|
||||
buflist_bar_item_update ();
|
||||
|
||||
buflist_mouse_init ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user