st_theme_node_lookup_double(): Extract function to get the value from the CRTerm

This makes the rest of the function have a similar structure to
st_theme_node_lookup_color(), which will aid refactoring.
parent 72873ec1
...@@ -597,6 +597,19 @@ st_theme_node_get_color (StThemeNode *node, ...@@ -597,6 +597,19 @@ st_theme_node_get_color (StThemeNode *node,
} }
} }
static GetFromTermResult
get_double_from_term (CRTerm *term,
double *value)
{
if (term->type != TERM_NUMBER || term->content.num->type != NUM_GENERIC)
{
return VALUE_NOT_FOUND;
}
*value = term->content.num->val;
return VALUE_FOUND;
}
/** /**
* st_theme_node_lookup_double: * st_theme_node_lookup_double:
* @node: a #StThemeNode * @node: a #StThemeNode
...@@ -635,18 +648,20 @@ st_theme_node_lookup_double (StThemeNode *node, ...@@ -635,18 +648,20 @@ st_theme_node_lookup_double (StThemeNode *node,
if (strcmp (decl->property->stryng->str, property_name) == 0) if (strcmp (decl->property->stryng->str, property_name) == 0)
{ {
CRTerm *term = decl->value; GetFromTermResult result = get_double_from_term (decl->value, value);
if (result == VALUE_FOUND)
if (term->type != TERM_NUMBER || term->content.num->type != NUM_GENERIC) {
continue; return TRUE;
}
*value = term->content.num->val; else if (result == VALUE_INHERIT)
result = TRUE; {
inherit = TRUE;
break; break;
} }
} }
}
if (!result && inherit && node->parent_node) if (inherit && node->parent_node)
result = st_theme_node_lookup_double (node->parent_node, property_name, inherit, value); result = st_theme_node_lookup_double (node->parent_node, property_name, inherit, value);
return result; return result;
......
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