[gir-repository] [GdkPixbuf] Add a custom library



commit b0a7e0e8f15a50f6be413773c1347ef864817266
Author: Johan Dahlin <johan gnome org>
Date:   Mon Feb 1 12:12:36 2010 -0200

    [GdkPixbuf] Add a custom library
    
    Add a custom library for GdkPixbuf which includes GType registration
    for GdkPixbufFormat. This allows gdk_pixbuf_get_formats() to work
    with included annotation.

 configure.ac           |    1 +
 gir/GdkPixbuf-custom.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 gir/GdkPixbuf-custom.h |   15 +++++++++++++++
 gir/Makefile.am        |   16 +++++++++++++---
 4 files changed, 71 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 44be9db..43fc3f0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,6 +56,7 @@ GIR_CHECK(Gtk, gtk+-2.0 >= 1.12.0)
 GDK_TARGET=
 GDK_TARGET_GIRS=
 if $have_gtk; then
+    PKG_CHECK_MODULES(GDKPIXBUF, gdk-pixbuf-2.0)
     PKG_CHECK_MODULES(GDK, gdk-2.0)
 
     GDK_TARGET="$($PKG_CONFIG --variable=target gtk+-2.0)"
diff --git a/gir/GdkPixbuf-custom.c b/gir/GdkPixbuf-custom.c
index e5f8a87..f67ff04 100644
--- a/gir/GdkPixbuf-custom.c
+++ b/gir/GdkPixbuf-custom.c
@@ -1,5 +1,47 @@
 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
 
+
+#define GDK_PIXBUF_ENABLE_BACKEND /* just to get the GdkPixbufFormat struct */
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#undef GDK_PIXBUF_ENABLE_BACKEND
+
+static GdkPixbufFormat*
+gdk_pixbuf_format_copy (const GdkPixbufFormat *format)
+{
+  GdkPixbufFormat *new_format;
+
+  g_return_val_if_fail (format != NULL, NULL);
+
+  new_format = g_slice_new (GdkPixbufFormat);
+  *new_format = *format;
+  return new_format;
+}
+
+static void
+gdk_pixbuf_format_free (GdkPixbufFormat *format)
+{
+  g_return_if_fail (format != NULL);
+
+  g_slice_free (GdkPixbufFormat, format);
+}
+
+GType
+gdk_pixbuf_format_get_type (void)
+{
+  static GType our_type = 0;
+
+  if (our_type == 0)
+    our_type = g_boxed_type_register_static (g_intern_static_string ("GdkPixbufFormat"),
+                         (GBoxedCopyFunc)gdk_pixbuf_format_copy,
+                         (GBoxedFreeFunc)gdk_pixbuf_format_free);
+  return our_type;
+}
+
+/**
+ * gdk_pixbuf_get_formats:
+ * Returns: (element-type PixbufFormat) (transfer container)
+ */
+
 /**
  * gdk_pixbuf_format_get_extensions:
  * Returns: (array zero-terminated=1) (transfer full):
diff --git a/gir/GdkPixbuf-custom.h b/gir/GdkPixbuf-custom.h
new file mode 100644
index 0000000..6f09770
--- /dev/null
+++ b/gir/GdkPixbuf-custom.h
@@ -0,0 +1,15 @@
+/* Copyright 2010 litl, LLC. All Rights Reserved. */
+
+#ifndef __GIREPO_GDKPIXBUF_CUSTOM_H__
+#define __GIREPO_GDKPIXBUF_CUSTOM_H__
+
+#include <glib.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+G_BEGIN_DECLS
+
+GType gdk_pixbuf_format_get_type (void);
+
+G_END_DECLS
+
+#endif  /* __GIREPO_GDKPIXBUF_CUSTOM_H__ */
diff --git a/gir/Makefile.am b/gir/Makefile.am
index 7e34006..1c48ef4 100644
--- a/gir/Makefile.am
+++ b/gir/Makefile.am
@@ -237,10 +237,17 @@ endif
 
 # Gtk
 
+libgirepo_GdkPixbuf_custom_la_CPPFLAGS = $(GDKPIXBUF_CFLAGS)
+libgirepo_GdkPixbuf_custom_la_LIBADD = $(GDKPIXBUF_LIBS)
+libgirepo_GdkPixbuf_custom_la_LDFLAGS = $(COMMON_CUSTOM_LDFLAGS)
+libgirepo_GdkPixbuf_custom_la_SOURCES =	\
+	$(srcdir)/GdkPixbuf-custom.c		\
+	$(srcdir)/Gdk-custom.h
+
 libgirepo_Gdk_custom_la_CPPFLAGS = $(GDK_CFLAGS)
 libgirepo_Gdk_custom_la_LIBADD = $(GDK_LIBS)
 libgirepo_Gdk_custom_la_LDFLAGS = $(COMMON_CUSTOM_LDFLAGS)
-libgirepo_Gdk_custom_la_SOURCES = 	\
+libgirepo_Gdk_custom_la_SOURCES =	\
 	$(srcdir)/Gdk-custom.c		\
 	$(srcdir)/Gdk-custom.h
 
@@ -251,20 +258,23 @@ libgirepo_Gtk_custom_la_SOURCES =	\
 	$(srcdir)/Gtk-custom.c		\
 	$(srcdir)/Gtk-custom.h
 
-EXTRA_DIST += $(srcdir)/GdkPixbuf-custom.c
+lib_LTLIBRARIES += libgirepo-GdkPixbuf-custom.la
+
 if BUILD_GTK
 GDKPIXBUF_INCLUDEDIR=`pkg-config --variable=includedir gdk-pixbuf-2.0`/gtk-2.0
-GdkPixbuf-2.0.gir: $(INTROSPECTION_SCANNER) GdkPixbuf-custom.c
+GdkPixbuf-2.0.gir: $(INTROSPECTION_SCANNER) libgirepo-GdkPixbuf-custom.la
 	$(INTROSPECTION_SCANNER) -v --namespace GdkPixbuf --nsversion=2.0 --strip-prefix=Gdk\
 	    --add-include-path=$(srcdir) --add-include-path=. \
              --include=Gio-2.0 \
 	     --library=gdk_pixbuf-2.0 \
+	     --library=libgirepo-GdkPixbuf-custom.la \
 	     --libtool="$(LIBTOOL)" \
              --output $@ \
              --pkg gobject-2.0 \
              --pkg gio-2.0 \
              --pkg gdk-pixbuf-2.0 \
              $(srcdir)/GdkPixbuf-custom.c \
+             $(srcdir)/GdkPixbuf-custom.h \
              $(GDKPIXBUF_INCLUDEDIR)/gdk-pixbuf/*.h
 BUILT_GIRSOURCES += GdkPixbuf-2.0.gir
 XPATH_TESTS += GdkPixbuf-2.0.xpath



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