gtk-css-engine r8 - in bzr-playground: . libccd/ccd themes/gtk-css-test/gtk-2.0
- From: robsta svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk-css-engine r8 - in bzr-playground: . libccd/ccd themes/gtk-css-test/gtk-2.0
- Date: Mon, 18 Aug 2008 13:50:43 +0000 (UTC)
Author: robsta
Date: Mon Aug 18 13:50:43 2008
New Revision: 8
URL: http://svn.gnome.org/viewvc/gtk-css-engine?rev=8&view=rev
Log:
Basic SVG support.
Modified:
bzr-playground/ (props changed)
bzr-playground/configure.in
bzr-playground/libccd/ccd/ccd-background.c
bzr-playground/libccd/ccd/ccd-features.h.in
bzr-playground/libccd/ccd/ccd-image.c
bzr-playground/themes/gtk-css-test/gtk-2.0/gtkrc
bzr-playground/themes/gtk-css-test/gtk-2.0/styles.css
Modified: bzr-playground/configure.in
==============================================================================
--- bzr-playground/configure.in (original)
+++ bzr-playground/configure.in Mon Aug 18 13:50:43 2008
@@ -37,8 +37,20 @@
### Checks for libraries.
-# gtk >= 2.12 is needed for GtkBuilder
-PKG_CHECK_MODULES(GCE, gtk+-2.0 >= 2.12.0 libcroco-0.6)
+
+# Maybe it would work with gtk+-2.8, the first sporting cairo, right?
+pkgs='gtk+-2.0 >= 2.10.0 libcroco-0.6'
+
+# Guessing a version.
+rsvg_req='librsvg-2.0 >= 2.16'
+gce_cv_rsvg="no"
+PKG_CHECK_EXISTS([ $rsvg_req ],
+[
+ gce_cv_rsvg="yes"
+ pkgs="$pkgs $rsvg_req"
+])
+
+PKG_CHECK_MODULES(GCE, $pkgs)
AC_SUBST([GCE_CFLAGS])
AC_SUBST([GCE_LIBS])
@@ -46,6 +58,11 @@
AC_DEFINE([CCD_WITH_GTK], [1], [Support for drawing Gtk+ primitives like `box-gap'])
AM_CONDITIONAL([CCD_WITH_GTK], [test "yes" = "yes"])
+if test "$gce_cv_rsvg" = "yes"; then
+ AC_DEFINE([CCD_WITH_RSVG], [1], [SVG support through the `rsvg' library])
+fi
+AM_CONDITIONAL([CCD_WITH_RSVG], [test "$gce_cv_rsvg" = "yes"])
+
AC_SUBST([CCD_CFLAGS], [$GCE_CFLAGS])
AC_SUBST([CCD_LIBS], [$GCE_LIBS])
@@ -89,3 +106,8 @@
themes/gtk-css-test/gtk-2.0/Makefile])
AC_OUTPUT
+echo "
+Configuration
+
+ Support for SVG images $gce_cv_rsvg
+"
Modified: bzr-playground/libccd/ccd/ccd-background.c
==============================================================================
--- bzr-playground/libccd/ccd/ccd-background.c (original)
+++ bzr-playground/libccd/ccd/ccd-background.c Mon Aug 18 13:50:43 2008
@@ -78,7 +78,6 @@
}
if (self->image_spec != CCD_PROPERTY_SPEC_UNKNOWN) {
-printf ("%s()\n", __FUNCTION__);
dx = (double) width /
cairo_image_surface_get_width (self->image.surface);
dy = (double) height /
Modified: bzr-playground/libccd/ccd/ccd-features.h.in
==============================================================================
--- bzr-playground/libccd/ccd/ccd-features.h.in (original)
+++ bzr-playground/libccd/ccd/ccd-features.h.in Mon Aug 18 13:50:43 2008
@@ -26,5 +26,8 @@
/* Support for drawing Gtk+ primitives like `box-gap' */
#undef CCD_WITH_GTK
+/* SVG support through the `rsvg' library */
+#undef CCD_WITH_RSVG
+
#endif /* CCD_FEATURES_H */
Modified: bzr-playground/libccd/ccd/ccd-image.c
==============================================================================
--- bzr-playground/libccd/ccd/ccd-image.c (original)
+++ bzr-playground/libccd/ccd/ccd-image.c Mon Aug 18 13:50:43 2008
@@ -25,6 +25,10 @@
#include "ccd-function.h"
#include "ccd-image.h"
+#if CCD_WITH_RSVG
+#include <librsvg/rsvg.h>
+#endif
+
void
ccd_image_discard (ccd_image_t *self)
{
@@ -39,10 +43,102 @@
}
}
+static char *
+parse_uri (char const *uri,
+ char **id)
+{
+ char const *suffix;
+ char const *hash;
+ char *basename;
+
+ suffix = strrchr (uri, '.');
+ hash = strrchr (uri, '#');
+
+ basename = NULL;
+ if (suffix && hash && hash > suffix && hash[1] != '\0') {
+ basename = g_strndup (uri, hash - uri);
+ *id = g_strdup (hash + 1);
+ } else {
+ basename = g_strdup (uri);
+ *id = NULL;
+ }
+
+ return basename;
+}
+
+#if CCD_WITH_RSVG
+
+static bool
+load_svg (ccd_image_t *self,
+ char const *uri,
+ char const *id)
+{
+ RsvgHandle *handle;
+ GError *error;
+ RsvgDimensionData dimensions;
+ cairo_t *cr;
+ cairo_status_t status;
+
+ error = NULL;
+ handle = rsvg_handle_new_from_file (uri, &error);
+ if (error) {
+ g_warning (error->message);
+ g_warning ("Could not load `%s'", uri);
+ g_error_free (error);
+ return false;
+ }
+
+ rsvg_handle_get_dimensions (handle, &dimensions);
+ self->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ dimensions.width,
+ dimensions.height);
+
+ status = cairo_surface_status(self->surface);
+ if (status != CAIRO_STATUS_SUCCESS) {
+ g_warning (cairo_status_to_string (status));
+ cairo_surface_destroy (self->surface);
+ self->surface = NULL;
+ return false;
+ }
+
+ cr = cairo_create (self->surface);
+ rsvg_handle_render_cairo_sub (handle, cr, id);
+ cairo_destroy (cr), cr = NULL;
+
+ g_object_unref (G_OBJECT (handle)), handle = NULL;
+
+ return true;
+}
+
+#endif
+
static bool
-load_image (ccd_image_t *self)
+load_image (ccd_image_t *self)
{
- self->surface = cairo_image_surface_create_from_png (self->uri);
+ char *basename;
+ char *suffix;
+ char *id;
+ bool matched;
+
+ basename = parse_uri (self->uri, &id);
+ g_return_val_if_fail (basename, NULL);
+
+ matched = false;
+#if CCD_WITH_RSVG
+ if (!matched &&
+ g_str_has_suffix (basename, ".svg")) {
+ matched = true;
+ load_svg (self, basename, id);
+ }
+#endif
+
+ if (!matched) {
+ self->surface = cairo_image_surface_create_from_png (basename);
+
+ }
+
+ g_free (basename);
+ g_free (id);
return (bool) self->surface;
}
Modified: bzr-playground/themes/gtk-css-test/gtk-2.0/gtkrc
==============================================================================
--- bzr-playground/themes/gtk-css-test/gtk-2.0/gtkrc (original)
+++ bzr-playground/themes/gtk-css-test/gtk-2.0/gtkrc Mon Aug 18 13:50:43 2008
@@ -1,7 +1,7 @@
style "default"
{
- xthickness = 1
- ythickness = 1
+# xthickness = 3
+# ythickness = 2
engine "css"
{
Modified: bzr-playground/themes/gtk-css-test/gtk-2.0/styles.css
==============================================================================
--- bzr-playground/themes/gtk-css-test/gtk-2.0/styles.css (original)
+++ bzr-playground/themes/gtk-css-test/gtk-2.0/styles.css Mon Aug 18 13:50:43 2008
@@ -56,15 +56,19 @@
arrow[orientation=up] {
background-image: url(arrow-up.png);
}
+
arrow[orientation=down] {
- background-image: url(arrow-down.png);
+ background-color: yellow;
+ background-image: url(foo.svg);
}
+
arrow[orientation=left] {
background-image: url(arrow-left.png);
}
arrow[orientation=right] {
background-image: url(arrow-right.png);
}
+
tab {
background-color: blue;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]