Commit 544d210a authored by Benjamin Otte's avatar Benjamin Otte

css: Move a bunch of functions

... from GtkStyleProperty to GtkCssStyleProperty.
parent 0a3ac5ef
......@@ -23,7 +23,7 @@
#include "gtkcsstypesprivate.h"
#include "gtkprivatetypebuiltins.h"
#include "gtkstylepropertyprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkstylepropertiesprivate.h"
struct _GtkCssLookup {
......@@ -35,7 +35,7 @@ GtkCssLookup *
_gtk_css_lookup_new (void)
{
GtkCssLookup *lookup;
guint n = _gtk_style_property_get_count ();
guint n = _gtk_css_style_property_get_n_properties ();
lookup = g_malloc0 (sizeof (GtkCssLookup) + sizeof (const GValue *) * n);
lookup->missing = _gtk_bitmask_new ();
......@@ -117,12 +117,12 @@ _gtk_css_lookup_resolve (GtkCssLookup *lookup,
g_return_val_if_fail (lookup != NULL, NULL);
g_return_val_if_fail (parent == NULL || GTK_IS_STYLE_CONTEXT (parent), NULL);
n = _gtk_style_property_get_count ();
n = _gtk_css_style_property_get_n_properties ();
props = gtk_style_properties_new ();
for (i = 0; i < n; i++)
{
GtkStyleProperty *prop = _gtk_style_property_get (i);
GtkCssStyleProperty *prop = _gtk_css_style_property_lookup_by_id (i);
const GValue *result;
/* http://www.w3.org/TR/css3-cascade/#cascade
......@@ -155,7 +155,7 @@ _gtk_css_lookup_resolve (GtkCssLookup *lookup,
/* if the value of the winning declaration is ‘initial’,
* the initial value (see below) becomes the specified value.
*/
result = _gtk_style_property_get_initial_value (prop);
result = _gtk_css_style_property_get_initial_value (prop);
break;
default:
/* This is part of (2) above */
......@@ -166,7 +166,7 @@ _gtk_css_lookup_resolve (GtkCssLookup *lookup,
}
else
{
if (_gtk_style_property_is_inherit (prop))
if (_gtk_css_style_property_is_inherit (prop))
{
/* 4) if the property is inherited, the inherited value becomes
* the specified value.
......@@ -177,7 +177,7 @@ _gtk_css_lookup_resolve (GtkCssLookup *lookup,
{
/* 5) Otherwise, the initial value becomes the specified value.
*/
result = _gtk_style_property_get_initial_value (prop);
result = _gtk_css_style_property_get_initial_value (prop);
}
}
......@@ -195,14 +195,14 @@ _gtk_css_lookup_resolve (GtkCssLookup *lookup,
_gtk_style_properties_set_property_by_property (props,
prop,
0,
_gtk_style_property_get_initial_value (prop));
_gtk_css_style_property_get_initial_value (prop));
}
else
{
GValue value = { 0, };
/* Set NULL here and do the inheritance upon lookup? */
gtk_style_context_get_property (parent,
_gtk_style_property_get_name (prop),
_gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)),
gtk_style_context_get_state (parent),
&value);
_gtk_style_properties_set_property_by_property (props,
......
......@@ -1211,9 +1211,17 @@ gtk_css_ruleset_add (GtkCssRuleset *ruleset,
property_value_free (value);
return;
}
_gtk_bitmask_set (ruleset->set_styles, _gtk_style_property_get_id (prop), TRUE);
g_hash_table_insert (ruleset->style, (gpointer) prop, value);
else if (GTK_IS_CSS_STYLE_PROPERTY (prop))
{
_gtk_bitmask_set (ruleset->set_styles,
_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (prop)),
TRUE);
g_hash_table_insert (ruleset->style, prop, value);
}
else
{
g_assert_not_reached ();
}
}
static gboolean
......@@ -1422,7 +1430,7 @@ gtk_css_provider_get_style (GtkStyleProvider *provider,
while (g_hash_table_iter_next (&iter, &key, &val))
{
GtkStyleProperty *prop = key;
GtkCssStyleProperty *prop = key;
PropertyValue *value = val;
_gtk_style_properties_set_property_by_property (props,
......@@ -1545,13 +1553,14 @@ gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
while (g_hash_table_iter_next (&iter, &key, &val))
{
GtkStyleProperty *prop = key;
GtkCssStyleProperty *prop = key;
PropertyValue *value = val;
guint id = _gtk_css_style_property_get_id (prop);
if (!_gtk_css_lookup_is_missing (lookup, _gtk_style_property_get_id (prop)))
if (!_gtk_css_lookup_is_missing (lookup, id))
continue;
_gtk_css_lookup_set (lookup, _gtk_style_property_get_id (prop), &value->value);
_gtk_css_lookup_set (lookup, id, &value->value);
}
}
}
......
......@@ -142,3 +142,19 @@ _gtk_css_style_property_get_id (GtkCssStyleProperty *property)
return property->id;
}
gboolean
_gtk_css_style_property_is_inherit (GtkCssStyleProperty *property)
{
g_return_val_if_fail (property != NULL, FALSE);
return GTK_STYLE_PROPERTY (property)->flags & GTK_STYLE_PROPERTY_INHERIT ? TRUE : FALSE;
}
const GValue *
_gtk_css_style_property_get_initial_value (GtkCssStyleProperty *property)
{
g_return_val_if_fail (property != NULL, NULL);
return &GTK_STYLE_PROPERTY (property)->initial_value;
}
......@@ -54,7 +54,10 @@ GType _gtk_css_style_property_get_type (void) G_GNUC_CO
guint _gtk_css_style_property_get_n_properties(void);
GtkCssStyleProperty * _gtk_css_style_property_lookup_by_id (guint id);
gboolean _gtk_css_style_property_is_inherit (GtkCssStyleProperty *property);
guint _gtk_css_style_property_get_id (GtkCssStyleProperty *property);
const GValue * _gtk_css_style_property_get_initial_value
(GtkCssStyleProperty *property);
G_END_DECLS
......
......@@ -327,12 +327,12 @@ gtk_style_properties_provider_lookup (GtkStyleProviderPrivate *provider,
while (g_hash_table_iter_next (&iter, &key, &value))
{
GtkStyleProperty *prop = key;
GtkCssStyleProperty *prop = key;
PropertyData *data = value;
const GValue *value;
guint id;
id = _gtk_style_property_get_id (prop);
id = _gtk_css_style_property_get_id (prop);
if (!_gtk_css_lookup_is_missing (lookup, id))
continue;
......@@ -521,10 +521,10 @@ gtk_style_properties_lookup_color (GtkStyleProperties *props,
}
void
_gtk_style_properties_set_property_by_property (GtkStyleProperties *props,
GtkStyleProperty *style_prop,
GtkStateFlags state,
const GValue *value)
_gtk_style_properties_set_property_by_property (GtkStyleProperties *props,
GtkCssStyleProperty *style_prop,
GtkStateFlags state,
const GValue *value)
{
GtkStylePropertiesPrivate *priv;
PropertyData *prop;
......@@ -552,8 +552,8 @@ _gtk_style_properties_set_property_by_property (GtkStyleProperties *props,
}
g_value_copy (value, val);
if (_gtk_style_property_get_value_type (style_prop) == G_VALUE_TYPE (value))
g_param_value_validate (style_prop->pspec, val);
if (_gtk_style_property_get_value_type (GTK_STYLE_PROPERTY (style_prop)) == G_VALUE_TYPE (value))
g_param_value_validate (GTK_STYLE_PROPERTY (style_prop)->pspec, val);
}
/**
......@@ -680,9 +680,9 @@ gtk_style_properties_set (GtkStyleProperties *props,
}
const GValue *
_gtk_style_properties_peek_property (GtkStyleProperties *props,
GtkStyleProperty *property,
GtkStateFlags state)
_gtk_style_properties_peek_property (GtkStyleProperties *props,
GtkCssStyleProperty *property,
GtkStateFlags state)
{
GtkStylePropertiesPrivate *priv;
PropertyData *prop;
......
......@@ -21,7 +21,7 @@
#define __GTK_STYLE_PROPERTIES_PRIVATE_H__
#include "gtkstyleproperties.h"
#include "gtkstylepropertyprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtksymboliccolorprivate.h"
......@@ -40,10 +40,10 @@ void _gtk_style_properties_get_valist (GtkStylePropertie
va_list args);
const GValue * _gtk_style_properties_peek_property (GtkStyleProperties *props,
GtkStyleProperty *property,
GtkCssStyleProperty *property,
GtkStateFlags state);
void _gtk_style_properties_set_property_by_property (GtkStyleProperties *props,
GtkStyleProperty *property,
GtkCssStyleProperty *property,
GtkStateFlags state,
const GValue *value);
......
......@@ -1612,18 +1612,6 @@ transparent_color_value_parse (GtkCssParser *parser,
/*** API ***/
guint
_gtk_style_property_get_count (void)
{
return _gtk_css_style_property_get_n_properties ();
}
GtkStyleProperty *
_gtk_style_property_get (guint id)
{
return GTK_STYLE_PROPERTY (_gtk_css_style_property_lookup_by_id (id));
}
static void
css_string_funcs_init (void)
{
......@@ -1816,25 +1804,6 @@ _gtk_style_property_default_value (GtkStyleProperty *property,
g_value_copy (&property->initial_value, value);
}
gboolean
_gtk_style_property_is_inherit (GtkStyleProperty *property)
{
g_return_val_if_fail (property != NULL, FALSE);
return property->flags & GTK_STYLE_PROPERTY_INHERIT ? TRUE : FALSE;
}
guint
_gtk_style_property_get_id (GtkStyleProperty *property)
{
g_return_val_if_fail (property != NULL, FALSE);
if (GTK_IS_CSS_STYLE_PROPERTY (property))
return _gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (property));
else
return 0;
}
static gboolean
resolve_color (GtkStyleProperties *props,
GValue *value)
......@@ -2009,14 +1978,6 @@ _gtk_style_property_resolve (GtkStyleProperty *property,
g_value_copy (val, val_out);
}
const GValue *
_gtk_style_property_get_initial_value (GtkStyleProperty *property)
{
g_return_val_if_fail (property != NULL, NULL);
return &property->initial_value;
}
GParameter *
_gtk_style_property_unpack (GtkStyleProperty *property,
const GValue *value,
......@@ -2076,7 +2037,7 @@ _gtk_style_property_assign (GtkStyleProperty *property,
else if (GTK_IS_CSS_STYLE_PROPERTY (property))
{
_gtk_style_properties_set_property_by_property (props,
property,
GTK_CSS_STYLE_PROPERTY (property),
state,
value);
}
......@@ -2093,22 +2054,32 @@ _gtk_style_property_query (GtkStyleProperty *property,
GtkStylePropertyContext *context,
GValue *value)
{
const GValue *val;
g_return_if_fail (property != NULL);
g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
g_return_if_fail (context != NULL);
g_return_if_fail (value != NULL);
val = _gtk_style_properties_peek_property (props, property, state);
g_value_init (value, property->pspec->value_type);
if (val)
_gtk_style_property_resolve (property, props, state, context, (GValue *) val, value);
if (GTK_IS_CSS_STYLE_PROPERTY (property))
{
const GValue *val;
val = _gtk_style_properties_peek_property (props, GTK_CSS_STYLE_PROPERTY (property), state);
if (val)
_gtk_style_property_resolve (property, props, state, context, (GValue *) val, value);
else
_gtk_style_property_default_value (property, props, state, value);
}
else if (GTK_IS_CSS_SHORTHAND_PROPERTY (property))
_gtk_style_property_pack (property, props, state, context, value);
{
_gtk_style_property_pack (property, props, state, context, value);
}
else
_gtk_style_property_default_value (property, props, state, value);
{
g_assert_not_reached ();
}
}
#define rgba_init(rgba, r, g, b, a) G_STMT_START{ \
......
......@@ -81,9 +81,6 @@ struct _GtkStylePropertyClass
GType _gtk_style_property_get_type (void) G_GNUC_CONST;
guint _gtk_style_property_get_count (void);
GtkStyleProperty * _gtk_style_property_get (guint id);
GtkStyleProperty * _gtk_style_property_lookup (const char *name);
const char * _gtk_style_property_get_name (GtkStyleProperty *property);
......@@ -95,12 +92,6 @@ void _gtk_style_property_register (GParamSpec
GtkStylePrintFunc print_func,
const GValue *initial_value);
gboolean _gtk_style_property_is_inherit (GtkStyleProperty * property);
guint _gtk_style_property_get_id (GtkStyleProperty * property);
const GValue * _gtk_style_property_get_initial_value
(GtkStyleProperty * property);
GParameter * _gtk_style_property_unpack (GtkStyleProperty * property,
const GValue *value,
guint *n_params);
......
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