cssstyleproperty: Make it possible to query CSS opacity with gtk_style_context_get()

Add a query implementation to opacity property. Also fix the assert in
gtk_css_style_property_register() to allow registering properties with
query but without assign function.

https://bugzilla.gnome.org/show_bug.cgi?id=760933
This commit is contained in:
Carlos Garcia Campos 2016-01-21 14:36:42 +01:00 committed by Carlos Garcia Campos
parent bd4aaa1285
commit 0f7b4dad0f

View File

@ -88,7 +88,7 @@ gtk_css_style_property_register (const char * name,
g_assert (initial_value != NULL);
g_assert (parse_value != NULL);
g_assert (value_type == G_TYPE_NONE || query_value != NULL);
g_assert (value_type == G_TYPE_NONE || assign_value != NULL);
g_assert (assign_value == NULL || query_value != NULL);
node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY,
"value-type", value_type,
@ -457,6 +457,15 @@ opacity_parse (GtkCssStyleProperty *property,
return _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER);
}
static void
opacity_query (GtkCssStyleProperty *property,
const GtkCssValue *css_value,
GValue *value)
{
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, _gtk_css_number_value_get (css_value, 100));
}
static GtkCssValue *
parse_one_css_play_state (GtkCssParser *parser)
@ -1761,11 +1770,11 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("opacity",
GTK_CSS_PROPERTY_OPACITY,
G_TYPE_NONE,
G_TYPE_DOUBLE,
GTK_STYLE_PROPERTY_ANIMATED,
0,
opacity_parse,
NULL,
opacity_query,
NULL,
_gtk_css_number_value_new (1, GTK_CSS_NUMBER));
gtk_css_style_property_register ("-gtk-icon-effect",