gtk-css-engine r155 - in trunk: . libccss/cccss



Author: robsta
Date: Thu Oct  2 13:07:50 2008
New Revision: 155
URL: http://svn.gnome.org/viewvc/gtk-css-engine?rev=155&view=rev

Log:
* configure.in:
* libccss/cccss/Makefile.am:
* libccss/cccss/example-1.c:
* libccss/cccss/example-1.css:
* libccss/cccss/example-1.css (added):
* libccss/cccss/Makefile.am (added):
* libccss/cccss/example-1.c (added):
Add simple clutter example.



Added:
   trunk/libccss/cccss/Makefile.am
   trunk/libccss/cccss/example-1.c
   trunk/libccss/cccss/example-1.css
Modified:
   trunk/ChangeLog
   trunk/configure.in

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Thu Oct  2 13:07:50 2008
@@ -176,7 +176,7 @@
 AM_CONDITIONAL([CCSS_WITH_SOUP], [test "$with_soup" = "yes"])
 
 
-clutter_req='clutter-0.8'
+clutter_req='clutter-cairo-0.8'
 PKG_CHECK_EXISTS([ $clutter_req ],
 [
   with_clutter="yes"

Added: trunk/libccss/cccss/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/libccss/cccss/Makefile.am	Thu Oct  2 13:07:50 2008
@@ -0,0 +1,14 @@
+
+AM_CPPFLAGS = \
+	$(CCSS_CFLAGS) \
+	-I$(top_srcdir)/libccss \
+	-I$(top_builddir)/libccss
+
+LDADD = \
+	$(CCSS_LIBS) \
+	./../ccss/libccss-1.la
+
+noinst_PROGRAMS = example-1
+
+example_1_SOURCES = example-1.c
+

Added: trunk/libccss/cccss/example-1.c
==============================================================================
--- (empty file)
+++ trunk/libccss/cccss/example-1.c	Thu Oct  2 13:07:50 2008
@@ -0,0 +1,87 @@
+/* The Cairo 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 <stdlib.h>
+#include <ccss/ccss.h>
+#include <clutter/clutter.h>
+#include <clutter-cairo/clutter-cairo.h>
+
+static void
+paint_css (ccss_stylesheet_t	*stylesheet,
+	   cairo_t		*cr)
+{
+	ccss_selector_group_t const	*group;
+	ccss_style_t			 style;
+	cairo_surface_t			*surface;
+	int				 width;
+	int				 height;
+
+	/* We want to cover the whole actor. */
+	surface = cairo_get_target (cr);
+	width = cairo_image_surface_get_width (surface);
+	height = cairo_image_surface_get_height (surface);
+
+	/* Query the stylesheet for the type to be drawn. */
+	group = ccss_stylesheet_query_type (stylesheet, "foo");
+	g_return_if_fail (group);
+
+	/* Initialise style with its drawing properties. */
+	ccss_style_init (&style);
+	ccss_selector_group_apply (group, &style);
+
+	/* Draw the style covering the actor. */
+	ccss_style_draw_rectangle (&style, cr, 0, 0, width, height);
+}
+
+int
+main (int	  argc,
+      char	**argv)
+{
+	ClutterActor		*stage;
+	ClutterActor		*actor;
+	ClutterColor		 stage_color = { 0x00, 0x00, 0x00, 0xff };
+	ClutterColor		 actor_color = { 0xff, 0xff, 0xff, 0x99 };
+	ccss_stylesheet_t	*stylesheet;
+	cairo_t			*cr;
+
+	clutter_init (&argc, &argv);
+
+	/* Load the stylesheet. */
+	stylesheet = ccss_stylesheet_new_from_file ("example-1.css");
+
+	stage = clutter_stage_get_default ();
+	clutter_actor_set_size (stage, 480, 320);
+	clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
+
+	actor = clutter_cairo_new (150, 30);
+	clutter_actor_set_position (actor, 50, 20);
+	clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
+
+	cr = clutter_cairo_create (CLUTTER_CAIRO (actor));
+	paint_css (stylesheet, cr);
+	cairo_destroy (cr);
+
+	clutter_actor_show (actor);
+	clutter_actor_show (stage);
+	clutter_main ();
+
+	ccss_stylesheet_free (stylesheet);
+
+	return EXIT_SUCCESS;
+}

Added: trunk/libccss/cccss/example-1.css
==============================================================================
--- (empty file)
+++ trunk/libccss/cccss/example-1.css	Thu Oct  2 13:07:50 2008
@@ -0,0 +1,7 @@
+
+foo {
+	background-color: white;
+	border: 2px solid red;
+	border-radius: 5px;
+}
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]