diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2022-03-07 21:37:25 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2022-03-13 10:35:29 +0100 |
commit | fbbed9fbf7262ad497a012e40f9e6e3d39dd6030 (patch) | |
tree | 14b312001a94db301a6dd14eb331adbc09a1b9aa /src/core | |
parent | 310b4dd2a03e87d2875c2d231cd607b118a14137 (diff) | |
download | weechat-fbbed9fbf7262ad497a012e40f9e6e3d39dd6030.zip |
core: add function gui_buffer_new_props (issue #1759)
This function allows to create a buffer and set properties via a hashtable,
before the signal "buffer_opened" is sent.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hook/wee-hook-line.c | 2 | ||||
-rw-r--r-- | src/core/wee-command.c | 12 | ||||
-rw-r--r-- | src/core/wee-secure-buffer.c | 33 |
3 files changed, 31 insertions, 16 deletions
diff --git a/src/core/hook/wee-hook-line.c b/src/core/hook/wee-hook-line.c index f4b605964..6c1d3f03c 100644 --- a/src/core/hook/wee-hook-line.c +++ b/src/core/hook/wee-hook-line.c @@ -71,7 +71,7 @@ hook_line (struct t_weechat_plugin *plugin, const char *buffer_type, new_hook->hook_data = new_hook_line; new_hook_line->callback = callback; if (!buffer_type || !buffer_type[0]) - new_hook_line->buffer_type = GUI_BUFFER_TYPE_FORMATTED; + new_hook_line->buffer_type = GUI_BUFFER_TYPE_DEFAULT; else if (strcmp (buffer_type, "*") == 0) new_hook_line->buffer_type = -1; else diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 219c0400e..7d218ae6d 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -628,9 +628,9 @@ COMMAND_CALLBACK(buffer) ptr_buffer = gui_buffer_search_by_name (PLUGIN_CORE, argv[arg_name]); if (!ptr_buffer) { - ptr_buffer = gui_buffer_new_user (argv[arg_name]); - if (ptr_buffer && type_free) - gui_buffer_set (ptr_buffer, "type", "free"); + ptr_buffer = gui_buffer_new_user ( + argv[arg_name], + (type_free) ? GUI_BUFFER_TYPE_FREE : GUI_BUFFER_TYPE_DEFAULT); } if (ptr_buffer && switch_to_buffer) gui_window_switch_to_buffer (gui_current_window, ptr_buffer, 1); @@ -5137,9 +5137,9 @@ COMMAND_CALLBACK(print) argv[arg_new_buffer_name]); if (!ptr_buffer) { - ptr_buffer = gui_buffer_new_user (argv[arg_new_buffer_name]); - if (ptr_buffer && new_buffer_type_free) - gui_buffer_set (ptr_buffer, "type", "free"); + ptr_buffer = gui_buffer_new_user ( + argv[arg_new_buffer_name], + (new_buffer_type_free) ? GUI_BUFFER_TYPE_FREE : GUI_BUFFER_TYPE_DEFAULT); } } else diff --git a/src/core/wee-secure-buffer.c b/src/core/wee-secure-buffer.c index 86dab6a36..2fea6fcc3 100644 --- a/src/core/wee-secure-buffer.c +++ b/src/core/wee-secure-buffer.c @@ -204,20 +204,35 @@ secure_buffer_assign () void secure_buffer_open () { + struct t_hashtable *properties; + if (!secure_buffer) { - secure_buffer = gui_buffer_new (NULL, SECURE_BUFFER_NAME, - &secure_buffer_input_cb, NULL, NULL, - &secure_buffer_close_cb, NULL, NULL); - if (secure_buffer) + properties = hashtable_new ( + 32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, NULL); + if (properties) { - if (!secure_buffer->short_name) - secure_buffer->short_name = strdup (SECURE_BUFFER_NAME); - gui_buffer_set (secure_buffer, "type", "free"); - gui_buffer_set (secure_buffer, "localvar_set_no_log", "1"); - gui_buffer_set (secure_buffer, "key_bind_meta-v", "/secure toggle_values"); + hashtable_set (properties, "type", "free"); + hashtable_set (properties, "localvar_set_no_log", "1"); + hashtable_set (properties, + "key_bind_meta-v", "/secure toggle_values"); } + + secure_buffer = gui_buffer_new_props ( + NULL, SECURE_BUFFER_NAME, properties, + &secure_buffer_input_cb, NULL, NULL, + &secure_buffer_close_cb, NULL, NULL); + + if (secure_buffer && !secure_buffer->short_name) + secure_buffer->short_name = strdup (SECURE_BUFFER_NAME); + secure_buffer_display_values = 0; + + if (properties) + hashtable_free (properties); } if (!secure_buffer) |