[gdk-pixbuf] gdk-pixbuf: add gdk_pixbuf_format_is_save_option_supported() API



commit 6385d35df0475d357cf4433afa05600ddeb08a7a
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Oct 23 11:20:17 2014 -0700

    gdk-pixbuf: add gdk_pixbuf_format_is_save_option_supported() API
    
    This is useful when you want to set an option (e.g. icc-profile) that
    might be supported by different formats, but not all of them.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683371

 docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt |    1 +
 gdk-pixbuf/gdk-pixbuf-io.c                        |   35 +++++++++++++++++++++
 gdk-pixbuf/gdk-pixbuf-io.h                        |   10 ++++--
 3 files changed, 43 insertions(+), 3 deletions(-)
---
diff --git a/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt 
b/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt
index 8e7d6d8..7c7730d 100644
--- a/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt
+++ b/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt
@@ -331,6 +331,7 @@ gdk_pixbuf_format_get_name
 gdk_pixbuf_format_get_description
 gdk_pixbuf_format_get_mime_types
 gdk_pixbuf_format_get_extensions
+gdk_pixbuf_format_is_save_option_supported
 gdk_pixbuf_format_is_writable
 gdk_pixbuf_format_is_scalable
 gdk_pixbuf_format_is_disabled
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index f5a9081..b49929b 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
@@ -3392,6 +3392,41 @@ gdk_pixbuf_format_free (GdkPixbufFormat *format)
                 g_slice_free (GdkPixbufFormat, format);
 }
 
+/**
+ * gdk_pixbuf_format_is_save_option_supported:
+ * @format: a #GdkPixbufFormat
+ * @option_key: the name of an option
+ *
+ * Returns %TRUE if the save option specified by @option_key is supported when
+ * saving a pixbuf using the module implementing @format.
+ * See gdk_pixbuf_save() for more information about option keys.
+ *
+ * Returns: %TRUE if the specified option is supported
+ *
+ * Since: 2.36
+ */
+gboolean
+gdk_pixbuf_format_is_save_option_supported (GdkPixbufFormat *format,
+                                            const gchar *option_key)
+{
+        GdkPixbufModule *module;
+
+        g_return_val_if_fail (format != NULL, FALSE);
+        g_return_val_if_fail (option_key != NULL, FALSE);
+
+        module = _gdk_pixbuf_get_named_module (format->name, NULL);
+        if (!module)
+                return FALSE;
+
+        if (!_gdk_pixbuf_load_module (module, NULL))
+                return FALSE;
+
+        if (!module->is_save_option_supported)
+                return FALSE;
+
+        return (* module->is_save_option_supported) (option_key);
+}
+
 G_DEFINE_BOXED_TYPE (GdkPixbufFormat, gdk_pixbuf_format,
                     gdk_pixbuf_format_copy,
                     gdk_pixbuf_format_free)
diff --git a/gdk-pixbuf/gdk-pixbuf-io.h b/gdk-pixbuf/gdk-pixbuf-io.h
index d8df010..88e21b5 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.h
+++ b/gdk-pixbuf/gdk-pixbuf-io.h
@@ -54,6 +54,9 @@ GDK_PIXBUF_AVAILABLE_IN_2_2
 gchar    **gdk_pixbuf_format_get_mime_types  (GdkPixbufFormat *format);
 GDK_PIXBUF_AVAILABLE_IN_2_2
 gchar    **gdk_pixbuf_format_get_extensions  (GdkPixbufFormat *format);
+GDK_PIXBUF_AVAILABLE_IN_2_36
+gboolean   gdk_pixbuf_format_is_save_option_supported (GdkPixbufFormat *format,
+                                                       const gchar     *option_key);
 GDK_PIXBUF_AVAILABLE_IN_2_2
 gboolean   gdk_pixbuf_format_is_writable     (GdkPixbufFormat *format);
 GDK_PIXBUF_AVAILABLE_IN_2_6
@@ -219,6 +222,7 @@ struct _GdkPixbufModulePattern {
  * @load_animation: loads an animation from a file.
  * @save: saves a #GdkPixbuf to a file.
  * @save_to_callback: saves a #GdkPixbuf by calling the given #GdkPixbufSaveFunc.
+ * @is_save_option_supported: returns whether a save option key is supported by the module
  * 
  * A #GdkPixbufModule contains the necessary functions to load and save 
  * images in a certain file format. 
@@ -271,13 +275,13 @@ struct _GdkPixbufModule {
                                      gchar **option_values,
                                      GError **error);
   
+        gboolean (* is_save_option_supported) (const gchar *option_key);
+
   /*< private >*/
        void (*_reserved1) (void); 
        void (*_reserved2) (void); 
        void (*_reserved3) (void); 
-       void (*_reserved4) (void); 
-       void (*_reserved5) (void); 
-
+       void (*_reserved4) (void);
 };
 
 /**


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