/pidgin/main: a804a812858c: PurpleImage: add be_eager param to p...
Tomasz Wasilczyk
twasilczyk at pidgin.im
Wed Apr 9 13:55:00 EDT 2014
Changeset: a804a812858cb95aef62f5f94a152d0e20c7c0c7
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2014-04-09 19:54 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/a804a812858c
Description:
PurpleImage: add be_eager param to purple_image_new_from_file
diffstat:
libpurple/image.c | 20 ++++++++++++++++++--
libpurple/image.h | 2 +-
2 files changed, 19 insertions(+), 3 deletions(-)
diffs (48 lines):
diff --git a/libpurple/image.c b/libpurple/image.c
--- a/libpurple/image.c
+++ b/libpurple/image.c
@@ -151,14 +151,30 @@ fill_data(PurpleImage *image)
******************************************************************************/
PurpleImage *
-purple_image_new_from_file(const gchar *path)
+purple_image_new_from_file(const gchar *path, gboolean be_eager)
{
+ PurpleImage *img;
+
g_return_val_if_fail(path != NULL, NULL);
g_return_val_if_fail(g_file_test(path, G_FILE_TEST_EXISTS), NULL);
- return g_object_new(PURPLE_TYPE_IMAGE,
+ img = g_object_new(PURPLE_TYPE_IMAGE,
"path", path,
NULL);
+
+ if (be_eager) {
+ PurpleImagePrivate *priv = PURPLE_IMAGE_GET_PRIVATE(img);
+
+ fill_data(img);
+ if (!priv->contents) {
+ g_object_unref(img);
+ return NULL;
+ }
+
+ g_assert(priv->is_ready && !priv->has_failed);
+ }
+
+ return img;
}
PurpleImage *
diff --git a/libpurple/image.h b/libpurple/image.h
--- a/libpurple/image.h
+++ b/libpurple/image.h
@@ -81,7 +81,7 @@ GType
purple_image_get_type(void);
PurpleImage *
-purple_image_new_from_file(const gchar *path);
+purple_image_new_from_file(const gchar *path, gboolean be_eager);
PurpleImage *
purple_image_new_from_data(gpointer data, gsize length);
More information about the Commits
mailing list