css: Add a check function for specified types
... and use it. It seems kinda necessary for the refactoring I'm about to do...
This commit is contained in:
@ -1212,6 +1212,9 @@ gtk_css_ruleset_add (GtkCssRuleset *ruleset,
|
|||||||
}
|
}
|
||||||
else if (GTK_IS_CSS_STYLE_PROPERTY (prop))
|
else if (GTK_IS_CSS_STYLE_PROPERTY (prop))
|
||||||
{
|
{
|
||||||
|
g_return_if_fail (_gtk_css_style_property_is_specified_type (GTK_CSS_STYLE_PROPERTY (prop),
|
||||||
|
G_VALUE_TYPE (&value->value)));
|
||||||
|
|
||||||
_gtk_bitmask_set (ruleset->set_styles,
|
_gtk_bitmask_set (ruleset->set_styles,
|
||||||
_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (prop)),
|
_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (prop)),
|
||||||
TRUE);
|
TRUE);
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
#include "gtkprivatetypebuiltins.h"
|
#include "gtkprivatetypebuiltins.h"
|
||||||
#include "gtkstylepropertiesprivate.h"
|
#include "gtkstylepropertiesprivate.h"
|
||||||
|
|
||||||
|
#include <cairo-gobject.h>
|
||||||
#include "gtkcssimagegradientprivate.h"
|
#include "gtkcssimagegradientprivate.h"
|
||||||
#include "gtkcssimageprivate.h"
|
#include "gtkcssimageprivate.h"
|
||||||
|
|
||||||
@ -441,6 +442,28 @@ _gtk_css_style_property_get_specified_type (GtkCssStyleProperty *property)
|
|||||||
return G_VALUE_TYPE (&property->initial_value);
|
return G_VALUE_TYPE (&property->initial_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_gtk_css_style_property_is_specified_type (GtkCssStyleProperty *property,
|
||||||
|
GType type)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), FALSE);
|
||||||
|
|
||||||
|
/* If it's our specified type, of course it's valid */
|
||||||
|
if (type == G_VALUE_TYPE (&property->initial_value))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
/* The special values 'inherit' and 'initial' are always valid */
|
||||||
|
if (type == GTK_TYPE_CSS_SPECIAL_VALUE)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
/* XXX: Someone needs to fix that legacy */
|
||||||
|
if (G_VALUE_TYPE (&property->initial_value) == CAIRO_GOBJECT_TYPE_PATTERN &&
|
||||||
|
type == GTK_TYPE_GRADIENT)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _gtk_css_style_property_compute_value:
|
* _gtk_css_style_property_compute_value:
|
||||||
* @property: the property
|
* @property: the property
|
||||||
|
|||||||
@ -80,6 +80,8 @@ const GValue * _gtk_css_style_property_get_initial_value
|
|||||||
(GtkCssStyleProperty *property);
|
(GtkCssStyleProperty *property);
|
||||||
GType _gtk_css_style_property_get_computed_type (GtkCssStyleProperty *property);
|
GType _gtk_css_style_property_get_computed_type (GtkCssStyleProperty *property);
|
||||||
GType _gtk_css_style_property_get_specified_type (GtkCssStyleProperty *property);
|
GType _gtk_css_style_property_get_specified_type (GtkCssStyleProperty *property);
|
||||||
|
gboolean _gtk_css_style_property_is_specified_type (GtkCssStyleProperty *property,
|
||||||
|
GType type);
|
||||||
|
|
||||||
void _gtk_css_style_property_compute_value (GtkCssStyleProperty *property,
|
void _gtk_css_style_property_compute_value (GtkCssStyleProperty *property,
|
||||||
GValue *computed,
|
GValue *computed,
|
||||||
|
|||||||
Reference in New Issue
Block a user