summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Staudinger <robsta@gnome.org>2008-12-10 13:53:46 +0100
committerRobert Staudinger <robsta@gnome.org>2008-12-10 13:53:46 +0100
commita5d66059fc09d64bd3c8928c0d53f30fa54be1e7 (patch)
tree86d4e1965c30e357ff6a0514c000ca53bb425f50
parent2c9a7e5e3a57a52d10540092b91f4f3021d847c6 (diff)
* ccss-cairo/ccss-cairo-color.h:
* ccss-cairo/ccss-cairo.sym: * ccss-gtk/ccss-gtk-grammar.c (parse_gtk_style_property), (property_convert): * ccss-gtk/ccss-gtk-grammar.h: Hook up gtk style property infrastructure.
-rw-r--r--ChangeLog9
-rw-r--r--ccss-cairo/ccss-cairo-color.h16
-rw-r--r--ccss-cairo/ccss-cairo.sym1
-rw-r--r--ccss-gtk/ccss-gtk-grammar.c112
-rw-r--r--ccss-gtk/ccss-gtk-grammar.h23
5 files changed, 120 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 7d6fd44..9ea8a50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-12-10 Robert Staudinger <robsta@gnome.org>
+
+ * ccss-cairo/ccss-cairo-color.h:
+ * ccss-cairo/ccss-cairo.sym:
+ * ccss-gtk/ccss-gtk-grammar.c (parse_gtk_style_property),
+ (property_convert):
+ * ccss-gtk/ccss-gtk-grammar.h:
+ Hook up gtk style property infrastructure.
+
2008-12-09 Robert Staudinger <robsta@gnome.org>
* ccss-cairo/Makefile.am:
diff --git a/ccss-cairo/ccss-cairo-color.h b/ccss-cairo/ccss-cairo-color.h
index f6d187c..32bde03 100644
--- a/ccss-cairo/ccss-cairo-color.h
+++ b/ccss-cairo/ccss-cairo-color.h
@@ -34,28 +34,12 @@ typedef struct {
double blue;
} ccss_cairo_color_t;
-ccss_property_base_t *
-ccss_cairo_color_create (ccss_grammar_t const *grammar,
- CRTerm const *value,
- void *user_data);
-
-void
-ccss_cairo_color_destroy (ccss_cairo_color_t *self);
-
-bool
-ccss_cairo_color_convert (ccss_cairo_color_t const *property,
- ccss_property_type_t target,
- void *value);
-
bool
ccss_cairo_color_parse (ccss_cairo_color_t *self,
ccss_grammar_t const *grammar,
void *user_data,
CRTerm const **values);
-ccss_property_class_t const *
-ccss_cairo_color_get_ptable (void);
-
CCSS_END_DECLS
#endif /* CCSS_CAIRO_COLOR_H */
diff --git a/ccss-cairo/ccss-cairo.sym b/ccss-cairo/ccss-cairo.sym
index 5baed3e..d07df77 100644
--- a/ccss-cairo/ccss-cairo.sym
+++ b/ccss-cairo/ccss-cairo.sym
@@ -1,5 +1,6 @@
ccss_cairo_init
ccss_cairo_shutdown
+ccss_cairo_color_parse
ccss_cairo_grammar_create
ccss_cairo_style_draw_line
ccss_cairo_style_draw_outline
diff --git a/ccss-gtk/ccss-gtk-grammar.c b/ccss-gtk/ccss-gtk-grammar.c
index d38df17..d587609 100644
--- a/ccss-gtk/ccss-gtk-grammar.c
+++ b/ccss-gtk/ccss-gtk-grammar.c
@@ -19,10 +19,31 @@
#include <math.h>
#include <string.h>
+#include <gtk/gtk.h>
#include <ccss-cairo/ccss-cairo.h>
#include "ccss-gtk-grammar.h"
#include "config.h"
+typedef struct {
+ ccss_property_base_t base;
+ char *class_name;
+ char *property_name;
+ GType gtype;
+ union {
+ gboolean gboolean_val;
+ gchararray gchararray_val;
+ gfloat gfloat_val;
+ gint gint_val;
+ guchar guchar_val;
+ GdkColor gdkcolor_val;
+ GtkBorder gtkborder_val;
+ GtkReliefStyle gtkreliefstyle_val;
+ GtkRequisition gtkrequisition_val;
+ GtkShadowType gtkshadowtype_val;
+ GtkToolbarSpaceStyle gtktoolbarspacestyle_val;
+ } content;
+} ccss_gtk_property_t;
+
static ccss_property_class_t const *
peek_property_class (void);
@@ -448,6 +469,8 @@ parse_gtk_style_property (ccss_grammar_t const *grammar,
self = g_new0 (ccss_gtk_property_t, 1);
*self = s;
}
+ } else {
+ g_assert_not_reached ();
}
if (self) {
@@ -482,11 +505,96 @@ property_destroy (ccss_gtk_property_t *self)
}
static bool
-property_convert (ccss_property_base_t const *self,
+property_convert (ccss_gtk_property_t const *self,
ccss_property_type_t target,
void *value)
{
- return false;
+ char *prefix;
+
+ g_return_val_if_fail (self, false);
+ g_return_val_if_fail (value, false);
+
+ if (CCSS_PROPERTY_TYPE_DOUBLE == target) {
+ return false;
+ }
+
+ if (self->class_name) {
+ prefix = g_strdup_printf ("%s::", self->class_name);
+ } else {
+ prefix = g_strdup ("");
+ }
+
+ if (G_TYPE_BOOLEAN == self->gtype) {
+ * (char **) value = g_strdup_printf ("%s%s = %s",
+ prefix, self->property_name,
+ self->content.gboolean_val ?
+ "TRUE" : "FALSE");
+ } else if (G_TYPE_STRING == self->gtype) {
+ * (char **) value = g_strdup_printf ("%s%s = \"%s\"",
+ prefix, self->property_name,
+ self->content.gchararray_val);
+ } else if (G_TYPE_FLOAT == self->gtype) {
+ * (char **) value = g_strdup_printf ("%s%s = %f",
+ prefix, self->property_name,
+ self->content.gfloat_val);
+ } else if (G_TYPE_INT == self->gtype) {
+ * (char **) value = g_strdup_printf ("%s%s = %d",
+ prefix, self->property_name,
+ self->content.gint_val);
+ } else if (G_TYPE_UCHAR == self->gtype) {
+ * (char **) value = g_strdup_printf ("%s%s = %d",
+ prefix, self->property_name,
+ self->content.guchar_val);
+ } else if (GDK_TYPE_COLOR == self->gtype) {
+ char *val;
+ val = gdk_color_to_string (&self->content.gdkcolor_val);
+ * (char **) value = g_strdup_printf ("%s%s = %s",
+ prefix, self->property_name,
+ val);
+ g_free (val);
+ } else if (GTK_TYPE_BORDER == self->gtype) {
+ * (char **) value = g_strdup_printf ("%s%s = { %d, %d, %d, %d }",
+ prefix, self->property_name,
+ self->content.gtkborder_val.left,
+ self->content.gtkborder_val.right,
+ self->content.gtkborder_val.top,
+ self->content.gtkborder_val.bottom);
+ } else if (GTK_TYPE_RELIEF_STYLE == self->gtype) {
+ char const *val;
+ val = self->content.gtkreliefstyle_val == GTK_RELIEF_NORMAL ? "NORMAL" :
+ self->content.gtkreliefstyle_val == GTK_RELIEF_HALF ? "HALF" :
+ self->content.gtkreliefstyle_val == GTK_RELIEF_NONE ? "NONE" : "";
+ * (char **) value = g_strdup_printf ("%s%s = %s",
+ prefix, self->property_name,
+ val);
+ } else if (GTK_TYPE_REQUISITION == self->gtype) {
+ * (char **) value = g_strdup_printf ("%s%s = { %d, %d }",
+ prefix, self->property_name,
+ self->content.gtkrequisition_val.width,
+ self->content.gtkrequisition_val.height);
+ } else if (GTK_TYPE_SHADOW_TYPE == self->gtype) {
+ char const *val;
+ val = self->content.gtkshadowtype_val == GTK_SHADOW_NONE ? "NONE" :
+ self->content.gtkshadowtype_val == GTK_SHADOW_IN ? "IN" :
+ self->content.gtkshadowtype_val == GTK_SHADOW_OUT ? "OUT" :
+ self->content.gtkshadowtype_val == GTK_SHADOW_ETCHED_IN ? "ETCHED_IN" :
+ self->content.gtkshadowtype_val == GTK_SHADOW_ETCHED_OUT ? "ETCHED_OUT" : "";
+ * (char **) value = g_strdup_printf ("%s%s = %s",
+ prefix, self->property_name,
+ val);
+ } else if (GTK_TYPE_TOOLBAR_SPACE_STYLE == self->gtype) {
+ char const *val;
+ val = self->content.gtktoolbarspacestyle_val == GTK_TOOLBAR_SPACE_EMPTY ? "EMPTY" :
+ self->content.gtktoolbarspacestyle_val == GTK_TOOLBAR_SPACE_LINE ? "LINE" : "";
+ * (char **) value = g_strdup_printf ("%s%s = %s",
+ prefix, self->property_name,
+ val);
+ } else {
+ g_assert_not_reached ();
+ }
+
+ g_free (prefix), prefix = NULL;
+ return true;
}
static bool
diff --git a/ccss-gtk/ccss-gtk-grammar.h b/ccss-gtk/ccss-gtk-grammar.h
index 0330fa9..56dcd87 100644
--- a/ccss-gtk/ccss-gtk-grammar.h
+++ b/ccss-gtk/ccss-gtk-grammar.h
@@ -21,32 +21,9 @@
#define CCSS_GTK_GRAMMAR_H
#include <ccss/ccss.h>
-#include <gtk/gtk.h>
CCSS_BEGIN_DECLS
-/* */
-
-typedef struct {
- ccss_property_base_t base;
- char *class_name;
- char *property_name;
- GType gtype;
- union {
- gboolean gboolean_val;
- gchararray gchararray_val;
- gfloat gfloat_val;
- gint gint_val;
- guchar guchar_val;
- GdkColor gdkcolor_val;
- GtkBorder gtkborder_val;
- GtkReliefStyle gtkreliefstyle_val;
- GtkRequisition gtkrequisition_val;
- GtkShadowType gtkshadowtype_val;
- GtkToolbarSpaceStyle gtktoolbarspacestyle_val;
- } content;
-} ccss_gtk_property_t;
-
ccss_grammar_t *
ccss_gtk_grammar_create (void);