[gtk+/parser] css: Move binding set parsing to strfuncs
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/parser] css: Move binding set parsing to strfuncs
- Date: Wed, 18 May 2011 16:44:29 +0000 (UTC)
commit f31ea009bf2183c83ea43a6c3226091a6898b97c
Author: Benjamin Otte <otte redhat com>
Date: Wed May 18 18:03:23 2011 +0200
css: Move binding set parsing to strfuncs
gtk/gtkcssprovider.c | 32 --------------------------
gtk/gtkcssstringfuncs.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 32 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index b8aa56b..6122f52 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1377,32 +1377,6 @@ css_provider_commit (GtkCssProvider *css_provider,
}
static void
-resolve_binding_sets (const gchar *value_str,
- GValue *value)
-{
- GPtrArray *array;
- gchar **bindings, **str;
-
- bindings = g_strsplit (value_str, ",", -1);
- array = g_ptr_array_new ();
-
- for (str = bindings; *str; str++)
- {
- GtkBindingSet *binding_set;
-
- binding_set = gtk_binding_set_find (g_strstrip (*str));
-
- if (!binding_set)
- continue;
-
- g_ptr_array_add (array, binding_set);
- }
-
- g_value_take_boxed (value, array);
- g_strfreev (bindings);
-}
-
-static void
gtk_css_provider_reset (GtkCssProvider *css_provider)
{
GtkCssProviderPrivate *priv;
@@ -1981,12 +1955,6 @@ parse_declaration (GtkCssScanner *scanner,
g_param_value_set_default (pspec, val);
gtk_css_ruleset_add (ruleset, pspec, val);
}
- else if (strcmp (pspec->name, "gtk-key-bindings") == 0)
- {
- /* Private property holding the binding sets */
- resolve_binding_sets (value_str, val);
- gtk_css_ruleset_add (ruleset, pspec, val);
- }
else if (parse_func)
{
GError *error = NULL;
diff --git a/gtk/gtkcssstringfuncs.c b/gtk/gtkcssstringfuncs.c
index dec1bdd..bb70bb9 100644
--- a/gtk/gtkcssstringfuncs.c
+++ b/gtk/gtkcssstringfuncs.c
@@ -33,6 +33,7 @@
/* the actual parsers we have */
#include "gtkanimationdescription.h"
+#include "gtkbindings.h"
#include "gtk9slice.h"
#include "gtkgradient.h"
#include "gtkthemingengine.h"
@@ -1231,6 +1232,58 @@ flags_value_to_string (const GValue *value)
return g_string_free (string, FALSE);
}
+static gboolean
+bindings_value_from_string (const char *str,
+ GFile *base,
+ GValue *value,
+ GError **error)
+{
+ GPtrArray *array;
+ gchar **bindings, **name;
+
+ bindings = g_strsplit (str, ",", -1);
+ array = g_ptr_array_new ();
+
+ for (name = bindings; *name; name++)
+ {
+ GtkBindingSet *binding_set;
+
+ binding_set = gtk_binding_set_find (g_strstrip (*name));
+
+ if (!binding_set)
+ continue;
+
+ g_ptr_array_add (array, binding_set);
+ }
+
+ g_value_take_boxed (value, array);
+ g_strfreev (bindings);
+
+ return TRUE;
+}
+
+static char *
+bindings_value_to_string (const GValue *value)
+{
+ GPtrArray *array;
+ GString *str;
+ guint i;
+
+ array = g_value_get_boxed (value);
+ str = g_string_new (NULL);
+
+ for (i = 0; i < array->len; i++)
+ {
+ GtkBindingSet *binding_set = g_ptr_array_index (array, i);
+
+ if (i > 0)
+ g_string_append (str, ", ");
+ g_string_append (str, binding_set->set_name);
+ }
+
+ return g_string_free (str, FALSE);
+}
+
/*** API ***/
static void
@@ -1296,6 +1349,9 @@ css_string_funcs_init (void)
register_conversion_function (G_TYPE_FLAGS,
flags_value_from_string,
flags_value_to_string);
+ register_conversion_function (G_TYPE_PTR_ARRAY,
+ bindings_value_from_string,
+ bindings_value_to_string);
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]