mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
fset: always use a timer to refresh buffer when options are changed
This commit is contained in:
@@ -237,7 +237,6 @@ fset_command_fset (const void *pointer, void *data,
|
||||
{
|
||||
if (fset_option_count_marked > 0)
|
||||
{
|
||||
fset_option_enable_timer_config_changed ();
|
||||
num_options = weechat_arraylist_size (fset_options);
|
||||
for (i = 0; i < num_options; i++)
|
||||
{
|
||||
@@ -249,7 +248,6 @@ fset_command_fset (const void *pointer, void *data,
|
||||
fset_option_toggle_value (ptr_fset_option, ptr_option);
|
||||
}
|
||||
}
|
||||
fset_option_disable_timer_config_changed ();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -270,7 +268,6 @@ fset_command_fset (const void *pointer, void *data,
|
||||
|
||||
if (fset_option_count_marked > 0)
|
||||
{
|
||||
fset_option_enable_timer_config_changed ();
|
||||
num_options = weechat_arraylist_size (fset_options);
|
||||
for (i = 0; i < num_options; i++)
|
||||
{
|
||||
@@ -282,7 +279,6 @@ fset_command_fset (const void *pointer, void *data,
|
||||
fset_option_add_value (ptr_fset_option, ptr_option, value);
|
||||
}
|
||||
}
|
||||
fset_option_disable_timer_config_changed ();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -306,7 +302,6 @@ fset_command_fset (const void *pointer, void *data,
|
||||
{
|
||||
if (fset_option_count_marked > 0)
|
||||
{
|
||||
fset_option_enable_timer_config_changed ();
|
||||
num_options = weechat_arraylist_size (fset_options);
|
||||
for (i = 0; i < num_options; i++)
|
||||
{
|
||||
@@ -318,7 +313,6 @@ fset_command_fset (const void *pointer, void *data,
|
||||
fset_option_reset_value (ptr_fset_option, ptr_option);
|
||||
}
|
||||
}
|
||||
fset_option_disable_timer_config_changed ();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -332,7 +326,6 @@ fset_command_fset (const void *pointer, void *data,
|
||||
{
|
||||
if (fset_option_count_marked > 0)
|
||||
{
|
||||
fset_option_enable_timer_config_changed ();
|
||||
num_options = weechat_arraylist_size (fset_options);
|
||||
for (i = 0; i < num_options; i++)
|
||||
{
|
||||
@@ -344,7 +337,6 @@ fset_command_fset (const void *pointer, void *data,
|
||||
fset_option_unset_value (ptr_fset_option, ptr_option);
|
||||
}
|
||||
}
|
||||
fset_option_disable_timer_config_changed ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -130,7 +130,6 @@ fset_config_change_show_plugins_desc_cb (const void *pointer, void *data,
|
||||
|
||||
if (fset_buffer)
|
||||
{
|
||||
fset_buffer_selected_line = 0;
|
||||
fset_option_get_options ();
|
||||
fset_buffer_refresh (1);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ struct t_hashtable *fset_option_filter_hashtable_extra_vars = NULL;
|
||||
struct t_hashtable *fset_option_filter_hashtable_options = NULL;
|
||||
|
||||
/* refresh */
|
||||
int fset_option_config_changed_use_timer = 0;
|
||||
struct t_hashtable *fset_option_timer_options_changed = NULL;
|
||||
struct t_hook *fset_option_timer_hook = NULL;
|
||||
|
||||
@@ -1477,18 +1476,10 @@ fset_option_config_timer_cb (const void *pointer,
|
||||
(void) data;
|
||||
(void) remaining_calls;
|
||||
|
||||
if (fset_option_timer_options_changed)
|
||||
{
|
||||
weechat_hashtable_map (fset_option_timer_options_changed,
|
||||
&fset_option_timer_option_changed_cb,
|
||||
NULL);
|
||||
weechat_hashtable_free (fset_option_timer_options_changed);
|
||||
fset_option_timer_options_changed = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
fset_option_config_changed (NULL);
|
||||
}
|
||||
weechat_hashtable_map (fset_option_timer_options_changed,
|
||||
&fset_option_timer_option_changed_cb,
|
||||
NULL);
|
||||
weechat_hashtable_remove_all (fset_option_timer_options_changed);
|
||||
|
||||
fset_option_timer_hook = NULL;
|
||||
|
||||
@@ -1521,57 +1512,19 @@ fset_option_config_cb (const void *pointer,
|
||||
if (ptr_info && (strcmp (ptr_info, "1") == 0))
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
if (fset_option_config_changed_use_timer)
|
||||
weechat_hashtable_set (fset_option_timer_options_changed,
|
||||
option, NULL);
|
||||
|
||||
if (!fset_option_timer_hook)
|
||||
{
|
||||
if (!fset_option_timer_hook)
|
||||
{
|
||||
fset_option_timer_hook = weechat_hook_timer (
|
||||
1, 0, 1,
|
||||
&fset_option_config_timer_cb, NULL, NULL);
|
||||
}
|
||||
weechat_hashtable_set (fset_option_timer_options_changed,
|
||||
option, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
fset_option_config_changed (option);
|
||||
fset_option_timer_hook = weechat_hook_timer (
|
||||
1, 0, 1,
|
||||
&fset_option_config_timer_cb, NULL, NULL);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enables a timer when options are changed.
|
||||
*/
|
||||
|
||||
void
|
||||
fset_option_enable_timer_config_changed ()
|
||||
{
|
||||
if (fset_option_timer_options_changed)
|
||||
{
|
||||
weechat_hashtable_remove_all (fset_option_timer_options_changed);
|
||||
}
|
||||
else
|
||||
{
|
||||
fset_option_timer_options_changed = weechat_hashtable_new (
|
||||
32,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_POINTER,
|
||||
NULL, NULL);
|
||||
}
|
||||
fset_option_config_changed_use_timer = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disables timer when options are changed.
|
||||
*/
|
||||
|
||||
void
|
||||
fset_option_disable_timer_config_changed ()
|
||||
{
|
||||
fset_option_config_changed_use_timer = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns hdata for option.
|
||||
*/
|
||||
@@ -1769,6 +1722,21 @@ fset_option_init ()
|
||||
weechat_hashtable_set (fset_option_filter_hashtable_options,
|
||||
"type", "condition");
|
||||
|
||||
fset_option_timer_options_changed = weechat_hashtable_new (
|
||||
128,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_POINTER,
|
||||
NULL, NULL);
|
||||
if (!fset_option_timer_options_changed)
|
||||
{
|
||||
weechat_arraylist_free (fset_options);
|
||||
free (fset_option_max_length);
|
||||
weechat_hashtable_free (fset_option_filter_hashtable_pointers);
|
||||
weechat_hashtable_free (fset_option_filter_hashtable_extra_vars);
|
||||
weechat_hashtable_free (fset_option_filter_hashtable_options);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,8 +120,6 @@ extern int fset_option_config_cb (const void *pointer,
|
||||
void *data,
|
||||
const char *option,
|
||||
const char *value);
|
||||
extern void fset_option_enable_timer_config_changed ();
|
||||
extern void fset_option_disable_timer_config_changed ();
|
||||
extern struct t_hdata *fset_option_hdata_option_cb (const void *pointer,
|
||||
void *data,
|
||||
const char *hdata_name);
|
||||
|
||||
Reference in New Issue
Block a user