summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2014-10-23 11:20:17 -0700
committerMatthias Clasen <mclasen@redhat.com>2016-08-02 15:19:21 -0400
commit6385d35df0475d357cf4433afa05600ddeb08a7a (patch)
treeda2d5580e2beaf904fe9fbd87409d6704bf896c0
parent97877a64af55e7b73d18b85aafffbface9666ebf (diff)
downloadgdk-pixbuf-6385d35df0475d357cf4433afa05600ddeb08a7a.tar.gz
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
-rw-r--r--docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt1
-rw-r--r--gdk-pixbuf/gdk-pixbuf-io.c35
-rw-r--r--gdk-pixbuf/gdk-pixbuf-io.h10
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 8e7d6d841..7c7730d00 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 f5a90813c..b49929b7c 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 d8df01049..88e21b563 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);
};
/**