/soc/2013/ankitkv/gobjectification: 111f747bbe9f: Kept PurpleBud...

Ankit Vani a at nevitus.org
Fri Jul 19 12:29:30 EDT 2013


Changeset: 111f747bbe9f12f5918f4f2a562f8eedd00264b1
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-19 21:59 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/111f747bbe9f

Description:

Kept PurpleBuddyIcon as a GBoxed, since it's more appropriate. g_boxed_copy() and g_boxed_free() ref and unref the icon.

diffstat:

 libpurple/blistnodetypes.c    |   3 ---
 libpurple/buddyicon.c         |  17 ++---------------
 libpurple/buddyicon.h         |   2 --
 libpurple/conversationtypes.c |   3 ---
 4 files changed, 2 insertions(+), 23 deletions(-)

diffs (100 lines):

diff --git a/libpurple/blistnodetypes.c b/libpurple/blistnodetypes.c
--- a/libpurple/blistnodetypes.c
+++ b/libpurple/blistnodetypes.c
@@ -549,7 +549,6 @@ purple_buddy_set_property(GObject *obj, 
 			purple_buddy_set_server_alias(buddy, g_value_get_string(value));
 			break;
 		case BUDDY_PROP_ICON:
-#warning TODO: change get_pointer to get_object when PurpleBuddyIcon is a GObject
 			purple_buddy_set_icon(buddy, g_value_get_pointer(value));
 			break;
 		case BUDDY_PROP_ACCOUNT:
@@ -582,7 +581,6 @@ purple_buddy_get_property(GObject *obj, 
 			g_value_set_string(value, purple_buddy_get_server_alias(buddy));
 			break;
 		case BUDDY_PROP_ICON:
-#warning TODO: change set_pointer to set_object when PurpleBuddyIcon is a GObject
 			g_value_set_pointer(value, purple_buddy_get_icon(buddy));
 			break;
 		case BUDDY_PROP_ACCOUNT:
@@ -700,7 +698,6 @@ static void purple_buddy_class_init(Purp
 				G_PARAM_READWRITE)
 			);
 
-#warning TODO: change spec_pointer to spec_object when PurpleBuddyIcon is a GObject
 	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."),
diff --git a/libpurple/buddyicon.c b/libpurple/buddyicon.c
--- a/libpurple/buddyicon.c
+++ b/libpurple/buddyicon.c
@@ -1132,19 +1132,6 @@ void purple_buddy_icon_get_scale_size(Pu
 	*height = new_height;
 }
 
-static PurpleBuddyIcon *
-purple_buddy_icon_copy(PurpleBuddyIcon *icon)
-{
-	PurpleBuddyIcon *icon_copy;
-
-	g_return_val_if_fail(icon != NULL, NULL);
-
-	icon_copy = g_new(PurpleBuddyIcon, 1);
-	*icon_copy = *icon;
-
-	return icon_copy;
-}
-
 GType
 purple_buddy_icon_get_type(void)
 {
@@ -1152,8 +1139,8 @@ purple_buddy_icon_get_type(void)
 
 	if (type == 0) {
 		type = g_boxed_type_register_static("PurpleBuddyIcon",
-				(GBoxedCopyFunc)purple_buddy_icon_copy,
-				(GBoxedFreeFunc)g_free);
+				(GBoxedCopyFunc)purple_buddy_icon_ref,
+				(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
@@ -50,8 +50,6 @@ 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);
 
diff --git a/libpurple/conversationtypes.c b/libpurple/conversationtypes.c
--- a/libpurple/conversationtypes.c
+++ b/libpurple/conversationtypes.c
@@ -390,7 +390,6 @@ purple_im_conversation_set_property(GObj
 		case IM_PROP_TYPING_STATE:
 			purple_im_conversation_set_typing_state(im, g_value_get_enum(value));
 			break;
-#warning TODO: change get_pointer to get_object when PurpleBuddyIcon is a GObject
 		case IM_PROP_ICON:
 			purple_im_conversation_set_icon(im, g_value_get_pointer(value));
 			break;
@@ -411,7 +410,6 @@ purple_im_conversation_get_property(GObj
 		case IM_PROP_TYPING_STATE:
 			g_value_set_enum(value, purple_im_conversation_get_typing_state(im));
 			break;
-#warning TODO: change set_pointer to set_object when PurpleBuddyIcon is a GObject
 		case IM_PROP_ICON:
 			g_value_set_pointer(value, purple_im_conversation_get_icon(im));
 			break;
@@ -515,7 +513,6 @@ static void purple_im_conversation_class
 				G_PARAM_READWRITE)
 			);
 
-#warning TODO: change spec_pointer to spec_object when PurpleBuddyIcon is a GObject
 	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."),



More information about the Commits mailing list