diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-05-20 16:30:32 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-05-20 17:08:28 +0200 |
commit | 00f4ae760d03cd5d1781e940d95b46d707e72585 (patch) | |
tree | afdaea0f9a26a1a65c464dabff0e32d7bca0c636 /src/plugins/relay/relay-buffer.c | |
parent | 1ad45598b5db3b639047f69d3e95ce84a59db100 (diff) | |
download | weechat-00f4ae760d03cd5d1781e940d95b46d707e72585.zip |
relay: create buffers 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/relay/relay-buffer.c')
-rw-r--r-- | src/plugins/relay/relay-buffer.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/plugins/relay/relay-buffer.c b/src/plugins/relay/relay-buffer.c index aa72d80a8..191f076cf 100644 --- a/src/plugins/relay/relay-buffer.c +++ b/src/plugins/relay/relay-buffer.c @@ -245,20 +245,32 @@ relay_buffer_close_cb (const void *pointer, void *data, void relay_buffer_open () { - if (!relay_buffer) + struct t_hashtable *buffer_props; + + if (relay_buffer) + return; + + buffer_props = weechat_hashtable_new ( + 32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, NULL); + if (buffer_props) { - relay_buffer = weechat_buffer_new (RELAY_BUFFER_NAME, - &relay_buffer_input_cb, NULL, NULL, - &relay_buffer_close_cb, NULL, NULL); - - /* failed to create buffer ? then exit */ - if (!relay_buffer) - return; - - weechat_buffer_set (relay_buffer, "type", "free"); - weechat_buffer_set (relay_buffer, "title", _("List of clients for relay")); - weechat_buffer_set (relay_buffer, "key_bind_up", "/relay up"); - weechat_buffer_set (relay_buffer, "key_bind_down", "/relay down"); - weechat_buffer_set (relay_buffer, "localvar_set_type", "relay"); + weechat_hashtable_set (buffer_props, "type", "free"); + weechat_hashtable_set (buffer_props, + "title", _("List of clients for relay")); + weechat_hashtable_set (buffer_props, "key_bind_up", "/relay up"); + weechat_hashtable_set (buffer_props, "key_bind_down", "/relay down"); + weechat_hashtable_set (buffer_props, "localvar_set_type", "relay"); } + + relay_buffer = weechat_buffer_new_props ( + RELAY_BUFFER_NAME, + buffer_props, + &relay_buffer_input_cb, NULL, NULL, + &relay_buffer_close_cb, NULL, NULL); + + if (buffer_props) + weechat_hashtable_free (buffer_props); } |