forked from AuroraMiddleware/gtk
gdk-pixbuf-animation.c gdk-pixbuf-io.c io-xbm.c io-xpm.c
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.
This commit is contained in:
parent
9350f2c6cf
commit
6ba75ff95b
@ -1,3 +1,31 @@
|
||||
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 ===
|
||||
|
@ -15,6 +15,13 @@ gdk_pixbuf-win32res.lo : gdk_pixbuf.rc
|
||||
$(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
|
||||
@ -40,7 +47,7 @@ uninstall-ms-lib:
|
||||
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
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include "gdk-pixbuf-i18n.h"
|
||||
#include "gdk-pixbuf-animation.h"
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
typedef struct _GdkPixbufNonAnim GdkPixbufNonAnim;
|
||||
typedef struct _GdkPixbufNonAnimClass GdkPixbufNonAnimClass;
|
||||
|
||||
@ -114,7 +116,7 @@ gdk_pixbuf_animation_get_type (void)
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -143,7 +145,7 @@ gdk_pixbuf_animation_new_from_file (const char *filename,
|
||||
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,
|
||||
@ -251,6 +253,30 @@ gdk_pixbuf_animation_new_from_file (const char *filename,
|
||||
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.
|
||||
|
@ -48,6 +48,10 @@ typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -116,6 +116,13 @@ GdkPixbuf *gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf,
|
||||
|
||||
/* 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,
|
||||
|
@ -75,6 +75,7 @@ main (int argc,
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GError *error = NULL;
|
||||
gchar *infilename;
|
||||
|
||||
/* initialize glib/GdkPixbuf */
|
||||
g_type_init ();
|
||||
@ -90,7 +91,13 @@ main (int argc,
|
||||
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",
|
||||
@ -111,11 +118,20 @@ main (int argc,
|
||||
|
||||
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",
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include "gdk-pixbuf-private.h"
|
||||
#include "gdk-pixbuf-io.h"
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
@ -800,7 +802,7 @@ _gdk_pixbuf_generic_image_load (GdkPixbufModule *module,
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -828,7 +830,7 @@ gdk_pixbuf_new_from_file (const char *filename,
|
||||
|
||||
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,
|
||||
@ -901,6 +903,29 @@ gdk_pixbuf_new_from_file (const char *filename,
|
||||
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,
|
||||
@ -932,9 +957,68 @@ size_prepared_cb (GdkPixbufLoader *loader,
|
||||
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
|
||||
@ -976,7 +1060,7 @@ gdk_pixbuf_new_from_file_at_scale (const char *filename,
|
||||
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,
|
||||
@ -1036,37 +1120,35 @@ gdk_pixbuf_new_from_file_at_scale (const char *filename,
|
||||
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,
|
||||
@ -1120,7 +1202,7 @@ gdk_pixbuf_get_file_info (const gchar *filename,
|
||||
|
||||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
|
||||
f = fopen (filename, "rb");
|
||||
f = g_fopen (filename, "rb");
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
@ -1379,7 +1461,7 @@ save_to_callback_with_tmp_file (GdkPixbufModule *image_module,
|
||||
if (f)
|
||||
fclose (f);
|
||||
if (filename) {
|
||||
unlink (filename);
|
||||
g_unlink (filename);
|
||||
g_free (filename);
|
||||
}
|
||||
g_free (buf);
|
||||
@ -1549,7 +1631,7 @@ gdk_pixbuf_savev (GdkPixbuf *pixbuf,
|
||||
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);
|
||||
|
@ -13,7 +13,10 @@ gdk_pixbuf_animation_iter_get_delay_time
|
||||
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
|
||||
@ -59,9 +62,18 @@ gdk_pixbuf_loader_set_size
|
||||
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
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include <errno.h>
|
||||
#include "gdk-pixbuf-private.h"
|
||||
#include "gdk-pixbuf-io.h"
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
|
||||
typedef struct _XBMData XBMData;
|
||||
@ -416,7 +416,7 @@ gdk_pixbuf__xbm_image_stop_load (gpointer data,
|
||||
}
|
||||
|
||||
fclose (context->file);
|
||||
unlink (context->tempname);
|
||||
g_unlink (context->tempname);
|
||||
g_free (context->tempname);
|
||||
g_free ((XBMData *) context);
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include <errno.h>
|
||||
#include "gdk-pixbuf-private.h"
|
||||
#include "gdk-pixbuf-io.h"
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
|
||||
/* I have must have done something to deserve this.
|
||||
@ -1499,7 +1499,7 @@ gdk_pixbuf__xpm_image_stop_load (gpointer data,
|
||||
}
|
||||
|
||||
fclose (context->file);
|
||||
unlink (context->tempname);
|
||||
g_unlink (context->tempname);
|
||||
g_free (context->tempname);
|
||||
g_free ((XPMContext *) context);
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#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>
|
||||
@ -168,15 +168,20 @@ main (int argc, char **argv)
|
||||
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"
|
||||
@ -189,19 +194,26 @@ main (int argc, char **argv)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -210,25 +210,30 @@ int main (int argc, char **argv)
|
||||
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, '\\');
|
||||
@ -236,11 +241,13 @@ int main (int argc, char **argv)
|
||||
*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
|
||||
@ -258,6 +265,10 @@ int main (int argc, char **argv)
|
||||
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;
|
||||
|
||||
@ -283,9 +294,14 @@ int main (int argc, char **argv)
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user