gtk-css-engine r194 - in trunk: . src
- From: robsta svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk-css-engine r194 - in trunk: . src
- Date: Wed, 19 Nov 2008 15:46:36 +0000 (UTC)
Author: robsta
Date: Wed Nov 19 15:46:35 2008
New Revision: 194
URL: http://svn.gnome.org/viewvc/gtk-css-engine?rev=194&view=rev
Log:
* src/Makefile.am:
* src/css2gtkrc.c (main):
* src/gce-properties.c (gce_gtk_border_new),
(gce_gtk_border_convert), (gce_properties_get_vtable):
* src/gce-properties.h:
* src/gce-theme.c (theme_init):
Move towards handling gtk style properties.
Added:
trunk/src/gce-properties.c
trunk/src/gce-properties.h
Modified:
trunk/ChangeLog
trunk/src/Makefile.am
trunk/src/css2gtkrc.c
trunk/src/gce-theme.c
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Wed Nov 19 15:46:35 2008
@@ -30,6 +30,8 @@
gce-maps.h \
gce-node.c \
gce-node.h \
+ gce-properties.c \
+ gce-properties.h \
gce-rc-style.c \
gce-rc-style.h \
gce-serialize.c \
@@ -44,6 +46,8 @@
css2gtkrc_SOURCES = \
css2gtkrc.c \
+ gce-properties.c \
+ gce-properties.h \
gce-serialize.c \
gce-serialize.h
Modified: trunk/src/css2gtkrc.c
==============================================================================
--- trunk/src/css2gtkrc.c (original)
+++ trunk/src/css2gtkrc.c Wed Nov 19 15:46:35 2008
@@ -20,21 +20,24 @@
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
+#include "gce-properties.h"
#include "gce-serialize.h"
int
main (int argc,
char **argv)
{
- ccss_stylesheet_t *stylesheet;
- char *gtkrc;
+ ccss_stylesheet_t *stylesheet;
+ ccss_property_impl_t const *properties;
+ char *gtkrc;
if (argc <= 1) {
fprintf (stderr, "Need filename.\n");
return EXIT_FAILURE;
}
- ccss_init (NULL);
+ properties = gce_properties_get_vtable ();
+ ccss_init (properties, NULL);
stylesheet = ccss_stylesheet_new_from_file (argv[1]);
g_assert (stylesheet);
Added: trunk/src/gce-properties.c
==============================================================================
--- (empty file)
+++ trunk/src/gce-properties.c Wed Nov 19 15:46:35 2008
@@ -0,0 +1,85 @@
+/* The CSS Theme Engine for Gtk+.
+ * Copyright (C) 2008 Robert Staudinger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#include "gce-properties.h"
+
+typedef struct {
+ ccss_property_state_t state;
+ GtkBorder border;
+} GceGtkBorder;
+
+static GceGtkBorder *
+gce_gtk_border_new (CRTerm const *values)
+{
+ GceGtkBorder *border;
+ gint *border_widths[4];
+
+ g_return_val_if_fail (values, NULL);
+
+ border = g_new0 (GceGtkBorder, 1);
+ /* PONDERING: support `none' and `inherit' for gtk style properties? */
+ border->state = CCSS_PROPERTY_STATE_SET;
+
+ border_widths[0] = &border->border.left;
+ border_widths[1] = &border->border.right;
+ border_widths[2] = &border->border.top;
+ border_widths[3] = &border->border.bottom;
+ for (guint i = 0; i < 4; i++) {
+ if (NULL == values || values->type != TERM_NUMBER) {
+ g_free (border), border = NULL;
+ break;
+ }
+ *border_widths[i] = (gint) values->content.num->val;
+ }
+
+ return border;
+}
+
+static gboolean
+gce_gtk_border_convert (GceGtkBorder const *self,
+ ccss_property_type_t target,
+ void *value)
+{
+ g_return_val_if_fail (self && value, FALSE);
+
+ if (target != CCSS_PROPERTY_TYPE_STRING) {
+ return FALSE;
+ }
+
+ * (char **) value = g_strdup_printf ("{ %d, %d, %d, %d }",
+ self->border.left,
+ self->border.right,
+ self->border.top,
+ self->border.bottom);
+
+ return TRUE;
+}
+
+ccss_property_impl_t const _property_impls[] = {
+ { "gtk-default-border", (ccss_property_new_f) gce_gtk_border_new, (ccss_property_free_f) g_free, (ccss_property_convert_f) gce_gtk_border_convert },
+
+ { NULL, NULL, NULL, NULL }
+};
+
+ccss_property_impl_t const *
+gce_properties_get_vtable (void)
+{
+ return _property_impls;
+}
+
Added: trunk/src/gce-properties.h
==============================================================================
--- (empty file)
+++ trunk/src/gce-properties.h Wed Nov 19 15:46:35 2008
@@ -0,0 +1,32 @@
+/* The CSS Theme Engine for Gtk+.
+ * Copyright (C) 2008 Robert Staudinger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#ifndef GCE_PROPERTIES_H
+#define GCE_PROPERTIES_H
+
+#include <ccss-gtk/ccss-gtk.h>
+
+G_BEGIN_DECLS
+
+ccss_property_impl_t const * gce_properties_get_vtable (void);
+
+G_END_DECLS
+
+#endif /* GCE_PROPERTIES_H */
+
Modified: trunk/src/gce-theme.c
==============================================================================
--- trunk/src/gce-theme.c (original)
+++ trunk/src/gce-theme.c Wed Nov 19 15:46:35 2008
@@ -23,6 +23,7 @@
#include "gce-functions.h"
#include "gce-node.h"
+#include "gce-properties.h"
#include "gce-style.h"
#include "gce-rc-style.h"
@@ -35,13 +36,15 @@
G_MODULE_EXPORT void
theme_init (GTypeModule *module)
{
- ccss_function_t const *vtable;
+ ccss_property_impl_t const *properties;
+ ccss_function_t const *functions;
gce_rc_style_register_type (module);
gce_style_register_type (module);
- vtable = gce_functions_get_vtable ();
- ccss_init (vtable);
+ properties = gce_properties_get_vtable ();
+ functions = gce_functions_get_vtable ();
+ ccss_init (properties, functions);
}
G_MODULE_EXPORT void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]