<commit_before>/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* GdkPixbuf library - Progressive loader object
 *
 * Copyright (C) 1999 The Free Software Foundation
 *
 * Authors: <NAME> <<EMAIL>>
 *          <NAME> <<EMAIL>>
 *          <NAME> <<EMAIL>>
 *          <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */

#include "config.h"
#include <string.h>

#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-animation.h"
#include "gdk-pixbuf-scaled-anim.h"
#include "gdk-pixbuf-loader.h"
#include "gdk-pixbuf-marshal.h"

/**
 * SECTION:gdk-pixbuf-loader
 * @Short_description: Application-driven progressive image loading.
 * @Title: GdkPixbufLoader
 * @See_also: gdk_pixbuf_new_from_file(), gdk_pixbuf_animation_new_from_file()
 * 
 * #GdkPixbufLoader provides a way for applications to drive the
 * process of loading an image, by letting them send the image data
 * directly to the loader instead of having the loader read the data
 * from a file.  Applications can use this functionality instead of
 * gdk_pixbuf_new_from_file() or gdk_pixbuf_animation_new_from_file() 
 * when they need to parse image data in
 * small chunks.  For example, it should be used when reading an
 * image from a (potentially) slow network connection, or when
 * loading an extremely large file.
 * 
 * 
 * To use #GdkPixbufLoader to load an image, just create a new one, and
 * call gdk_pixbuf_loader_write() to send the data to it.  When done,
 * gdk_pixbuf_loader_close() should be called to end the stream and
 * finalize everything. The loader will emit three important signals
 * throughout the process. The first, #GdkPixbufLoader::size-prepared,
 * will be emitted as soon as the image has enough information to
 * determine the size of the image to be used. If you want to scale
 * the image while loading it, you can call gdk_pixbuf_loader_set_size()
 * in response to this signal.
 * 
 * 
 * The second signal, #GdkPixbufLoader::area-prepared, will be emitted as
 * soon as the pixbuf of the desired has been allocated. You can obtain it
 * by calling gdk_pixbuf_loader_get_pixbuf(). If you want to use it, simply
 * ref it. You can also call gdk_pixbuf_loader_get_pixbuf() later and get
 * the same pixbuf.
 * 
 * The last signal, #GdkPixbufLoader::area-updated, gets emitted every time
 * a region is updated. This way you can update a partially completed image.
 * Note that you do not know anything about the completeness of an image
 * from the updated area. For example, in an interlaced image, you need to
 * make several passes before the image is done loading.
 * 
 * # Loading an animation 
 *
 * Loading an animation is almost as easy as loading an image. Once the first
 * #GdkPixbufLoader::area-prepared signal has been emitted, you can call
 * gdk_pixbuf_loader_get_animation() to get the #GdkPixbufAnimation struct
 * and gdk_pixbuf_animation_get_iter() to get a #GdkPixbufAnimationIter for
 * displaying it. 
 */


enum {
        SIZE_PREPARED,
        AREA_PREPARED,
        AREA_UPDATED,
        CLOSED,
        LAST_SIGNAL
};


static void gdk_pixbuf_loader_finalize (GObject *loader);

static guint    pixbuf_loader_signals[LAST_SIGNAL] = { 0 };

/* Internal data */

typedef struct
{
        GdkPixbufAnimation *animation;
        gboolean closed;
        guchar header_buf[SNIFF_BUFFER_SIZE];
        gint header_buf_offset;
        GdkPixbufModule *image_module;
        gpointer context;
        gint width;
        gint height;
        gboolean size_fixed;
        gboolean needs_scale;
	gchar *filename;
} GdkPixbufLoaderPrivate;

G_DEFINE_TYPE (GdkPixbufLoader, gdk_pixbuf_loader, G_TYPE_OBJECT)


static void
gdk_pixbuf_loader_class_init (GdkPixbufLoaderClass *class)
{
        GObjectClass *object_class;
  
        object_class = (GObjectClass *) class;
  
        object_class->finalize = gdk_pixbuf_loader_finalize;

        /**
         * GdkPixbufLoader::size-prepared:
         * @loader: the object which received the signal.
         * @width: the original width of the image
         * @height: the original height of the image
         *
         * This signal is emitted when the pixbuf loader has been fed the
         * initial amount of data that is required to figure out the size
         * of the image that it will create.  Applications can call  
         * gdk_pixbuf_loader_set_size() in response to this signal to set
         * the desired size to which the image should be scaled.
         */
        pixbuf_loader_signals[SIZE_PREPARED] =
                g_signal_new ("size-prepared",
                              G_TYPE_FROM_CLASS (object_class),
                              G_SIGNAL_RUN_LAST,
                              G_STRUCT_OFFSET (GdkPixbufLoaderClass, size_prepared),
                              NULL, NULL,
                              _gdk_pixbuf_marshal_VOID__INT_INT,
                              G_TYPE_NONE, 2, 
                              G_TYPE_INT,
                              G_TYPE_INT);
  
        /**
         * GdkPixbufLoader::area-prepared:
         * @loader: the object which received the signal.
         *
         * This signal is emitted when the pixbuf loader has allocated the 
         * pixbuf in the desired size.  After this signal is emitted, 
         * applications can call gdk_pixbuf_loader_get_pixbuf() to fetch 
         * the partially-loaded pixbuf.
         */
        pixbuf_loader_signals[AREA_PREPARED] =
                g_signal_new ("area-prepared",
                              G_TYPE_FROM_CLASS (object_class),
                              G_SIGNAL_RUN_LAST,
                              G_STRUCT_OFFSET (GdkPixbufLoaderClass, area_prepared),
                              NULL, NULL,
                              _gdk_pixbuf_marshal_VOID__VOID,
                              G_TYPE_NONE, 0);

        /**
         * GdkPixbufLoader::area-updated:
         * @loader: the object which received the signal.
         * @x: X offset of upper-left corner of the updated area.
         * @y: Y offset of upper-left corner of the updated area.
         * @width: Width of updated area.
         * @height: Height of updated area.
         *
         * This signal is emitted when a significant area of the image being
         * loaded has been updated.  Normally it means that a complete
         * scanline has been read in, but it could be a different area as
         * well.  Applications can use this signal to know when to repaint
         * areas of an image that is being loaded.
         */
        pixbuf_loader_signals[AREA_UPDATED] =
                g_signal_new ("area-updated",
                              G_TYPE_FROM_CLASS (object_class),
                              G_SIGNAL_RUN_LAST,
                              G_STRUCT_OFFSET (GdkPixbufLoaderClass, area_updated),
                              NULL, NULL,
                              _gdk_pixbuf_marshal_VOID__INT_INT_INT_INT,
                              G_TYPE_NONE, 4,
                              G_TYPE_INT,
                              G_TYPE_INT,
                              G_TYPE_INT,
                              G_TYPE_INT);
  
        /**
         * GdkPixbufLoader::closed:
         * @loader: the object which received the signal.
         *
         * This signal is emitted when gdk_pixbuf_loader_close() is called.
         * It can be used by different parts of an application to receive
         * notification when an image loader is closed by the code that
         * drives it.
         */
        pixbuf_loader_signals[CLOSED] =
                g_signal_new ("closed",
                              G_TYPE_FROM_CLASS (object_class),
                              G_SIGNAL_RUN_LAST,
                              G_STRUCT_OFFSET (GdkPixbufLoaderClass, closed),
                              NULL, NULL,
                              _gdk_pixbuf_marshal_VOID__VOID,
                              G_TYPE_NONE, 0);
}

static void
gdk_pixbuf_loader_init (GdkPixbufLoader *loader)
{
        GdkPixbufLoaderPrivate *priv;
  
        priv = g_new0 (GdkPixbufLoaderPrivate, 1);
        priv->width = -1;
        priv->height = -1;

        loader->priv = priv;
}

static void
gdk_pixbuf_loader_finalize (GObject *object)
{
        GdkPixbufLoader *loader;
        GdkPixbufLoaderPrivate *priv = NULL;
  
        loader = GDK_PIXBUF_LOADER (object);
        priv = loader->priv;

        if (!priv->closed) {
                g_warning ("GdkPixbufLoader finalized without calling gdk_pixbuf_loader_close() - this is not allowed. You must explicitly end the data stream to the loader before dropping the last reference.");
        }
        if (priv->animation)
                g_object_unref (priv->animation);
  
	g_free (priv->filename);

        g_free (priv);
  
        G_OBJECT_CLASS (gdk_pixbuf_loader_parent_class)->finalize (object);
}

/**
 * gdk_pixbuf_loader_set_size:
 * @loader: A pixbuf loader.
 * @width: The desired width of the image being loaded.
 * @height: The desired height of the image being loaded.
 *
 * Causes the image to be scaled while it is loaded. The desired
 * image size can be determined relative to the original size of
 * the image by calling gdk_pixbuf_loader_set_size() from a
 * signal handler for the ::size-prepared signal.
 *
 * Attempts to set the desired image size  are ignored after the 
 * emission of the ::size-prepared signal.
 *
 * Since: 2.2
 */
void 
gdk_pixbuf_loader_set_size (GdkPixbufLoader *loader,
			    gint             width,
			    gint             height)
{
        GdkPixbufLoaderPrivate *priv;

        g_return_if_fail (GDK_IS_PIXBUF_LOADER (loader));
        g_return_if_fail (width >= 0 && height >= 0);

        priv = GDK_PIXBUF_LOADER (loader)->priv;

        if (!priv->size_fixed) 
                {
                        priv->width = width;
                        priv->height = height;
                }
}

static void
gdk_pixbuf_loader_size_func (gint *width, gint *height, gpointer loader)
{
        GdkPixbufLoaderPrivate *priv = GDK_PIXBUF_LOADER (loader)->priv;

        /* allow calling gdk_pixbuf_loader_set_size() before the signal */
        if (priv->width == -1 && priv->height == -1) 
                {
                        priv->width = *width;
                        priv->height = *height;
                }

        g_signal_emit (loader, pixbuf_loader_signals[SIZE_PREPARED], 0, *width, *height);
        priv->size_fixed = TRUE;

        *width = priv->width;
        *height = priv->height;
}

static void
gdk_pixbuf_loader_prepare (GdkPixbuf          *pixbuf,
                           GdkPixbufAnimation *anim,
			   gpointer            loader)
{
        GdkPixbufLoaderPrivate *priv = GDK_PIXBUF_LOADER (loader)->priv;
        gint width, height;
        g_return_if_fail (pixbuf != NULL);

        width = anim ? gdk_pixbuf_animation_get_width (anim) :
                gdk_pixbuf_get_width (pixbuf);
        height = anim ? gdk_pixbuf_animation_get_height (anim) :
                gdk_pixbuf_get_height (pixbuf);

        if (!priv->size_fixed) 
                {
			gint w = width;
			gint h = height;
                        /* Defend against lazy loaders which don't call size_func */
                        gdk_pixbuf_loader_size_func (&w, &h, loader);
                }

        priv->needs_scale = FALSE;
        if (priv->width > 0 && priv->height > 0 &&
            (priv->width != width || priv->height != height))
                priv->needs_scale = TRUE;

        if (anim)
                g_object_ref (anim);
        else
                anim = gdk_pixbuf_non_anim_new (pixbuf);
  
	if (priv->needs_scale && width != 0 && height != 0) {
		priv->animation  = GDK_PIXBUF_ANIMATION (_gdk_pixbuf_scaled_anim_new (anim,
                                         (double) priv->width / width,
                                         (double) priv->height / height,
					  1.0));
			g_object_unref (anim);
	}
	else
        	priv->animation = anim;
  
        if (!priv->needs_scale)
                g_signal_emit (loader, pixbuf_loader_signals[AREA_PREPARED], 0);
}

static void<commit_msg>loader: Expose the dimensions of the original image<commit_after>/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* GdkPixbuf library - Progressive loader object
 *
 * Copyright (C) 1999 The Free Software Foundation
 *
 * Authors: <NAME> <<EMAIL>>
 *          <NAME> <<EMAIL>>
 *          <NAME> <<EMAIL>>
 *          <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */

#include "config.h"
#include <string.h>

#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-animation.h"
#include "gdk-pixbuf-scaled-anim.h"
#include "gdk-pixbuf-loader.h"
#include "gdk-pixbuf-marshal.h"

/**
 * SECTION:gdk-pixbuf-loader
 * @Short_description: Application-driven progressive image loading.
 * @Title: GdkPixbufLoader
 * @See_also: gdk_pixbuf_new_from_file(), gdk_pixbuf_animation_new_from_file()
 * 
 * #GdkPixbufLoader provides a way for applications to drive the
 * process of loading an image, by letting them send the image data
 * directly to the loader instead of having the loader read the data
 * from a file.  Applications can use this functionality instead of
 * gdk_pixbuf_new_from_file() or gdk_pixbuf_animation_new_from_file() 
 * when they need to parse image data in
 * small chunks.  For example, it should be used when reading an
 * image from a (potentially) slow network connection, or when
 * loading an extremely large file.
 * 
 * 
 * To use #GdkPixbufLoader to load an image, just create a new one, and
 * call gdk_pixbuf_loader_write() to send the data to it.  When done,
 * gdk_pixbuf_loader_close() should be called to end the stream and
 * finalize everything. The loader will emit three important signals
 * throughout the process. The first, #GdkPixbufLoader::size-prepared,
 * will be emitted as soon as the image has enough information to
 * determine the size of the image to be used. If you want to scale
 * the image while loading it, you can call gdk_pixbuf_loader_set_size()
 * in response to this signal.
 * 
 * 
 * The second signal, #GdkPixbufLoader::area-prepared, will be emitted as
 * soon as the pixbuf of the desired has been allocated. You can obtain it
 * by calling gdk_pixbuf_loader_get_pixbuf(). If you want to use it, simply
 * ref it. You can also call gdk_pixbuf_loader_get_pixbuf() later and get
 * the same pixbuf.
 * 
 * The last signal, #GdkPixbufLoader::area-updated, gets emitted every time
 * a region is updated. This way you can update a partially completed image.
 * Note that you do not know anything about the completeness of an image
 * from the updated area. For example, in an interlaced image, you need to
 * make several passes before the image is done loading.
 * 
 * # Loading an animation 
 *
 * Loading an animation is almost as easy as loading an image. Once the first
 * #GdkPixbufLoader::area-prepared signal has been emitted, you can call
 * gdk_pixbuf_loader_get_animation() to get the #GdkPixbufAnimation struct
 * and gdk_pixbuf_animation_get_iter() to get a #GdkPixbufAnimationIter for
 * displaying it. 
 */


enum {
        SIZE_PREPARED,
        AREA_PREPARED,
        AREA_UPDATED,
        CLOSED,
        LAST_SIGNAL
};


static void gdk_pixbuf_loader_finalize (GObject *loader);

static guint    pixbuf_loader_signals[LAST_SIGNAL] = { 0 };

/* Internal data */

typedef struct
{
        GdkPixbufAnimation *animation;
        gboolean closed;
        guchar header_buf[SNIFF_BUFFER_SIZE];
        gint header_buf_offset;
        GdkPixbufModule *image_module;
        gpointer context;
        gint original_width;
        gint original_height;
        gint width;
        gint height;
        gboolean size_fixed;
        gboolean needs_scale;
	gchar *filename;
} GdkPixbufLoaderPrivate;

G_DEFINE_TYPE (GdkPixbufLoader, gdk_pixbuf_loader, G_TYPE_OBJECT)


static void
gdk_pixbuf_loader_class_init (GdkPixbufLoaderClass *class)
{
        GObjectClass *object_class;
  
        object_class = (GObjectClass *) class;
  
        object_class->finalize = gdk_pixbuf_loader_finalize;

        /**
         * GdkPixbufLoader::size-prepared:
         * @loader: the object which received the signal.
         * @width: the original width of the image
         * @height: the original height of the image
         *
         * This signal is emitted when the pixbuf loader has been fed the
         * initial amount of data that is required to figure out the size
         * of the image that it will create.  Applications can call  
         * gdk_pixbuf_loader_set_size() in response to this signal to set
         * the desired size to which the image should be scaled.
         */
        pixbuf_loader_signals[SIZE_PREPARED] =
                g_signal_new ("size-prepared",
                              G_TYPE_FROM_CLASS (object_class),
                              G_SIGNAL_RUN_LAST,
                              G_STRUCT_OFFSET (GdkPixbufLoaderClass, size_prepared),
                              NULL, NULL,
                              _gdk_pixbuf_marshal_VOID__INT_INT,
                              G_TYPE_NONE, 2, 
                              G_TYPE_INT,
                              G_TYPE_INT);
  
        /**
         * GdkPixbufLoader::area-prepared:
         * @loader: the object which received the signal.
         *
         * This signal is emitted when the pixbuf loader has allocated the 
         * pixbuf in the desired size.  After this signal is emitted, 
         * applications can call gdk_pixbuf_loader_get_pixbuf() to fetch 
         * the partially-loaded pixbuf.
         */
        pixbuf_loader_signals[AREA_PREPARED] =
                g_signal_new ("area-prepared",
                              G_TYPE_FROM_CLASS (object_class),
                              G_SIGNAL_RUN_LAST,
                              G_STRUCT_OFFSET (GdkPixbufLoaderClass, area_prepared),
                              NULL, NULL,
                              _gdk_pixbuf_marshal_VOID__VOID,
                              G_TYPE_NONE, 0);

        /**
         * GdkPixbufLoader::area-updated:
         * @loader: the object which received the signal.
         * @x: X offset of upper-left corner of the updated area.
         * @y: Y offset of upper-left corner of the updated area.
         * @width: Width of updated area.
         * @height: Height of updated area.
         *
         * This signal is emitted when a significant area of the image being
         * loaded has been updated.  Normally it means that a complete
         * scanline has been read in, but it could be a different area as
         * well.  Applications can use this signal to know when to repaint
         * areas of an image that is being loaded.
         */
        pixbuf_loader_signals[AREA_UPDATED] =
                g_signal_new ("area-updated",
                              G_TYPE_FROM_CLASS (object_class),
                              G_SIGNAL_RUN_LAST,
                              G_STRUCT_OFFSET (GdkPixbufLoaderClass, area_updated),
                              NULL, NULL,
                              _gdk_pixbuf_marshal_VOID__INT_INT_INT_INT,
                              G_TYPE_NONE, 4,
                              G_TYPE_INT,
                              G_TYPE_INT,
                              G_TYPE_INT,
                              G_TYPE_INT);
  
        /**
         * GdkPixbufLoader::closed:
         * @loader: the object which received the signal.
         *
         * This signal is emitted when gdk_pixbuf_loader_close() is called.
         * It can be used by different parts of an application to receive
         * notification when an image loader is closed by the code that
         * drives it.
         */
        pixbuf_loader_signals[CLOSED] =
                g_signal_new ("closed",
                              G_TYPE_FROM_CLASS (object_class),
                              G_SIGNAL_RUN_LAST,
                              G_STRUCT_OFFSET (GdkPixbufLoaderClass, closed),
                              NULL, NULL,
                              _gdk_pixbuf_marshal_VOID__VOID,
                              G_TYPE_NONE, 0);
}

static void
gdk_pixbuf_loader_init (GdkPixbufLoader *loader)
{
        GdkPixbufLoaderPrivate *priv;
  
        priv = g_new0 (GdkPixbufLoaderPrivate, 1);
        priv->original_width = -1;
        priv->original_height = -1;
        priv->width = -1;
        priv->height = -1;

        loader->priv = priv;
}

static void
gdk_pixbuf_loader_finalize (GObject *object)
{
        GdkPixbufLoader *loader;
        GdkPixbufLoaderPrivate *priv = NULL;
  
        loader = GDK_PIXBUF_LOADER (object);
        priv = loader->priv;

        if (!priv->closed) {
                g_warning ("GdkPixbufLoader finalized without calling gdk_pixbuf_loader_close() - this is not allowed. You must explicitly end the data stream to the loader before dropping the last reference.");
        }
        if (priv->animation)
                g_object_unref (priv->animation);
  
	g_free (priv->filename);

        g_free (priv);
  
        G_OBJECT_CLASS (gdk_pixbuf_loader_parent_class)->finalize (object);
}

/**
 * gdk_pixbuf_loader_set_size:
 * @loader: A pixbuf loader.
 * @width: The desired width of the image being loaded.
 * @height: The desired height of the image being loaded.
 *
 * Causes the image to be scaled while it is loaded. The desired
 * image size can be determined relative to the original size of
 * the image by calling gdk_pixbuf_loader_set_size() from a
 * signal handler for the ::size-prepared signal.
 *
 * Attempts to set the desired image size  are ignored after the 
 * emission of the ::size-prepared signal.
 *
 * Since: 2.2
 */
void 
gdk_pixbuf_loader_set_size (GdkPixbufLoader *loader,
			    gint             width,
			    gint             height)
{
        GdkPixbufLoaderPrivate *priv;

        g_return_if_fail (GDK_IS_PIXBUF_LOADER (loader));
        g_return_if_fail (width >= 0 && height >= 0);

        priv = GDK_PIXBUF_LOADER (loader)->priv;

        if (!priv->size_fixed) 
                {
                        priv->width = width;
                        priv->height = height;
                }
}

static void
gdk_pixbuf_loader_size_func (gint *width, gint *height, gpointer loader)
{
        GdkPixbufLoaderPrivate *priv = GDK_PIXBUF_LOADER (loader)->priv;

        priv->original_width = *width;
        priv->original_height = *height;

        /* allow calling gdk_pixbuf_loader_set_size() before the signal */
        if (priv->width == -1 && priv->height == -1) 
                {
                        priv->width = *width;
                        priv->height = *height;
                }

        g_signal_emit (loader, pixbuf_loader_signals[SIZE_PREPARED], 0, *width, *height);
        priv->size_fixed = TRUE;

        *width = priv->width;
        *height = priv->height;
}

static void
gdk_pixbuf_loader_prepare (GdkPixbuf          *pixbuf,
                           GdkPixbufAnimation *anim,
			   gpointer            loader)
{
        GdkPixbufLoaderPrivate *priv = GDK_PIXBUF_LOADER (loader)->priv;
        gint width, height;
        g_return_if_fail (pixbuf != NULL);

        width = anim ? gdk_pixbuf_animation_get_width (anim) :
                gdk_pixbuf_get_width (pixbuf);
        height = anim ? gdk_pixbuf_animation_get_height (anim) :
                gdk_pixbuf_get_height (pixbuf);

        if (!priv->size_fixed) 
                {
			gint w = width;
			gint h = height;
                        /* Defend against lazy loaders which don't call size_func */
                        gdk_pixbuf_loader_size_func (&w, &h, loader);
                }

        priv->needs_scale = FALSE;
        if (priv->width > 0 && priv->height > 0 &&
            (priv->width != width || priv->height != height))
                priv->needs_scale = TRUE;

        if (anim)
                g_object_ref (anim);
        else {
                if (priv->original_width > 0) {
                        char *original_width_str = NULL;

                        original_width_str = g_strdup_printf ("%d", priv->original_width);
                        gdk_pixbuf_set_option (pixbuf, "original-width", original_width_str);
                        g_free (original_width_str);
                }

                if (priv->original_height > 0) {
                        char *original_height_str = NULL;

                        original_height_str = g_strdup_printf ("%d", priv->original_height);
                        gdk_pixbuf_set_option (pixbuf, "original-height", original_height_str);
                        g_free (original_height_str);
                }

                anim = gdk_pixbuf_non_anim_new (pixbuf);
        }
  
	if (priv->needs_scale && width != 0 && height != 0) {
		priv->animation  = GDK_PIXBUF_ANIMATION (_gdk_pixbuf_scaled_anim_new (anim,
                                         (double) priv->width / width,
                                         (double) priv->height / height,
					  1.0));
			g_object_unref (anim);
	}
	else
        	priv->animation = anim;
  
        if (!priv->needs_scale)
                g_signal_emit (loader, pixbuf_loader_signals[AREA_PREPARED], 0);
}

static void
{'fraction_non_alphanumeric': 0.07505643340857787, 'fraction_numerical': 0.0024078254326561324, 'mean_word_length': 2.0486294299805023, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 121, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5977045', 'n_tokens_mistral': 7839, 'n_tokens_neox': 7415, 'n_words': 2340}