Commit 6385d35d authored by Cosimo Cecchi's avatar Cosimo Cecchi Committed by Matthias Clasen
Browse files

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
parent 97877a64
......@@ -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
......
......@@ -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)
......@@ -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);
};
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment