disabling pixbuf loaders
- From: Matthias Clasen <mclasen redhat com>
- To: gtk-devel-list gnome org
- Subject: disabling pixbuf loaders
- Date: Fri, 02 Jul 2004 01:24:51 -0400
Here is what I plan to commit shortly to gdk-pixbuf HEAD,
the patch adds three new functions to get license information about
image loaders and to disable individual loaders. Doing things the
way I have done here means that image loaders compiled against 2.6 will
not be loadable by 2.4, since they will attempt to write beyond the
GdkPixbufFormat struct when setting info->license. If people think that
we should spend the extra effort to make that working, we could add
a separate GdkPixbufModuleFillLicenseInfo function and set the license
info in that function.
Matthias
Index: gdk-pixbuf-io.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/gdk-pixbuf-io.h,v
retrieving revision 1.34
diff -u -p -r1.34 gdk-pixbuf-io.h
--- gdk-pixbuf-io.h 20 Jun 2004 05:11:57 -0000 1.34
+++ gdk-pixbuf-io.h 2 Jul 2004 05:16:24 -0000
@@ -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);
-
-GdkPixbufFormat *gdk_pixbuf_get_file_info (const gchar *filename,
- gint *width,
- gint *height);
+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);
#ifdef GDK_PIXBUF_ENABLE_BACKEND
@@ -151,6 +155,8 @@ struct _GdkPixbufFormat {
gchar **mime_types;
gchar **extensions;
guint32 flags;
+ gboolean disabled;
+ gchar *license;
};
Index: gdk-pixbuf-io.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/gdk-pixbuf-io.c,v
retrieving revision 1.94
diff -u -p -r1.94 gdk-pixbuf-io.c
--- gdk-pixbuf-io.c 5 Jun 2004 05:16:18 -0000 1.94
+++ gdk-pixbuf-io.c 2 Jul 2004 05:16:24 -0000
@@ -615,6 +615,10 @@ _gdk_pixbuf_get_named_module (const char
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,
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;
@@ -1841,6 +1849,67 @@ gdk_pixbuf_format_is_scalable (GdkPixbuf
g_return_val_if_fail (format != NULL, FALSE);
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 *
Index: io-ani.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-ani.c,v
retrieving revision 1.5
diff -u -p -r1.5 io-ani.c
--- io-ani.c 13 Apr 2004 14:57:03 -0000 1.5
+++ io-ani.c 2 Jul 2004 05:16:24 -0000
@@ -677,6 +677,7 @@ MODULE_ENTRY (ani, fill_info) (GdkPixbuf
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
+ info->license = "LGPL";
}
Index: io-bmp.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-bmp.c,v
retrieving revision 1.39
diff -u -p -r1.39 io-bmp.c
--- io-bmp.c 5 Mar 2004 21:20:28 -0000 1.39
+++ io-bmp.c 2 Jul 2004 05:16:24 -0000
@@ -1119,5 +1119,6 @@ MODULE_ENTRY (bmp, fill_info) (GdkPixbuf
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
+ info->license = "LGPL";
}
Index: io-gif.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-gif.c,v
retrieving revision 1.73
diff -u -p -r1.73 io-gif.c
--- io-gif.c 12 Jun 2004 02:08:45 -0000 1.73
+++ io-gif.c 2 Jul 2004 05:16:25 -0000
@@ -1651,4 +1651,5 @@ MODULE_ENTRY (gif, fill_info) (GdkPixbuf
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
+ info->license = "LGPL";
}
Index: io-ico.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-ico.c,v
retrieving revision 1.34
diff -u -p -r1.34 io-ico.c
--- io-ico.c 7 Jan 2004 00:26:58 -0000 1.34
+++ io-ico.c 2 Jul 2004 05:16:25 -0000
@@ -1203,6 +1203,7 @@ MODULE_ENTRY (ico, fill_info) (GdkPixbuf
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_WRITABLE;
+ info->license = "LGPL";
}
Index: io-jpeg.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-jpeg.c,v
retrieving revision 1.53
diff -u -p -r1.53 io-jpeg.c
--- io-jpeg.c 8 Feb 2004 09:13:18 -0000 1.53
+++ io-jpeg.c 2 Jul 2004 05:16:25 -0000
@@ -1070,4 +1070,5 @@ MODULE_ENTRY (jpeg, fill_info) (GdkPixbu
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_WRITABLE;
+ info->license = "LGPL";
}
Index: io-pcx.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-pcx.c,v
retrieving revision 1.4
diff -u -p -r1.4 io-pcx.c
--- io-pcx.c 6 Mar 2004 03:37:23 -0000 1.4
+++ io-pcx.c 2 Jul 2004 05:16:25 -0000
@@ -759,4 +759,5 @@ MODULE_ENTRY (pcx, fill_info) (GdkPixbuf
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
+ info->license = "LGPL";
}
Index: io-png.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-png.c,v
retrieving revision 1.58
diff -u -p -r1.58 io-png.c
--- io-png.c 7 Jan 2004 01:57:42 -0000 1.58
+++ io-png.c 2 Jul 2004 05:16:25 -0000
@@ -995,4 +995,5 @@ MODULE_ENTRY (png, fill_info) (GdkPixbuf
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_WRITABLE;
+ info->license = "LGPL";
}
Index: io-pnm.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-pnm.c,v
retrieving revision 1.33
diff -u -p -r1.33 io-pnm.c
--- io-pnm.c 12 Jun 2004 02:08:45 -0000 1.33
+++ io-pnm.c 2 Jul 2004 05:16:26 -0000
@@ -1083,4 +1083,5 @@ MODULE_ENTRY (pnm, fill_info) (GdkPixbuf
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
+ info->license = "LGPL";
}
Index: io-ras.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-ras.c,v
retrieving revision 1.26
diff -u -p -r1.26 io-ras.c
--- io-ras.c 7 Jan 2004 00:26:58 -0000 1.26
+++ io-ras.c 2 Jul 2004 05:16:26 -0000
@@ -544,5 +544,6 @@ MODULE_ENTRY (ras, fill_info) (GdkPixbuf
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
+ info->license = "LGPL";
}
Index: io-tga.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-tga.c,v
retrieving revision 1.17
diff -u -p -r1.17 io-tga.c
--- io-tga.c 12 Jun 2004 02:08:45 -0000 1.17
+++ io-tga.c 2 Jul 2004 05:16:26 -0000
@@ -996,4 +996,5 @@ MODULE_ENTRY (tga, fill_info) (GdkPixbuf
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
+ info->license = "LGPL";
}
Index: io-tiff.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-tiff.c,v
retrieving revision 1.40
diff -u -p -r1.40 io-tiff.c
--- io-tiff.c 16 Jun 2004 17:52:49 -0000 1.40
+++ io-tiff.c 2 Jul 2004 05:16:26 -0000
@@ -626,4 +626,5 @@ MODULE_ENTRY (tiff, fill_info) (GdkPixbu
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
+ info->license = "LGPL";
}
Index: io-wbmp.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-wbmp.c,v
retrieving revision 1.18
diff -u -p -r1.18 io-wbmp.c
--- io-wbmp.c 27 May 2003 21:21:00 -0000 1.18
+++ io-wbmp.c 2 Jul 2004 05:16:26 -0000
@@ -369,4 +369,5 @@ MODULE_ENTRY (wbmp, fill_info) (GdkPixbu
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
+ info->license = "LGPL";
}
Index: io-xbm.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-xbm.c,v
retrieving revision 1.15
diff -u -p -r1.15 io-xbm.c
--- io-xbm.c 28 Feb 2004 13:17:53 -0000 1.15
+++ io-xbm.c 2 Jul 2004 05:16:26 -0000
@@ -477,4 +477,5 @@ MODULE_ENTRY (xbm, fill_info) (GdkPixbuf
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
+ info->license = "LGPL";
}
Index: io-xpm.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-xpm.c,v
retrieving revision 1.43
diff -u -p -r1.43 io-xpm.c
--- io-xpm.c 12 Jun 2004 02:08:45 -0000 1.43
+++ io-xpm.c 2 Jul 2004 05:16:27 -0000
@@ -1544,4 +1544,5 @@ MODULE_ENTRY (xpm, fill_info) (GdkPixbuf
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
+ info->license = "LGPL";
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]