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.
This commit is contained in:
Matthias Clasen 2004-07-08 03:56:36 +00:00 committed by Matthias Clasen
parent f141bf2b9f
commit 2c08beafcf
17 changed files with 112 additions and 4 deletions

View File

@ -1,3 +1,22 @@
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>
* gdk-pixbuf-features.h.in: Fix the build.

View File

@ -615,6 +615,10 @@ _gdk_pixbuf_get_named_module (const char *name,
for (modules = get_file_formats (); modules; modules = g_slist_next (modules)) {
GdkPixbufModule *module = (GdkPixbufModule *)modules->data;
if (module->info->disabled)
continue;
if (!strcmp (name, module->module_name))
return module;
}
@ -641,6 +645,10 @@ _gdk_pixbuf_get_module (guchar *buffer, guint size,
for (modules = get_file_formats (); modules; modules = g_slist_next (modules)) {
GdkPixbufModule *module = (GdkPixbufModule *)modules->data;
if (module->info->disabled)
continue;
score = format_check (module, buffer, size);
if (score > best) {
best = score;
@ -1843,6 +1851,67 @@ gdk_pixbuf_format_is_scalable (GdkPixbufFormat *format)
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 *
_gdk_pixbuf_get_format (GdkPixbufModule *module)
{

View File

@ -39,17 +39,21 @@ G_BEGIN_DECLS
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_description (GdkPixbufFormat *format);
gchar **gdk_pixbuf_format_get_mime_types (GdkPixbufFormat *format);
gchar **gdk_pixbuf_format_get_extensions (GdkPixbufFormat *format);
gboolean gdk_pixbuf_format_is_writable (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,
gint *width,
gint *height);
GdkPixbufFormat *gdk_pixbuf_get_file_info (const gchar *filename,
gint *width,
gint *height);
#ifdef GDK_PIXBUF_ENABLE_BACKEND
@ -151,6 +155,8 @@ struct _GdkPixbufFormat {
gchar **mime_types;
gchar **extensions;
guint32 flags;
gboolean disabled;
gchar *license;
};

View File

@ -677,6 +677,7 @@ MODULE_ENTRY (ani, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
info->license = "LGPL";
}

View File

@ -1119,5 +1119,6 @@ MODULE_ENTRY (bmp, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
info->license = "LGPL";
}

View File

@ -1651,4 +1651,5 @@ MODULE_ENTRY (gif, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
info->license = "LGPL";
}

View File

@ -1203,6 +1203,7 @@ MODULE_ENTRY (ico, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_WRITABLE;
info->license = "LGPL";
}

View File

@ -1070,4 +1070,5 @@ MODULE_ENTRY (jpeg, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_WRITABLE;
info->license = "LGPL";
}

View File

@ -759,4 +759,5 @@ MODULE_ENTRY (pcx, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
info->license = "LGPL";
}

View File

@ -995,4 +995,5 @@ MODULE_ENTRY (png, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_WRITABLE;
info->license = "LGPL";
}

View File

@ -1083,4 +1083,5 @@ MODULE_ENTRY (pnm, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
info->license = "LGPL";
}

View File

@ -544,5 +544,6 @@ MODULE_ENTRY (ras, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
info->license = "LGPL";
}

View File

@ -996,4 +996,5 @@ MODULE_ENTRY (tga, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
info->license = "LGPL";
}

View File

@ -626,4 +626,5 @@ MODULE_ENTRY (tiff, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
info->license = "LGPL";
}

View File

@ -369,4 +369,5 @@ MODULE_ENTRY (wbmp, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
info->license = "LGPL";
}

View File

@ -477,4 +477,5 @@ MODULE_ENTRY (xbm, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
info->license = "LGPL";
}

View File

@ -1544,4 +1544,5 @@ MODULE_ENTRY (xpm, fill_info) (GdkPixbufFormat *info)
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
info->license = "LGPL";
}