Mercurial > pidgin.yaz
changeset 22886:0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 07 Mar 2008 23:14:23 +0000 |
parents | e04a69cf1d8e |
children | b65997110933 |
files | libpurple/imgstore.c libpurple/imgstore.h |
diffstat | 2 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/imgstore.c Fri Mar 07 21:32:09 2008 +0000 +++ b/libpurple/imgstore.c Fri Mar 07 23:14:23 2008 +0000 @@ -70,6 +70,22 @@ return img; } +PurpleStoredImage * +purple_imgstore_new_from_file(const char *path) +{ + gchar *data = NULL; + size_t len; + GError *err = NULL; + + if (!g_file_get_contents(path, &data, &len, &err)) { + purple_debug_error("imgstore", "Error reading %s: %s\n", + path, err->message); + g_error_free(err); + return NULL; + } + return purple_imgstore_add(data, len, path); +} + int purple_imgstore_add_with_id(gpointer data, size_t size, const char *filename) {
--- a/libpurple/imgstore.h Fri Mar 07 21:32:09 2008 +0000 +++ b/libpurple/imgstore.h Fri Mar 07 23:14:23 2008 +0000 @@ -56,6 +56,17 @@ purple_imgstore_add(gpointer data, size_t size, const char *filename); /** + * Create an image and add it to the store. + * + * @param path The path to the image. + * + * @return The stored image. + * @since 2.X.X + */ +PurpleStoredImage * +purple_imgstore_new_from_file(const char *path); + +/** * Add an image to the store, allocating an ID. * * The caller owns a reference to the image in the store, and must dereference