summaryrefslogtreecommitdiff
path: root/ccss-gtk
diff options
context:
space:
mode:
authorRobert Staudinger <robsta@gnome.org>2009-06-18 14:34:53 +0200
committerRobert Staudinger <robsta@gnome.org>2009-06-18 14:34:53 +0200
commit949af080159efae6cb49183b5974ae1cfb805216 (patch)
tree8dad122c3377d1d5cddbb245b62785308393d621 /ccss-gtk
parent1645dd8a257cbece1882a164c4d1ae624f33871c (diff)
[ccss-gtk] Move over stylesheet translation utility from the engine.
Diffstat (limited to 'ccss-gtk')
-rw-r--r--ccss-gtk/Makefile.am10
-rw-r--r--ccss-gtk/ccss-stylesheet-to-gtkrc.c72
2 files changed, 81 insertions, 1 deletions
diff --git a/ccss-gtk/Makefile.am b/ccss-gtk/Makefile.am
index 118a339..8b8c08b 100644
--- a/ccss-gtk/Makefile.am
+++ b/ccss-gtk/Makefile.am
@@ -23,7 +23,6 @@ libccss_gtk_1_la_LDFLAGS = \
$(NULL)
libccss_gtk_1_la_LIBADD = \
- ../ccss/libccss-1.la \
$(CCSS_GTK_LIBS) \
$(NULL)
@@ -47,6 +46,15 @@ headers_DATA = \
ccss-gtk-stylesheet.h \
$(NULL)
+bin_PROGRAMS = ccss-stylesheet-to-gtkrc
+
+ccss_stylesheet_to_gtkrc_SOURCES = \
+ ccss-stylesheet-to-gtkrc.c
+
+ccss_stylesheet_to_gtkrc_LDADD = \
+ $(CCSS_GTK_LIBS) \
+ libccss-gtk-1.la
+
EXTRA_DIST = \
ccss-gtk.sym \
$(NULL)
diff --git a/ccss-gtk/ccss-stylesheet-to-gtkrc.c b/ccss-gtk/ccss-stylesheet-to-gtkrc.c
new file mode 100644
index 0000000..26ce74c
--- /dev/null
+++ b/ccss-gtk/ccss-stylesheet-to-gtkrc.c
@@ -0,0 +1,72 @@
+/* vim: set ts=8 sw=8 noexpandtab: */
+
+/* The Gtk+ CSS Drawing Library.
+ * 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 <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ccss-gtk/ccss-gtk.h>
+#include <gtk/gtk.h>
+#include "config.h"
+
+int
+main (int argc,
+ char **argv)
+{
+ ccss_grammar_t *grammar;
+ ccss_stylesheet_t *stylesheet;
+ char *gtkrc;
+ int ret = EXIT_FAILURE;
+
+ if (argc <= 1) {
+ fprintf (stderr, "Need filename.\n");
+ return EXIT_FAILURE;
+ }
+
+ gtk_init (&argc, &argv);
+
+ grammar = ccss_gtk_grammar_create ();
+ stylesheet = ccss_grammar_create_stylesheet_from_file (grammar, argv[1],
+ NULL);
+ ccss_grammar_destroy (grammar), grammar = NULL;
+
+ if (NULL == stylesheet) {
+ goto bail;
+ }
+
+ gtkrc = ccss_gtk_stylesheet_to_gtkrc (stylesheet);
+ ccss_stylesheet_destroy (stylesheet), stylesheet = NULL;
+
+ if (NULL == gtkrc) {
+ fprintf (stderr, "Conversion failed.\n");
+ goto bail;
+ }
+
+ puts (gtkrc);
+ puts ("\n");
+
+ g_free (gtkrc), gtkrc = NULL;
+
+ ret = EXIT_SUCCESS;
+
+bail:
+ return ret;
+}
+