[librsvg] Add Vala bindings



commit 729a3d6b6486faa92c7a56a5a4f5bf04173c8624
Author: Evan Nemerson <evan coeus-group com>
Date:   Thu Jun 14 14:50:12 2012 -0700

    Add Vala bindings
    
    https://bugzilla.gnome.org/show_bug.cgi?id=677676

 .gitignore            |    2 +-
 Makefile.am           |   20 ++++++++++-
 Rsvg-2.0-custom.vala  |   37 +++++++++++++++++++
 Rsvg-2.0.metadata     |    2 +
 configure.in          |    5 +++
 librsvg-features.h.in |    2 +-
 m4/vapigen.m4         |   96 +++++++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 161 insertions(+), 3 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 16ad686..b41e047 100644
--- a/.gitignore
+++ b/.gitignore
@@ -61,4 +61,4 @@ tests/styles
 tools/test-memory
 Rsvg-2.0.gir
 Rsvg-2.0.typelib
-
+librsvg-2.0.vapi
diff --git a/Makefile.am b/Makefile.am
index e116fd0..6b80031 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -216,7 +216,7 @@ if HAVE_INTROSPECTION
 -include $(INTROSPECTION_MAKEFILE)
 
 INTROSPECTION_GIRS = Rsvg- RSVG_API_VERSION@.gir
-INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir)
+INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) --symbol-prefix=rsvg --symbol-prefix=librsvg
 INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
 
 Rsvg- RSVG_API_VERSION@.gir: librsvg- RSVG_API_MAJOR_VERSION@.la
@@ -250,6 +250,24 @@ nodist_typelibs_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
 
 CLEANFILES += $(nodist_gir_DATA) $(nodist_typelibs_DATA)
 
+if ENABLE_VAPIGEN
+include $(VAPIGEN_MAKEFILE)
+
+librsvg-$(RSVG_API_VERSION).vapi: Rsvg-$(RSVG_API_VERSION).gir
+
+VAPIGEN_VAPIS = librsvg-$(RSVG_API_VERSION).vapi
+
+librsvg_ RSVG_API_VERSION_U@_vapi_DEPS = gio-2.0 cairo
+librsvg_ RSVG_API_VERSION_U@_vapi_METADATADIRS = $(srcdir)
+librsvg_ RSVG_API_VERSION_U@_vapi_FILES = Rsvg-$(RSVG_API_VERSION).gir Rsvg-$(RSVG_API_VERSION)-custom.vala
+
+vapidir = $(datadir)/vala/vapi
+vapi_DATA = $(VAPIGEN_VAPIS)
+
+CLEANFILES += $(VAPIGEN_VAPIS)
+
+endif # ENABLE_VAPIGEN
+
 endif # HAVE_INTROSPECTION
 
 # ChangeLog generation
diff --git a/Rsvg-2.0-custom.vala b/Rsvg-2.0-custom.vala
new file mode 100644
index 0000000..46f1a6f
--- /dev/null
+++ b/Rsvg-2.0-custom.vala
@@ -0,0 +1,37 @@
+namespace Rsvg {
+	public class Handle : GLib.Object {
+		[Deprecated (since = "2.36")]
+		public unowned string get_desc ();
+		[Deprecated (replacement = "GLib.Object.unref")]
+		public void free ();
+		[Deprecated (replacement = "render_cairo")]
+		public void set_size_callback (owned Rsvg.SizeFunc size_func);
+		[Deprecated (since = "2.36")]
+		public unowned string get_title ();
+		[Deprecated (since = "2.36")]
+		public unowned string get_metadata ();
+	}
+
+	namespace Version {
+		[CCode (cname = "LIBRSVG_CHECK_VERSION")]
+		public static bool check (int major, int minor, int micro);
+	}
+
+	[Deprecated]
+	public delegate void SizeFunc (ref int width, ref int height);
+
+	[Deprecated (since = "2.36")]
+	public static void init ();
+	[Deprecated]
+	public static Gdk.Pixbuf pixbuf_from_file (string file_name) throws GLib.Error;
+	[Deprecated]
+	public static Gdk.Pixbuf pixbuf_from_file_at_max_size (string file_name, int max_width, int max_height) throws GLib.Error;
+	[Deprecated]
+	public static Gdk.Pixbuf pixbuf_from_file_at_size (string file_name, int width, int height) throws GLib.Error;
+	[Deprecated]
+	public static Gdk.Pixbuf pixbuf_from_file_at_zoom (string file_name, double x_zoom, double y_zoom) throws GLib.Error;
+	[Deprecated]
+	public static Gdk.Pixbuf pixbuf_from_file_at_zoom_with_max (string file_name, double x_zoom, double y_zoom, int max_width, int max_height) throws GLib.Error;
+	[Deprecated (since = "2.36")]
+	public static void term ();
+}
diff --git a/Rsvg-2.0.metadata b/Rsvg-2.0.metadata
new file mode 100644
index 0000000..450a42e
--- /dev/null
+++ b/Rsvg-2.0.metadata
@@ -0,0 +1,2 @@
+*_VERSION parent="Rsvg.Version" name="(.+)_VERSION"
+VERSION parent="Rsvg.Version" name="STRING"
diff --git a/configure.in b/configure.in
index d1107a1..6c89681 100644
--- a/configure.in
+++ b/configure.in
@@ -9,6 +9,7 @@ AC_INIT([RSVG],[rsvg_version],[https://bugzilla.gnome.org/enter_bug.cgi?product=
 
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_SRCDIR([rsvg.h])
+AC_CONFIG_MACRO_DIR([m4])
 
 AM_INIT_AUTOMAKE([1.9 foreign no-dist-gzip dist-bzip2])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
@@ -284,6 +285,9 @@ fi
 
 GOBJECT_INTROSPECTION_CHECK([0.10.8])
 
+# Vala bindings
+VAPIGEN_CHECK([0.17.1.26],,,[no])
+
 dnl ===========================================================================
 
 m4_copy([AC_DEFUN],[glib_DEFUN])
@@ -335,6 +339,7 @@ librsvg-$VERSION
 	compiler:                       ${CC}
 	
 	Build introspectable bindings:  ${found_introspection}
+	Build Vala bindings:            ${enable_vala}
 	Build GdkPixbuf loader:         ${enable_pixbuf_loader}
         GTK 2.0:                        ${have_gtk_2}
         GTK 3.0:                        ${have_gtk_3}
diff --git a/librsvg-features.h.in b/librsvg-features.h.in
index 53ea0ac..2c07a9f 100644
--- a/librsvg-features.h.in
+++ b/librsvg-features.h.in
@@ -3,7 +3,7 @@
 #endif
 
 #ifndef LIBRSVG_FEATURES_H
-#define LIBRSVG_FEATURES_H 1
+#define LIBRSVG_FEATURES_H
 
 #define LIBRSVG_MAJOR_VERSION (@LIBRSVG_MAJOR_VERSION@)
 #define LIBRSVG_MINOR_VERSION (@LIBRSVG_MINOR_VERSION@)
diff --git a/m4/vapigen.m4 b/m4/vapigen.m4
new file mode 100644
index 0000000..f2df12f
--- /dev/null
+++ b/m4/vapigen.m4
@@ -0,0 +1,96 @@
+dnl vapigen.m4
+dnl
+dnl Copyright 2012 Evan Nemerson
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+
+# VAPIGEN_CHECK([VERSION], [API_VERSION], [FOUND-INTROSPECTION], [DEFAULT])
+# --------------------------------------
+# Check vapigen existence and version
+#
+# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation
+AC_DEFUN([VAPIGEN_CHECK],
+[
+  AC_BEFORE([GOBJECT_INTROSPECTION_CHECK],[$0])
+  AC_BEFORE([GOBJECT_INTROSPECTION_REQUIRE],[$0])
+
+  AC_ARG_ENABLE([vala],
+    [AS_HELP_STRING([--enable-vala[=@<:@no/auto/yes@:>@]],[build Vala bindings @<:@default=]ifelse($4,,auto,$4)[@:>@])],,[
+      AS_IF([test "x$4" = "x"], [
+          enable_vala=auto
+        ], [
+          enable_vala=$4
+        ])
+    ])
+
+  AS_CASE([$enable_vala], [no], [enable_vala=no],
+      [yes], [
+        AS_IF([test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [
+            AC_MSG_ERROR([Vala bindings require GObject Introspection])
+          ])
+      ], [auto], [
+        AS_IF([test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [
+            enable_vala=no
+          ])
+      ], [
+        AC_MSG_ERROR([Invalid argument passed to --enable-vala, should be one of @<:@no/auto/yes@:>@])
+      ])
+
+  AS_IF([test "x$2" = "x"], [
+      vapigen_pkg_name=vapigen
+    ], [
+      vapigen_pkg_name=vapigen-$2
+    ])
+  AS_IF([test "x$1" = "x"], [
+      vapigen_pkg="$vapigen_pkg_name"
+    ], [
+      vapigen_pkg="$vapigen_pkg_name >= $1"
+    ])
+
+  PKG_PROG_PKG_CONFIG
+
+  PKG_CHECK_EXISTS([$vapigen_pkg], [
+      AS_IF([test "$enable_vala" = "auto"], [
+          enable_vala=yes
+        ])
+    ], [
+      AS_CASE([$enable_vala], [yes], [
+          AC_MSG_ERROR([$vapigen_pkg not found])
+        ], [auto], [
+          enable_vala=no
+        ])
+    ])
+
+  AC_MSG_CHECKING([for vala])
+
+  AS_CASE([$enable_vala],
+    [yes], [
+      VAPIGEN=`$PKG_CONFIG --variable=vapigen vapigen`
+      VAPIGEN_MAKEFILE=`$PKG_CONFIG --variable=datadir vapigen`/vala/Makefile.vapigen
+      AS_IF([test "x$2" = "x"], [
+          VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir vapigen`
+        ], [
+          VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir_versioned vapigen`
+        ])
+    ])
+
+  AC_MSG_RESULT([$enable_vala])
+
+  AC_SUBST([VAPIGEN])
+  AC_SUBST([VAPIGEN_VAPIDIR])
+  AC_SUBST([VAPIGEN_MAKEFILE])
+
+  AM_CONDITIONAL(ENABLE_VAPIGEN, test "x$enable_vala" = "xyes")
+])



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