[gtk+/nth-child: 17/22] styleproperty: Allow passing in a parse func and a print func
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/nth-child: 17/22] styleproperty: Allow passing in a parse func and a print func
- Date: Thu, 26 May 2011 03:32:00 +0000 (UTC)
commit 13d4f74ee91ab1caba97142572ef275c670d2457
Author: Benjamin Otte <otte redhat com>
Date: Thu May 26 01:46:49 2011 +0200
styleproperty: Allow passing in a parse func and a print func
It's not used yet, but it's now possible to specify a custom read or
write func.
gtk/gtkstyleproperties.c | 2 +
gtk/gtkstyleproperty.c | 43 +++++++++++++++++++++++++++-------------
gtk/gtkstylepropertyprivate.h | 12 ++++++++++-
3 files changed, 42 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c
index 3cb6880..97ecfd2 100644
--- a/gtk/gtkstyleproperties.c
+++ b/gtk/gtkstyleproperties.c
@@ -313,6 +313,8 @@ gtk_style_properties_register_property (GtkStylePropertyParser parse_func,
_gtk_style_property_register (pspec,
parse_func,
NULL,
+ NULL,
+ NULL,
NULL);
}
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index 79106d6..787de81 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -40,12 +40,6 @@
#include "gtkthemingengine.h"
#include "gtktypebuiltins.h"
-typedef gboolean (* GtkStyleParseFunc) (GtkCssParser *parser,
- GFile *base,
- GValue *value);
-typedef void (* GtkStylePrintFunc) (const GValue *value,
- GString *string);
-
static GHashTable *parse_funcs = NULL;
static GHashTable *print_funcs = NULL;
static GHashTable *properties = NULL;
@@ -1412,10 +1406,15 @@ _gtk_style_property_parse_value (const GtkStyleProperty *property,
return success;
}
+
+ func = property->parse_func;
}
+ else
+ func = NULL;
- func = g_hash_table_lookup (parse_funcs,
- GSIZE_TO_POINTER (G_VALUE_TYPE (value)));
+ if (func == NULL)
+ func = g_hash_table_lookup (parse_funcs,
+ GSIZE_TO_POINTER (G_VALUE_TYPE (value)));
if (func == NULL)
func = g_hash_table_lookup (parse_funcs,
GSIZE_TO_POINTER (g_type_fundamental (G_VALUE_TYPE (value))));
@@ -1440,8 +1439,14 @@ _gtk_style_property_print_value (const GtkStyleProperty *property,
css_string_funcs_init ();
- func = g_hash_table_lookup (print_funcs,
- GSIZE_TO_POINTER (G_VALUE_TYPE (value)));
+ if (property)
+ func = property->print_func;
+ else
+ func = NULL;
+
+ if (func == NULL)
+ func = g_hash_table_lookup (print_funcs,
+ GSIZE_TO_POINTER (G_VALUE_TYPE (value)));
if (func == NULL)
func = g_hash_table_lookup (print_funcs,
GSIZE_TO_POINTER (g_type_fundamental (G_VALUE_TYPE (value))));
@@ -1559,7 +1564,9 @@ gtk_style_property_init (void)
GTK_TYPE_BORDER, 0),
NULL,
unpack_margin,
- pack_margin);
+ pack_margin,
+ NULL,
+ NULL);
gtk_style_properties_register_property (NULL,
g_param_spec_int ("padding-top",
"padding top",
@@ -1586,7 +1593,9 @@ gtk_style_property_init (void)
GTK_TYPE_BORDER, 0),
NULL,
unpack_padding,
- pack_padding);
+ pack_padding,
+ NULL,
+ NULL);
gtk_style_properties_register_property (NULL,
g_param_spec_int ("border-top-width",
"border top width",
@@ -1613,7 +1622,9 @@ gtk_style_property_init (void)
GTK_TYPE_BORDER, 0),
NULL,
unpack_border_width,
- pack_border_width);
+ pack_border_width,
+ NULL,
+ NULL);
gtk_style_properties_register_property (NULL,
g_param_spec_int ("border-radius",
"Border radius",
@@ -1671,7 +1682,9 @@ void
_gtk_style_property_register (GParamSpec *pspec,
GtkStylePropertyParser property_parse_func,
GtkStyleUnpackFunc unpack_func,
- GtkStylePackFunc pack_func)
+ GtkStylePackFunc pack_func,
+ GtkStyleParseFunc parse_func,
+ GtkStylePrintFunc print_func)
{
const GtkStyleProperty *existing;
GtkStyleProperty *node;
@@ -1693,6 +1706,8 @@ _gtk_style_property_register (GParamSpec *pspec,
node->property_parse_func = property_parse_func;
node->pack_func = pack_func;
node->unpack_func = unpack_func;
+ node->parse_func = parse_func;
+ node->print_func = print_func;
g_hash_table_insert (properties, pspec->name, node);
}
diff --git a/gtk/gtkstylepropertyprivate.h b/gtk/gtkstylepropertyprivate.h
index 2fa772b..64789bc 100644
--- a/gtk/gtkstylepropertyprivate.h
+++ b/gtk/gtkstylepropertyprivate.h
@@ -31,6 +31,12 @@ typedef GParameter * (* GtkStyleUnpackFunc) (const GValue
typedef void (* GtkStylePackFunc) (GValue *value,
GtkStyleProperties *props,
GtkStateFlags state);
+typedef gboolean (* GtkStyleParseFunc) (GtkCssParser *parser,
+ GFile *base,
+ GValue *value);
+typedef void (* GtkStylePrintFunc) (const GValue *value,
+ GString *string);
+
struct _GtkStyleProperty
{
@@ -38,6 +44,8 @@ struct _GtkStyleProperty
GtkStylePropertyParser property_parse_func;
GtkStyleUnpackFunc unpack_func;
GtkStylePackFunc pack_func;
+ GtkStyleParseFunc parse_func;
+ GtkStylePrintFunc print_func;
};
const GtkStyleProperty * _gtk_style_property_lookup (const char *name);
@@ -45,7 +53,9 @@ const GtkStyleProperty * _gtk_style_property_lookup (const char
void _gtk_style_property_register (GParamSpec *pspec,
GtkStylePropertyParser property_parse_func,
GtkStyleUnpackFunc unpack_func,
- GtkStylePackFunc pack_func);
+ GtkStylePackFunc pack_func,
+ GtkStyleParseFunc parse_func,
+ GtkStylePrintFunc print_func);
gboolean _gtk_style_property_is_shorthand (const GtkStyleProperty *property);
GParameter * _gtk_style_property_unpack (const GtkStyleProperty *property,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]