<commit_before>/* GdkPixbuf library - Main header file
 *
 * 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, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <string.h>

#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-loader.h"
#include "gdk-pixbuf-io.h"

#include "gtksignal.h"

enum {
  AREA_UPDATED,
  AREA_PREPARED,
  FRAME_DONE,
  ANIMATION_DONE,
  CLOSED,
  LAST_SIGNAL
};


static void gdk_pixbuf_loader_class_init    (GdkPixbufLoaderClass   *klass);
static void gdk_pixbuf_loader_init          (GdkPixbufLoader        *loader);
static void gdk_pixbuf_loader_destroy       (GtkObject              *loader);
static void gdk_pixbuf_loader_finalize      (GObject                *loader);

static gpointer parent_class = NULL;
static guint    pixbuf_loader_signals[LAST_SIGNAL] = { 0 };


/* Internal data */

#define LOADER_HEADER_SIZE 128

typedef struct
{
  GdkPixbuf *pixbuf;
  GdkPixbufAnimation *animation;
  gboolean closed;
  guchar header_buf[LOADER_HEADER_SIZE];
  gint header_buf_offset;
  GdkPixbufModule *image_module;
  gpointer context;
} GdkPixbufLoaderPrivate;


/**
 * gdk_pixbuf_loader_get_type:
 * @void:
 *
 * Registers the #GdkPixubfLoader class if necessary, and returns the type ID
 * associated to it.
 *
 * Return value: The type ID of the #GdkPixbufLoader class.
 **/
GtkType
gdk_pixbuf_loader_get_type (void)
{
  static GtkType loader_type = 0;
  
  if (!loader_type)
    {
      static const GtkTypeInfo loader_info = {
	"GdkPixbufLoader",
	sizeof (GdkPixbufLoader),
	sizeof (GdkPixbufLoaderClass),
	(GtkClassInitFunc) gdk_pixbuf_loader_class_init,
	(GtkObjectInitFunc) gdk_pixbuf_loader_init,
	/* reserved_1 */ NULL,
	/* reserved_2 */ NULL,
	(GtkClassInitFunc) NULL,
      };
      
      loader_type = gtk_type_unique (GTK_TYPE_OBJECT, &loader_info);
    }
  
  return loader_type;
}

static void
gdk_pixbuf_loader_class_init (GdkPixbufLoaderClass *class)
{
  GObjectClass *gobject_class;
  GtkObjectClass *object_class;
  
  object_class = (GtkObjectClass *) class;
  gobject_class = (GObjectClass *) class;
  
  parent_class = gtk_type_class (GTK_TYPE_OBJECT);
  
  pixbuf_loader_signals[AREA_PREPARED] =
    gtk_signal_new ("area_prepared",
		    GTK_RUN_LAST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GdkPixbufLoaderClass, area_prepared),
		    gtk_marshal_VOID__VOID,
		    GTK_TYPE_NONE, 0);
  
  pixbuf_loader_signals[AREA_UPDATED] =
    gtk_signal_new ("area_updated",
		    GTK_RUN_LAST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GdkPixbufLoaderClass, area_updated),
		    gtk_marshal_VOID__INT_INT_INT_INT,
		    GTK_TYPE_NONE, 4,
		    GTK_TYPE_INT,
		    GTK_TYPE_INT,
		    GTK_TYPE_INT,
		    GTK_TYPE_INT);
  
  pixbuf_loader_signals[FRAME_DONE] =
    gtk_signal_new ("frame_done",
		    GTK_RUN_LAST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GdkPixbufLoaderClass, frame_done),
		    gtk_marshal_VOID__POINTER,
		    GTK_TYPE_NONE, 1,
		    GTK_TYPE_POINTER);
  
  pixbuf_loader_signals[ANIMATION_DONE] =
    gtk_signal_new ("animation_done",
		    GTK_RUN_LAST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GdkPixbufLoaderClass, animation_done),
		    gtk_marshal_VOID__VOID,
		    GTK_TYPE_NONE, 0);
  
  pixbuf_loader_signals[CLOSED] =
    gtk_signal_new ("closed",
		    GTK_RUN_LAST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GdkPixbufLoaderClass, closed),
		    gtk_marshal_VOID__VOID,
		    GTK_TYPE_NONE, 0);
  
  gtk_object_class_add_signals (object_class, pixbuf_loader_signals, LAST_SIGNAL);
  
  object_class->destroy = gdk_pixbuf_loader_destroy;
  gobject_class->finalize = gdk_pixbuf_loader_finalize;
}

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

static void
gdk_pixbuf_loader_destroy (GtkObject *object)
{
  GdkPixbufLoader *loader;
  GdkPixbufLoaderPrivate *priv = NULL;
  
  g_return_if_fail (object != NULL);
  g_return_if_fail (GDK_IS_PIXBUF_LOADER (object));
  
  loader = GDK_PIXBUF_LOADER (object);
  priv = loader->private;
  
  if (!priv->closed)<commit_msg>doh, this was broken beyond believe.<commit_after>/* GdkPixbuf library - Main header file
 *
 * 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, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <string.h>

#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-loader.h"
#include "gdk-pixbuf-io.h"

#include "gtksignal.h"

enum {
  AREA_UPDATED,
  AREA_PREPARED,
  FRAME_DONE,
  ANIMATION_DONE,
  CLOSED,
  LAST_SIGNAL
};


static void gdk_pixbuf_loader_class_init    (GdkPixbufLoaderClass   *klass);
static void gdk_pixbuf_loader_init          (GdkPixbufLoader        *loader);
static void gdk_pixbuf_loader_destroy       (GtkObject              *loader);
static void gdk_pixbuf_loader_finalize      (GObject                *loader);

static gpointer parent_class = NULL;
static guint    pixbuf_loader_signals[LAST_SIGNAL] = { 0 };


/* Internal data */

#define LOADER_HEADER_SIZE 128

typedef struct
{
  GdkPixbuf *pixbuf;
  GdkPixbufAnimation *animation;
  gboolean closed;
  guchar header_buf[LOADER_HEADER_SIZE];
  gint header_buf_offset;
  GdkPixbufModule *image_module;
  gpointer context;
} GdkPixbufLoaderPrivate;


/**
 * gdk_pixbuf_loader_get_type:
 * @void:
 *
 * Registers the #GdkPixubfLoader class if necessary, and returns the type ID
 * associated to it.
 *
 * Return value: The type ID of the #GdkPixbufLoader class.
 **/
GtkType
gdk_pixbuf_loader_get_type (void)
{
  static GtkType loader_type = 0;
  
  if (!loader_type)
    {
      static const GtkTypeInfo loader_info = {
	"GdkPixbufLoader",
	sizeof (GdkPixbufLoader),
	sizeof (GdkPixbufLoaderClass),
	(GtkClassInitFunc) gdk_pixbuf_loader_class_init,
	(GtkObjectInitFunc) gdk_pixbuf_loader_init,
	/* reserved_1 */ NULL,
	/* reserved_2 */ NULL,
	(GtkClassInitFunc) NULL,
      };
      
      loader_type = gtk_type_unique (GTK_TYPE_OBJECT, &loader_info);
    }
  
  return loader_type;
}

static void
gdk_pixbuf_loader_class_init (GdkPixbufLoaderClass *class)
{
  GObjectClass *gobject_class;
  GtkObjectClass *object_class;
  
  object_class = (GtkObjectClass *) class;
  gobject_class = (GObjectClass *) class;
  
  parent_class = gtk_type_class (GTK_TYPE_OBJECT);
  
  object_class->destroy = gdk_pixbuf_loader_destroy;
  gobject_class->finalize = gdk_pixbuf_loader_finalize;

  pixbuf_loader_signals[AREA_PREPARED] =
    gtk_signal_new ("area_prepared",
		    GTK_RUN_LAST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GdkPixbufLoaderClass, area_prepared),
		    gtk_marshal_VOID__VOID,
		    GTK_TYPE_NONE, 0);
  
  pixbuf_loader_signals[AREA_UPDATED] =
    gtk_signal_new ("area_updated",
		    GTK_RUN_LAST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GdkPixbufLoaderClass, area_updated),
		    gtk_marshal_VOID__INT_INT_INT_INT,
		    GTK_TYPE_NONE, 4,
		    GTK_TYPE_INT,
		    GTK_TYPE_INT,
		    GTK_TYPE_INT,
		    GTK_TYPE_INT);
  
  pixbuf_loader_signals[FRAME_DONE] =
    gtk_signal_new ("frame_done",
		    GTK_RUN_LAST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GdkPixbufLoaderClass, frame_done),
		    gtk_marshal_VOID__POINTER,
		    GTK_TYPE_NONE, 1,
		    GTK_TYPE_POINTER);
  
  pixbuf_loader_signals[ANIMATION_DONE] =
    gtk_signal_new ("animation_done",
		    GTK_RUN_LAST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GdkPixbufLoaderClass, animation_done),
		    gtk_marshal_VOID__VOID,
		    GTK_TYPE_NONE, 0);
  
  pixbuf_loader_signals[CLOSED] =
    gtk_signal_new ("closed",
		    GTK_RUN_LAST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GdkPixbufLoaderClass, closed),
		    gtk_marshal_VOID__VOID,
		    GTK_TYPE_NONE, 0);
}

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

static void
gdk_pixbuf_loader_destroy (GtkObject *object)
{
  GdkPixbufLoader *loader;
  GdkPixbufLoaderPrivate *priv = NULL;
  
  g_return_if_fail (object != NULL);
  g_return_if_fail (GDK_IS_PIXBUF_LOADER (object));
  
  loader = GDK_PIXBUF_LOADER (object);
  priv = loader->private;
  
  if (!priv->closed)
{'fraction_non_alphanumeric': 0.08302229395742963, 'fraction_numerical': 0.006657923938262887, 'mean_word_length': 3.922542204568024, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4015146', 'n_tokens_mistral': 3788, 'n_tokens_neox': 3503, 'n_words': 782}