/soc/2013/ankitkv/gobjectification: d193657a4b37: Added GBoxed w...

Ankit Vani a at nevitus.org
Sun Jul 14 05:39:06 EDT 2013


Changeset: d193657a4b371e5451c6a94d6e8c06380d0a0b79
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-14 14:39 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/d193657a4b37

Description:

Added GBoxed wrapping to PurpleBuddyIcon

diffstat:

 libpurple/blistnodetypes.c    |   8 ++++----
 libpurple/buddyicon.c         |  22 ++++++++++++++++++++++
 libpurple/buddyicon.h         |   7 +++++++
 libpurple/conversationtypes.c |   8 ++++----
 4 files changed, 37 insertions(+), 8 deletions(-)

diffs (117 lines):

diff --git a/libpurple/blistnodetypes.c b/libpurple/blistnodetypes.c
--- a/libpurple/blistnodetypes.c
+++ b/libpurple/blistnodetypes.c
@@ -549,7 +549,7 @@ purple_buddy_set_property(GObject *obj, 
 			purple_buddy_set_server_alias(buddy, g_value_get_string(value));
 			break;
 		case BUDDY_PROP_ICON:
-			purple_buddy_set_icon(buddy, g_value_get_pointer(value));
+			purple_buddy_set_icon(buddy, g_value_get_boxed(value));
 			break;
 		case BUDDY_PROP_ACCOUNT:
 			priv->account = g_value_get_object(value);
@@ -581,7 +581,7 @@ purple_buddy_get_property(GObject *obj, 
 			g_value_set_string(value, purple_buddy_get_server_alias(buddy));
 			break;
 		case BUDDY_PROP_ICON:
-			g_value_set_pointer(value, purple_buddy_get_icon(buddy));
+			g_value_set_static_boxed(value, purple_buddy_get_icon(buddy));
 			break;
 		case BUDDY_PROP_ACCOUNT:
 			g_value_set_object(value, purple_buddy_get_account(buddy));
@@ -699,8 +699,8 @@ static void purple_buddy_class_init(Purp
 			);
 
 	g_object_class_install_property(obj_class, BUDDY_PROP_ICON,
-			g_param_spec_pointer(BUDDY_PROP_ICON_S, _("Buddy icon"),
-				_("The icon for the buddy."),
+			g_param_spec_boxed(BUDDY_PROP_ICON_S, _("Buddy icon"),
+				_("The icon for the buddy."), PURPLE_TYPE_BUDDY_ICON,
 				G_PARAM_READWRITE)
 			);
 
diff --git a/libpurple/buddyicon.c b/libpurple/buddyicon.c
--- a/libpurple/buddyicon.c
+++ b/libpurple/buddyicon.c
@@ -1131,3 +1131,25 @@ void purple_buddy_icon_get_scale_size(Pu
 	*width = new_width;
 	*height = new_height;
 }
+
+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);
+}
+
+GType
+purple_buddy_icon_get_type(void)
+{
+	static GType type = 0;
+
+	if (type == 0) {
+		type = g_boxed_type_register_static("PurpleBuddyIcon",
+				(GBoxedCopyFunc)purple_buddy_icon_copy,
+				(GBoxedFreeFunc)purple_buddy_icon_unref);
+	}
+
+	return type;
+}
diff --git a/libpurple/buddyicon.h b/libpurple/buddyicon.h
--- a/libpurple/buddyicon.h
+++ b/libpurple/buddyicon.h
@@ -26,6 +26,8 @@
 #ifndef _PURPLE_BUDDYICON_H_
 #define _PURPLE_BUDDYICON_H_
 
+#define PURPLE_TYPE_BUDDY_ICON (purple_buddy_icon_get_type())
+
 /** An opaque structure representing a buddy icon for a particular user on a
  *  particular #PurpleAccount.  Instances are reference-counted; use
  *  purple_buddy_icon_ref() and purple_buddy_icon_unref() to take and release
@@ -47,6 +49,11 @@ G_BEGIN_DECLS
 /*@{*/
 
 /**
+ * Returns the GType for the PurpleBuddyIcon boxed structure.
+ */
+GType purple_buddy_icon_get_type(void);
+
+/**
  * Creates a new buddy icon structure and populates it.
  *
  * If an icon for this account+username already exists, you'll get a reference
diff --git a/libpurple/conversationtypes.c b/libpurple/conversationtypes.c
--- a/libpurple/conversationtypes.c
+++ b/libpurple/conversationtypes.c
@@ -391,7 +391,7 @@ purple_im_conversation_set_property(GObj
 			purple_im_conversation_set_typing_state(im, g_value_get_enum(value));
 			break;
 		case IM_PROP_ICON:
-			purple_im_conversation_set_icon(im, g_value_get_pointer(value));
+			purple_im_conversation_set_icon(im, g_value_get_boxed(value));
 			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -411,7 +411,7 @@ purple_im_conversation_get_property(GObj
 			g_value_set_enum(value, purple_im_conversation_get_typing_state(im));
 			break;
 		case IM_PROP_ICON:
-			g_value_set_pointer(value, purple_im_conversation_get_icon(im));
+			g_value_set_static_boxed(value, purple_im_conversation_get_icon(im));
 			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -512,8 +512,8 @@ static void purple_im_conversation_class
 			);
 
 	g_object_class_install_property(obj_class, IM_PROP_ICON,
-			g_param_spec_pointer(IM_PROP_ICON_S, _("Buddy icon"),
-				_("The buddy icon for the IM."),
+			g_param_spec_boxed(IM_PROP_ICON_S, _("Buddy icon"),
+				_("The buddy icon for the IM."), PURPLE_TYPE_BUDDY_ICON,
 				G_PARAM_READWRITE)
 			);
 



More information about the Commits mailing list