GtkThemingEngine: Add gtk_theming_engine_register_property().
This function may be used for custom property registration from theming engines. The property names will have the -${engine-type-name}-${prop-name} format, the parser has been modified to allow properties with '-' as the first char.
This commit is contained in:
parent
d9e3782391
commit
e04dfd4d6d
@ -622,6 +622,14 @@ gtk_css_provider_get_style (GtkStyleProvider *provider,
|
|||||||
{
|
{
|
||||||
gchar *prop = key;
|
gchar *prop = key;
|
||||||
|
|
||||||
|
/* Properties starting with '-' may be both widget style properties
|
||||||
|
* or custom properties from the theming engine, so check whether
|
||||||
|
* the type is registered or not.
|
||||||
|
*/
|
||||||
|
if (prop[0] == '-' &&
|
||||||
|
!gtk_style_set_lookup_property (prop, NULL, NULL))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (info->state == GTK_STATE_NORMAL)
|
if (info->state == GTK_STATE_NORMAL)
|
||||||
gtk_style_set_set_default (set, key, value);
|
gtk_style_set_set_default (set, key, value);
|
||||||
else
|
else
|
||||||
@ -1423,18 +1431,7 @@ parse_rule (GtkCssProvider *css_provider,
|
|||||||
|
|
||||||
value_str = g_strstrip (scanner->value.v_identifier);
|
value_str = g_strstrip (scanner->value.v_identifier);
|
||||||
|
|
||||||
if (prop[0] == '-' &&
|
if (gtk_style_set_lookup_property (prop, &prop_type, &parse_func))
|
||||||
g_ascii_isupper (prop[1]))
|
|
||||||
{
|
|
||||||
GValue *val;
|
|
||||||
|
|
||||||
val = g_slice_new0 (GValue);
|
|
||||||
g_value_init (val, G_TYPE_STRING);
|
|
||||||
g_value_set_string (val, value_str);
|
|
||||||
|
|
||||||
g_hash_table_insert (priv->cur_properties, prop, val);
|
|
||||||
}
|
|
||||||
else if (gtk_style_set_lookup_property (prop, &prop_type, &parse_func))
|
|
||||||
{
|
{
|
||||||
GValue *val;
|
GValue *val;
|
||||||
|
|
||||||
@ -1464,6 +1461,17 @@ parse_rule (GtkCssProvider *css_provider,
|
|||||||
return G_TOKEN_IDENTIFIER;
|
return G_TOKEN_IDENTIFIER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (prop[0] == '-' &&
|
||||||
|
g_ascii_isupper (prop[1]))
|
||||||
|
{
|
||||||
|
GValue *val;
|
||||||
|
|
||||||
|
val = g_slice_new0 (GValue);
|
||||||
|
g_value_init (val, G_TYPE_STRING);
|
||||||
|
g_value_set_string (val, value_str);
|
||||||
|
|
||||||
|
g_hash_table_insert (priv->cur_properties, prop, val);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
g_free (prop);
|
g_free (prop);
|
||||||
|
|
||||||
|
@ -194,6 +194,25 @@ _gtk_theming_engine_set_context (GtkThemingEngine *engine,
|
|||||||
priv->context = context;
|
priv->context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gtk_theming_engine_register_property (GtkThemingEngine *engine,
|
||||||
|
const gchar *property_name,
|
||||||
|
GType type,
|
||||||
|
const GValue *default_value,
|
||||||
|
GtkStylePropertyParser parse_func)
|
||||||
|
{
|
||||||
|
gchar *name;
|
||||||
|
|
||||||
|
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
||||||
|
g_return_if_fail (property_name != NULL);
|
||||||
|
g_return_if_fail (type != G_TYPE_INVALID);
|
||||||
|
g_return_if_fail (default_value != NULL && G_IS_VALUE (default_value));
|
||||||
|
|
||||||
|
name = g_strdup_printf ("-%s-%s", G_OBJECT_TYPE_NAME (engine), property_name);
|
||||||
|
gtk_style_set_register_property (name, type, default_value, parse_func);
|
||||||
|
g_free (name);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gtk_theming_engine_get_property (GtkThemingEngine *engine,
|
gtk_theming_engine_get_property (GtkThemingEngine *engine,
|
||||||
const gchar *property,
|
const gchar *property,
|
||||||
|
@ -139,6 +139,12 @@ GType gtk_theming_engine_get_type (void) G_GNUC_CONST;
|
|||||||
void _gtk_theming_engine_set_context (GtkThemingEngine *engine,
|
void _gtk_theming_engine_set_context (GtkThemingEngine *engine,
|
||||||
GtkStyleContext *context);
|
GtkStyleContext *context);
|
||||||
|
|
||||||
|
void gtk_theming_engine_register_property (GtkThemingEngine *engine,
|
||||||
|
const gchar *property_name,
|
||||||
|
GType type,
|
||||||
|
const GValue *default_value,
|
||||||
|
GtkStylePropertyParser parse_func);
|
||||||
|
|
||||||
void gtk_theming_engine_get_property (GtkThemingEngine *engine,
|
void gtk_theming_engine_get_property (GtkThemingEngine *engine,
|
||||||
const gchar *property,
|
const gchar *property,
|
||||||
GtkStateType state,
|
GtkStateType state,
|
||||||
|
Loading…
Reference in New Issue
Block a user