icontheme: Remove GENERIC_FALLBACKS

Instead, rely on people passing fallbacks explicitly.

Alternatively, GThemedIcon provides the functionality to create
fallbacks, which is what GtkImage and the testsuite now use.
That method is slightly better, too, so the expected test results
have been updated accordingly.
This commit is contained in:
Benjamin Otte 2020-02-04 04:26:19 +01:00 committed by Alexander Larsson
parent 571021cbc1
commit 138de60ab2
9 changed files with 175 additions and 154 deletions

View File

@ -112,7 +112,7 @@ get_image_paintable (GtkImage *image)
NULL,
48, 1,
gtk_widget_get_direction (GTK_WIDGET (image)),
GTK_ICON_LOOKUP_GENERIC_FALLBACK);
0);
if (icon == NULL)
return NULL;
return GDK_PAINTABLE (icon);

View File

@ -140,7 +140,7 @@ insert_text (GtkTextView *view)
NULL,
32, 1,
gtk_widget_get_direction (widget),
GTK_ICON_LOOKUP_GENERIC_FALLBACK);
0);
texture = gtk_icon_download_texture (icon, NULL);
g_object_unref (icon);
g_assert (texture);

View File

@ -372,7 +372,7 @@ get_image_paintable (GtkImage *image)
NULL,
size, 1,
gtk_widget_get_direction (GTK_WIDGET (image)),
GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
GTK_ICON_LOOKUP_FORCE_SIZE);
if (icon == NULL)
return NULL;
return GDK_PAINTABLE (icon);

View File

@ -74,7 +74,7 @@ gtk_css_image_icon_theme_snapshot (GtkCssImage *image,
NULL,
size, icon_theme->scale,
GTK_TEXT_DIR_NONE,
0 | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
0);
g_assert (icon != NULL);

View File

@ -115,7 +115,7 @@ ensure_paintable_for_gicon (GtkIconHelper *self,
NULL,
width, scale,
dir,
flags | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
flags);
*symbolic = gtk_icon_is_symbolic (icon);
return GDK_PAINTABLE (icon);

View File

@ -2198,60 +2198,7 @@ gtk_icon_theme_lookup_icon (GtkIconTheme *self,
gtk_icon_theme_lock (self);
if (flags & GTK_ICON_LOOKUP_GENERIC_FALLBACK)
{
gchar **names, **nonsymbolic_names;
gint dashes, i;
gchar *p, *nonsymbolic_icon_name;
gboolean is_symbolic;
int icon_name_len = strlen (icon_name);
g_warn_if_fail (fallbacks == NULL);
is_symbolic = icon_name_is_symbolic (icon_name, icon_name_len);
if (is_symbolic)
nonsymbolic_icon_name = g_strndup (icon_name, icon_name_len - strlen ("-symbolic"));
else
nonsymbolic_icon_name = g_strdup (icon_name);
dashes = 0;
for (p = (gchar *) nonsymbolic_icon_name; *p; p++)
if (*p == '-')
dashes++;
nonsymbolic_names = g_new (gchar *, dashes + 2);
nonsymbolic_names[0] = nonsymbolic_icon_name;
for (i = 1; i <= dashes; i++)
{
nonsymbolic_names[i] = g_strdup (nonsymbolic_names[i - 1]);
p = strrchr (nonsymbolic_names[i], '-');
*p = '\0';
}
nonsymbolic_names[dashes + 1] = NULL;
if (is_symbolic)
{
names = g_new (gchar *, 2 * dashes + 3);
for (i = 0; nonsymbolic_names[i] != NULL; i++)
{
names[i] = g_strconcat (nonsymbolic_names[i], "-symbolic", NULL);
names[dashes + 1 + i] = nonsymbolic_names[i];
}
names[dashes + 1 + i] = NULL;
g_free (nonsymbolic_names);
}
else
{
names = nonsymbolic_names;
}
icon = choose_icon (self, (const char **) names, size, scale, direction, flags, FALSE, NULL);
g_strfreev (names);
}
else if (fallbacks)
if (fallbacks)
{
gsize n_fallbacks = g_strv_length ((char **) fallbacks);
const char **names = g_new (const char *, n_fallbacks + 2);
@ -3859,7 +3806,6 @@ gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self,
g_return_val_if_fail (GTK_IS_ICON_THEME (self), NULL);
g_return_val_if_fail (G_IS_ICON (gicon), NULL);
g_warn_if_fail ((flags & GTK_ICON_LOOKUP_GENERIC_FALLBACK) == 0);
if (GDK_IS_PIXBUF (gicon))
{

View File

@ -40,10 +40,6 @@ typedef struct _GtkIconTheme GtkIconTheme;
/**
* GtkIconLookupFlags:
* @GTK_ICON_LOOKUP_GENERIC_FALLBACK: Try to shorten icon name at '-'
* characters before looking at inherited themes. This flag is only
* supported in functions that take a single icon name. For more general
* fallback, see gtk_icon_theme_choose_icon()
* @GTK_ICON_LOOKUP_FORCE_SIZE: Always get the icon scaled to the
* requested size
* @GTK_ICON_LOOKUP_FORCE_REGULAR: Try to always load regular icons, even
@ -55,10 +51,9 @@ typedef struct _GtkIconTheme GtkIconTheme;
*/
typedef enum
{
GTK_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 0,
GTK_ICON_LOOKUP_FORCE_SIZE = 1 << 1,
GTK_ICON_LOOKUP_FORCE_REGULAR = 1 << 2,
GTK_ICON_LOOKUP_FORCE_SYMBOLIC = 1 << 3
GTK_ICON_LOOKUP_FORCE_SIZE = 1 << 0,
GTK_ICON_LOOKUP_FORCE_REGULAR = 1 << 1,
GTK_ICON_LOOKUP_FORCE_SYMBOLIC = 1 << 2
} GtkIconLookupFlags;
/**

View File

@ -30,7 +30,7 @@ get_image_texture (GtkImage *image,
NULL,
width, 1,
gtk_widget_get_direction (GTK_WIDGET (image)),
GTK_ICON_LOOKUP_GENERIC_FALLBACK);
0);
if (icon)
texture = gtk_icon_download_texture (icon, NULL);
g_object_unref (icon);

View File

@ -53,12 +53,24 @@ assert_icon_lookup_size (const char *icon_name,
gint size,
GtkTextDirection direction,
GtkIconLookupFlags flags,
gboolean fallbacks,
const char *filename,
gint pixbuf_size)
{
GtkIcon *info;
if (fallbacks)
{
GThemedIcon *fallback_icons = G_THEMED_ICON (g_themed_icon_new_with_default_fallbacks (icon_name));
const char **fallback_names = (const char **) g_themed_icon_get_names (fallback_icons);
info = gtk_icon_theme_lookup_icon (get_test_icontheme (FALSE), icon_name, &fallback_names[1], size, 1, direction, flags);
g_object_unref (fallback_icons);
}
else
{
info = gtk_icon_theme_lookup_icon (get_test_icontheme (FALSE), icon_name, NULL, size, 1, direction, flags);
}
if (info == NULL)
{
g_error ("Could not look up an icon for \"%s\" with flags %s at size %d",
@ -100,9 +112,10 @@ assert_icon_lookup (const char *icon_name,
gint size,
GtkTextDirection direction,
GtkIconLookupFlags flags,
gboolean fallbacks,
const char *filename)
{
assert_icon_lookup_size (icon_name, size, direction, flags, filename, -1);
assert_icon_lookup_size (icon_name, size, direction, flags, fallbacks, filename, -1);
}
static void
@ -162,6 +175,7 @@ assert_lookup_order (const char *icon_name,
gint size,
GtkTextDirection direction,
GtkIconLookupFlags flags,
gboolean fallbacks,
const char *first,
...)
{
@ -177,7 +191,18 @@ assert_lookup_order (const char *icon_name,
g_assert (lookups == NULL);
if (fallbacks)
{
GThemedIcon *fallback_icons = G_THEMED_ICON (g_themed_icon_new_with_default_fallbacks (icon_name));
const char **fallback_names = (const char **) g_themed_icon_get_names (fallback_icons);
info = gtk_icon_theme_lookup_icon (get_test_icontheme (FALSE), icon_name, &fallback_names[1], size, 1, direction, flags);
g_object_unref (fallback_icons);
}
else
{
info = gtk_icon_theme_lookup_icon (get_test_icontheme (FALSE), icon_name, NULL, size, 1, direction, flags);
}
if (info)
g_object_unref (info);
@ -205,30 +230,39 @@ static void
test_basics (void)
{
/* just a basic boring lookup so we know everything works */
assert_icon_lookup ("simple", 16, GTK_TEXT_DIR_NONE, 0, "/icons/16x16/simple.png");
assert_icon_lookup ("simple", 16, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/16x16/simple.png");
}
static void
test_lookup_order (void)
{
assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_GENERIC_FALLBACK,
assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_NONE, 0, TRUE,
"foo-bar-baz",
"foo-bar",
"foo",
"foo-bar-baz-symbolic",
"foo-bar-symbolic",
"foo-symbolic",
NULL);
assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_RTL, GTK_ICON_LOOKUP_GENERIC_FALLBACK,
assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_RTL, 0, TRUE,
"foo-bar-baz-rtl",
"foo-bar-baz",
"foo-bar-rtl",
"foo-bar",
"foo-rtl",
"foo",
"foo-bar-baz-symbolic-rtl",
"foo-bar-baz-symbolic",
"foo-bar-symbolic-rtl",
"foo-bar-symbolic",
"foo-symbolic-rtl",
"foo-symbolic",
NULL);
assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_RTL, 0,
assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_RTL, 0, FALSE,
"foo-bar-baz-rtl",
"foo-bar-baz",
NULL);
assert_lookup_order ("foo-bar-baz-symbolic", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_GENERIC_FALLBACK,
assert_lookup_order ("foo-bar-baz-symbolic", 16, GTK_TEXT_DIR_NONE, 0, TRUE,
"foo-bar-baz-symbolic",
"foo-bar-symbolic",
"foo-symbolic",
@ -237,13 +271,15 @@ test_lookup_order (void)
"foo",
NULL);
assert_lookup_order ("bla-bla", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
assert_lookup_order ("bla-bla", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
"bla-bla-symbolic",
"bla-symbolic",
"bla-bla-symbolic", /* awkward */
"bla-symbolic", /* awkward */
"bla-bla",
"bla",
NULL);
assert_lookup_order ("bla-bla-symbolic", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
assert_lookup_order ("bla-bla-symbolic", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
"bla-bla-symbolic",
"bla-symbolic",
"bla-bla-symbolic", /* awkward */
@ -252,17 +288,21 @@ test_lookup_order (void)
"bla",
NULL);
assert_lookup_order ("bar-baz", 16, GTK_TEXT_DIR_RTL, GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_GENERIC_FALLBACK,
assert_lookup_order ("bar-baz", 16, GTK_TEXT_DIR_RTL, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
"bar-baz-symbolic-rtl",
"bar-baz-symbolic",
"bar-symbolic-rtl",
"bar-symbolic",
"bar-baz-symbolic-rtl", /* awkward */
"bar-baz-symbolic", /* awkward */
"bar-symbolic-rtl", /* awkward */
"bar-symbolic", /* awkward */
"bar-baz-rtl",
"bar-baz",
"bar-rtl",
"bar",
NULL);
assert_lookup_order ("bar-baz-symbolic", 16, GTK_TEXT_DIR_RTL, GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_GENERIC_FALLBACK,
assert_lookup_order ("bar-baz-symbolic", 16, GTK_TEXT_DIR_RTL, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
"bar-baz-symbolic-rtl",
"bar-baz-symbolic",
"bar-symbolic-rtl",
@ -277,17 +317,21 @@ test_lookup_order (void)
"bar",
NULL);
assert_lookup_order ("bar-baz", 16, GTK_TEXT_DIR_LTR, GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_GENERIC_FALLBACK,
assert_lookup_order ("bar-baz", 16, GTK_TEXT_DIR_LTR, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
"bar-baz-symbolic-ltr",
"bar-baz-symbolic",
"bar-symbolic-ltr",
"bar-symbolic",
"bar-baz-symbolic-ltr", /* awkward */
"bar-baz-symbolic", /* awkward */
"bar-symbolic-ltr", /* awkward */
"bar-symbolic", /* awkward */
"bar-baz-ltr",
"bar-baz",
"bar-ltr",
"bar",
NULL);
assert_lookup_order ("bar-baz-symbolic", 16, GTK_TEXT_DIR_LTR, GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_GENERIC_FALLBACK,
assert_lookup_order ("bar-baz-symbolic", 16, GTK_TEXT_DIR_LTR, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
"bar-baz-symbolic-ltr",
"bar-baz-symbolic",
"bar-symbolic-ltr",
@ -310,14 +354,16 @@ test_generic_fallback (void)
assert_icon_lookup ("simple-foo-bar",
16,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
0,
TRUE,
"/icons/16x16/simple.png");
/* Check generic fallback also works for symbolics falling back to regular items */
assert_icon_lookup ("simple-foo-bar-symbolic",
16,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
0,
TRUE,
"/icons/16x16/simple.png");
/* Check we fall back to more generic symbolic icons before falling back to
@ -325,7 +371,8 @@ test_generic_fallback (void)
assert_icon_lookup ("everything-justregular-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
0,
TRUE,
"/icons/scalable/everything-symbolic.svg");
}
@ -337,12 +384,14 @@ test_force_symbolic (void)
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
FALSE,
"/icons/scalable/everything-symbolic.svg");
/* check forcing symbolic also works for symbolic icons (d'oh) */
assert_icon_lookup ("everything-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
FALSE,
"/icons/scalable/everything-symbolic.svg");
/* check all the combos for fallbacks on an icon that only exists as symbolic */
@ -350,21 +399,25 @@ test_force_symbolic (void)
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
FALSE,
"/icons/scalable/everything-justsymbolic-symbolic.svg");
assert_icon_lookup ("everything-justsymbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
TRUE,
"/icons/scalable/everything-justsymbolic-symbolic.svg");
assert_icon_lookup ("everything-justsymbolic-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
FALSE,
"/icons/scalable/everything-justsymbolic-symbolic.svg");
assert_icon_lookup ("everything-justsymbolic-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
TRUE,
"/icons/scalable/everything-justsymbolic-symbolic.svg");
/* check all the combos for fallbacks, this time for an icon that only exists as regular */
@ -372,11 +425,13 @@ test_force_symbolic (void)
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
FALSE,
"/icons/scalable/everything-justregular.svg");
assert_icon_lookup ("everything-justregular",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
TRUE,
"/icons/scalable/everything-symbolic.svg");
assert_icon_lookup_fails ("everything-justregular-symbolic",
SCALABLE_IMAGE_SIZE,
@ -385,7 +440,8 @@ test_force_symbolic (void)
assert_icon_lookup ("everything-justregular-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
TRUE,
"/icons/scalable/everything-symbolic.svg");
}
@ -397,12 +453,14 @@ test_force_regular (void)
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_FORCE_REGULAR,
FALSE,
"/icons/scalable/everything.svg");
/* check forcing regular also works for symbolic icons ) */
assert_icon_lookup ("everything-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_FORCE_REGULAR,
FALSE,
"/icons/scalable/everything.svg");
/* check all the combos for fallbacks on an icon that only exists as regular */
@ -410,21 +468,25 @@ test_force_regular (void)
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_FORCE_REGULAR,
FALSE,
"/icons/scalable/everything-justregular.svg");
assert_icon_lookup ("everything-justregular",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_REGULAR,
GTK_ICON_LOOKUP_FORCE_REGULAR,
TRUE,
"/icons/scalable/everything-justregular.svg");
assert_icon_lookup ("everything-justregular-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_FORCE_REGULAR,
FALSE,
"/icons/scalable/everything-justregular.svg");
assert_icon_lookup ("everything-justregular-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_REGULAR,
GTK_ICON_LOOKUP_FORCE_REGULAR,
TRUE,
"/icons/scalable/everything-justregular.svg");
/* check all the combos for fallbacks, this time for an icon that only exists as symbolic */
@ -435,17 +497,20 @@ test_force_regular (void)
assert_icon_lookup ("everything-justsymbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_REGULAR,
GTK_ICON_LOOKUP_FORCE_REGULAR,
TRUE,
"/icons/scalable/everything.svg");
assert_icon_lookup ("everything-justsymbolic-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_FORCE_REGULAR,
FALSE,
"/icons/scalable/everything-justsymbolic-symbolic.svg");
assert_icon_lookup ("everything-justsymbolic-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_REGULAR,
GTK_ICON_LOOKUP_FORCE_REGULAR,
TRUE,
"/icons/scalable/everything.svg");
}
@ -456,11 +521,13 @@ test_rtl (void)
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_RTL,
0,
FALSE,
"/icons/scalable/everything-rtl.svg");
assert_icon_lookup ("everything-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_RTL,
0,
FALSE,
"/icons/scalable/everything-symbolic-rtl.svg");
assert_icon_lookup_fails ("everything-justrtl",
@ -475,22 +542,26 @@ test_rtl (void)
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_RTL,
0,
FALSE,
"/icons/scalable/everything-justrtl-rtl.svg");
assert_icon_lookup ("everything-justrtl",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
0,
TRUE,
"/icons/scalable/everything.svg");
assert_icon_lookup ("everything-justrtl",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_LTR,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
0,
TRUE,
"/icons/scalable/everything.svg");
assert_icon_lookup ("everything-justrtl",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_RTL,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
0,
TRUE,
"/icons/scalable/everything-justrtl-rtl.svg");
}
@ -502,17 +573,20 @@ test_symbolic_single_size (void)
32,
GTK_TEXT_DIR_NONE,
0,
FALSE,
"/icons/32x32/only32-symbolic.svg");
/* Check that we still properly load it even if a different size is requested */
assert_icon_lookup ("only32-symbolic",
16,
GTK_TEXT_DIR_NONE,
0,
FALSE,
"/icons/32x32/only32-symbolic.svg");
assert_icon_lookup ("only32-symbolic",
128,
GTK_TEXT_DIR_NONE,
0,
FALSE,
"/icons/32x32/only32-symbolic.svg");
}
@ -524,69 +598,69 @@ test_svg_size (void)
* account for choosing).
*/
/* Check we properly load a svg icon from a sized directory */
assert_icon_lookup_size ("twosize-fixed", 48, GTK_TEXT_DIR_NONE, 0, "/icons/32x32/twosize-fixed.svg", 32);
assert_icon_lookup_size ("twosize-fixed", 32, GTK_TEXT_DIR_NONE, 0, "/icons/32x32/twosize-fixed.svg", 32);
assert_icon_lookup_size ("twosize-fixed", 20, GTK_TEXT_DIR_NONE, 0, "/icons/32x32/twosize-fixed.svg", 32);
assert_icon_lookup_size ("twosize-fixed", 16, GTK_TEXT_DIR_NONE, 0, "/icons/16x16/twosize-fixed.svg", 16);
assert_icon_lookup_size ("twosize-fixed", 48, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/32x32/twosize-fixed.svg", 32);
assert_icon_lookup_size ("twosize-fixed", 32, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/32x32/twosize-fixed.svg", 32);
assert_icon_lookup_size ("twosize-fixed", 20, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/32x32/twosize-fixed.svg", 32);
assert_icon_lookup_size ("twosize-fixed", 16, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/16x16/twosize-fixed.svg", 16);
/* Check that we still properly load it even if a different size is requested */
assert_icon_lookup_size ("twosize", 64, GTK_TEXT_DIR_NONE, 0, "/icons/32x32s/twosize.svg", 48);
assert_icon_lookup_size ("twosize", 48, GTK_TEXT_DIR_NONE, 0, "/icons/32x32s/twosize.svg", 48);
assert_icon_lookup_size ("twosize", 32, GTK_TEXT_DIR_NONE, 0, "/icons/32x32s/twosize.svg", 32);
assert_icon_lookup_size ("twosize", 24, GTK_TEXT_DIR_NONE, 0, "/icons/32x32s/twosize.svg", 24);
assert_icon_lookup_size ("twosize", 16, GTK_TEXT_DIR_NONE, 0, "/icons/16x16s/twosize.svg", 16);
assert_icon_lookup_size ("twosize", 12, GTK_TEXT_DIR_NONE, 0, "/icons/16x16s/twosize.svg", 12);
assert_icon_lookup_size ("twosize", 8, GTK_TEXT_DIR_NONE, 0, "/icons/16x16s/twosize.svg", 12);
assert_icon_lookup_size ("twosize", 64, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/32x32s/twosize.svg", 48);
assert_icon_lookup_size ("twosize", 48, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/32x32s/twosize.svg", 48);
assert_icon_lookup_size ("twosize", 32, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/32x32s/twosize.svg", 32);
assert_icon_lookup_size ("twosize", 24, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/32x32s/twosize.svg", 24);
assert_icon_lookup_size ("twosize", 16, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/16x16s/twosize.svg", 16);
assert_icon_lookup_size ("twosize", 12, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/16x16s/twosize.svg", 12);
assert_icon_lookup_size ("twosize", 8, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/16x16s/twosize.svg", 12);
}
static void
test_size (void)
{
assert_icon_lookup_size ("size-test", 12, GTK_TEXT_DIR_NONE, 0, "/icons/15/size-test.png", 15);
assert_icon_lookup_size ("size-test", 13, GTK_TEXT_DIR_NONE, 0, "/icons/15/size-test.png", 15);
assert_icon_lookup_size ("size-test", 14, GTK_TEXT_DIR_NONE, 0, "/icons/15/size-test.png", 15);
assert_icon_lookup_size ("size-test", 15, GTK_TEXT_DIR_NONE, 0, "/icons/15/size-test.png", 15);
assert_icon_lookup_size ("size-test", 16, GTK_TEXT_DIR_NONE, 0, "/icons/16-22/size-test.png", 19);
assert_icon_lookup_size ("size-test", 17, GTK_TEXT_DIR_NONE, 0, "/icons/16-22/size-test.png", 19);
assert_icon_lookup_size ("size-test", 18, GTK_TEXT_DIR_NONE, 0, "/icons/16-22/size-test.png", 19);
assert_icon_lookup_size ("size-test", 19, GTK_TEXT_DIR_NONE, 0, "/icons/16-22/size-test.png", 19);
assert_icon_lookup_size ("size-test", 12, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/15/size-test.png", 15);
assert_icon_lookup_size ("size-test", 13, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/15/size-test.png", 15);
assert_icon_lookup_size ("size-test", 14, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/15/size-test.png", 15);
assert_icon_lookup_size ("size-test", 15, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/15/size-test.png", 15);
assert_icon_lookup_size ("size-test", 16, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/16-22/size-test.png", 19);
assert_icon_lookup_size ("size-test", 17, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/16-22/size-test.png", 19);
assert_icon_lookup_size ("size-test", 18, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/16-22/size-test.png", 19);
assert_icon_lookup_size ("size-test", 19, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/16-22/size-test.png", 19);
/* the next 3 are because we never scale up */
assert_icon_lookup_size ("size-test", 20, GTK_TEXT_DIR_NONE, 0, "/icons/25+/size-test.svg", 25);
assert_icon_lookup_size ("size-test", 21, GTK_TEXT_DIR_NONE, 0, "/icons/25+/size-test.svg", 25);
assert_icon_lookup_size ("size-test", 22, GTK_TEXT_DIR_NONE, 0, "/icons/25+/size-test.svg", 25);
assert_icon_lookup_size ("size-test", 20, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/25+/size-test.svg", 25);
assert_icon_lookup_size ("size-test", 21, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/25+/size-test.svg", 25);
assert_icon_lookup_size ("size-test", 22, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/25+/size-test.svg", 25);
assert_icon_lookup_size ("size-test", 23, GTK_TEXT_DIR_NONE, 0, "/icons/25+/size-test.svg", 25);
assert_icon_lookup_size ("size-test", 23, GTK_TEXT_DIR_NONE, 0, "/icons/25+/size-test.svg", 25);
assert_icon_lookup_size ("size-test", 25, GTK_TEXT_DIR_NONE, 0, "/icons/25+/size-test.svg", 25);
assert_icon_lookup_size ("size-test", 28, GTK_TEXT_DIR_NONE, 0, "/icons/25+/size-test.svg", 28);
assert_icon_lookup_size ("size-test", 23, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/25+/size-test.svg", 25);
assert_icon_lookup_size ("size-test", 23, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/25+/size-test.svg", 25);
assert_icon_lookup_size ("size-test", 25, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/25+/size-test.svg", 25);
assert_icon_lookup_size ("size-test", 28, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/25+/size-test.svg", 28);
/* the next 2 are because we never scale up */
assert_icon_lookup_size ("size-test", 31, GTK_TEXT_DIR_NONE, 0, "/icons/35+/size-test.svg", 35);
assert_icon_lookup_size ("size-test", 34, GTK_TEXT_DIR_NONE, 0, "/icons/35+/size-test.svg", 35);
assert_icon_lookup_size ("size-test", 31, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/35+/size-test.svg", 35);
assert_icon_lookup_size ("size-test", 34, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/35+/size-test.svg", 35);
assert_icon_lookup_size ("size-test", 37, GTK_TEXT_DIR_NONE, 0, "/icons/35+/size-test.svg", 37);
assert_icon_lookup_size ("size-test", 40, GTK_TEXT_DIR_NONE, 0, "/icons/35+/size-test.svg", 40);
assert_icon_lookup_size ("size-test", 45, GTK_TEXT_DIR_NONE, 0, "/icons/35+/size-test.svg", 45);
assert_icon_lookup_size ("size-test", 37, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/35+/size-test.svg", 37);
assert_icon_lookup_size ("size-test", 40, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/35+/size-test.svg", 40);
assert_icon_lookup_size ("size-test", 45, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/35+/size-test.svg", 45);
assert_icon_lookup_size ("size-test", 12, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/15/size-test.png", 12);
assert_icon_lookup_size ("size-test", 13, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/15/size-test.png", 13);
assert_icon_lookup_size ("size-test", 14, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/15/size-test.png", 14);
assert_icon_lookup_size ("size-test", 15, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/15/size-test.png", 15);
assert_icon_lookup_size ("size-test", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/16-22/size-test.png", 16);
assert_icon_lookup_size ("size-test", 17, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/16-22/size-test.png", 17);
assert_icon_lookup_size ("size-test", 18, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/16-22/size-test.png", 18);
assert_icon_lookup_size ("size-test", 19, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/16-22/size-test.png", 19);
//assert_icon_lookup_size ("size-test", 20, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/16-22/size-test.png", 20);
//assert_icon_lookup_size ("size-test", 21, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/16-22/size-test.png", 21);
//assert_icon_lookup_size ("size-test", 22, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/16-22/size-test.png", 22);
assert_icon_lookup_size ("size-test", 23, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/25+/size-test.svg", 23);
assert_icon_lookup_size ("size-test", 24, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/25+/size-test.svg", 24);
assert_icon_lookup_size ("size-test", 25, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/25+/size-test.svg", 25);
assert_icon_lookup_size ("size-test", 28, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/25+/size-test.svg", 28);
//assert_icon_lookup_size ("size-test", 31, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/25+/size-test.svg", 31);
//assert_icon_lookup_size ("size-test", 34, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/25+/size-test.svg", 34);
assert_icon_lookup_size ("size-test", 37, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/35+/size-test.svg", 37);
assert_icon_lookup_size ("size-test", 40, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/35+/size-test.svg", 40);
assert_icon_lookup_size ("size-test", 45, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/35+/size-test.svg", 45);
assert_icon_lookup_size ("size-test", 12, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/15/size-test.png", 12);
assert_icon_lookup_size ("size-test", 13, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/15/size-test.png", 13);
assert_icon_lookup_size ("size-test", 14, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/15/size-test.png", 14);
assert_icon_lookup_size ("size-test", 15, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/15/size-test.png", 15);
assert_icon_lookup_size ("size-test", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/16-22/size-test.png", 16);
assert_icon_lookup_size ("size-test", 17, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/16-22/size-test.png", 17);
assert_icon_lookup_size ("size-test", 18, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/16-22/size-test.png", 18);
assert_icon_lookup_size ("size-test", 19, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/16-22/size-test.png", 19);
//assert_icon_lookup_size ("size-test", 20, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/16-22/size-test.png", 20);
//assert_icon_lookup_size ("size-test", 21, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/16-22/size-test.png", 21);
//assert_icon_lookup_size ("size-test", 22, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/16-22/size-test.png", 22);
assert_icon_lookup_size ("size-test", 23, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/25+/size-test.svg", 23);
assert_icon_lookup_size ("size-test", 24, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/25+/size-test.svg", 24);
assert_icon_lookup_size ("size-test", 25, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/25+/size-test.svg", 25);
assert_icon_lookup_size ("size-test", 28, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/25+/size-test.svg", 28);
//assert_icon_lookup_size ("size-test", 31, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/25+/size-test.svg", 31);
//assert_icon_lookup_size ("size-test", 34, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/25+/size-test.svg", 34);
assert_icon_lookup_size ("size-test", 37, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/35+/size-test.svg", 37);
assert_icon_lookup_size ("size-test", 40, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/35+/size-test.svg", 40);
assert_icon_lookup_size ("size-test", 45, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, FALSE, "/icons/35+/size-test.svg", 45);
}
static void
@ -633,32 +707,38 @@ test_inherit (void)
assert_icon_lookup ("one-two-three",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
0,
TRUE,
"/icons/scalable/one-two.svg");
assert_icon_lookup ("one-two-three",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_RTL,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
0,
TRUE,
"/icons/scalable/one-two-rtl.svg");
assert_icon_lookup ("one-two-three-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
0,
TRUE,
"/icons2/scalable/one-two-three-symbolic.svg");
assert_icon_lookup ("one-two-three-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_RTL,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
0,
TRUE,
"/icons2/scalable/one-two-three-symbolic.svg");
assert_icon_lookup ("one-two-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_NONE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
0,
TRUE,
"/icons2/scalable/one-two-symbolic.svg");
assert_icon_lookup ("one-two-symbolic",
SCALABLE_IMAGE_SIZE,
GTK_TEXT_DIR_RTL,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
0,
TRUE,
"/icons2/scalable/one-two-symbolic-rtl.svg");
}