Fix g_icon_to_string() regression (doc inconsistency).

g_icon_new_for_string() docs states that it should return a single name
when created with a single name. I add a second condition to this case:
the themed icon must not include default fallbacks (i.e. it must not
have been created with `g_themed_icon_new_with_default_fallbacks()`).
Otherwise the return value of `g_icon_new_for_string()` would not
recreate the same icon list when passed to `g_icon_new_for_string()`
(which would be another documentation inconsistency).

g_icon_new_for_string() is now back to old behavior for this specific
case.

I also revert the unit test for this case, and add a new unit test when
using g_themed_icon_new_with_default_fallbacks() with a single name as
well.

Closes #1513.
This commit is contained in:
Jehan
2018-09-05 14:51:18 +02:00
committed by Philip Withnall
parent d89e862f3c
commit ad26f4c75d
2 changed files with 24 additions and 6 deletions

View File

@@ -119,7 +119,17 @@ test_g_icon_to_string (void)
icon = g_themed_icon_new ("network-server");
data = g_icon_to_string (icon);
g_assert_cmpstr (data, ==, ". GThemedIcon network-server network-server-symbolic");
g_assert_cmpstr (data, ==, "network-server");
icon2 = g_icon_new_for_string (data, &error);
g_assert_no_error (error);
g_assert (g_icon_equal (icon, icon2));
g_free (data);
g_object_unref (icon);
g_object_unref (icon2);
icon = g_themed_icon_new_with_default_fallbacks ("network-server");
data = g_icon_to_string (icon);
g_assert_cmpstr (data, ==, ". GThemedIcon network-server network network-server-symbolic network-symbolic");
icon2 = g_icon_new_for_string (data, &error);
g_assert_no_error (error);
g_assert (g_icon_equal (icon, icon2));