diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-08-25 11:57:04 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-08-25 11:57:04 -0400 |
commit | 58a094163919dacd4c3853dfe0c6020538c2bb99 (patch) | |
tree | 3ec859983ec0a26c2bf1c4d61d70bf42a9a41bdc /gdk-pixbuf/gdk-pixbuf-animation.c | |
parent | 3bdf3b74b3c0e535392b540458095f7a95ba11e7 (diff) | |
download | gdk-pixbuf-58a094163919dacd4c3853dfe0c6020538c2bb99.tar.gz |
Formatting fixes
Diffstat (limited to 'gdk-pixbuf/gdk-pixbuf-animation.c')
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-animation.c | 202 |
1 files changed, 94 insertions, 108 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf-animation.c b/gdk-pixbuf/gdk-pixbuf-animation.c index f80898ff5..191335a9d 100644 --- a/gdk-pixbuf/gdk-pixbuf-animation.c +++ b/gdk-pixbuf/gdk-pixbuf-animation.c @@ -33,7 +33,7 @@ * @Short_description: Animated images. * @Title: Animations * @See_also: #GdkPixbufLoader. - * + * * The GdkPixBuf library provides a simple mechanism to load and * represent animations. An animation is conceptually a series of * frames to be displayed over time. The animation may not be @@ -42,7 +42,6 @@ * a background. To display an animation you don't need to understand * its representation, however; you just ask GdkPixBuf what should * be displayed at a given point in time. - * */ typedef struct _GdkPixbufNonAnim GdkPixbufNonAnim; @@ -65,7 +64,6 @@ struct _GdkPixbufNonAnim { struct _GdkPixbufNonAnimClass { GdkPixbufAnimationClass parent_class; - }; @@ -107,9 +105,9 @@ gdk_pixbuf_animation_init (GdkPixbufAnimation *animation) } static void -prepared_notify (GdkPixbuf *pixbuf, - GdkPixbufAnimation *anim, - gpointer user_data) +prepared_notify (GdkPixbuf *pixbuf, + GdkPixbufAnimation *anim, + gpointer user_data) { if (anim != NULL) g_object_ref (anim); @@ -124,8 +122,8 @@ prepared_notify (GdkPixbuf *pixbuf, * @filename: Name of file to load, in the GLib file name encoding * @error: return location for error * - * Creates a new animation by loading it from a file. The file format is - * detected automatically. If the file's format does not support multi-frame + * Creates a new animation by loading it from a file. The file format is + * detected automatically. If the file's format does not support multi-frame * images, then an animation with a single frame will be created. Possible errors * are in the #GDK_PIXBUF_ERROR and #G_FILE_ERROR domains. * @@ -133,15 +131,15 @@ prepared_notify (GdkPixbuf *pixbuf, * if any of several error conditions ocurred: the file could not be opened, * there was no loader for the file's format, there was not enough memory to * allocate the image buffer, or the image file contained invalid data. - **/ + */ GdkPixbufAnimation * -gdk_pixbuf_animation_new_from_file (const char *filename, - GError **error) +gdk_pixbuf_animation_new_from_file (const gchar *filename, + GError **error) { GdkPixbufAnimation *animation; int size; FILE *f; - guchar buffer [SNIFF_BUFFER_SIZE]; + guchar buffer[SNIFF_BUFFER_SIZE]; GdkPixbufModule *image_module; gchar *display_name; @@ -201,7 +199,6 @@ gdk_pixbuf_animation_new_from_file (const char *filename, * the invariant that error gets set if NULL * is returned. */ - g_warning ("Bug! gdk-pixbuf loader '%s' didn't set an error on failure.", image_module->module_name); g_set_error (error, @@ -210,7 +207,7 @@ gdk_pixbuf_animation_new_from_file (const char *filename, _("Failed to load animation '%s': reason not known, probably a corrupt animation file"), display_name); } - + fclose (f); } else if (image_module->begin_load != NULL) { guchar buffer[4096]; @@ -225,7 +222,7 @@ gdk_pixbuf_animation_new_from_file (const char *filename, context = image_module->begin_load (NULL, prepared_notify, NULL, &animation, error); if (!context) goto fail_begin_load; - + while (!feof (f) && !ferror (f)) { length = fread (buffer, 1, sizeof (buffer), f); if (length > 0) { @@ -269,7 +266,7 @@ fail_begin_load: * want user code to segfault as a result. We need to maintain * the invariant that error gets set if NULL is returned. */ - + g_warning ("Bug! gdk-pixbuf loader '%s' didn't set an error on failure.", image_module->module_name); g_set_error (error, @@ -278,7 +275,7 @@ fail_begin_load: _("Failed to load image '%s': reason not known, probably a corrupt image file"), display_name); } - + if (pixbuf == NULL) { g_free (display_name); animation = NULL; @@ -301,13 +298,14 @@ fail_begin_load: #undef gdk_pixbuf_animation_new_from_file GdkPixbufAnimation * -gdk_pixbuf_animation_new_from_file (const char *filename, - GError **error) +gdk_pixbuf_animation_new_from_file (const gchar *filename, + GError **error) { - gchar *utf8_filename = - g_locale_to_utf8 (filename, -1, NULL, NULL, error); + gchar *utf8_filename; GdkPixbufAnimation *retval; + utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, error); + if (utf8_filename == NULL) return NULL; @@ -328,25 +326,25 @@ gdk_pixbuf_animation_new_from_file (const char *filename, * * Creates a new animation by loading it from an input stream. * - * The file format is detected automatically. If %NULL is returned, then + * The file format is detected automatically. If %NULL is returned, then * @error will be set. The @cancellable can be used to abort the operation - * from another thread. If the operation was cancelled, the error - * %G_IO_ERROR_CANCELLED will be returned. Other possible errors are in - * the #GDK_PIXBUF_ERROR and %G_IO_ERROR domains. + * from another thread. If the operation was cancelled, the error + * %G_IO_ERROR_CANCELLED will be returned. Other possible errors are in + * the #GDK_PIXBUF_ERROR and %G_IO_ERROR domains. * * The stream is not closed. * - * Return value: A newly-created pixbuf, or %NULL if any of several error - * conditions occurred: the file could not be opened, the image format is - * not supported, there was not enough memory to allocate the image buffer, + * Return value: A newly-created pixbuf, or %NULL if any of several error + * conditions occurred: the file could not be opened, the image format is + * not supported, there was not enough memory to allocate the image buffer, * the stream contained invalid data, or the operation was cancelled. * * Since: 2.28 - **/ + */ GdkPixbufAnimation * -gdk_pixbuf_animation_new_from_stream (GInputStream *stream, - GCancellable *cancellable, - GError **error) +gdk_pixbuf_animation_new_from_stream (GInputStream *stream, + GCancellable *cancellable, + GError **error) { GdkPixbufAnimation *animation; GdkPixbufLoader *loader; @@ -361,12 +359,8 @@ gdk_pixbuf_animation_new_from_stream (GInputStream *stream, loader = gdk_pixbuf_loader_new (); res = TRUE; - while (1) { - n_read = g_input_stream_read (stream, - buffer, - sizeof (buffer), - cancellable, - error); + while (1) { + n_read = g_input_stream_read (stream, buffer, sizeof (buffer), cancellable, error); if (n_read < 0) { res = FALSE; error = NULL; /* Ignore further errors */ @@ -376,10 +370,7 @@ gdk_pixbuf_animation_new_from_stream (GInputStream *stream, if (n_read == 0) break; - if (!gdk_pixbuf_loader_write (loader, - buffer, - n_read, - error)) { + if (!gdk_pixbuf_loader_write (loader, buffer, n_read, error)) { res = FALSE; error = NULL; break; @@ -504,10 +495,10 @@ gdk_pixbuf_animation_new_from_stream_finish (GAsyncResult *async_result, * the stream contained invalid data, or the operation was cancelled. * * Since: 2.28 - **/ + */ GdkPixbufAnimation * -gdk_pixbuf_animation_new_from_resource (const char *resource_path, - GError **error) +gdk_pixbuf_animation_new_from_resource (const gchar *resource_path, + GError **error) { GInputStream *stream; GdkPixbufAnimation *anim; @@ -538,7 +529,7 @@ gdk_pixbuf_animation_new_from_resource (const char *resource_path, * Return value: The same as the @animation argument. * * Deprecated: 2.0: Use g_object_ref(). - **/ + */ GdkPixbufAnimation * gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation) { @@ -552,7 +543,7 @@ gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation) * Removes a reference from an animation. * * Deprecated: 2.0: Use g_object_unref(). - **/ + */ void gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation) { @@ -562,14 +553,14 @@ gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation) /** * gdk_pixbuf_animation_is_static_image: * @animation: a #GdkPixbufAnimation - * - * If you load a file with gdk_pixbuf_animation_new_from_file() and it turns - * out to be a plain, unanimated image, then this function will return - * %TRUE. Use gdk_pixbuf_animation_get_static_image() to retrieve + * + * If you load a file with gdk_pixbuf_animation_new_from_file() and it + * turns out to be a plain, unanimated image, then this function will + * return %TRUE. Use gdk_pixbuf_animation_get_static_image() to retrieve * the image. - * + * * Return value: %TRUE if the "animation" was really just an image - **/ + */ gboolean gdk_pixbuf_animation_is_static_image (GdkPixbufAnimation *animation) { @@ -581,21 +572,21 @@ gdk_pixbuf_animation_is_static_image (GdkPixbufAnimation *animation) /** * gdk_pixbuf_animation_get_static_image: * @animation: a #GdkPixbufAnimation - * + * * If an animation is really just a plain image (has only one frame), * this function returns that image. If the animation is an animation, * this function returns a reasonable thing to display as a static * unanimated image, which might be the first frame, or something more * sophisticated. If an animation hasn't loaded any frames yet, this * function will return %NULL. - * + * * Return value: (transfer none): unanimated image representing the animation - **/ + */ GdkPixbuf* gdk_pixbuf_animation_get_static_image (GdkPixbufAnimation *animation) { g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION (animation), NULL); - + return GDK_PIXBUF_ANIMATION_GET_CLASS (animation)->get_static_image (animation); } @@ -604,20 +595,19 @@ gdk_pixbuf_animation_get_static_image (GdkPixbufAnimation *animation) * @animation: An animation. * * Queries the width of the bounding box of a pixbuf animation. - * + * * Return value: Width of the bounding box of the animation. - **/ -int + */ +gint gdk_pixbuf_animation_get_width (GdkPixbufAnimation *animation) { - int width; - + gint width; + g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION (animation), 0); width = 0; GDK_PIXBUF_ANIMATION_GET_CLASS (animation)->get_size (animation, &width, NULL); - return width; } @@ -627,20 +617,19 @@ gdk_pixbuf_animation_get_width (GdkPixbufAnimation *animation) * @animation: An animation. * * Queries the height of the bounding box of a pixbuf animation. - * + * * Return value: Height of the bounding box of the animation. - **/ -int + */ +gint gdk_pixbuf_animation_get_height (GdkPixbufAnimation *animation) { - int height; - + gint height; + g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION (animation), 0); height = 0; GDK_PIXBUF_ANIMATION_GET_CLASS (animation)->get_size (animation, NULL, &height); - return height; } @@ -650,16 +639,16 @@ gdk_pixbuf_animation_get_height (GdkPixbufAnimation *animation) * gdk_pixbuf_animation_get_iter: * @animation: a #GdkPixbufAnimation * @start_time: (allow-none): time when the animation starts playing - * + * * Get an iterator for displaying an animation. The iterator provides - * the frames that should be displayed at a given time. - * It should be freed after use with g_object_unref(). - * - * @start_time would normally come from g_get_current_time(), and - * marks the beginning of animation playback. After creating an - * iterator, you should immediately display the pixbuf returned by - * gdk_pixbuf_animation_iter_get_pixbuf(). Then, you should install a - * timeout (with g_timeout_add()) or by some other mechanism ensure + * the frames that should be displayed at a given time. It should be + * freed after use with g_object_unref(). + * + * @start_time would normally come from g_get_current_time(), and marks + * the beginning of animation playback. After creating an iterator, you + * should immediately display the pixbuf returned by + * gdk_pixbuf_animation_iter_get_pixbuf(). Then, you should install + * a timeout (with g_timeout_add()) or by some other mechanism ensure * that you'll update the image after * gdk_pixbuf_animation_iter_get_delay_time() milliseconds. Each time * the image is updated, you should reinstall the timeout with the new, @@ -684,15 +673,15 @@ gdk_pixbuf_animation_get_height (GdkPixbufAnimation *animation) * area_updated signal. * * A delay time of -1 is possible, indicating "infinite." - * + * * Return value: (transfer full): an iterator to move over the animation - **/ + */ GdkPixbufAnimationIter* gdk_pixbuf_animation_get_iter (GdkPixbufAnimation *animation, const GTimeVal *start_time) { GTimeVal val; - + g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION (animation), NULL); @@ -700,7 +689,7 @@ gdk_pixbuf_animation_get_iter (GdkPixbufAnimation *animation, val = *start_time; else g_get_current_time (&val); - + return GDK_PIXBUF_ANIMATION_GET_CLASS (animation)->get_iter (animation, &val); } @@ -730,8 +719,8 @@ gdk_pixbuf_animation_iter_init (GdkPixbufAnimationIter *iter) * for GIF images is currently 20 milliseconds. * * Return value: delay time in milliseconds (thousandths of a second) - **/ -int + */ +gint gdk_pixbuf_animation_iter_get_delay_time (GdkPixbufAnimationIter *iter) { g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION_ITER (iter), -1); @@ -743,12 +732,12 @@ gdk_pixbuf_animation_iter_get_delay_time (GdkPixbufAnimationIter *iter) /** * gdk_pixbuf_animation_iter_get_pixbuf: * @iter: an animation iterator - * + * * Gets the current pixbuf which should be displayed; the pixbuf might not * be the same size as the animation itself - * (gdk_pixbuf_animation_get_width(), gdk_pixbuf_animation_get_height()). - * This pixbuf should be displayed for - * gdk_pixbuf_animation_iter_get_delay_time() milliseconds. The caller + * (gdk_pixbuf_animation_get_width(), gdk_pixbuf_animation_get_height()). + * This pixbuf should be displayed for + * gdk_pixbuf_animation_iter_get_delay_time() milliseconds. The caller * of this function does not own a reference to the returned pixbuf; * the returned pixbuf will become invalid when the iterator advances * to the next frame, which may happen anytime you call @@ -757,7 +746,7 @@ gdk_pixbuf_animation_iter_get_delay_time (GdkPixbufAnimationIter *iter) * the iterator. * * Return value: (transfer none): the pixbuf to be displayed - **/ + */ GdkPixbuf* gdk_pixbuf_animation_iter_get_pixbuf (GdkPixbufAnimationIter *iter) { @@ -778,7 +767,7 @@ gdk_pixbuf_animation_iter_get_pixbuf (GdkPixbufAnimationIter *iter) * the updated area. * * Return value: %TRUE if the frame we're on is partially loaded, or the last frame - **/ + */ gboolean gdk_pixbuf_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter) { @@ -814,8 +803,7 @@ gdk_pixbuf_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *it * and update the display with the new pixbuf. * * Returns: %TRUE if the image may need updating - * - **/ + */ gboolean gdk_pixbuf_animation_iter_advance (GdkPixbufAnimationIter *iter, const GTimeVal *current_time) @@ -837,8 +825,8 @@ static void gdk_pixbuf_non_anim_finalize (GObject static gboolean gdk_pixbuf_non_anim_is_static_image (GdkPixbufAnimation *animation); static GdkPixbuf* gdk_pixbuf_non_anim_get_static_image (GdkPixbufAnimation *animation); static void gdk_pixbuf_non_anim_get_size (GdkPixbufAnimation *anim, - int *width, - int *height); + gint *width, + gint *height); static GdkPixbufAnimationIter* gdk_pixbuf_non_anim_get_iter (GdkPixbufAnimation *anim, const GTimeVal *start_time); @@ -849,7 +837,7 @@ gdk_pixbuf_non_anim_class_init (GdkPixbufNonAnimClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GdkPixbufAnimationClass *anim_class = GDK_PIXBUF_ANIMATION_CLASS (klass); - + object_class->finalize = gdk_pixbuf_non_anim_finalize; anim_class->is_static_image = gdk_pixbuf_non_anim_is_static_image; @@ -870,7 +858,7 @@ gdk_pixbuf_non_anim_finalize (GObject *object) if (non_anim->pixbuf) g_object_unref (non_anim->pixbuf); - + G_OBJECT_CLASS (gdk_pixbuf_non_anim_parent_class)->finalize (object); } @@ -890,7 +878,7 @@ gdk_pixbuf_non_anim_new (GdkPixbuf *pixbuf) } static gboolean -gdk_pixbuf_non_anim_is_static_image (GdkPixbufAnimation *animation) +gdk_pixbuf_non_anim_is_static_image (GdkPixbufAnimation *animation) { return TRUE; @@ -908,8 +896,8 @@ gdk_pixbuf_non_anim_get_static_image (GdkPixbufAnimation *animation) static void gdk_pixbuf_non_anim_get_size (GdkPixbufAnimation *anim, - int *width, - int *height) + gint *width, + gint *height) { GdkPixbufNonAnim *non_anim; @@ -933,20 +921,18 @@ gdk_pixbuf_non_anim_get_iter (GdkPixbufAnimation *anim, iter->non_anim = GDK_PIXBUF_NON_ANIM (anim); g_object_ref (iter->non_anim); - + return GDK_PIXBUF_ANIMATION_ITER (iter); } static void gdk_pixbuf_non_anim_iter_finalize (GObject *object); -static int gdk_pixbuf_non_anim_iter_get_delay_time (GdkPixbufAnimationIter *iter); +static gint gdk_pixbuf_non_anim_iter_get_delay_time (GdkPixbufAnimationIter *iter); static GdkPixbuf* gdk_pixbuf_non_anim_iter_get_pixbuf (GdkPixbufAnimationIter *iter); static gboolean gdk_pixbuf_non_anim_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter); static gboolean gdk_pixbuf_non_anim_iter_advance (GdkPixbufAnimationIter *iter, const GTimeVal *current_time); -G_DEFINE_TYPE (GdkPixbufNonAnimIter, - gdk_pixbuf_non_anim_iter, - GDK_TYPE_PIXBUF_ANIMATION_ITER); +G_DEFINE_TYPE (GdkPixbufNonAnimIter, gdk_pixbuf_non_anim_iter, GDK_TYPE_PIXBUF_ANIMATION_ITER) static void gdk_pixbuf_non_anim_iter_class_init (GdkPixbufNonAnimIterClass *klass) @@ -954,7 +940,7 @@ gdk_pixbuf_non_anim_iter_class_init (GdkPixbufNonAnimIterClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); GdkPixbufAnimationIterClass *anim_iter_class = GDK_PIXBUF_ANIMATION_ITER_CLASS (klass); - + object_class->finalize = gdk_pixbuf_non_anim_iter_finalize; anim_iter_class->get_delay_time = gdk_pixbuf_non_anim_iter_get_delay_time; @@ -974,11 +960,11 @@ gdk_pixbuf_non_anim_iter_finalize (GObject *object) GdkPixbufNonAnimIter *iter = GDK_PIXBUF_NON_ANIM_ITER (object); g_object_unref (iter->non_anim); - + G_OBJECT_CLASS (gdk_pixbuf_non_anim_iter_parent_class)->finalize (object); } -static int +static gint gdk_pixbuf_non_anim_iter_get_delay_time (GdkPixbufAnimationIter *iter) { return -1; /* show only frame forever */ @@ -996,7 +982,7 @@ gdk_pixbuf_non_anim_iter_on_currently_loading_frame (GdkPixbufAnimationIter *ite { return TRUE; } - + static gboolean gdk_pixbuf_non_anim_iter_advance (GdkPixbufAnimationIter *iter, const GTimeVal *current_time) |