<commit_before>/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* GdkPixbuf library - animated gdip support
 *
 * Copyright (C) 1999 The Free Software Foundation
 *
 * Authors: <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 <errno.h>
#include "io-gdip-native.h"
#include "io-gdip-animation.h"

static void gdk_pixbuf_gdip_anim_finalize   (GObject        *object);

static gboolean                gdk_pixbuf_gdip_anim_is_static_image  (GdkPixbufAnimation *animation);
static GdkPixbuf*              gdk_pixbuf_gdip_anim_get_static_image (GdkPixbufAnimation *animation);

static void                    gdk_pixbuf_gdip_anim_get_size (GdkPixbufAnimation *anim,
                                                             int                *width,
                                                             int                *height);
static GdkPixbufAnimationIter* gdk_pixbuf_gdip_anim_get_iter (GdkPixbufAnimation *anim,
                                                             const GTimeVal     *start_time);


G_DEFINE_TYPE (GdkPixbufGdipAnim, gdk_pixbuf_gdip_anim, GDK_TYPE_PIXBUF_ANIMATION);

static void
gdk_pixbuf_gdip_anim_init (GdkPixbufGdipAnim *anim)
{
}

static void
gdk_pixbuf_gdip_anim_class_init (GdkPixbufGdipAnimClass *klass)
{
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
        GdkPixbufAnimationClass *anim_class = GDK_PIXBUF_ANIMATION_CLASS (klass);

        object_class->finalize = gdk_pixbuf_gdip_anim_finalize;

        anim_class->is_static_image = gdk_pixbuf_gdip_anim_is_static_image;
        anim_class->get_static_image = gdk_pixbuf_gdip_anim_get_static_image;
        anim_class->get_size = gdk_pixbuf_gdip_anim_get_size;
        anim_class->get_iter = gdk_pixbuf_gdip_anim_get_iter;
}

static void
gdk_pixbuf_gdip_anim_finalize (GObject *object)
{
        GdkPixbufGdipAnim *gdip_anim = GDK_PIXBUF_GDIP_ANIM (object);

        GList *l;
        GdkPixbufFrame *frame;

        for (l = gdip_anim->frames; l; l = l->next) {
                frame = l->data;
                g_object_unref (frame->pixbuf);
                g_free (frame);
        }

        g_list_free (gdip_anim->frames);

        G_OBJECT_CLASS (gdk_pixbuf_gdip_anim_parent_class)->finalize (object);
}

static gboolean
gdk_pixbuf_gdip_anim_is_static_image  (GdkPixbufAnimation *animation)
{
        GdkPixbufGdipAnim *gdip_anim;

        gdip_anim = GDK_PIXBUF_GDIP_ANIM (animation);

        return (gdip_anim->frames != NULL &&
                gdip_anim->frames->next == NULL);
}

static GdkPixbuf*
gdk_pixbuf_gdip_anim_get_static_image (GdkPixbufAnimation *animation)
{
        GdkPixbufGdipAnim *gdip_anim;

        gdip_anim = GDK_PIXBUF_GDIP_ANIM (animation);

        if (gdip_anim->frames == NULL)
                return NULL;
        else
                return GDK_PIXBUF (((GdkPixbufFrame*)gdip_anim->frames->data)->pixbuf);
}

static void
gdk_pixbuf_gdip_anim_get_size (GdkPixbufAnimation *anim,
                              int                *width,
                              int                *height)
{
        GdkPixbufGdipAnim *gdip_anim;

        gdip_anim = GDK_PIXBUF_GDIP_ANIM (anim);

        if (width)
                *width = gdip_anim->width;

        if (height)
                *height = gdip_anim->height;
}


static void
iter_clear (GdkPixbufGdipAnimIter *iter)
{
        iter->current_frame = NULL;
}

static void
iter_restart (GdkPixbufGdipAnimIter *iter)
{
        iter_clear (iter);

        iter->current_frame = iter->gdip_anim->frames;
}

static GdkPixbufAnimationIter*
gdk_pixbuf_gdip_anim_get_iter (GdkPixbufAnimation *anim,
                              const GTimeVal     *start_time)
{
        GdkPixbufGdipAnimIter *iter;

        iter = g_object_new (GDK_TYPE_PIXBUF_GDIP_ANIM_ITER, NULL);

        iter->gdip_anim = GDK_PIXBUF_GDIP_ANIM (anim);

        g_object_ref (iter->gdip_anim);

        iter_restart (iter);

        iter->start_time = *start_time;
        iter->current_time = *start_time;
        iter->first_loop_slowness = 0;

        return GDK_PIXBUF_ANIMATION_ITER (iter);
}

static void gdk_pixbuf_gdip_anim_iter_finalize   (GObject                   *object);

static int        gdk_pixbuf_gdip_anim_iter_get_delay_time             (GdkPixbufAnimationIter *iter);
static GdkPixbuf* gdk_pixbuf_gdip_anim_iter_get_pixbuf                 (GdkPixbufAnimationIter *iter);
static gboolean   gdk_pixbuf_gdip_anim_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter);
static gboolean   gdk_pixbuf_gdip_anim_iter_advance                    (GdkPixbufAnimationIter *iter,
                                                                       const GTimeVal         *current_time);

G_DEFINE_TYPE (GdkPixbufGdipAnimIter, gdk_pixbuf_gdip_anim_iter, GDK_TYPE_PIXBUF_ANIMATION_ITER);

static void
gdk_pixbuf_gdip_anim_iter_class_init (GdkPixbufGdipAnimIterClass *klass)<commit_msg>Add a missing init function<commit_after>/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* GdkPixbuf library - animated gdip support
 *
 * Copyright (C) 1999 The Free Software Foundation
 *
 * Authors: <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 <errno.h>
#include "io-gdip-native.h"
#include "io-gdip-animation.h"

static void gdk_pixbuf_gdip_anim_finalize   (GObject        *object);

static gboolean                gdk_pixbuf_gdip_anim_is_static_image  (GdkPixbufAnimation *animation);
static GdkPixbuf*              gdk_pixbuf_gdip_anim_get_static_image (GdkPixbufAnimation *animation);

static void                    gdk_pixbuf_gdip_anim_get_size (GdkPixbufAnimation *anim,
                                                             int                *width,
                                                             int                *height);
static GdkPixbufAnimationIter* gdk_pixbuf_gdip_anim_get_iter (GdkPixbufAnimation *anim,
                                                             const GTimeVal     *start_time);


G_DEFINE_TYPE (GdkPixbufGdipAnim, gdk_pixbuf_gdip_anim, GDK_TYPE_PIXBUF_ANIMATION);

static void
gdk_pixbuf_gdip_anim_init (GdkPixbufGdipAnim *anim)
{
}

static void
gdk_pixbuf_gdip_anim_class_init (GdkPixbufGdipAnimClass *klass)
{
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
        GdkPixbufAnimationClass *anim_class = GDK_PIXBUF_ANIMATION_CLASS (klass);

        object_class->finalize = gdk_pixbuf_gdip_anim_finalize;

        anim_class->is_static_image = gdk_pixbuf_gdip_anim_is_static_image;
        anim_class->get_static_image = gdk_pixbuf_gdip_anim_get_static_image;
        anim_class->get_size = gdk_pixbuf_gdip_anim_get_size;
        anim_class->get_iter = gdk_pixbuf_gdip_anim_get_iter;
}

static void
gdk_pixbuf_gdip_anim_finalize (GObject *object)
{
        GdkPixbufGdipAnim *gdip_anim = GDK_PIXBUF_GDIP_ANIM (object);

        GList *l;
        GdkPixbufFrame *frame;

        for (l = gdip_anim->frames; l; l = l->next) {
                frame = l->data;
                g_object_unref (frame->pixbuf);
                g_free (frame);
        }

        g_list_free (gdip_anim->frames);

        G_OBJECT_CLASS (gdk_pixbuf_gdip_anim_parent_class)->finalize (object);
}

static gboolean
gdk_pixbuf_gdip_anim_is_static_image  (GdkPixbufAnimation *animation)
{
        GdkPixbufGdipAnim *gdip_anim;

        gdip_anim = GDK_PIXBUF_GDIP_ANIM (animation);

        return (gdip_anim->frames != NULL &&
                gdip_anim->frames->next == NULL);
}

static GdkPixbuf*
gdk_pixbuf_gdip_anim_get_static_image (GdkPixbufAnimation *animation)
{
        GdkPixbufGdipAnim *gdip_anim;

        gdip_anim = GDK_PIXBUF_GDIP_ANIM (animation);

        if (gdip_anim->frames == NULL)
                return NULL;
        else
                return GDK_PIXBUF (((GdkPixbufFrame*)gdip_anim->frames->data)->pixbuf);
}

static void
gdk_pixbuf_gdip_anim_get_size (GdkPixbufAnimation *anim,
                              int                *width,
                              int                *height)
{
        GdkPixbufGdipAnim *gdip_anim;

        gdip_anim = GDK_PIXBUF_GDIP_ANIM (anim);

        if (width)
                *width = gdip_anim->width;

        if (height)
                *height = gdip_anim->height;
}


static void
iter_clear (GdkPixbufGdipAnimIter *iter)
{
        iter->current_frame = NULL;
}

static void
iter_restart (GdkPixbufGdipAnimIter *iter)
{
        iter_clear (iter);

        iter->current_frame = iter->gdip_anim->frames;
}

static GdkPixbufAnimationIter*
gdk_pixbuf_gdip_anim_get_iter (GdkPixbufAnimation *anim,
                              const GTimeVal     *start_time)
{
        GdkPixbufGdipAnimIter *iter;

        iter = g_object_new (GDK_TYPE_PIXBUF_GDIP_ANIM_ITER, NULL);

        iter->gdip_anim = GDK_PIXBUF_GDIP_ANIM (anim);

        g_object_ref (iter->gdip_anim);

        iter_restart (iter);

        iter->start_time = *start_time;
        iter->current_time = *start_time;
        iter->first_loop_slowness = 0;

        return GDK_PIXBUF_ANIMATION_ITER (iter);
}

static void gdk_pixbuf_gdip_anim_iter_finalize   (GObject                   *object);

static int        gdk_pixbuf_gdip_anim_iter_get_delay_time             (GdkPixbufAnimationIter *iter);
static GdkPixbuf* gdk_pixbuf_gdip_anim_iter_get_pixbuf                 (GdkPixbufAnimationIter *iter);
static gboolean   gdk_pixbuf_gdip_anim_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter);
static gboolean   gdk_pixbuf_gdip_anim_iter_advance                    (GdkPixbufAnimationIter *iter,
                                                                       const GTimeVal         *current_time);

G_DEFINE_TYPE (GdkPixbufGdipAnimIter, gdk_pixbuf_gdip_anim_iter, GDK_TYPE_PIXBUF_ANIMATION_ITER);

static void
gdk_pixbuf_gdip_anim_iter_init (GdkPixbufGdipAnimIter *iter)
{
}

static void
gdk_pixbuf_gdip_anim_iter_class_init (GdkPixbufGdipAnimIterClass *klass)
{'fraction_non_alphanumeric': 0.07340817400456061, 'fraction_numerical': 0.003858972110156113, 'mean_word_length': 2.632685568652437, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5875370', 'n_tokens_mistral': 3874, 'n_tokens_neox': 3652, 'n_words': 770}