1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2/* GdkPixbuf library - Animation support
3 *
4 * Copyright (C) 1999 The Free Software Foundation
5 *
6 * Authors: Mark Crichton <crichton@gimp.org>
7 * Miguel de Icaza <miguel@gnu.org>
8 * Federico Mena-Quintero <federico@gimp.org>
9 * Havoc Pennington <hp@redhat.com>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
23 */
24
25#ifndef GDK_PIXBUF_ANIMATION_H
26#define GDK_PIXBUF_ANIMATION_H
27
28#if defined(GDK_PIXBUF_DISABLE_SINGLE_INCLUDES) && !defined (GDK_PIXBUF_H_INSIDE) && !defined (GDK_PIXBUF_COMPILATION)
29#error "Only <gdk-pixbuf/gdk-pixbuf.h> can be included directly."
30#endif
31
32#include <glib-object.h>
33#include <gdk-pixbuf/gdk-pixbuf-core.h>
34
35G_BEGIN_DECLS
36
37/* Animation support */
38
39/**
40 * GdkPixbufAnimation:
41 *
42 * An opaque struct representing an animation.
43 */
44typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
45
46
47/**
48 * GdkPixbufAnimationIter:
49 *
50 * An opaque struct representing an iterator which points to a
51 * certain position in an animation.
52 */
53typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter;
54
55#define GDK_TYPE_PIXBUF_ANIMATION (gdk_pixbuf_animation_get_type ())
56#define GDK_PIXBUF_ANIMATION(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimation))
57#define GDK_IS_PIXBUF_ANIMATION(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANIMATION))
58
59#define GDK_TYPE_PIXBUF_ANIMATION_ITER (gdk_pixbuf_animation_iter_get_type ())
60#define GDK_PIXBUF_ANIMATION_ITER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANIMATION_ITER, GdkPixbufAnimationIter))
61#define GDK_IS_PIXBUF_ANIMATION_ITER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANIMATION_ITER))
62
63GDK_PIXBUF_AVAILABLE_IN_ALL
64GType gdk_pixbuf_animation_get_type (void) G_GNUC_CONST;
65
66#ifdef G_OS_WIN32
67/* API/ABI compat, see gdk-pixbuf-core.h for details */
68GDK_PIXBUF_AVAILABLE_IN_ALL
69GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file_utf8 (const char *filename,
70 GError **error);
71#endif
72
73GDK_PIXBUF_AVAILABLE_IN_ALL
74GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file (const char *filename,
75 GError **error);
76GDK_PIXBUF_AVAILABLE_IN_2_28
77GdkPixbufAnimation *gdk_pixbuf_animation_new_from_stream (GInputStream *stream,
78 GCancellable *cancellable,
79 GError **error);
80GDK_PIXBUF_AVAILABLE_IN_2_28
81void gdk_pixbuf_animation_new_from_stream_async (GInputStream *stream,
82 GCancellable *cancellable,
83 GAsyncReadyCallback callback,
84 gpointer user_data);
85GDK_PIXBUF_AVAILABLE_IN_2_28
86GdkPixbufAnimation *gdk_pixbuf_animation_new_from_stream_finish (GAsyncResult*async_result,
87 GError **error);
88GDK_PIXBUF_AVAILABLE_IN_2_28
89GdkPixbufAnimation *gdk_pixbuf_animation_new_from_resource(const char *resource_path,
90 GError **error);
91
92#ifndef GDK_PIXBUF_DISABLE_DEPRECATED
93
94GDK_PIXBUF_DEPRECATED_IN_2_0_FOR(g_object_ref)
95GdkPixbufAnimation *gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation);
96GDK_PIXBUF_DEPRECATED_IN_2_0_FOR(g_object_unref)
97void gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation);
98#endif
99
100GDK_PIXBUF_AVAILABLE_IN_ALL
101int gdk_pixbuf_animation_get_width (GdkPixbufAnimation *animation);
102GDK_PIXBUF_AVAILABLE_IN_ALL
103int gdk_pixbuf_animation_get_height (GdkPixbufAnimation *animation);
104GDK_PIXBUF_AVAILABLE_IN_ALL
105gboolean gdk_pixbuf_animation_is_static_image (GdkPixbufAnimation *animation);
106GDK_PIXBUF_AVAILABLE_IN_ALL
107GdkPixbuf *gdk_pixbuf_animation_get_static_image (GdkPixbufAnimation *animation);
108
109GDK_PIXBUF_AVAILABLE_IN_ALL
110GdkPixbufAnimationIter *gdk_pixbuf_animation_get_iter (GdkPixbufAnimation *animation,
111 const GTimeVal *start_time);
112GDK_PIXBUF_AVAILABLE_IN_ALL
113GType gdk_pixbuf_animation_iter_get_type (void) G_GNUC_CONST;
114GDK_PIXBUF_AVAILABLE_IN_ALL
115int gdk_pixbuf_animation_iter_get_delay_time (GdkPixbufAnimationIter *iter);
116GDK_PIXBUF_AVAILABLE_IN_ALL
117GdkPixbuf *gdk_pixbuf_animation_iter_get_pixbuf (GdkPixbufAnimationIter *iter);
118GDK_PIXBUF_AVAILABLE_IN_ALL
119gboolean gdk_pixbuf_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter);
120GDK_PIXBUF_AVAILABLE_IN_ALL
121gboolean gdk_pixbuf_animation_iter_advance (GdkPixbufAnimationIter *iter,
122 const GTimeVal *current_time);
123
124
125#ifdef GDK_PIXBUF_ENABLE_BACKEND
126
127
128
129/**
130 * GdkPixbufAnimationClass:
131 * @parent_class: the parent class
132 * @is_static_image: returns whether the given animation is just a static image.
133 * @get_static_image: returns a static image representing the given animation.
134 * @get_size: fills @width and @height with the frame size of the animation.
135 * @get_iter: returns an iterator for the given animation.
136 *
137 * Modules supporting animations must derive a type from
138 * #GdkPixbufAnimation, providing suitable implementations of the
139 * virtual functions.
140 */
141typedef struct _GdkPixbufAnimationClass GdkPixbufAnimationClass;
142
143#define GDK_PIXBUF_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimationClass))
144#define GDK_IS_PIXBUF_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_ANIMATION))
145#define GDK_PIXBUF_ANIMATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimationClass))
146
147/* Private part of the GdkPixbufAnimation structure */
148struct _GdkPixbufAnimation {
149 GObject parent_instance;
150
151};
152
153struct _GdkPixbufAnimationClass {
154 GObjectClass parent_class;
155
156 /*< public >*/
157
158 gboolean (*is_static_image) (GdkPixbufAnimation *anim);
159
160 GdkPixbuf* (*get_static_image) (GdkPixbufAnimation *anim);
161
162 void (*get_size) (GdkPixbufAnimation *anim,
163 int *width,
164 int *height);
165
166 GdkPixbufAnimationIter* (*get_iter) (GdkPixbufAnimation *anim,
167 const GTimeVal *start_time);
168
169};
170
171
172
173/**
174 * GdkPixbufAnimationIterClass:
175 * @parent_class: the parent class
176 * @get_delay_time: returns the time in milliseconds that the current frame
177 * should be shown.
178 * @get_pixbuf: returns the current frame.
179 * @on_currently_loading_frame: returns whether the current frame of @iter is
180 * being loaded.
181 * @advance: advances the iterator to @current_time, possibly changing the
182 * current frame.
183 *
184 * Modules supporting animations must derive a type from
185 * #GdkPixbufAnimationIter, providing suitable implementations of the
186 * virtual functions.
187 */
188typedef struct _GdkPixbufAnimationIterClass GdkPixbufAnimationIterClass;
189
190#define GDK_PIXBUF_ANIMATION_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_ANIMATION_ITER, GdkPixbufAnimationIterClass))
191#define GDK_IS_PIXBUF_ANIMATION_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_ANIMATION_ITER))
192#define GDK_PIXBUF_ANIMATION_ITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_ANIMATION_ITER, GdkPixbufAnimationIterClass))
193
194struct _GdkPixbufAnimationIter {
195 GObject parent_instance;
196
197};
198
199struct _GdkPixbufAnimationIterClass {
200 GObjectClass parent_class;
201
202 /*< public >*/
203
204 int (*get_delay_time) (GdkPixbufAnimationIter *iter);
205
206 GdkPixbuf* (*get_pixbuf) (GdkPixbufAnimationIter *iter);
207
208 gboolean (*on_currently_loading_frame) (GdkPixbufAnimationIter *iter);
209
210 gboolean (*advance) (GdkPixbufAnimationIter *iter,
211 const GTimeVal *current_time);
212};
213
214
215GDK_PIXBUF_AVAILABLE_IN_ALL
216GType gdk_pixbuf_non_anim_get_type (void) G_GNUC_CONST;
217GDK_PIXBUF_AVAILABLE_IN_ALL
218GdkPixbufAnimation* gdk_pixbuf_non_anim_new (GdkPixbuf *pixbuf);
219
220#endif /* GDK_PIXBUF_ENABLE_BACKEND */
221
222G_END_DECLS
223
224#endif /* GDK_PIXBUF_ANIMATION_H */
225