diff --git a/CHANGELOG.md b/CHANGELOG.md index 84b0f296f..dc532451e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Changed +- **breaking:** core, plugins: force "short_name" in buffers to non-empty value (name by default), remove buffer property "short_name_is_set" - **breaking:** alias: display an error with `/alias add` or `/alias addcompletion` when the alias already exists, add options `addreplace` and `addreplacecompletion` in command `/alias` ([#2095](https://github.com/weechat/weechat/issues/2095)) - **breaking:** irc: rename parameter `-re` to `-raw` in command `/list` ([#2124](https://github.com/weechat/weechat/issues/2124)) - core: add option `addreplace` in commands `/bar` and `/proxy` ([#2095](https://github.com/weechat/weechat/issues/2095)) diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc index 1452d4ee0..4375ead9f 100644 --- a/doc/en/weechat_plugin_api.en.adoc +++ b/doc/en/weechat_plugin_api.en.adoc @@ -14618,7 +14618,6 @@ Arguments: ** _number_: number of buffer (starts to 1) ** _layout_number_: number of buffer saved in layout ** _layout_number_merge_order_: order in merge for layout -** _short_name_is_set_: 1 if short name is set, 0 if not set ** _type_: buffer type (0: formatted, 1: free content) ** _notify_: notify level for buffer ** _num_displayed_: number of windows displaying buffer diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc index a6e8e3fb8..bbc503d41 100644 --- a/doc/fr/weechat_plugin_api.fr.adoc +++ b/doc/fr/weechat_plugin_api.fr.adoc @@ -14935,7 +14935,6 @@ Paramètres : ** _number_ : numéro du tampon (commence à 1) ** _layout_number_ : numéro du tampon sauvegardé dans le "layout" ** _layout_number_merge_order_ : ordre du tampon mélangé pour le "layout" -** _short_name_is_set_ : 1 si le nom court est défini, 0 si non défini ** _type_ : type de tampon (0 : formaté, 1 : contenu libre) ** _notify_ : niveau de notification du tampon ** _num_displayed_ : nombre de fenêtres affichant ce tampon diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc index 524ffe5b2..18a24d1d4 100644 --- a/doc/it/weechat_plugin_api.it.adoc +++ b/doc/it/weechat_plugin_api.it.adoc @@ -15292,7 +15292,6 @@ Argomenti: ** _number_: numero del buffer (inizia da 1) ** _layout_number_: numero del buffer salvato nel layout ** _layout_number_merge_order_: ordine di unione per i layout -** _short_name_is_set_: 1 se il nome breve è impostato, 0 in caso contrario ** _type_: tipo dibuffer (0: formattato, 1: contenuto libero) ** _notify_: livello di notifica per il buffer ** _num_displayed_: numero delle finestre che visualizzano il buffer diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc index d4bbd4048..0d7667695 100644 --- a/doc/ja/weechat_plugin_api.ja.adoc +++ b/doc/ja/weechat_plugin_api.ja.adoc @@ -14836,7 +14836,6 @@ int weechat_buffer_get_integer (struct t_gui_buffer *buffer, ** _number_: バッファの番号 (1 以上) ** _layout_number_: レイアウトに保存されたバッファの番号 ** _layout_number_merge_order_: レイアウトのマージをする際の順番 -** _short_name_is_set_: 短い名前が設定されている場合は 1、そうでない場合は 0 ** _type_: バッファタイプ (0: 書式あり、1: 自由内容) ** _notify_: バッファの通知レベル ** _num_displayed_: バッファを表示しているウィンドウの数 diff --git a/doc/sr/weechat_plugin_api.sr.adoc b/doc/sr/weechat_plugin_api.sr.adoc index f146bd383..d1e636243 100644 --- a/doc/sr/weechat_plugin_api.sr.adoc +++ b/doc/sr/weechat_plugin_api.sr.adoc @@ -14196,7 +14196,6 @@ int weechat_buffer_get_integer (struct t_gui_buffer *buffer, ** _number_: број бафера (почиње се од 1) ** _layout_number_: број бафера сачуван у распореду ** _layout_number_merge_order_: редослед у спајању за распоред -** _short_name_is_set_: 1 ако је постављено кратко име, 0 ако није ** _type_: тип бафера (0: форматиран, 1: слободни садржај) ** _notify_: ниво обавештавања за бафер ** _num_displayed_: број прозора који приказују бафер diff --git a/src/core/core-upgrade.c b/src/core/core-upgrade.c index aaffc1f88..f621045dc 100644 --- a/src/core/core-upgrade.c +++ b/src/core/core-upgrade.c @@ -448,7 +448,7 @@ upgrade_weechat_read_buffer (struct t_infolist *infolist) upgrade_current_buffer = gui_buffer_new_props_with_id ( id, NULL, /* plugin */ - infolist_string (infolist, "name"), + name, NULL, /* properties */ NULL, NULL, NULL, /* input callback */ NULL, NULL, NULL); /* close callback */ @@ -480,7 +480,7 @@ upgrade_weechat_read_buffer (struct t_infolist *infolist) /* short name */ free (ptr_buffer->short_name); str = infolist_string (infolist, "short_name"); - ptr_buffer->short_name = (str) ? strdup (str) : NULL; + ptr_buffer->short_name = strdup ((str) ? str : name); /* buffer type */ ptr_buffer->type = infolist_integer (infolist, "type"); diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index 90abc93a9..2ba4c870a 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -906,7 +906,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, else length_allowed = mixed_lines->buffer_max_length; - short_name = gui_buffer_get_short_name (line->data->buffer); + short_name = line->data->buffer->short_name; length = gui_chat_strlen_screen (short_name); num_spaces = length_allowed - length; diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index d2e9067a8..6181a791d 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -1277,7 +1277,7 @@ gui_bar_item_buffer_short_name_cb (const void *pointer, void *data, snprintf (str_short_name, sizeof (str_short_name), "%s%s", gui_color_get_custom ( gui_color_get_name (CONFIG_COLOR(config_color_status_name))), - gui_buffer_get_short_name (buffer)); + buffer->short_name); return strdup (str_short_name); } @@ -1628,7 +1628,7 @@ gui_bar_item_hotlist_cb (const void *pointer, void *data, strcat (str_hotlist, ":"); strcat (str_hotlist, GUI_COLOR_CUSTOM_BAR_FG); ptr_buffer_name = (CONFIG_BOOLEAN(config_look_hotlist_short_names)) ? - gui_buffer_get_short_name (ptr_hotlist->buffer) : ptr_hotlist->buffer->name; + ptr_hotlist->buffer->short_name : ptr_hotlist->buffer->name; if (CONFIG_INTEGER(config_look_hotlist_names_length) == 0) { buffer_name = strdup (ptr_buffer_name); diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index a9791df7d..e94c396b6 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -214,21 +214,6 @@ gui_buffer_get_plugin_name (struct t_gui_buffer *buffer) return plugin_get_name (buffer->plugin); } -/* - * Get short name of buffer (or name if short_name is NULL). - * - * Note: this function never returns NULL. - */ - -const char * -gui_buffer_get_short_name (struct t_gui_buffer *buffer) -{ - if (!buffer) - return NULL; - - return (buffer->short_name) ? buffer->short_name : buffer->name; -} - /* * Builds "full_name" of buffer (for example after changing name or * plugin_name_for_upgrade). @@ -862,7 +847,7 @@ gui_buffer_new_props_with_id (long long id, new_buffer->full_name = NULL; new_buffer->old_full_name = NULL; gui_buffer_build_full_name (new_buffer); - new_buffer->short_name = NULL; + new_buffer->short_name = strdup (name); new_buffer->type = GUI_BUFFER_TYPE_DEFAULT; new_buffer->notify = CONFIG_ENUM(config_look_buffer_notify_default); new_buffer->num_displayed = 0; @@ -1435,8 +1420,6 @@ gui_buffer_get_integer (struct t_gui_buffer *buffer, const char *property) return buffer->layout_number; else if (strcmp (property, "layout_number_merge_order") == 0) return buffer->layout_number_merge_order; - else if (strcmp (property, "short_name_is_set") == 0) - return (buffer->short_name) ? 1 : 0; else if (strcmp (property, "type") == 0) return buffer->type; else if (strcmp (property, "notify") == 0) @@ -1552,7 +1535,7 @@ gui_buffer_get_string (struct t_gui_buffer *buffer, const char *property) else if (strcmp (property, "old_full_name") == 0) return buffer->old_full_name; else if (strcmp (property, "short_name") == 0) - return gui_buffer_get_short_name (buffer); + return buffer->short_name; else if (strcmp (property, "type") == 0) return gui_buffer_type_string[buffer->type]; else if (strcmp (property, "title") == 0) @@ -1706,12 +1689,14 @@ gui_buffer_set_name (struct t_gui_buffer *buffer, const char *name) void gui_buffer_set_short_name (struct t_gui_buffer *buffer, const char *short_name) { - if (!buffer || (string_strcmp (buffer->short_name, short_name) == 0)) + if (!buffer || !short_name || !short_name[0] + || (string_strcmp (buffer->short_name, short_name) == 0)) + { return; + } free (buffer->short_name); - buffer->short_name = (short_name && short_name[0]) ? - strdup (short_name) : NULL; + buffer->short_name = strdup (short_name); if (buffer->mixed_lines) buffer->mixed_lines->buffer_max_length_refresh = 1; @@ -5432,7 +5417,7 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist, return 0; if (!infolist_new_var_string (ptr_item, "old_full_name", buffer->old_full_name)) return 0; - if (!infolist_new_var_string (ptr_item, "short_name", gui_buffer_get_short_name (buffer))) + if (!infolist_new_var_string (ptr_item, "short_name", buffer->short_name)) return 0; if (!infolist_new_var_integer (ptr_item, "type", buffer->type)) return 0; diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h index 3b7074221..0c27816c0 100644 --- a/src/gui/gui-buffer.h +++ b/src/gui/gui-buffer.h @@ -302,7 +302,6 @@ extern int gui_buffer_send_signal (struct t_gui_buffer *buffer, const char *signal, const char *type_data, void *signal_data); extern const char *gui_buffer_get_plugin_name (struct t_gui_buffer *buffer); -extern const char *gui_buffer_get_short_name (struct t_gui_buffer *buffer); extern void gui_buffer_build_full_name (struct t_gui_buffer *buffer); extern void gui_buffer_local_var_add (struct t_gui_buffer *buffer, const char *name, diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c index 8708d8978..226c38d85 100644 --- a/src/gui/gui-line.c +++ b/src/gui/gui-line.c @@ -329,7 +329,7 @@ gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line, { if ((CONFIG_ENUM(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE) && (CONFIG_ENUM(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE)) - length_buffer = gui_chat_strlen_screen (gui_buffer_get_short_name (line->data->buffer)) + 1; + length_buffer = gui_chat_strlen_screen (line->data->buffer->short_name) + 1; else { if (CONFIG_ENUM(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE) @@ -1149,17 +1149,15 @@ gui_line_compute_buffer_max_length (struct t_gui_buffer *buffer, { struct t_gui_buffer *ptr_buffer; int length; - const char *short_name; lines->buffer_max_length = 0; for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer) { - short_name = gui_buffer_get_short_name (ptr_buffer); if (ptr_buffer->number == buffer->number) { - length = gui_chat_strlen_screen (short_name); + length = gui_chat_strlen_screen (ptr_buffer->short_name); if (length > lines->buffer_max_length) lines->buffer_max_length = length; } diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c index 8532355d4..825344024 100644 --- a/src/gui/gui-window.c +++ b/src/gui/gui-window.c @@ -208,7 +208,7 @@ gui_window_get_context_at_xy (struct t_gui_window *window, else if ((win_x >= window->coords[win_y].buffer_x1) && (win_x <= window->coords[win_y].buffer_x2)) { - *word = gui_color_decode (gui_buffer_get_short_name ((*line)->data->buffer), NULL); + *word = gui_color_decode ((*line)->data->buffer->short_name, NULL); } else if ((win_x >= window->coords[win_y].prefix_x1) && (win_x <= window->coords[win_y].prefix_x2)) diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index f9cc704e9..a102977be 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -190,7 +190,6 @@ irc_channel_create_buffer (struct t_irc_server *server, int buffer_created, current_buffer_number, buffer_position; int autojoin_join, manual_join, noswitch; char str_number[32], *channel_name_lower, *buffer_name, *prompt; - const char *short_name, *localvar_channel; buffer_created = 0; buffer_props = NULL; @@ -218,6 +217,7 @@ irc_channel_create_buffer (struct t_irc_server *server, NULL, NULL); if (buffer_props) { + weechat_hashtable_set (buffer_props, "short_name", channel_name); weechat_hashtable_set ( buffer_props, "input_multiline", @@ -251,6 +251,7 @@ irc_channel_create_buffer (struct t_irc_server *server, { if (!irc_upgrading) weechat_nicklist_remove_all (ptr_buffer); + weechat_hashtable_remove (buffer_props, "short_name"); weechat_hashtable_map (buffer_props, &irc_channel_apply_props, ptr_buffer); } else @@ -312,25 +313,6 @@ irc_channel_create_buffer (struct t_irc_server *server, buffer_created = 1; } - if (buffer_created) - { - if (!weechat_buffer_get_integer (ptr_buffer, "short_name_is_set")) - weechat_buffer_set (ptr_buffer, "short_name", channel_name); - } - else - { - short_name = weechat_buffer_get_string (ptr_buffer, "short_name"); - localvar_channel = weechat_buffer_get_string (ptr_buffer, - "localvar_channel"); - if (!short_name - || (localvar_channel - && (strcmp (localvar_channel, short_name) == 0))) - { - /* update the short_name only if it was not changed by the user */ - weechat_buffer_set (ptr_buffer, "short_name", channel_name); - } - } - if (buffer_created) { (void) weechat_hook_signal_send ("logger_backlog", diff --git a/src/plugins/irc/irc-raw.c b/src/plugins/irc/irc-raw.c index 0ab77202f..0c0016c2c 100644 --- a/src/plugins/irc/irc-raw.c +++ b/src/plugins/irc/irc-raw.c @@ -390,6 +390,8 @@ irc_raw_open (int switch_to_buffer) NULL, NULL); if (buffer_props) { + weechat_hashtable_set (buffer_props, + "short_name", IRC_RAW_BUFFER_NAME); weechat_hashtable_set (buffer_props, "localvar_set_type", "debug"); weechat_hashtable_set (buffer_props, @@ -412,12 +414,6 @@ irc_raw_open (int switch_to_buffer) if (!irc_raw_buffer) return; - if (!weechat_buffer_get_integer (irc_raw_buffer, "short_name_is_set")) - { - weechat_buffer_set (irc_raw_buffer, "short_name", - IRC_RAW_BUFFER_NAME); - } - irc_raw_set_localvar_filter (); irc_raw_refresh (0); diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 3c2a2c495..a47c55661 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -4804,6 +4804,7 @@ irc_server_create_buffer (struct t_irc_server *server) NULL, NULL); if (buffer_props) { + weechat_hashtable_set (buffer_props, "short_name", server->name); weechat_hashtable_set (buffer_props, "localvar_set_type", "server"); weechat_hashtable_set (buffer_props, "localvar_set_server", server->name); @@ -4833,9 +4834,6 @@ irc_server_create_buffer (struct t_irc_server *server) if (!server->buffer) return NULL; - if (!weechat_buffer_get_integer (server->buffer, "short_name_is_set")) - weechat_buffer_set (server->buffer, "short_name", server->name); - (void) weechat_hook_signal_send ("logger_backlog", WEECHAT_HOOK_SIGNAL_POINTER, server->buffer); diff --git a/src/plugins/relay/relay-raw.c b/src/plugins/relay/relay-raw.c index 1e575be2d..48d6ec5e0 100644 --- a/src/plugins/relay/relay-raw.c +++ b/src/plugins/relay/relay-raw.c @@ -83,6 +83,8 @@ relay_raw_open (int switch_to_buffer) NULL, NULL); if (buffer_props) { + weechat_hashtable_set (buffer_props, + "short_name", RELAY_RAW_BUFFER_NAME); weechat_hashtable_set (buffer_props, "title", _("Relay raw messages")); weechat_hashtable_set (buffer_props, @@ -107,12 +109,6 @@ relay_raw_open (int switch_to_buffer) if (!relay_raw_buffer) return; - if (!weechat_buffer_get_integer (relay_raw_buffer, "short_name_is_set")) - { - weechat_buffer_set (relay_raw_buffer, "short_name", - RELAY_RAW_BUFFER_NAME); - } - /* print messages in list */ for (ptr_raw_message = relay_raw_messages; ptr_raw_message; ptr_raw_message = ptr_raw_message->next_message) diff --git a/src/plugins/trigger/trigger-buffer.c b/src/plugins/trigger/trigger-buffer.c index 3d7daa8d4..9b2c3f741 100644 --- a/src/plugins/trigger/trigger-buffer.c +++ b/src/plugins/trigger/trigger-buffer.c @@ -211,6 +211,8 @@ trigger_buffer_open (const char *filter, int switch_to_buffer) NULL, NULL); if (buffer_props) { + weechat_hashtable_set ( + buffer_props, "short_name", TRIGGER_BUFFER_NAME); weechat_hashtable_set ( buffer_props, "localvar_set_type", "debug"); weechat_hashtable_set ( @@ -233,9 +235,6 @@ trigger_buffer_open (const char *filter, int switch_to_buffer) /* failed to create buffer ? then return */ if (!trigger_buffer) return; - - if (!weechat_buffer_get_integer (trigger_buffer, "short_name_is_set")) - weechat_buffer_set (trigger_buffer, "short_name", TRIGGER_BUFFER_NAME); } if (filter && filter[0]) diff --git a/src/plugins/xfer/xfer-chat.c b/src/plugins/xfer/xfer-chat.c index 1fb35cc16..934c8d052 100644 --- a/src/plugins/xfer/xfer-chat.c +++ b/src/plugins/xfer/xfer-chat.c @@ -335,6 +335,24 @@ xfer_chat_buffer_close_cb (const void *pointer, void *data, return WEECHAT_RC_OK; } +/* + * Applies properties to a buffer. + */ + +void +xfer_chat_apply_props (void *data, + struct t_hashtable *hashtable, + const void *key, + const void *value) +{ + /* make C compiler happy */ + (void) hashtable; + + weechat_buffer_set ((struct t_gui_buffer *)data, + (const char *)key, + (const char *)value); +} + /* * Creates buffer for DCC chat. */ @@ -342,50 +360,51 @@ xfer_chat_buffer_close_cb (const void *pointer, void *data, void xfer_chat_open_buffer (struct t_xfer *xfer) { + struct t_hashtable *buffer_props; char *name; - int length, buffer_created; - buffer_created = 0; + buffer_props = NULL; - length = strlen (xfer->plugin_name) + 8 + strlen (xfer->plugin_id) + 1 - + strlen (xfer->remote_nick) + 1; - name = malloc (length); - if (!name) - return; + if (weechat_asprintf (&name, "%s_dcc.%s.%s", + xfer->plugin_name, + xfer->plugin_id, + xfer->remote_nick) < 0) + goto end; - snprintf (name, length, "%s_dcc.%s.%s", - xfer->plugin_name, xfer->plugin_id, xfer->remote_nick); - xfer->buffer = weechat_buffer_search (XFER_PLUGIN_NAME, name); - if (!xfer->buffer) + buffer_props = weechat_hashtable_new ( + 32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, NULL); + if (buffer_props) { - xfer->buffer = weechat_buffer_new ( - name, - &xfer_chat_buffer_input_cb, NULL, NULL, - &xfer_chat_buffer_close_cb, NULL, NULL); - buffer_created = 1; - /* failed to create buffer ? then return */ - if (!xfer->buffer) - { - free (name); - return; - } + weechat_hashtable_set (buffer_props, "title", _("xfer chat")); + weechat_hashtable_set (buffer_props, "short_name", xfer->remote_nick); + weechat_hashtable_set (buffer_props, "input_prompt", xfer->local_nick); + weechat_hashtable_set (buffer_props, "localvar_set_type", "private"); + weechat_hashtable_set (buffer_props, "localvar_set_nick", xfer->local_nick); + weechat_hashtable_set (buffer_props, "localvar_set_channel", xfer->remote_nick); + weechat_hashtable_set (buffer_props, "localvar_set_tls_version", "cleartext"); + weechat_hashtable_set (buffer_props, "highlight_words_add", "$nick"); } - if (buffer_created) + xfer->buffer = weechat_buffer_search (XFER_PLUGIN_NAME, name); + if (xfer->buffer) { - weechat_buffer_set (xfer->buffer, "title", _("xfer chat")); - if (!weechat_buffer_get_integer (xfer->buffer, "short_name_is_set")) - { - weechat_buffer_set (xfer->buffer, "short_name", - xfer->remote_nick); - } - weechat_buffer_set (xfer->buffer, "input_prompt", xfer->local_nick); - weechat_buffer_set (xfer->buffer, "localvar_set_type", "private"); - weechat_buffer_set (xfer->buffer, "localvar_set_nick", xfer->local_nick); - weechat_buffer_set (xfer->buffer, "localvar_set_channel", xfer->remote_nick); - weechat_buffer_set (xfer->buffer, "localvar_set_tls_version", "cleartext"); - weechat_buffer_set (xfer->buffer, "highlight_words_add", "$nick"); + weechat_hashtable_remove (buffer_props, "short_name"); + weechat_hashtable_remove (buffer_props, "highlight_words_add"); + weechat_hashtable_map (buffer_props, &xfer_chat_apply_props, xfer->buffer); + } + else + { + xfer->buffer = weechat_buffer_new_props ( + name, + buffer_props, + &xfer_chat_buffer_input_cb, NULL, NULL, + &xfer_chat_buffer_close_cb, NULL, NULL); + if (!xfer->buffer) + goto end; } weechat_printf (xfer->buffer, @@ -395,5 +414,7 @@ xfer_chat_open_buffer (struct t_xfer *xfer) xfer->remote_nick, xfer->remote_address_str); +end: + weechat_hashtable_free (buffer_props); free (name); } diff --git a/tests/unit/gui/test-gui-buffer.cpp b/tests/unit/gui/test-gui-buffer.cpp index 1e3d4d16a..d70d502ec 100644 --- a/tests/unit/gui/test-gui-buffer.cpp +++ b/tests/unit/gui/test-gui-buffer.cpp @@ -173,11 +173,10 @@ TEST(GuiBuffer, GetPluginName) /* * Tests functions: - * gui_buffer_get_short_name * gui_buffer_set_short_name */ -TEST(GuiBuffer, GetSetShortName) +TEST(GuiBuffer, SetShortName) { struct t_gui_buffer *buffer; @@ -186,22 +185,14 @@ TEST(GuiBuffer, GetSetShortName) NULL, NULL, NULL); CHECK(buffer); - POINTERS_EQUAL(NULL, gui_buffer_get_short_name (NULL)); - - POINTERS_EQUAL(NULL, buffer->short_name); - STRCMP_EQUAL(TEST_BUFFER_NAME, gui_buffer_get_short_name (buffer)); - - gui_buffer_set_short_name (buffer, NULL); - POINTERS_EQUAL(NULL, buffer->short_name); - STRCMP_EQUAL(TEST_BUFFER_NAME, gui_buffer_get_short_name (buffer)); - - gui_buffer_set_short_name (buffer, "short"); - STRCMP_EQUAL("short", buffer->short_name); - STRCMP_EQUAL("short", gui_buffer_get_short_name (buffer)); + STRCMP_EQUAL(TEST_BUFFER_NAME, buffer->short_name); + /* forbidden value => short_name unchanged */ gui_buffer_set_short_name (buffer, ""); - POINTERS_EQUAL(NULL, buffer->short_name); - STRCMP_EQUAL(TEST_BUFFER_NAME, gui_buffer_get_short_name (buffer)); + STRCMP_EQUAL(TEST_BUFFER_NAME, buffer->short_name); + + gui_buffer_set_short_name (buffer, "t"); + STRCMP_EQUAL("t", buffer->short_name); gui_buffer_close (buffer); } @@ -468,7 +459,7 @@ TEST(GuiBuffer, ApplyConfigProperties) NULL, NULL, NULL); CHECK(buffer); - POINTERS_EQUAL(NULL, buffer->short_name); + STRCMP_EQUAL(TEST_BUFFER_NAME, buffer->short_name); gui_buffer_close (buffer); } @@ -536,7 +527,7 @@ TEST(GuiBuffer, NewProps) STRCMP_EQUAL(TEST_BUFFER_NAME, buffer->name); STRCMP_EQUAL("core." TEST_BUFFER_NAME, buffer->full_name); POINTERS_EQUAL(NULL, buffer->old_full_name); - POINTERS_EQUAL(NULL, buffer->short_name); + STRCMP_EQUAL(TEST_BUFFER_NAME, buffer->short_name); LONGS_EQUAL(GUI_BUFFER_TYPE_FREE, buffer->type); LONGS_EQUAL(GUI_BUFFER_NOTIFY_ALL, buffer->notify); LONGS_EQUAL(0, buffer->num_displayed); @@ -690,7 +681,7 @@ TEST(GuiBuffer, New) STRCMP_EQUAL(TEST_BUFFER_NAME, buffer->name); STRCMP_EQUAL("core." TEST_BUFFER_NAME, buffer->full_name); POINTERS_EQUAL(NULL, buffer->old_full_name); - POINTERS_EQUAL(NULL, buffer->short_name); + STRCMP_EQUAL(TEST_BUFFER_NAME, buffer->short_name); gui_buffer_close (buffer); } @@ -875,7 +866,6 @@ TEST(GuiBuffer, GetInteger) LONGS_EQUAL(1, gui_buffer_get_integer (gui_buffers, "number")); LONGS_EQUAL(0, gui_buffer_get_integer (gui_buffers, "layout_number")); LONGS_EQUAL(0, gui_buffer_get_integer (gui_buffers, "layout_number_merge_order")); - LONGS_EQUAL(1, gui_buffer_get_integer (gui_buffers, "short_name_is_set")); LONGS_EQUAL(GUI_BUFFER_TYPE_FORMATTED, gui_buffer_get_integer (gui_buffers, "type")); LONGS_EQUAL(GUI_BUFFER_NOTIFY_ALL, gui_buffer_get_integer (gui_buffers, "notify")); LONGS_EQUAL(1, gui_buffer_get_integer (gui_buffers, "num_displayed"));