mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-10 21:03:51 +01:00
Merge branch 'master' into 'master'
Issue #1513: fix g_icon_to_string() regression (doc inconsistency). Closes #1513 See merge request GNOME/glib!305
This commit is contained in:
commit
f928dfdf57
18
gio/gicon.c
18
gio/gicon.c
@ -199,8 +199,8 @@ g_icon_to_string_tokenized (GIcon *icon, GString *s)
|
|||||||
* native, the returned string is the result of g_file_get_uri()
|
* native, the returned string is the result of g_file_get_uri()
|
||||||
* (such as `sftp://path/to/my%20icon.png`).
|
* (such as `sftp://path/to/my%20icon.png`).
|
||||||
*
|
*
|
||||||
* - If @icon is a #GThemedIcon with exactly one name, the encoding is
|
* - If @icon is a #GThemedIcon with exactly one name and no fallbacks,
|
||||||
* simply the name (such as `network-server`).
|
* the encoding is simply the name (such as `network-server`).
|
||||||
*
|
*
|
||||||
* Virtual: to_tokens
|
* Virtual: to_tokens
|
||||||
* Returns: (nullable): An allocated NUL-terminated UTF8 string or
|
* Returns: (nullable): An allocated NUL-terminated UTF8 string or
|
||||||
@ -237,15 +237,23 @@ g_icon_to_string (GIcon *icon)
|
|||||||
}
|
}
|
||||||
else if (G_IS_THEMED_ICON (icon))
|
else if (G_IS_THEMED_ICON (icon))
|
||||||
{
|
{
|
||||||
const char * const *names;
|
char **names = NULL;
|
||||||
|
gboolean use_default_fallbacks = FALSE;
|
||||||
|
|
||||||
names = g_themed_icon_get_names (G_THEMED_ICON (icon));
|
g_object_get (G_OBJECT (icon),
|
||||||
|
"names", &names,
|
||||||
|
"use-default-fallbacks", &use_default_fallbacks,
|
||||||
|
NULL);
|
||||||
|
/* Themed icon initialized with a single name and no fallbacks. */
|
||||||
if (names != NULL &&
|
if (names != NULL &&
|
||||||
names[0] != NULL &&
|
names[0] != NULL &&
|
||||||
names[0][0] != '.' && /* Allowing icons starting with dot would break G_ICON_SERIALIZATION_MAGIC0 */
|
names[0][0] != '.' && /* Allowing icons starting with dot would break G_ICON_SERIALIZATION_MAGIC0 */
|
||||||
g_utf8_validate (names[0], -1, NULL) && /* Only return utf8 strings */
|
g_utf8_validate (names[0], -1, NULL) && /* Only return utf8 strings */
|
||||||
names[1] == NULL)
|
names[1] == NULL &&
|
||||||
|
! use_default_fallbacks)
|
||||||
ret = g_strdup (names[0]);
|
ret = g_strdup (names[0]);
|
||||||
|
|
||||||
|
g_strfreev (names);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
|
@ -119,7 +119,17 @@ test_g_icon_to_string (void)
|
|||||||
|
|
||||||
icon = g_themed_icon_new ("network-server");
|
icon = g_themed_icon_new ("network-server");
|
||||||
data = g_icon_to_string (icon);
|
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);
|
icon2 = g_icon_new_for_string (data, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
g_assert (g_icon_equal (icon, icon2));
|
g_assert (g_icon_equal (icon, icon2));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user