[gtk+] cssstyleproperty: Make it possible to query CSS opacity with gtk_style_context_get()
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] cssstyleproperty: Make it possible to query CSS opacity with gtk_style_context_get()
- Date: Thu, 21 Jan 2016 13:59:38 +0000 (UTC)
commit 0f7b4dad0f6cef80172638efb019ce094d7eadee
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Thu Jan 21 14:36:42 2016 +0100
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
gtk/gtkcssstylepropertyimpl.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index b817f16..1b99a78 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -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",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]