diff options
-rw-r--r-- | gdk-pixbuf/Makefile.am | 9 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-animation.c | 30 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-animation.h | 4 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-core.h | 7 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-csource.c | 22 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-io.c | 152 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf.symbols | 20 | ||||
-rw-r--r-- | gdk-pixbuf/io-xbm.c | 4 | ||||
-rw-r--r-- | gdk-pixbuf/io-xpm.c | 4 | ||||
-rw-r--r-- | gdk-pixbuf/make-inline-pixbuf.c | 28 | ||||
-rw-r--r-- | gdk-pixbuf/queryloaders.c | 50 |
11 files changed, 256 insertions, 74 deletions
diff --git a/gdk-pixbuf/Makefile.am b/gdk-pixbuf/Makefile.am index 090c5419b..46dd1243d 100644 --- a/gdk-pixbuf/Makefile.am +++ b/gdk-pixbuf/Makefile.am @@ -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 diff --git a/gdk-pixbuf/gdk-pixbuf-animation.c b/gdk-pixbuf/gdk-pixbuf-animation.c index b40446299..22bf24560 100644 --- a/gdk-pixbuf/gdk-pixbuf-animation.c +++ b/gdk-pixbuf/gdk-pixbuf-animation.c @@ -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. diff --git a/gdk-pixbuf/gdk-pixbuf-animation.h b/gdk-pixbuf/gdk-pixbuf-animation.h index bebe81990..43347de65 100644 --- a/gdk-pixbuf/gdk-pixbuf-animation.h +++ b/gdk-pixbuf/gdk-pixbuf-animation.h @@ -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); diff --git a/gdk-pixbuf/gdk-pixbuf-core.h b/gdk-pixbuf/gdk-pixbuf-core.h index c9ad9c0e5..d7d9771ed 100644 --- a/gdk-pixbuf/gdk-pixbuf-core.h +++ b/gdk-pixbuf/gdk-pixbuf-core.h @@ -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, diff --git a/gdk-pixbuf/gdk-pixbuf-csource.c b/gdk-pixbuf/gdk-pixbuf-csource.c index 9b0a66230..4e21553d5 100644 --- a/gdk-pixbuf/gdk-pixbuf-csource.c +++ b/gdk-pixbuf/gdk-pixbuf-csource.c @@ -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", diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c index 02d4eed61..3afb09f19 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.c +++ b/gdk-pixbuf/gdk-pixbuf-io.c @@ -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, @@ -933,8 +958,67 @@ size_prepared_cb (GdkPixbufLoader *loader, } /** + * 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); diff --git a/gdk-pixbuf/gdk-pixbuf.symbols b/gdk-pixbuf/gdk-pixbuf.symbols index 72c9e920b..83ceef58f 100644 --- a/gdk-pixbuf/gdk-pixbuf.symbols +++ b/gdk-pixbuf/gdk-pixbuf.symbols @@ -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 diff --git a/gdk-pixbuf/io-xbm.c b/gdk-pixbuf/io-xbm.c index 6c9244cf6..9d808703e 100644 --- a/gdk-pixbuf/io-xbm.c +++ b/gdk-pixbuf/io-xbm.c @@ -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); diff --git a/gdk-pixbuf/io-xpm.c b/gdk-pixbuf/io-xpm.c index f8267d5b7..2125b9c45 100644 --- a/gdk-pixbuf/io-xpm.c +++ b/gdk-pixbuf/io-xpm.c @@ -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); diff --git a/gdk-pixbuf/make-inline-pixbuf.c b/gdk-pixbuf/make-inline-pixbuf.c index fea4ea388..079d37d37 100644 --- a/gdk-pixbuf/make-inline-pixbuf.c +++ b/gdk-pixbuf/make-inline-pixbuf.c @@ -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); } diff --git a/gdk-pixbuf/queryloaders.c b/gdk-pixbuf/queryloaders.c index 1fc5d58b3..d35b4d3a0 100644 --- a/gdk-pixbuf/queryloaders.c +++ b/gdk-pixbuf/queryloaders.c @@ -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); } |