summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-05-20 16:54:53 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-05-20 17:08:33 +0200
commit7461a5cb870953259f2d9dd5562ec88d707d05df (patch)
tree131b3a4de73ac0f948f5726b0ee82f2001b683bd /src/plugins
parentdb931b78067640a99505e490ce03477d53c23e2b (diff)
downloadweechat-7461a5cb870953259f2d9dd5562ec88d707d05df.zip
xfer: 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')
-rw-r--r--src/plugins/xfer/xfer-buffer.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/plugins/xfer/xfer-buffer.c b/src/plugins/xfer/xfer-buffer.c
index 4c27b5d9f..fab8aabec 100644
--- a/src/plugins/xfer/xfer-buffer.c
+++ b/src/plugins/xfer/xfer-buffer.c
@@ -346,20 +346,31 @@ xfer_buffer_close_cb (const void *pointer, void *data,
void
xfer_buffer_open ()
{
- if (!xfer_buffer)
+ struct t_hashtable *buffer_props;
+
+ if (xfer_buffer)
+ return;
+
+ buffer_props = weechat_hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL, NULL);
+ if (buffer_props)
{
- xfer_buffer = weechat_buffer_new (XFER_BUFFER_NAME,
- &xfer_buffer_input_cb, NULL, NULL,
- &xfer_buffer_close_cb, NULL, NULL);
-
- /* failed to create buffer ? then exit */
- if (!xfer_buffer)
- return;
-
- weechat_buffer_set (xfer_buffer, "type", "free");
- weechat_buffer_set (xfer_buffer, "title", _("Xfer list"));
- weechat_buffer_set (xfer_buffer, "key_bind_up", "/xfer up");
- weechat_buffer_set (xfer_buffer, "key_bind_down", "/xfer down");
- weechat_buffer_set (xfer_buffer, "localvar_set_type", "xfer");
+ weechat_hashtable_set (buffer_props, "type", "free");
+ weechat_hashtable_set (buffer_props, "title", _("Xfer list"));
+ weechat_hashtable_set (buffer_props, "key_bind_up", "/xfer up");
+ weechat_hashtable_set (buffer_props, "key_bind_down", "/xfer down");
+ weechat_hashtable_set (buffer_props, "localvar_set_type", "xfer");
}
+
+ xfer_buffer = weechat_buffer_new_props (
+ XFER_BUFFER_NAME,
+ buffer_props,
+ &xfer_buffer_input_cb, NULL, NULL,
+ &xfer_buffer_close_cb, NULL, NULL);
+
+ if (buffer_props)
+ weechat_hashtable_free (buffer_props);
}