+2004-12-05 Tor Lillqvist <tml@iki.fi>
+
+ * gdk-pixbuf-animation.c
+ * gdk-pixbuf-io.c
+ * io-xbm.c
+ * io-xpm.c
+ * make-inline-pixbuf.c
+ * queryloaders.c: Use gstdio wrappers. Document that file names
+ are in the GLib file name encoding.
+
+ * gdk-pixbuf-csource.c
+ * queryloaders.c: On Windows, convert command line arguments and
+ environment variable values from locale encoding to UTF-8.
+
+ * queryloaders.c: On Windows, use wide character API when
+ available.
+
+ * Makefile.am
+ * gdk-pixbuf-core.h
+ * gdk-pixbuf-io.c
+ * gdk-pixbuf-animation.h
+ * gdk-pixbuf-animation.c: Like in GLib, for DLL ABI stability on
+ Windows, add binary compatibility versions of functions that take
+ file names as arguments. They use the system codepage, not GLib
+ file name encoding (which is UTF-8 on Windows). Use #defines to
+ make newly compiled code use the "real" functions that use the
+ GLib file name encoding scheme.
+
2004-12-02 Matthias Clasen <mclasen@redhat.com>
* === Released 2.5.6 ===
$(top_srcdir)/build/win32/lt-compile-resource gdk_pixbuf.rc gdk_pixbuf-win32res.lo
install-libtool-import-lib:
+# Don't put the binary compatibility entries in the import lib!
+# (Unfortunately the GNU linker doesn't yet understand the PRIVATE
+# directive in .def files.)
+ for entry in `grep PRIVATE gdk_pixbuf.def | sed -e 's/PRIVATE//'`; do \
+ file=`nm -A .libs/libgdk_pixbuf-$(GTK_API_VERSION).dll.a | tr -d '\r' | grep -m 1 -E $$entry'$$' | cut -d: -f2`; \
+ ar d .libs/libgdk_pixbuf-$(GTK_API_VERSION).dll.a $$file; \
+ done
$(INSTALL) .libs/libgdk_pixbuf-$(GTK_API_VERSION).dll.a $(DESTDIR)$(libdir)
uninstall-libtool-import-lib:
-rm $(DESTDIR)$(libdir)/libgdk_pixbuf-$(GTK_API_VERSION).dll.a
endif
gdk_pixbuf.def: gdk-pixbuf.symbols
- (echo -e EXPORTS; $(CPP) -P -DINCLUDE_VARIABLES - <$(srcdir)/gdk-pixbuf.symbols | sed -e '/^$$/d' -e 's/^/ /' -e 's/G_GNUC_[^ ]*//g') > gdk_pixbuf.def
+ (echo -e EXPORTS; $(CPP) -P -DINCLUDE_VARIABLES -DG_OS_WIN32 - <$(srcdir)/gdk-pixbuf.symbols | sed -e '/^$$/d' -e 's/^/ /' -e 's/G_GNUC_[^ ]*//g') > gdk_pixbuf.def
gdk-pixbuf-alias.h: gdk-pixbuf.symbols
$(PERL) $(srcdir)/makegdkpixbufalias.pl < $(srcdir)/gdk-pixbuf.symbols > gdk-pixbuf-alias.h
#include "gdk-pixbuf-i18n.h"
#include "gdk-pixbuf-animation.h"
+#include <glib/gstdio.h>
+
typedef struct _GdkPixbufNonAnim GdkPixbufNonAnim;
typedef struct _GdkPixbufNonAnimClass GdkPixbufNonAnimClass;
/**
* gdk_pixbuf_animation_new_from_file:
- * @filename: Name of file to load.
+ * @filename: Name of file to load, in the GLib file name encoding
* @error: return location for error
*
* Creates a new animation by loading it from a file. The file format is
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
display_name = g_filename_display_name (filename);
- f = fopen (filename, "rb");
+ f = g_fopen (filename, "rb");
if (!f) {
g_set_error (error,
G_FILE_ERROR,
return animation;
}
+#ifdef G_OS_WIN32
+
+#undef gdk_pixbuf_animation_new_from_file
+
+GdkPixbufAnimation *
+gdk_pixbuf_animation_new_from_file (const char *filename,
+ GError **error)
+{
+ gchar *utf8_filename =
+ g_locale_to_utf8 (filename, -1, NULL, NULL, error);
+ GdkPixbufAnimation *retval;
+
+ if (utf8_filename == NULL)
+ return NULL;
+
+ retval = gdk_pixbuf_animation_new_from_file_utf8 (utf8_filename, error);
+
+ g_free (utf8_filename);
+
+ return retval;
+}
+
+#endif
+
/**
* gdk_pixbuf_animation_ref:
* @animation: An animation.
GType gdk_pixbuf_animation_get_type (void) G_GNUC_CONST;
+#ifdef G_OS_WIN32
+#define gdk_pixbuf_animation_new_from_file gdk_pixbuf_animation_new_from_file_utf8
+#endif
+
GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file (const char *filename,
GError **error);
/* Simple loading */
+#ifdef G_OS_WIN32
+/* DLL ABI stability hack. */
+#define gdk_pixbuf_new_from_file gdk_pixbuf_new_from_file_utf8
+#define gdk_pixbuf_new_from_file_at_size gdk_pixbuf_new_from_file_at_size_utf8
+#define gdk_pixbuf_new_from_file_at_scale gdk_pixbuf_new_from_file_at_scale_utf8
+#endif
+
GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename,
GError **error);
GdkPixbuf *gdk_pixbuf_new_from_file_at_size (const char *filename,
{
GdkPixbuf *pixbuf;
GError *error = NULL;
+ gchar *infilename;
/* initialize glib/GdkPixbuf */
g_type_init ();
return 1;
}
- pixbuf = gdk_pixbuf_new_from_file (argv[1], &error);
+#ifdef G_OS_WIN32
+ infilename = g_locale_to_utf8 (argv[1], -1, NULL, NULL, NULL);
+#else
+ infilename = argv[1];
+#endif
+
+ pixbuf = gdk_pixbuf_new_from_file (infilename, &error);
if (!pixbuf)
{
g_fprintf (stderr, "failed to load \"%s\": %s\n",
while (j--)
{
+#ifdef G_OS_WIN32
+ infilename = g_locale_to_utf8 (*p, -1, NULL, NULL, NULL);
+#else
+ infilename = *p;
+#endif
+
if (!toggle)
- image_name = *p++;
+ {
+ image_name = infilename;
+ p++;
+ }
else
{
- pixbuf = gdk_pixbuf_new_from_file (*p, &error);
+ pixbuf = gdk_pixbuf_new_from_file (infilename, &error);
if (!pixbuf)
{
g_fprintf (stderr, "failed to load \"%s\": %s\n",
#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-io.h"
+#include <glib/gstdio.h>
+
#ifdef G_OS_WIN32
#define STRICT
#include <windows.h>
/**
* gdk_pixbuf_new_from_file:
- * @filename: Name of file to load.
+ * @filename: Name of file to load, in the GLib file name encoding
* @error: Return location for an error
*
* Creates a new pixbuf by loading an image from a file. The file format is
display_name = g_filename_display_name (filename);
- f = fopen (filename, "rb");
+ f = g_fopen (filename, "rb");
if (!f) {
g_set_error (error,
G_FILE_ERROR,
return pixbuf;
}
+#ifdef G_OS_WIN32
+
+#undef gdk_pixbuf_new_from_file
+
+GdkPixbuf *
+gdk_pixbuf_new_from_file (const char *filename,
+ GError **error)
+{
+ gchar *utf8_filename =
+ g_locale_to_utf8 (filename, -1, NULL, NULL, error);
+ GdkPixbuf *retval;
+
+ if (utf8_filename == NULL)
+ return NULL;
+
+ retval = gdk_pixbuf_new_from_file_utf8 (utf8_filename, error);
+
+ g_free (utf8_filename);
+
+ return retval;
+}
+#endif
+
static void
size_prepared_cb (GdkPixbufLoader *loader,
int width,
gdk_pixbuf_loader_set_size (loader, width, height);
}
+/**
+ * gdk_pixbuf_new_from_file_at_size:
+ * @filename: Name of file to load, in the GLib file name encoding
+ * @width: The width the image should have
+ * @height: The height the image should have
+ * @error: Return location for an error
+ *
+ * Creates a new pixbuf by loading an image from a file. The file format is
+ * detected automatically. If %NULL is returned, then @error will be set.
+ * Possible errors are in the #GDK_PIXBUF_ERROR and #G_FILE_ERROR domains.
+ * The image will be scaled to fit in the requested size, preserving
+ * the image's aspect ratio.
+ *
+ * Return value: A newly-created pixbuf with a reference count of 1, or
+ * %NULL if any of several error conditions occurred: the file could not
+ * be opened, there was no loader for the file's format, there was not
+ * enough memory to allocate the image buffer, or the image file contained
+ * invalid data.
+ *
+ * Since: 2.4
+ **/
+GdkPixbuf *
+gdk_pixbuf_new_from_file_at_size (const char *filename,
+ int width,
+ int height,
+ GError **error)
+{
+ return gdk_pixbuf_new_from_file_at_scale (filename,
+ width, height,
+ TRUE, error);
+}
+
+#ifdef G_OS_WIN32
+
+#undef gdk_pixbuf_new_from_file_at_size
+
+GdkPixbuf *
+gdk_pixbuf_new_from_file_at_size (const char *filename,
+ int width,
+ int height,
+ GError **error)
+{
+ gchar *utf8_filename =
+ g_locale_to_utf8 (filename, -1, NULL, NULL, error);
+ GdkPixbuf *retval;
+
+ if (utf8_filename == NULL)
+ return NULL;
+
+ retval = gdk_pixbuf_new_from_file_at_size_utf8 (utf8_filename,
+ width, height,
+ error);
+
+ g_free (utf8_filename);
+
+ return retval;
+}
+#endif
+
/**
* gdk_pixbuf_new_from_file_at_scale:
- * @filename: Name of file to load.
+ * @filename: Name of file to load, in the GLib file name encoding
* @width: The width the image should have
* @height: The height the image should have
* @preserve_aspect_ratio: %TRUE to preserve the image's aspect ratio
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (width > 0 && height > 0, NULL);
- f = fopen (filename, "rb");
+ f = g_fopen (filename, "rb");
if (!f) {
gchar *display_name = g_filename_display_name (filename);
g_set_error (error,
return pixbuf;
}
-/**
- * gdk_pixbuf_new_from_file_at_size:
- * @filename: Name of file to load.
- * @width: The width the image should have
- * @height: The height the image should have
- * @error: Return location for an error
- *
- * Creates a new pixbuf by loading an image from a file. The file format is
- * detected automatically. If %NULL is returned, then @error will be set.
- * Possible errors are in the #GDK_PIXBUF_ERROR and #G_FILE_ERROR domains.
- * The image will be scaled to fit in the requested size, preserving
- * the image's aspect ratio.
- *
- * Return value: A newly-created pixbuf with a reference count of 1, or
- * %NULL if any of several error conditions occurred: the file could not
- * be opened, there was no loader for the file's format, there was not
- * enough memory to allocate the image buffer, or the image file contained
- * invalid data.
- *
- * Since: 2.4
- **/
+#ifdef G_OS_WIN32
+
+#undef gdk_pixbuf_new_from_file_at_scale
+
GdkPixbuf *
-gdk_pixbuf_new_from_file_at_size (const char *filename,
- int width,
- int height,
- GError **error)
+gdk_pixbuf_new_from_file_at_scale (const char *filename,
+ int width,
+ int height,
+ gboolean preserve_aspect_ratio,
+ GError **error)
{
- return gdk_pixbuf_new_from_file_at_scale (filename,
- width, height,
- TRUE, error);
+ gchar *utf8_filename =
+ g_locale_to_utf8 (filename, -1, NULL, NULL, error);
+ GdkPixbuf *retval;
+
+ if (utf8_filename == NULL)
+ return NULL;
+
+ retval = gdk_pixbuf_new_from_file_at_scale_utf8 (utf8_filename,
+ width, height,
+ preserve_aspect_ratio,
+ error);
+
+ g_free (utf8_filename);
+
+ return retval;
}
+#endif
+
static void
info_cb (GdkPixbufLoader *loader,
g_return_val_if_fail (filename != NULL, NULL);
- f = fopen (filename, "rb");
+ f = g_fopen (filename, "rb");
if (!f)
return NULL;
if (f)
fclose (f);
if (filename) {
- unlink (filename);
+ g_unlink (filename);
g_free (filename);
}
g_free (buf);
g_return_val_if_fail (type != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- f = fopen (filename, "wb");
+ f = g_fopen (filename, "wb");
if (f == NULL) {
gchar *display_name = g_filename_display_name (filename);
gdk_pixbuf_animation_iter_get_pixbuf
gdk_pixbuf_animation_iter_get_type G_GNUC_CONST
gdk_pixbuf_animation_iter_on_currently_loading_frame
-gdk_pixbuf_animation_new_from_file
+gdk_pixbuf_animation_new_from_file PRIVATE
+#ifdef G_OS_WIN32
+gdk_pixbuf_animation_new_from_file_utf8
+#endif
gdk_pixbuf_animation_ref
gdk_pixbuf_animation_unref
gdk_pixbuf_composite
gdk_pixbuf_loader_write
gdk_pixbuf_new
gdk_pixbuf_new_from_data
-gdk_pixbuf_new_from_file
-gdk_pixbuf_new_from_file_at_size
-gdk_pixbuf_new_from_file_at_scale
+gdk_pixbuf_new_from_file PRIVATE
+#ifdef G_OS_WIN32
+gdk_pixbuf_new_from_file_utf8
+#endif
+gdk_pixbuf_new_from_file_at_size PRIVATE
+#ifdef G_OS_WIN32
+gdk_pixbuf_new_from_file_at_size_utf8
+#endif
+gdk_pixbuf_new_from_file_at_scale PRIVATE
+#ifdef G_OS_WIN32
+gdk_pixbuf_new_from_file_at_scale_utf8
+#endif
gdk_pixbuf_new_from_inline
gdk_pixbuf_new_from_xpm_data
gdk_pixbuf_new_subpixbuf
#include <errno.h>
#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-io.h"
-
+#include <glib/gstdio.h>
\f
typedef struct _XBMData XBMData;
}
fclose (context->file);
- unlink (context->tempname);
+ g_unlink (context->tempname);
g_free (context->tempname);
g_free ((XBMData *) context);
#include <errno.h>
#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-io.h"
-
+#include <glib/gstdio.h>
\f
/* I have must have done something to deserve this.
}
fclose (context->file);
- unlink (context->tempname);
+ g_unlink (context->tempname);
g_free (context->tempname);
g_free ((XPMContext *) context);
#include <config.h>
#include "gdk-pixbuf-private.h"
-#include <glib/gprintf.h>
+#include <glib/gstdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
usage ();
}
- outfile = fopen (argv[i], "w");
+#ifdef G_OS_WIN32
+ outfilename = g_locale_to_utf8 (argv[i], -1, NULL, NULL, NULL)
+#else
+ outfilename = argv[i];
+#endif
+
+ outfile = g_fopen (outfilename, "w");
if (outfile == NULL)
{
g_fprintf (stderr, "Failed to open output file `%s': %s\n",
- argv[i], strerror (errno));
+ argv[i], strerror (errno));
exit (1);
}
- outfilename = argv[i];
++i;
fputs ("/* This file was automatically generated by the make-inline-pixbuf program.\n"
while (i < argc)
{
- GdkPixbuf *pixbuf;
+ GdkPixbuf *pixbuf = NULL;
GError *error;
-
+ gchar *infilename;
+
g_assert ((i + 1) < argc);
error = NULL;
- pixbuf = gdk_pixbuf_new_from_file (argv[i+1], &error);
+#ifdef G_OS_WIN32
+ infilename = g_locale_to_utf8 (argv[i+1], -1, NULL, NULL, &error);
+#else
+ infilename = argv[i+1];
+#endif
+ if (infilename)
+ pixbuf = gdk_pixbuf_new_from_file (infilename, &error);
if (pixbuf == NULL)
{
g_fprintf (stderr, "%s\n", error->message);
fclose (outfile);
- remove (outfilename);
+ g_remove (outfilename);
exit (1);
}
gint i;
#ifdef G_OS_WIN32
- gchar libdir[sizeof (PIXBUF_LIBDIR) + 100];
- gchar runtime_prefix[1000];
+ gchar *libdir;
+ gchar *runtime_prefix;
gchar *slash;
- strcpy (libdir, PIXBUF_LIBDIR);
-
if (g_ascii_strncasecmp (PIXBUF_LIBDIR, GTK_PREFIX, strlen (GTK_PREFIX)) == 0 &&
- (PIXBUF_LIBDIR[strlen (GTK_PREFIX)] == '/' ||
- PIXBUF_LIBDIR[strlen (GTK_PREFIX)] == '\\')) {
+ G_IS_DIR_SEPARATOR (PIXBUF_LIBDIR[strlen (GTK_PREFIX)])) {
/* GTK_PREFIX is a prefix of PIXBUF_LIBDIR, as it
* normally is. Replace that prefix in PIXBUF_LIBDIR
* with the installation directory on this machine.
* We assume this invokation of
* gdk-pixbuf-query-loaders is run from either a "bin"
* subdirectory of the installation directory, or in
- * the insallation directory itself.
+ * the installation directory itself.
*/
- GetModuleFileName (NULL, runtime_prefix, sizeof (runtime_prefix));
-
+ if (G_WIN32_HAVE_WIDECHAR_API ()) {
+ wchar_t fn[1000];
+ GetModuleFileNameW (NULL, fn, G_N_ELEMENTS (fn));
+ runtime_prefix = g_utf16_to_utf8 (fn, -1, NULL, NULL, NULL);
+ }
+ else {
+ char fn[1000];
+ GetModuleFileNameA (NULL, fn, G_N_ELEMENTS (fn));
+ runtime_prefix = g_locale_to_utf8 (fn, -1, NULL, NULL, NULL);
+ }
slash = strrchr (runtime_prefix, '\\');
*slash = '\0';
slash = strrchr (runtime_prefix, '\\');
*slash = '\0';
}
- if (strlen (runtime_prefix) + 1 + strlen (PIXBUF_LIBDIR) - strlen (GTK_PREFIX) < sizeof (libdir)) {
- strcpy (libdir, runtime_prefix);
- strcat (libdir, "/");
- strcat (libdir, PIXBUF_LIBDIR + strlen (GTK_PREFIX) + 1);
- }
+ libdir = g_strconcat (runtime_prefix,
+ "/",
+ PIXBUF_LIBDIR + strlen (GTK_PREFIX) + 1,
+ NULL);
+ }
+ else {
+ libdir = PIXBUF_LIBDIR;
}
#undef PIXBUF_LIBDIR
GDir *dir;
path = g_getenv ("GDK_PIXBUF_MODULEDIR");
+#ifdef G_OS_WIN32
+ if (path != NULL && *path != '\0')
+ path = g_locale_to_utf8 (path, -1, NULL, NULL, NULL);
+#endif
if (path == NULL || *path == '\0')
path = PIXBUF_LIBDIR;
else {
char *cwd = g_get_current_dir ();
- for (i = 1; i < argc; i++)
- query_module (cwd, argv[i]);
-
+ for (i = 1; i < argc; i++) {
+ char *infilename = argv[i];
+#ifdef G_OS_WIN32
+ infilename = g_locale_to_utf8 (infilename,
+ -1, NULL, NULL, NULL);
+#endif
+ query_module (cwd, infilename);
+ }
g_free (cwd);
}