gtk-css-engine r80 - in branches/bzr: . libccd/ccd src
- From: robsta svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk-css-engine r80 - in branches/bzr: . libccd/ccd src
- Date: Fri, 5 Sep 2008 11:33:56 +0000 (UTC)
Author: robsta
Date: Fri Sep 5 11:33:56 2008
New Revision: 80
URL: http://svn.gnome.org/viewvc/gtk-css-engine?rev=80&view=rev
Log:
Implement value transformation for matching.
Modified:
branches/bzr/ (props changed)
branches/bzr/libccd/ccd/ccd-node.c
branches/bzr/libccd/ccd/ccd-node.h
branches/bzr/libccd/ccd/ccd-selector.c
branches/bzr/src/gce-node.c
branches/bzr/src/gce-theme.c
Modified: branches/bzr/libccd/ccd/ccd-node.c
==============================================================================
--- branches/bzr/libccd/ccd/ccd-node.c (original)
+++ branches/bzr/libccd/ccd/ccd-node.c Fri Sep 5 11:33:56 2008
@@ -62,7 +62,7 @@
return NULL;
}
-static char const *
+static char *
get_attribute (ccd_node_t const *self,
char const *name)
{
Modified: branches/bzr/libccd/ccd/ccd-node.h
==============================================================================
--- branches/bzr/libccd/ccd/ccd-node.h (original)
+++ branches/bzr/libccd/ccd/ccd-node.h Fri Sep 5 11:33:56 2008
@@ -123,8 +123,8 @@
* Returns: attribute value or %NULL. The returned value must be valid until
* the current stylesheet query returns.
**/
-typedef const char * (*ccd_node_get_attribute_f) (ccd_node_t const *self,
- char const *name);
+typedef char * (*ccd_node_get_attribute_f) (ccd_node_t const *self,
+ char const *name);
/**
* ccd_node_release_f:
Modified: branches/bzr/libccd/ccd/ccd-selector.c
==============================================================================
--- branches/bzr/libccd/ccd/ccd-selector.c (original)
+++ branches/bzr/libccd/ccd/ccd-selector.c Fri Sep 5 11:33:56 2008
@@ -828,6 +828,7 @@
g_assert_not_reached ();
is_matching = false;
}
+ g_free (value), value = NULL;
break;
case CCD_SELECTOR_MODALITY_PSEUDO_CLASS:
name = node_class->get_pseudo_class (node);
Modified: branches/bzr/src/gce-node.c
==============================================================================
--- branches/bzr/src/gce-node.c (original)
+++ branches/bzr/src/gce-node.c Fri Sep 5 11:33:56 2008
@@ -226,12 +226,50 @@
return node->pseudo_class;
}
-static char const *
+static char *
+_to_string (GValue const *value)
+{
+ switch (G_VALUE_TYPE (value)) {
+ case G_TYPE_BOOLEAN:
+ return g_value_get_boolean (value) ?
+ g_strdup ("true") :
+ g_strdup ("false");
+ case G_TYPE_CHAR:
+ return g_strdup_printf ("%c", g_value_get_char (value));
+ case G_TYPE_UCHAR:
+ return g_strdup_printf ("%c", g_value_get_uchar (value));
+ case G_TYPE_INT:
+ return g_strdup_printf ("%d", g_value_get_int (value));
+ case G_TYPE_UINT:
+ return g_strdup_printf ("%u", g_value_get_uint (value));
+ case G_TYPE_LONG:
+ return g_strdup_printf ("%ld", g_value_get_long (value));
+ case G_TYPE_ULONG:
+ return g_strdup_printf ("%ld", g_value_get_ulong (value));
+/* Not supported by C99. TODO: enable after splitting out libccd.
+ case G_TYPE_INT64:
+ return g_strdup_printf ("%Ld", g_value_get_int64 (value));
+ case G_TYPE_UINT64:
+ return g_strdup_printf ("%Ld", g_value_get_uint64 (value));
+*/
+ case G_TYPE_FLOAT:
+ return g_strdup_printf ("%.03f", g_value_get_float (value));
+ case G_TYPE_DOUBLE:
+ return g_strdup_printf ("%.03f", g_value_get_double (value));
+ case G_TYPE_STRING:
+ return g_strdup (g_value_get_string (value));
+ default:
+ g_assert_not_reached ();
+ return NULL;
+ }
+}
+
+static char *
get_attribute (GceNode const *node,
char const *name)
{
- GValue property = { 0, };
- char const *value;
+ GParamSpec *param;
+ GValue property = { 0, };
g_assert (node && node->widget);
@@ -242,30 +280,34 @@
/* attributes provided in the drawing function take precedence */
if (0 == strcmp ("shadow", name)) {
- return node->shadow;
+ return g_strdup (node->shadow);
} else if (0 == strcmp ("orientation", name)) {
- return node->orientation;
+ return g_strdup (node->orientation);
} else if (0 == strcmp ("edge", name)) {
- return node->edge;
+ return g_strdup (node->edge);
} else if (0 == strcmp ("expander-style", name)) {
- return node->expander_style;
+ return g_strdup (node->expander_style);
} else if (0 == strcmp ("gap", name)) {
- return node->gap;
+ return g_strdup (node->gap);
}
/* now try to find an apropriate style property */
- /* TODO investigate that lifecycle of `value' is ok. */
- g_value_init (&property, G_TYPE_STRING);
- gtk_widget_style_get_property (node->widget, name, &property);
- value = g_value_get_string (&property);
- if (value) {
- return value;
+ param = gtk_widget_class_find_style_property (
+ GTK_WIDGET_CLASS (G_OBJECT_GET_CLASS (node->widget)),
+ name);
+ if (param) {
+ g_value_init (&property, param->value_type);
+ gtk_widget_style_get_property (node->widget, name, &property);
+ return _to_string (&property);
+ }
+
+ if (g_object_class_find_property (G_OBJECT_GET_CLASS (node->widget), name)) {
+ g_object_get_property (G_OBJECT (node->widget), name, &property);
+ return _to_string (&property);
}
- g_object_get_property (G_OBJECT (node->widget), name, &property);
- value = g_value_get_string (&property);
- return value;
+ return NULL;
}
static void
Modified: branches/bzr/src/gce-theme.c
==============================================================================
--- branches/bzr/src/gce-theme.c (original)
+++ branches/bzr/src/gce-theme.c Fri Sep 5 11:33:56 2008
@@ -32,17 +32,6 @@
G_MODULE_EXPORT GtkRcStyle * theme_create_rc_style (void);
G_MODULE_EXPORT const gchar * g_module_check_init (GModule *module);
-static void
-transform_boolean_string (const GValue *src,
- GValue *dst)
-{
- if (g_value_get_boolean (src)) {
- g_value_set_static_string (dst, "true");
- } else {
- g_value_set_static_string (dst, "false");
- }
-}
-
G_MODULE_EXPORT void
theme_init (GTypeModule *module)
{
@@ -55,9 +44,6 @@
node_class = gce_node_get_class ();
vtable = gce_functions_get_vtable ();
ccd_init (node_class, vtable);
-
- g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_STRING,
- transform_boolean_string);
}
G_MODULE_EXPORT void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]