summaryrefslogtreecommitdiff
path: root/src/plugins/fset
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-05-20 16:26:20 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-05-20 17:08:27 +0200
commit1ad45598b5db3b639047f69d3e95ce84a59db100 (patch)
tree897468d99e4dc2f9e72cba8c795b3455c45bedb9 /src/plugins/fset
parentb1759ab25a776417b4f05612719a37b69593e14f (diff)
downloadweechat-1ad45598b5db3b639047f69d3e95ce84a59db100.zip
fset: create buffer with function buffer_new_props (issue #1942)
With this function, buffer properties are set when the buffer is created and can be read immediately by other plugins/scripts, for example in a callback of signal "buffer_opened".
Diffstat (limited to 'src/plugins/fset')
-rw-r--r--src/plugins/fset/fset-buffer.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/plugins/fset/fset-buffer.c b/src/plugins/fset/fset-buffer.c
index edeb7912d..ff8a32688 100644
--- a/src/plugins/fset/fset-buffer.c
+++ b/src/plugins/fset/fset-buffer.c
@@ -1546,24 +1546,39 @@ fset_buffer_set_localvar_filter ()
void
fset_buffer_open ()
{
- if (!fset_buffer)
+ struct t_hashtable *buffer_props;
+
+ if (fset_buffer)
+ return;
+
+ buffer_props = weechat_hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER,
+ NULL,
+ NULL);
+ if (buffer_props)
{
- fset_buffer = weechat_buffer_new (
- FSET_BUFFER_NAME,
- &fset_buffer_input_cb, NULL, NULL,
- &fset_buffer_close_cb, NULL, NULL);
+ weechat_hashtable_set (buffer_props, "type", "free");
+ weechat_hashtable_set (buffer_props, "localvar_set_type", "option");
+ }
- /* failed to create buffer ? then exit */
- if (!fset_buffer)
- return;
+ fset_buffer = weechat_buffer_new_props (
+ FSET_BUFFER_NAME,
+ buffer_props,
+ &fset_buffer_input_cb, NULL, NULL,
+ &fset_buffer_close_cb, NULL, NULL);
- weechat_buffer_set (fset_buffer, "type", "free");
- fset_buffer_set_keys ();
- weechat_buffer_set (fset_buffer, "localvar_set_type", "option");
- fset_buffer_set_localvar_filter ();
+ if (buffer_props)
+ weechat_hashtable_free (buffer_props);
- fset_buffer_selected_line = 0;
- }
+ if (!fset_buffer)
+ return;
+
+ fset_buffer_set_keys ();
+ fset_buffer_set_localvar_filter ();
+
+ fset_buffer_selected_line = 0;
}
/*