mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-11 03:10:09 +00:00
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:
parent
bd4aaa1285
commit
0f7b4dad0f
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user