pidgin.custom_smiley: b8fd9375: Make it simple to create a stored-image ...

sadrul at pidgin.im sadrul at pidgin.im
Fri Mar 7 18:16:15 EST 2008


-----------------------------------------------------------------
Revision: b8fd9375fe55bcbe6ab48b64c11e5266ec1ac292
Ancestor: 6e4fd05eaddd93b079ba508657f640b1a1df9e55
Author: sadrul at pidgin.im
Date: 2008-03-07T23:14:23
Branch: im.pidgin.pidgin.custom_smiley
URL: http://d.pidgin.im/viewmtn/revision/info/b8fd9375fe55bcbe6ab48b64c11e5266ec1ac292

Modified files:
        libpurple/imgstore.c libpurple/imgstore.h

ChangeLog: 

Make it simple to create a stored-image from a filename.

-------------- next part --------------
============================================================
--- libpurple/imgstore.c	3aaae04427bdf9b88782c2d3b0d82c1e7f4983bc
+++ libpurple/imgstore.c	ddc848deca6527f6d74b503c6a70fffaa88e90d2
@@ -70,6 +70,22 @@ purple_imgstore_add(gpointer data, size_
 	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)
 {
============================================================
--- libpurple/imgstore.h	234f2755c6f3051ddef06a228ef133b2b57284b8
+++ libpurple/imgstore.h	7085b34d10cfb1239ee6f6e48082315ba05244f0
@@ -56,6 +56,17 @@ purple_imgstore_add(gpointer data, size_
 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


More information about the Commits mailing list