/soc/2013/ankitkv/gobjectification: 2cfb31e2f6dd: Added note to ...

Ankit Vani a at nevitus.org
Mon Jul 15 10:15:42 EDT 2013


Changeset: 2cfb31e2f6dd0f9259588f03c761411f7df717ff
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-15 19:41 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/2cfb31e2f6dd

Description:

Added note to make buddy icon a GObject. Made GBoxed copy return a copy instead of creating a new buddy icon.

diffstat:

 libpurple/buddyicon.c |  9 +++++----
 libpurple/buddyicon.h |  4 ++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diffs (54 lines):

diff --git a/libpurple/buddyicon.c b/libpurple/buddyicon.c
--- a/libpurple/buddyicon.c
+++ b/libpurple/buddyicon.c
@@ -1135,9 +1135,10 @@ void purple_buddy_icon_get_scale_size(Pu
 static PurpleBuddyIcon *
 purple_buddy_icon_copy(PurpleBuddyIcon *icon)
 {
-	return purple_buddy_icon_new(icon->account, icon->username,
-			(void *)purple_imgstore_get_data(icon->img),
-			purple_imgstore_get_size(icon->img), icon->checksum);
+	PurpleBuddyIcon *icon_copy = g_new(PurpleBuddyIcon, 1);
+	*icon_copy = *icon;
+
+	return icon_copy;
 }
 
 GType
@@ -1148,7 +1149,7 @@ purple_buddy_icon_get_type(void)
 	if (type == 0) {
 		type = g_boxed_type_register_static("PurpleBuddyIcon",
 				(GBoxedCopyFunc)purple_buddy_icon_copy,
-				(GBoxedFreeFunc)purple_buddy_icon_unref);
+				(GBoxedFreeFunc)g_free);
 	}
 
 	return type;
diff --git a/libpurple/buddyicon.h b/libpurple/buddyicon.h
--- a/libpurple/buddyicon.h
+++ b/libpurple/buddyicon.h
@@ -50,6 +50,8 @@ G_BEGIN_DECLS
 
 /**
  * Returns the GType for the PurpleBuddyIcon boxed structure.
+ * TODO Boxing of PurpleBuddyIcon is a temporary solution to having a GType for
+ *      icons. This should rather be a GObject instead of a GBoxed.
  */
 GType purple_buddy_icon_get_type(void);
 
@@ -73,6 +75,7 @@ PurpleBuddyIcon *purple_buddy_icon_new(P
 
 /**
  * Increments the reference count on a buddy icon.
+ * TODO This can be removed when PurpleBuddyIcon is a GObject.
  *
  * @param icon The buddy icon.
  *
@@ -82,6 +85,7 @@ PurpleBuddyIcon *purple_buddy_icon_ref(P
 
 /**
  * Decrements the reference count on a buddy icon.
+ * TODO This can be removed when PurpleBuddyIcon is a GObject.
  *
  * If the reference count reaches 0, the icon will be destroyed.
  *



More information about the Commits mailing list