[gdk-pixbuf] Add a GType for GdkPixbufFormat



commit 330f9555cdb557abd7a5bfff4f4127bacd0653fc
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Sat Jun 26 17:06:23 2010 -0400

    Add a GType for GdkPixbufFormat
    
    A simple boxed type, for use in language bindings.
    
    http://bugzilla.gnome.org/show_bug.cgi?id=608679

 gdk-pixbuf/gdk-pixbuf-io.c    |   49 +++++++++++++++++++++++++++++++++++++++++
 gdk-pixbuf/gdk-pixbuf-io.h    |    6 ++++-
 gdk-pixbuf/gdk-pixbuf.symbols |    3 ++
 3 files changed, 57 insertions(+), 1 deletions(-)
---
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index 2fbf367..2da98bd 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
@@ -2672,6 +2672,55 @@ gdk_pixbuf_get_formats (void)
         return result;
 }
 
+/**
+ * gdk_pixbuf_format_copy:
+ * @format: a #GdkPixbufFormat
+ *
+ * Creates a copy of @format
+ *
+ * Return value: the newly allocated copy of a #GdkPixbufFormat. Use
+ *   gdk_pixbuf_format_free() to free the resources when done
+ *
+ * Since: 2.22
+ */
+GdkPixbufFormat *
+gdk_pixbuf_format_copy (const GdkPixbufFormat *format)
+{
+        if (G_LIKELY (format != NULL))
+                return g_slice_dup (GdkPixbufFormat, format);
+
+        return NULL;
+}
+
+/**
+ * gdk_pixbuf_format_free:
+ * @format: a #GdkPixbufFormat
+ *
+ * Frees the resources allocated when copying a #GdkPixbufFormat
+ * using gdk_pixbuf_format_copy()
+ *
+ * Since: 2.22
+ */
+void
+gdk_pixbuf_format_free (GdkPixbufFormat *format)
+{
+        if (G_LIKELY (format != NULL))
+                g_slice_free (GdkPixbufFormat, format);
+}
+
+GType
+gdk_pixbuf_format_get_type (void)
+{
+        static volatile gsize format_id__volatile = 0;
+        if (g_once_init_enter (&format_id__volatile)) {
+                GType format_id =
+                        g_boxed_type_register_static (g_intern_static_string ("GdkPixbufFormat"),
+                                                      (GBoxedCopyFunc) gdk_pixbuf_format_copy,
+                                                      (GBoxedFreeFunc) gdk_pixbuf_format_free);
+                g_once_init_leave (&format_id__volatile, format_id);
+        }
+        return format_id__volatile;
+}
 
 #define __GDK_PIXBUF_IO_C__
 #include "gdk-pixbuf-aliasdef.c"
diff --git a/gdk-pixbuf/gdk-pixbuf-io.h b/gdk-pixbuf/gdk-pixbuf-io.h
index a6e07ca..4faee3e 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.h
+++ b/gdk-pixbuf/gdk-pixbuf-io.h
@@ -43,6 +43,8 @@ G_BEGIN_DECLS
 
 typedef struct _GdkPixbufFormat GdkPixbufFormat;
  
+GType gdk_pixbuf_format_get_type (void) G_GNUC_CONST;
+
 GSList    *gdk_pixbuf_get_formats            (void);
 gchar     *gdk_pixbuf_format_get_name        (GdkPixbufFormat *format);
 gchar     *gdk_pixbuf_format_get_description (GdkPixbufFormat *format);
@@ -59,6 +61,9 @@ GdkPixbufFormat *gdk_pixbuf_get_file_info    (const gchar     *filename,
 					      gint            *width, 
 					      gint            *height);
 
+GdkPixbufFormat *gdk_pixbuf_format_copy (const GdkPixbufFormat *format);
+void             gdk_pixbuf_format_free (GdkPixbufFormat       *format);
+
 #ifdef GDK_PIXBUF_ENABLE_BACKEND
 
 
@@ -164,7 +169,6 @@ struct _GdkPixbufFormat {
   gchar *license;
 };
 
-
 #endif /* GDK_PIXBUF_ENABLE_BACKEND */
 
 G_END_DECLS
diff --git a/gdk-pixbuf/gdk-pixbuf.symbols b/gdk-pixbuf/gdk-pixbuf.symbols
index 9418102..b1c7e17 100644
--- a/gdk-pixbuf/gdk-pixbuf.symbols
+++ b/gdk-pixbuf/gdk-pixbuf.symbols
@@ -146,6 +146,9 @@ gdk_pixbuf_scaled_anim_iter_get_type G_GNUC_CONST
 #if IN_HEADER(GDK_PIXBUF_IO_H)
 #if IN_FILE(__GDK_PIXBUF_IO_C__)
 gdk_pixbuf_get_formats
+gdk_pixbuf_format_get_type G_GNUC_CONST;
+gdk_pixbuf_format_copy
+gdk_pixbuf_format_free
 gdk_pixbuf_format_get_description
 gdk_pixbuf_format_get_extensions
 gdk_pixbuf_format_get_license



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