#include <config.h>
#include <errno.h>
+#include "gdk-pixbuf-alias.h"
#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-io.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
FILE *f;
guchar buffer [128];
GdkPixbufModule *image_module;
+ gchar *display_name;
+ gboolean locked;
g_return_val_if_fail (filename != NULL, NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- f = fopen (filename, "rb");
+ display_name = g_filename_display_name (filename);
+ f = g_fopen (filename, "rb");
if (!f) {
g_set_error (error,
G_FILE_ERROR,
g_file_error_from_errno (errno),
_("Failed to open file '%s': %s"),
- filename, g_strerror (errno));
+ display_name,
+ g_strerror (errno));
+ g_free (display_name);
return NULL;
}
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Image file '%s' contains no data"),
- filename);
-
+ display_name);
+ g_free (display_name);
fclose (f);
return NULL;
}
image_module = _gdk_pixbuf_get_module (buffer, size, filename, error);
if (!image_module) {
+ g_free (display_name);
fclose (f);
return NULL;
}
if (image_module->module == NULL)
if (!_gdk_pixbuf_load_module (image_module, error)) {
+ g_free (display_name);
fclose (f);
return NULL;
}
+ locked = _gdk_pixbuf_lock (image_module);
+
if (image_module->load_animation == NULL) {
GdkPixbuf *pixbuf;
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_FAILED,
_("Failed to load image '%s': reason not known, probably a corrupt image file"),
- filename);
+ display_name);
}
- if (pixbuf == NULL)
- return NULL;
+ if (pixbuf == NULL) {
+ g_free (display_name);
+ animation = NULL;
+ goto out_unlock;
+ }
animation = gdk_pixbuf_non_anim_new (pixbuf);
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_FAILED,
_("Failed to load animation '%s': reason not known, probably a corrupt animation file"),
- filename);
+ display_name);
}
fclose (f);
}
+ g_free (display_name);
+
+ out_unlock:
+ if (locked)
+ _gdk_pixbuf_unlock (image_module);
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.
*
- * Adds a reference to an animation. Deprecated; use
- * g_object_ref(). The reference must be released afterwards using
- * g_object_unref().
+ * Adds a reference to an animation.
*
* Return value: The same as the @animation argument.
+ *
+ * Deprecated: Use g_object_ref().
**/
GdkPixbufAnimation *
gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation)
* gdk_pixbuf_animation_unref:
* @animation: An animation.
*
- * Removes a reference from an animation. Deprecated; use g_object_unref().
+ * Removes a reference from an animation.
+ *
+ * Deprecated: Use g_object_unref().
**/
void
gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation)
*
* Gets the current pixbuf which should be displayed; the pixbuf will
* be the same size as the animation itself
- * (gdk_pixbuf_animation_get_width(),
- * gdk_pixbuf_animation_get_height()). This pixbuf should be displayed
- * for gdk_pixbuf_animation_get_delay_time() milliseconds. The caller
+ * (gdk_pixbuf_animation_get_width(), gdk_pixbuf_animation_get_height()).
+ * This pixbuf should be displayed for
+ * gdk_pixbuf_animation_iter_get_delay_time() milliseconds. The caller
* of this function does not own a reference to the returned pixbuf;
* the returned pixbuf will become invalid when the iterator advances
* to the next frame, which may happen anytime you call
static gpointer non_parent_class;
-GType
+static GType
gdk_pixbuf_non_anim_get_type (void)
{
static GType object_type = 0;