Commit 2c08beaf authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen
Browse files

New functions to disable/enable individual loaders and to obtain license

Wed Jul  7 23:53:58 2004  Matthias Clasen  <maclas@gmx.de>

	* gdk-pixbuf-io.h:
	* gdk-pixbuf-io.c (gdk_pixbuf_format_is_disabled):
	* gdk-pixbuf-io.c (gdk_pixbuf_format_set_disabled):
	* gdk-pixbuf-io.c (gdk_pixbuf_format_get_license):
	New functions to disable/enable individual loaders and to
	obtain license information about loaders.

	* gdk-pixbuf-io.h (GdkPixbufFormat): Add disabled and
	license fields.

	* gdk-pixbuf-io.c (_gdk_pixbuf_get_module):
	* gdk-pixbuf-io.c (_gdk_pixbuf_get_named_module): Skip
	disabled loaders.

	* io-*.c: Add license information in the fill_info
	functions.
parent f141bf2b
Wed Jul 7 23:53:58 2004 Matthias Clasen <maclas@gmx.de>
* gdk-pixbuf-io.h:
* gdk-pixbuf-io.c (gdk_pixbuf_format_is_disabled):
* gdk-pixbuf-io.c (gdk_pixbuf_format_set_disabled):
* gdk-pixbuf-io.c (gdk_pixbuf_format_get_license):
New functions to disable/enable individual loaders and to
obtain license information about loaders.
* gdk-pixbuf-io.h (GdkPixbufFormat): Add disabled and
license fields.
* gdk-pixbuf-io.c (_gdk_pixbuf_get_module):
* gdk-pixbuf-io.c (_gdk_pixbuf_get_named_module): Skip
disabled loaders.
* io-*.c: Add license information in the fill_info
functions.
2004-07-07 Matthias Clasen <mclasen@redhat.com> 2004-07-07 Matthias Clasen <mclasen@redhat.com>
* gdk-pixbuf-features.h.in: Fix the build. * gdk-pixbuf-features.h.in: Fix the build.
......
...@@ -615,6 +615,10 @@ _gdk_pixbuf_get_named_module (const char *name, ...@@ -615,6 +615,10 @@ _gdk_pixbuf_get_named_module (const char *name,
for (modules = get_file_formats (); modules; modules = g_slist_next (modules)) { for (modules = get_file_formats (); modules; modules = g_slist_next (modules)) {
GdkPixbufModule *module = (GdkPixbufModule *)modules->data; GdkPixbufModule *module = (GdkPixbufModule *)modules->data;
if (module->info->disabled)
continue;
if (!strcmp (name, module->module_name)) if (!strcmp (name, module->module_name))
return module; return module;
} }
...@@ -641,6 +645,10 @@ _gdk_pixbuf_get_module (guchar *buffer, guint size, ...@@ -641,6 +645,10 @@ _gdk_pixbuf_get_module (guchar *buffer, guint size,
for (modules = get_file_formats (); modules; modules = g_slist_next (modules)) { for (modules = get_file_formats (); modules; modules = g_slist_next (modules)) {
GdkPixbufModule *module = (GdkPixbufModule *)modules->data; GdkPixbufModule *module = (GdkPixbufModule *)modules->data;
if (module->info->disabled)
continue;
score = format_check (module, buffer, size); score = format_check (module, buffer, size);
if (score > best) { if (score > best) {
best = score; best = score;
...@@ -1843,6 +1851,67 @@ gdk_pixbuf_format_is_scalable (GdkPixbufFormat *format) ...@@ -1843,6 +1851,67 @@ gdk_pixbuf_format_is_scalable (GdkPixbufFormat *format)
return (format->flags & GDK_PIXBUF_FORMAT_SCALABLE) != 0; return (format->flags & GDK_PIXBUF_FORMAT_SCALABLE) != 0;
} }
/**
* gdk_pixbuf_format_is_disabled:
* @format: a #GdkPixbufFormat
*
* Returns whether this image format is disabled. See
* gdk_pixbuf_format_set_disabled().
*
* Return value: whether this image format is disabled.
*
* Since: 2.6
*/
gboolean
gdk_pixbuf_format_is_disabled (GdkPixbufFormat *format)
{
g_return_val_if_fail (format != NULL, FALSE);
return format->disabled;
}
/**
* gdk_pixbuf_format_set_disabled:
* @format: a #GdkPixbufFormat
* @disabled: %TRUE to disable the format @format
*
* Disables or enables an image format. If a format is disabled,
* gdk-pixbuf won't use the image loader for this format to load
* images. Applications can use this to avoid using image loaders
* with an inappropriate license, see gdk_pixbuf_format_get_license().
*
* Since: 2.6
*/
void
gdk_pixbuf_format_set_disabled (GdkPixbufFormat *format,
gboolean disabled)
{
g_return_val_if_fail (format != NULL, FALSE);
format->disabled = disabled != FALSE;
}
/**
* gdk_pixbuf_format_get_license:
* @format: a #GdkPixbufFormat
*
* Returns information about the license of the image loader
* for the format. The returned string should be a shorthand for
* a wellknown license, e.g. "LGPL", "GPL", "QPL", "GPL/QPL",
* or "other" to indicate some other license.
*
* Returns: a string describing the license of @format.
*
* Since: 2.6
*/
gchar*
gdk_pixbuf_format_get_license (GdkPixbufFormat *format)
{
g_return_val_if_fail (format != NULL, FALSE);
return g_strdup (format->license);
}
GdkPixbufFormat * GdkPixbufFormat *
_gdk_pixbuf_get_format (GdkPixbufModule *module) _gdk_pixbuf_get_format (GdkPixbufModule *module)
{ {
......
...@@ -39,17 +39,21 @@ G_BEGIN_DECLS ...@@ -39,17 +39,21 @@ G_BEGIN_DECLS
typedef struct _GdkPixbufFormat GdkPixbufFormat; typedef struct _GdkPixbufFormat GdkPixbufFormat;
GSList *gdk_pixbuf_get_formats (void); GSList *gdk_pixbuf_get_formats (void);
gchar *gdk_pixbuf_format_get_name (GdkPixbufFormat *format); gchar *gdk_pixbuf_format_get_name (GdkPixbufFormat *format);
gchar *gdk_pixbuf_format_get_description (GdkPixbufFormat *format); gchar *gdk_pixbuf_format_get_description (GdkPixbufFormat *format);
gchar **gdk_pixbuf_format_get_mime_types (GdkPixbufFormat *format); gchar **gdk_pixbuf_format_get_mime_types (GdkPixbufFormat *format);
gchar **gdk_pixbuf_format_get_extensions (GdkPixbufFormat *format); gchar **gdk_pixbuf_format_get_extensions (GdkPixbufFormat *format);
gboolean gdk_pixbuf_format_is_writable (GdkPixbufFormat *format); gboolean gdk_pixbuf_format_is_writable (GdkPixbufFormat *format);
gboolean gdk_pixbuf_format_is_scalable (GdkPixbufFormat *format); gboolean gdk_pixbuf_format_is_scalable (GdkPixbufFormat *format);
gboolean gdk_pixbuf_format_is_disabled (GdkPixbufFormat *format);
void gdk_pixbuf_format_set_disabled (GdkPixbufFormat *format,
gboolean disabled);
gchar *gdk_pixbuf_format_get_license (GdkPixbufFormat *format);
GdkPixbufFormat *gdk_pixbuf_get_file_info (const gchar *filename, GdkPixbufFormat *gdk_pixbuf_get_file_info (const gchar *filename,
gint *width, gint *width,
gint *height); gint *height);
#ifdef GDK_PIXBUF_ENABLE_BACKEND #ifdef GDK_PIXBUF_ENABLE_BACKEND
...@@ -151,6 +155,8 @@ struct _GdkPixbufFormat { ...@@ -151,6 +155,8 @@ struct _GdkPixbufFormat {
gchar **mime_types; gchar **mime_types;
gchar **extensions; gchar **extensions;
guint32 flags; guint32 flags;
gboolean disabled;
gchar *license;
}; };
......
...@@ -677,6 +677,7 @@ MODULE_ENTRY (ani, fill_info) (GdkPixbufFormat *info) ...@@ -677,6 +677,7 @@ MODULE_ENTRY (ani, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types; info->mime_types = mime_types;
info->extensions = extensions; info->extensions = extensions;
info->flags = 0; info->flags = 0;
info->license = "LGPL";
} }
......
...@@ -1119,5 +1119,6 @@ MODULE_ENTRY (bmp, fill_info) (GdkPixbufFormat *info) ...@@ -1119,5 +1119,6 @@ MODULE_ENTRY (bmp, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types; info->mime_types = mime_types;
info->extensions = extensions; info->extensions = extensions;
info->flags = 0; info->flags = 0;
info->license = "LGPL";
} }
...@@ -1651,4 +1651,5 @@ MODULE_ENTRY (gif, fill_info) (GdkPixbufFormat *info) ...@@ -1651,4 +1651,5 @@ MODULE_ENTRY (gif, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types; info->mime_types = mime_types;
info->extensions = extensions; info->extensions = extensions;
info->flags = 0; info->flags = 0;
info->license = "LGPL";
} }
...@@ -1203,6 +1203,7 @@ MODULE_ENTRY (ico, fill_info) (GdkPixbufFormat *info) ...@@ -1203,6 +1203,7 @@ MODULE_ENTRY (ico, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types; info->mime_types = mime_types;
info->extensions = extensions; info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_WRITABLE; info->flags = GDK_PIXBUF_FORMAT_WRITABLE;
info->license = "LGPL";
} }
......
...@@ -1070,4 +1070,5 @@ MODULE_ENTRY (jpeg, fill_info) (GdkPixbufFormat *info) ...@@ -1070,4 +1070,5 @@ MODULE_ENTRY (jpeg, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types; info->mime_types = mime_types;
info->extensions = extensions; info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_WRITABLE; info->flags = GDK_PIXBUF_FORMAT_WRITABLE;
info->license = "LGPL";
} }
...@@ -759,4 +759,5 @@ MODULE_ENTRY (pcx, fill_info) (GdkPixbufFormat *info) ...@@ -759,4 +759,5 @@ MODULE_ENTRY (pcx, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types; info->mime_types = mime_types;
info->extensions = extensions; info->extensions = extensions;
info->flags = 0; info->flags = 0;
info->license = "LGPL";
} }
...@@ -995,4 +995,5 @@ MODULE_ENTRY (png, fill_info) (GdkPixbufFormat *info) ...@@ -995,4 +995,5 @@ MODULE_ENTRY (png, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types; info->mime_types = mime_types;
info->extensions = extensions; info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_WRITABLE; info->flags = GDK_PIXBUF_FORMAT_WRITABLE;
info->license = "LGPL";
} }
...@@ -1083,4 +1083,5 @@ MODULE_ENTRY (pnm, fill_info) (GdkPixbufFormat *info) ...@@ -1083,4 +1083,5 @@ MODULE_ENTRY (pnm, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types; info->mime_types = mime_types;
info->extensions = extensions; info->extensions = extensions;
info->flags = 0; info->flags = 0;
info->license = "LGPL";
} }
...@@ -544,5 +544,6 @@ MODULE_ENTRY (ras, fill_info) (GdkPixbufFormat *info) ...@@ -544,5 +544,6 @@ MODULE_ENTRY (ras, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types; info->mime_types = mime_types;
info->extensions = extensions; info->extensions = extensions;
info->flags = 0; info->flags = 0;
info->license = "LGPL";
} }
...@@ -996,4 +996,5 @@ MODULE_ENTRY (tga, fill_info) (GdkPixbufFormat *info) ...@@ -996,4 +996,5 @@ MODULE_ENTRY (tga, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types; info->mime_types = mime_types;
info->extensions = extensions; info->extensions = extensions;
info->flags = 0; info->flags = 0;
info->license = "LGPL";
} }
...@@ -626,4 +626,5 @@ MODULE_ENTRY (tiff, fill_info) (GdkPixbufFormat *info) ...@@ -626,4 +626,5 @@ MODULE_ENTRY (tiff, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types; info->mime_types = mime_types;
info->extensions = extensions; info->extensions = extensions;
info->flags = 0; info->flags = 0;
info->license = "LGPL";
} }
...@@ -369,4 +369,5 @@ MODULE_ENTRY (wbmp, fill_info) (GdkPixbufFormat *info) ...@@ -369,4 +369,5 @@ MODULE_ENTRY (wbmp, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types; info->mime_types = mime_types;
info->extensions = extensions; info->extensions = extensions;
info->flags = 0; info->flags = 0;
info->license = "LGPL";
} }
...@@ -477,4 +477,5 @@ MODULE_ENTRY (xbm, fill_info) (GdkPixbufFormat *info) ...@@ -477,4 +477,5 @@ MODULE_ENTRY (xbm, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types; info->mime_types = mime_types;
info->extensions = extensions; info->extensions = extensions;
info->flags = 0; info->flags = 0;
info->license = "LGPL";
} }
...@@ -1544,4 +1544,5 @@ MODULE_ENTRY (xpm, fill_info) (GdkPixbufFormat *info) ...@@ -1544,4 +1544,5 @@ MODULE_ENTRY (xpm, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types; info->mime_types = mime_types;
info->extensions = extensions; info->extensions = extensions;
info->flags = 0; info->flags = 0;
info->license = "LGPL";
} }
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