/soc/2013/ankitkv/gobjectification: d9b286af48ba: Refactored the...

Ankit Vani a at nevitus.org
Fri Jul 19 05:36:39 EDT 2013


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

Description:

Refactored the codebase to use the GObject buddy icon API

diffstat:

 libpurple/blistnodetypes.c                 |  17 +++++++----------
 libpurple/conversationtypes.c              |  19 ++++++++-----------
 libpurple/plugins/perl/common/BuddyIcon.xs |   8 --------
 pidgin/gtkblist.c                          |   2 +-
 4 files changed, 16 insertions(+), 30 deletions(-)

diffs (154 lines):

diff --git a/libpurple/blistnodetypes.c b/libpurple/blistnodetypes.c
--- a/libpurple/blistnodetypes.c
+++ b/libpurple/blistnodetypes.c
@@ -155,8 +155,8 @@ purple_buddy_set_icon(PurpleBuddy *buddy
 
 	if (priv->icon != icon)
 	{
-		purple_buddy_icon_unref(priv->icon);
-		priv->icon = (icon != NULL ? purple_buddy_icon_ref(icon) : NULL);
+		g_object_unref(priv->icon);
+		priv->icon = (icon != NULL ? g_object_ref(icon) : NULL);
 	}
 
 	purple_signal_emit(purple_blist_get_handle(), "buddy-icon-changed", buddy);
@@ -549,8 +549,7 @@ 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));
+			purple_buddy_set_icon(buddy, g_value_get_object(value));
 			break;
 		case BUDDY_PROP_ACCOUNT:
 			priv->account = g_value_get_object(value);
@@ -582,8 +581,7 @@ 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));
+			g_value_set_object(value, purple_buddy_get_icon(buddy));
 			break;
 		case BUDDY_PROP_ACCOUNT:
 			g_value_set_object(value, purple_buddy_get_account(buddy));
@@ -646,7 +644,7 @@ purple_buddy_dispose(GObject *object)
 	}
 
 	/* Delete the node */
-	purple_buddy_icon_unref(priv->icon);
+	g_object_unref(priv->icon);
 	purple_presence_destroy(priv->presence);
 
 	PURPLE_DBUS_UNREGISTER_POINTER(buddy);
@@ -700,10 +698,9 @@ 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."),
+			g_param_spec_object(BUDDY_PROP_ICON_S, _("Buddy icon"),
+				_("The icon for the buddy."), PURPLE_TYPE_BUDDY_ICON,
 				G_PARAM_READWRITE)
 			);
 
diff --git a/libpurple/conversationtypes.c b/libpurple/conversationtypes.c
--- a/libpurple/conversationtypes.c
+++ b/libpurple/conversationtypes.c
@@ -179,9 +179,9 @@ purple_im_conversation_set_icon(PurpleIM
 
 	if (priv->icon != icon)
 	{
-		purple_buddy_icon_unref(priv->icon);
+		g_object_unref(priv->icon);
 
-		priv->icon = (icon == NULL ? NULL : purple_buddy_icon_ref(icon));
+		priv->icon = (icon == NULL ? NULL : g_object_ref(icon));
 	}
 
 	purple_conversation_update(PURPLE_CONVERSATION(im),
@@ -390,9 +390,8 @@ 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));
+			purple_im_conversation_set_icon(im, g_value_get_object(value));
 			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -411,9 +410,8 @@ 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));
+			g_value_set_object(value, purple_im_conversation_get_icon(im));
 			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -441,7 +439,7 @@ purple_im_conversation_constructed(GObje
 	{
 		purple_im_conversation_set_icon(im, icon);
 		/* purple_im_conversation_set_icon refs the icon. */
-		purple_buddy_icon_unref(icon);
+		g_object_unref(icon);
 	}
 
 	if (purple_prefs_get_bool("/purple/logging/log_ims"))
@@ -484,7 +482,7 @@ purple_im_conversation_finalize(GObject 
 	PurpleIMConversation *im = PURPLE_IM_CONVERSATION(object);
 	PurpleIMConversationPrivate *priv = PURPLE_IM_CONVERSATION_GET_PRIVATE(im);
 
-	purple_buddy_icon_unref(priv->icon);
+	g_object_unref(priv->icon);
 	priv->icon = NULL;
 
 	G_OBJECT_CLASS(parent_class)->finalize(object);
@@ -515,10 +513,9 @@ 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."),
+			g_param_spec_object(IM_PROP_ICON_S, _("Buddy icon"),
+				_("The buddy icon for the IM."), PURPLE_TYPE_BUDDY_ICON,
 				G_PARAM_READWRITE)
 			);
 
diff --git a/libpurple/plugins/perl/common/BuddyIcon.xs b/libpurple/plugins/perl/common/BuddyIcon.xs
--- a/libpurple/plugins/perl/common/BuddyIcon.xs
+++ b/libpurple/plugins/perl/common/BuddyIcon.xs
@@ -3,14 +3,6 @@
 MODULE = Purple::Buddy::Icon PACKAGE = Purple::Buddy::Icon   PREFIX = purple_buddy_icon_
 PROTOTYPES: ENABLE
 
-Purple::Buddy::Icon
-purple_buddy_icon_ref(icon)
-	Purple::Buddy::Icon icon
-
-void
-purple_buddy_icon_unref(icon)
-	Purple::Buddy::Icon icon
-
 void
 purple_buddy_icon_update(icon)
 	Purple::Buddy::Icon icon
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -2731,7 +2731,7 @@ static GdkPixbuf *pidgin_blist_get_buddy
 	}
 
 	buf = pidgin_pixbuf_from_data(data, len);
-	purple_buddy_icon_unref(icon);
+	g_object_unref(icon);
 	if (!buf) {
 		purple_debug_warning("gtkblist", "Couldn't load buddy icon "
 				"on account %s (%s)  buddyname=%s  "



More information about the Commits mailing list