1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = gdk-pixbuf-Animations.html 27 * outPack = gdkpixbuf 28 * outFile = PixbufAnimation 29 * strct = GdkPixbufAnimation 30 * realStrct= 31 * ctorStrct= 32 * clss = PixbufAnimation 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gdk_pixbuf_animation_ 41 * omit structs: 42 * omit prefixes: 43 * - gdk_pixbuf_animation_iter_ 44 * - gdk_pixbuf_simple_anim_ 45 * omit code: 46 * - gdk_pixbuf_animation_ref 47 * - gdk_pixbuf_animation_unref 48 * - gdk_pixbuf_animation_new_from_resource 49 * omit signals: 50 * imports: 51 * - glib.ErrorG 52 * - glib.GException 53 * - gdkpixbuf.PixbufAnimationIter 54 * - gdk.Pixbuf 55 * - glib.Str 56 * - gio.InputStream 57 * - gio.Cancellable 58 * - gio.AsyncResultIF 59 * structWrap: 60 * - GAsyncResult* -> AsyncResultIF 61 * - GCancellable* -> Cancellable 62 * - GInputStream* -> InputStream 63 * - GdkPixbuf* -> Pixbuf 64 * - GdkPixbufAnimation* -> PixbufAnimation 65 * - GdkPixbufAnimationIter* -> PixbufAnimationIter 66 * module aliases: 67 * local aliases: 68 * overrides: 69 */ 70 71 module gdkpixbuf.PixbufAnimation; 72 73 public import gtkc.gdkpixbuftypes; 74 75 private import gtkc.gdkpixbuf; 76 private import glib.ConstructionException; 77 private import gobject.ObjectG; 78 79 80 private import glib.ErrorG; 81 private import glib.GException; 82 private import gdkpixbuf.PixbufAnimationIter; 83 private import gdk.Pixbuf; 84 private import glib.Str; 85 private import gio.InputStream; 86 private import gio.Cancellable; 87 private import gio.AsyncResultIF; 88 89 90 91 private import gobject.ObjectG; 92 93 /** 94 * The GdkPixBuf library provides a simple mechanism to load and 95 * represent animations. An animation is conceptually a series of 96 * frames to be displayed over time. The animation may not be 97 * represented as a series of frames internally; for example, it may 98 * be stored as a sprite and instructions for moving the sprite around 99 * a background. To display an animation you don't need to understand 100 * its representation, however; you just ask GdkPixBuf what should 101 * be displayed at a given point in time. 102 */ 103 public class PixbufAnimation : ObjectG 104 { 105 106 /** the main Gtk struct */ 107 protected GdkPixbufAnimation* gdkPixbufAnimation; 108 109 110 public GdkPixbufAnimation* getPixbufAnimationStruct() 111 { 112 return gdkPixbufAnimation; 113 } 114 115 116 /** the main Gtk struct as a void* */ 117 protected override void* getStruct() 118 { 119 return cast(void*)gdkPixbufAnimation; 120 } 121 122 /** 123 * Sets our main struct and passes it to the parent class 124 */ 125 public this (GdkPixbufAnimation* gdkPixbufAnimation) 126 { 127 super(cast(GObject*)gdkPixbufAnimation); 128 this.gdkPixbufAnimation = gdkPixbufAnimation; 129 } 130 131 protected override void setStruct(GObject* obj) 132 { 133 super.setStruct(obj); 134 gdkPixbufAnimation = cast(GdkPixbufAnimation*)obj; 135 } 136 137 /** 138 * Creates a new pixbuf animation by loading an image from an resource. 139 * The file format is detected automatically. If NULL is returned, then 140 * error will be set. 141 * Since 2.28 142 * Params: 143 * resourcePath = the path of the resource file 144 * Throws: GException on failure. 145 * Throws: ConstructionException GTK+ fails to create the object. 146 */ 147 public static PixbufAnimation newFromResource(string resourcePath) 148 { 149 // GdkPixbufAnimation * gdk_pixbuf_animation_new_from_resource (const char *resource_path, GError **error); 150 GError* err = null; 151 152 auto p = gdk_pixbuf_animation_new_from_resource(Str.toStringz(resourcePath), &err); 153 154 if (err !is null) 155 { 156 throw new GException( new ErrorG(err) ); 157 } 158 159 if(p is null) 160 { 161 throw new ConstructionException("null returned by gdk_pixbuf_animation_new_from_resource(Str.toStringz(resourcePath), &err)"); 162 } 163 164 return new PixbufAnimation(cast(GdkPixbufAnimation*) p); 165 } 166 167 /** 168 */ 169 170 /** 171 * Creates a new animation by loading it from a file. The file format is 172 * detected automatically. If the file's format does not support multi-frame 173 * images, then an animation with a single frame will be created. Possible errors 174 * are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains. 175 * Params: 176 * filename = Name of file to load, in the GLib file name encoding 177 * Throws: GException on failure. 178 * Throws: ConstructionException GTK+ fails to create the object. 179 */ 180 public this (string filename) 181 { 182 // GdkPixbufAnimation * gdk_pixbuf_animation_new_from_file (const char *filename, GError **error); 183 GError* err = null; 184 185 auto p = gdk_pixbuf_animation_new_from_file(Str.toStringz(filename), &err); 186 187 if (err !is null) 188 { 189 throw new GException( new ErrorG(err) ); 190 } 191 192 if(p is null) 193 { 194 throw new ConstructionException("null returned by gdk_pixbuf_animation_new_from_file(Str.toStringz(filename), &err)"); 195 } 196 this(cast(GdkPixbufAnimation*) p); 197 } 198 199 /** 200 * Creates a new animation by loading it from an input stream. 201 * The file format is detected automatically. If NULL is returned, then 202 * error will be set. The cancellable can be used to abort the operation 203 * from another thread. If the operation was cancelled, the error 204 * G_IO_ERROR_CANCELLED will be returned. Other possible errors are in 205 * the GDK_PIXBUF_ERROR and G_IO_ERROR domains. 206 * The stream is not closed. 207 * Since 2.28 208 * Params: 209 * stream = a GInputStream to load the pixbuf from 210 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 211 * Throws: GException on failure. 212 * Throws: ConstructionException GTK+ fails to create the object. 213 */ 214 public this (InputStream stream, Cancellable cancellable) 215 { 216 // GdkPixbufAnimation * gdk_pixbuf_animation_new_from_stream (GInputStream *stream, GCancellable *cancellable, GError **error); 217 GError* err = null; 218 219 auto p = gdk_pixbuf_animation_new_from_stream((stream is null) ? null : stream.getInputStreamStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 220 221 if (err !is null) 222 { 223 throw new GException( new ErrorG(err) ); 224 } 225 226 if(p is null) 227 { 228 throw new ConstructionException("null returned by gdk_pixbuf_animation_new_from_stream((stream is null) ? null : stream.getInputStreamStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err)"); 229 } 230 this(cast(GdkPixbufAnimation*) p); 231 } 232 233 /** 234 * Creates a new animation by asynchronously loading an image from an input stream. 235 * For more details see gdk_pixbuf_new_from_stream(), which is the synchronous 236 * version of this function. 237 * When the operation is finished, callback will be called in the main thread. 238 * You can then call gdk_pixbuf_animation_new_from_stream_finish() to get the 239 * result of the operation. 240 * Since 2.28 241 * Params: 242 * stream = a GInputStream from which to load the animation 243 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 244 * callback = a GAsyncReadyCallback to call when the the pixbuf is loaded 245 * userData = the data to pass to the callback function 246 */ 247 public static void newFromStreamAsync(InputStream stream, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 248 { 249 // void gdk_pixbuf_animation_new_from_stream_async (GInputStream *stream, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 250 gdk_pixbuf_animation_new_from_stream_async((stream is null) ? null : stream.getInputStreamStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 251 } 252 253 /** 254 * Finishes an asynchronous pixbuf animation creation operation started with 255 * gdk_pixbuf_animation_new_from_stream_async(). 256 * Since 2.28 257 * Params: 258 * asyncResult = a GAsyncResult 259 * Throws: GException on failure. 260 * Throws: ConstructionException GTK+ fails to create the object. 261 */ 262 public this (AsyncResultIF asyncResult) 263 { 264 // GdkPixbufAnimation * gdk_pixbuf_animation_new_from_stream_finish (GAsyncResult *async_result, GError **error); 265 GError* err = null; 266 267 auto p = gdk_pixbuf_animation_new_from_stream_finish((asyncResult is null) ? null : asyncResult.getAsyncResultTStruct(), &err); 268 269 if (err !is null) 270 { 271 throw new GException( new ErrorG(err) ); 272 } 273 274 if(p is null) 275 { 276 throw new ConstructionException("null returned by gdk_pixbuf_animation_new_from_stream_finish((asyncResult is null) ? null : asyncResult.getAsyncResultTStruct(), &err)"); 277 } 278 this(cast(GdkPixbufAnimation*) p); 279 } 280 281 /** 282 * Queries the width of the bounding box of a pixbuf animation. 283 * Returns: Width of the bounding box of the animation. 284 */ 285 public int getWidth() 286 { 287 // int gdk_pixbuf_animation_get_width (GdkPixbufAnimation *animation); 288 return gdk_pixbuf_animation_get_width(gdkPixbufAnimation); 289 } 290 291 /** 292 * Queries the height of the bounding box of a pixbuf animation. 293 * Returns: Height of the bounding box of the animation. 294 */ 295 public int getHeight() 296 { 297 // int gdk_pixbuf_animation_get_height (GdkPixbufAnimation *animation); 298 return gdk_pixbuf_animation_get_height(gdkPixbufAnimation); 299 } 300 301 /** 302 * Get an iterator for displaying an animation. The iterator provides 303 * the frames that should be displayed at a given time. 304 * It should be freed after use with g_object_unref(). 305 * start_time would normally come from g_get_current_time(), and 306 * marks the beginning of animation playback. After creating an 307 * iterator, you should immediately display the pixbuf returned by 308 * gdk_pixbuf_animation_iter_get_pixbuf(). Then, you should install a 309 * timeout (with g_timeout_add()) or by some other mechanism ensure 310 * that you'll update the image after 311 * gdk_pixbuf_animation_iter_get_delay_time() milliseconds. Each time 312 * the image is updated, you should reinstall the timeout with the new, 313 * possibly-changed delay time. 314 * As a shortcut, if start_time is NULL, the result of 315 * g_get_current_time() will be used automatically. 316 * To update the image (i.e. possibly change the result of 317 * gdk_pixbuf_animation_iter_get_pixbuf() to a new frame of the animation), 318 * call gdk_pixbuf_animation_iter_advance(). 319 * If you're using GdkPixbufLoader, in addition to updating the image 320 * after the delay time, you should also update it whenever you 321 * receive the area_updated signal and 322 * gdk_pixbuf_animation_iter_on_currently_loading_frame() returns 323 * TRUE. In this case, the frame currently being fed into the loader 324 * has received new data, so needs to be refreshed. The delay time for 325 * a frame may also be modified after an area_updated signal, for 326 * example if the delay time for a frame is encoded in the data after 327 * the frame itself. So your timeout should be reinstalled after any 328 * area_updated signal. 329 * A delay time of -1 is possible, indicating "infinite." 330 * Params: 331 * startTime = time when the animation starts playing. [allow-none] 332 * Returns: an iterator to move over the animation. [transfer full] 333 */ 334 public PixbufAnimationIter getIter(ref GTimeVal startTime) 335 { 336 // GdkPixbufAnimationIter * gdk_pixbuf_animation_get_iter (GdkPixbufAnimation *animation, const GTimeVal *start_time); 337 auto p = gdk_pixbuf_animation_get_iter(gdkPixbufAnimation, &startTime); 338 339 if(p is null) 340 { 341 return null; 342 } 343 344 return ObjectG.getDObject!(PixbufAnimationIter)(cast(GdkPixbufAnimationIter*) p); 345 } 346 347 /** 348 * If you load a file with gdk_pixbuf_animation_new_from_file() and it turns 349 * out to be a plain, unanimated image, then this function will return 350 * TRUE. Use gdk_pixbuf_animation_get_static_image() to retrieve 351 * the image. 352 * Returns: TRUE if the "animation" was really just an image 353 */ 354 public int isStaticImage() 355 { 356 // gboolean gdk_pixbuf_animation_is_static_image (GdkPixbufAnimation *animation); 357 return gdk_pixbuf_animation_is_static_image(gdkPixbufAnimation); 358 } 359 360 /** 361 * If an animation is really just a plain image (has only one frame), 362 * this function returns that image. If the animation is an animation, 363 * this function returns a reasonable thing to display as a static 364 * unanimated image, which might be the first frame, or something more 365 * sophisticated. If an animation hasn't loaded any frames yet, this 366 * function will return NULL. 367 * Returns: unanimated image representing the animation. [transfer none] 368 */ 369 public Pixbuf getStaticImage() 370 { 371 // GdkPixbuf * gdk_pixbuf_animation_get_static_image (GdkPixbufAnimation *animation); 372 auto p = gdk_pixbuf_animation_get_static_image(gdkPixbufAnimation); 373 374 if(p is null) 375 { 376 return null; 377 } 378 379 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 380 } 381 }