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
109G_GNUC_BEGIN_IGNORE_DEPRECATIONS
110GDK_PIXBUF_AVAILABLE_IN_ALL
111GdkPixbufAnimationIter *gdk_pixbuf_animation_get_iter (GdkPixbufAnimation *animation,
112 const GTimeVal *start_time);
113G_GNUC_END_IGNORE_DEPRECATIONS
114
115GDK_PIXBUF_AVAILABLE_IN_ALL
116GType gdk_pixbuf_animation_iter_get_type (void) G_GNUC_CONST;
117GDK_PIXBUF_AVAILABLE_IN_ALL
118int gdk_pixbuf_animation_iter_get_delay_time (GdkPixbufAnimationIter *iter);
119GDK_PIXBUF_AVAILABLE_IN_ALL
120GdkPixbuf *gdk_pixbuf_animation_iter_get_pixbuf (GdkPixbufAnimationIter *iter);
121GDK_PIXBUF_AVAILABLE_IN_ALL
122gboolean gdk_pixbuf_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter);
123G_GNUC_BEGIN_IGNORE_DEPRECATIONS
124GDK_PIXBUF_AVAILABLE_IN_ALL
125gboolean gdk_pixbuf_animation_iter_advance (GdkPixbufAnimationIter *iter,
126 const GTimeVal *current_time);
127G_GNUC_END_IGNORE_DEPRECATIONS
128
129
130#ifdef GDK_PIXBUF_ENABLE_BACKEND
131
132
133
134/**
135 * GdkPixbufAnimationClass:
136 * @parent_class: the parent class
137 * @is_static_image: returns whether the given animation is just a static image.
138 * @get_static_image: returns a static image representing the given animation.
139 * @get_size: fills @width and @height with the frame size of the animation.
140 * @get_iter: returns an iterator for the given animation.
141 *
142 * Modules supporting animations must derive a type from
143 * #GdkPixbufAnimation, providing suitable implementations of the
144 * virtual functions.
145 */
146typedef struct _GdkPixbufAnimationClass GdkPixbufAnimationClass;
147
148#define GDK_PIXBUF_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimationClass))
149#define GDK_IS_PIXBUF_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_ANIMATION))
150#define GDK_PIXBUF_ANIMATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimationClass))
151
152/* Private part of the GdkPixbufAnimation structure */
153struct _GdkPixbufAnimation {
154 GObject parent_instance;
155
156};
157
158G_GNUC_BEGIN_IGNORE_DEPRECATIONS
159struct _GdkPixbufAnimationClass {
160 GObjectClass parent_class;
161
162 /*< public >*/
163
164 gboolean (*is_static_image) (GdkPixbufAnimation *anim);
165
166 GdkPixbuf* (*get_static_image) (GdkPixbufAnimation *anim);
167
168 void (*get_size) (GdkPixbufAnimation *anim,
169 int *width,
170 int *height);
171
172 GdkPixbufAnimationIter* (*get_iter) (GdkPixbufAnimation *anim,
173 const GTimeVal *start_time);
174
175};
176G_GNUC_END_IGNORE_DEPRECATIONS
177
178
179
180/**
181 * GdkPixbufAnimationIterClass:
182 * @parent_class: the parent class
183 * @get_delay_time: returns the time in milliseconds that the current frame
184 * should be shown.
185 * @get_pixbuf: returns the current frame.
186 * @on_currently_loading_frame: returns whether the current frame of @iter is
187 * being loaded.
188 * @advance: advances the iterator to @current_time, possibly changing the
189 * current frame.
190 *
191 * Modules supporting animations must derive a type from
192 * #GdkPixbufAnimationIter, providing suitable implementations of the
193 * virtual functions.
194 */
195typedef struct _GdkPixbufAnimationIterClass GdkPixbufAnimationIterClass;
196
197#define GDK_PIXBUF_ANIMATION_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_ANIMATION_ITER, GdkPixbufAnimationIterClass))
198#define GDK_IS_PIXBUF_ANIMATION_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_ANIMATION_ITER))
199#define GDK_PIXBUF_ANIMATION_ITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_ANIMATION_ITER, GdkPixbufAnimationIterClass))
200
201struct _GdkPixbufAnimationIter {
202 GObject parent_instance;
203
204};
205
206G_GNUC_BEGIN_IGNORE_DEPRECATIONS
207struct _GdkPixbufAnimationIterClass {
208 GObjectClass parent_class;
209
210 /*< public >*/
211
212 int (*get_delay_time) (GdkPixbufAnimationIter *iter);
213
214 GdkPixbuf* (*get_pixbuf) (GdkPixbufAnimationIter *iter);
215
216 gboolean (*on_currently_loading_frame) (GdkPixbufAnimationIter *iter);
217
218 gboolean (*advance) (GdkPixbufAnimationIter *iter,
219 const GTimeVal *current_time);
220};
221G_GNUC_END_IGNORE_DEPRECATIONS
222
223
224GDK_PIXBUF_AVAILABLE_IN_ALL
225GType gdk_pixbuf_non_anim_get_type (void) G_GNUC_CONST;
226GDK_PIXBUF_AVAILABLE_IN_ALL
227GdkPixbufAnimation* gdk_pixbuf_non_anim_new (GdkPixbuf *pixbuf);
228
229#endif /* GDK_PIXBUF_ENABLE_BACKEND */
230
231G_END_DECLS
232
233#endif /* GDK_PIXBUF_ANIMATION_H */
234