Use stylish_get_icon_style_from_term()

Add tests for getting the -st-icon-style property, and its default
value on a node that doesn't have that property
parent c2e1dfc1
Pipeline #135782 failed with stages
in 8 minutes and 57 seconds
......@@ -2056,8 +2056,10 @@ st_theme_node_get_transition_duration (StThemeNode *node)
return factor * node->transition_duration;
}
StIconStyle
st_theme_node_get_icon_style (StThemeNode *node)
static gboolean
st_theme_node_lookup_icon_style (StThemeNode *node,
gboolean inherit,
StIconStyle *style)
{
int i;
......@@ -2069,33 +2071,34 @@ st_theme_node_get_icon_style (StThemeNode *node)
if (strcmp (cr_declaration_name (decl), "-st-icon-style") == 0)
{
CRTerm *term;
for (term = decl->value; term; term = term->next)
GetFromTermResult result = stylish_get_icon_style_from_term (decl->value, style);
if (result == VALUE_FOUND)
{
if (term->type != TERM_IDENT)
goto next_decl;
if (strcmp (term->content.str->stryng->str, "requested") == 0)
return ST_ICON_STYLE_REQUESTED;
else if (strcmp (term->content.str->stryng->str, "regular") == 0)
return ST_ICON_STYLE_REGULAR;
else if (strcmp (term->content.str->stryng->str, "symbolic") == 0)
return ST_ICON_STYLE_SYMBOLIC;
else
g_warning ("Unknown -st-icon-style \"%s\"",
term->content.str->stryng->str);
return TRUE;
}
else if (result == VALUE_INHERIT)
{
inherit = TRUE;
break;
}
}
next_decl:
;
}
if (node->parent_node)
return st_theme_node_get_icon_style (node->parent_node);
if (inherit && node->parent_node)
return st_theme_node_lookup_icon_style (node->parent_node, inherit, style);
return ST_ICON_STYLE_REQUESTED;
return FALSE;
}
StIconStyle
st_theme_node_get_icon_style (StThemeNode *node)
{
StIconStyle style;
if (st_theme_node_lookup_icon_style (node, FALSE, &style))
return style;
else
return ST_ICON_STYLE_REQUESTED;
}
StTextDecoration
......
......@@ -323,6 +323,21 @@ test_url (void)
g_object_unref (file);
}
static void
test_icon_style (void)
{
StIconStyle style;
test = "icon_style";
style = st_theme_node_get_icon_style (group1);
g_assert (style == ST_ICON_STYLE_SYMBOLIC);
/* test the default value */
style = st_theme_node_get_icon_style (text1);
g_assert (style == ST_ICON_STYLE_REQUESTED);
}
static void
test_classes (void)
{
......@@ -639,6 +654,7 @@ main (int argc, char **argv)
test_time ();
test_lengths ();
test_url ();
test_icon_style ();
test_classes ();
test_type_inheritance ();
test_adjacent_selector ();
......
......@@ -22,6 +22,8 @@ stage {
time-ms: 42000ms;
url-prop: url("foo.svg");
-st-icon-style: symbolic;
}
#text1 {
......
Subproject commit e581508df3de7e1c5b49edeeab99b02a9a22fb4f
Subproject commit 21d14323c1cae3e24474628e5e40b3422b394a76
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment