/soc/2013/ankitkv/gobjectification: 4718438d053b: Cleaned up pro...

Ankit Vani a at nevitus.org
Fri Oct 11 07:25:53 EDT 2013


Changeset: 4718438d053b0d6af00e48688330a843194002de
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-10-11 15:31 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/4718438d053b

Description:

Cleaned up properties and added g_object_notify calls for everything else

diffstat:

 libpurple/presence.c   |  33 +++++++--------------
 libpurple/roomlist.c   |  17 +++++------
 libpurple/smiley.c     |  17 ++++------
 libpurple/status.c     |  18 +++++------
 libpurple/whiteboard.c |  24 +++++++--------
 libpurple/xfer.c       |  74 +++++++++++++++++++++++++-------------------------
 6 files changed, 82 insertions(+), 101 deletions(-)

diffs (truncated from 651 to 300 lines):

diff --git a/libpurple/presence.c b/libpurple/presence.c
--- a/libpurple/presence.c
+++ b/libpurple/presence.c
@@ -171,6 +171,8 @@ purple_presence_set_login_time(PurplePre
 		return;
 
 	priv->login_time = login_time;
+
+	g_object_notify(G_OBJECT(presence), "login-time");
 }
 
 GList *
@@ -321,13 +323,6 @@ purple_presence_get_login_time(const Pur
  * GObject code for PurplePresence
  **************************************************************************/
 
-/* GObject Property names */
-#define PRES_PROP_IDLE_S           "idle"
-#define PRES_PROP_IDLE_TIME_S      "idle-time"
-#define PRES_PROP_LOGIN_TIME_S     "login-time"
-#define PRES_PROP_STATUSES_S       "statuses"
-#define PRES_PROP_ACTIVE_STATUS_S  "active-status"
-
 /* Set method for GObject properties */
 static void
 purple_presence_set_property(GObject *obj, guint param_id, const GValue *value,
@@ -462,7 +457,7 @@ static void purple_presence_class_init(P
 	obj_class->set_property = purple_presence_set_property;
 
 	g_object_class_install_property(obj_class, PRES_PROP_IDLE,
-			g_param_spec_boolean(PRES_PROP_IDLE_S, _("Idle"),
+			g_param_spec_boolean("idle", _("Idle"),
 				_("Whether the presence is in idle state."), FALSE,
 				G_PARAM_READWRITE)
 			);
@@ -476,7 +471,7 @@ static void purple_presence_class_init(P
 #else
 #error Unknown size of time_t
 #endif
-				(PRES_PROP_IDLE_TIME_S, _("Idle time"),
+				("idle-time", _("Idle time"),
 				_("The idle time of the presence"),
 #if SIZEOF_TIME_T == 4
 				G_MININT, G_MAXINT, 0,
@@ -496,7 +491,7 @@ static void purple_presence_class_init(P
 #else
 #error Unknown size of time_t
 #endif
-				(PRES_PROP_LOGIN_TIME_S, _("Login time"),
+				("login-time", _("Login time"),
 				_("The login time of the presence."),
 #if SIZEOF_TIME_T == 4
 				G_MININT, G_MAXINT, 0,
@@ -509,13 +504,13 @@ static void purple_presence_class_init(P
 			);
 
 	g_object_class_install_property(obj_class, PRES_PROP_STATUSES,
-			g_param_spec_pointer(PRES_PROP_STATUSES_S, _("Statuses"),
+			g_param_spec_pointer("statuses", _("Statuses"),
 				_("The list of statuses in the presence."),
 				G_PARAM_READABLE)
 			);
 
 	g_object_class_install_property(obj_class, PRES_PROP_ACTIVE_STATUS,
-			g_param_spec_object(PRES_PROP_ACTIVE_STATUS_S, _("Active status"),
+			g_param_spec_object("active-status", _("Active status"),
 				_("The active status for the presence."), PURPLE_TYPE_STATUS,
 				G_PARAM_READWRITE)
 			);
@@ -688,9 +683,6 @@ purple_buddy_presence_compare(const Purp
  * GObject code for PurpleAccountPresence
  **************************************************************************/
 
-/* GObject Property names */
-#define ACPRES_PROP_ACCOUNT_S  "account"
-
 /* Set method for GObject properties */
 static void
 purple_account_presence_set_property(GObject *obj, guint param_id, const GValue *value,
@@ -757,7 +749,7 @@ static void purple_account_presence_clas
 	obj_class->set_property = purple_account_presence_set_property;
 
 	g_object_class_install_property(obj_class, ACPRES_PROP_ACCOUNT,
-			g_param_spec_object(ACPRES_PROP_ACCOUNT_S, _("Account"),
+			g_param_spec_object("account", _("Account"),
 				_("The account that this presence is of."), PURPLE_TYPE_ACCOUNT,
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
 			);
@@ -798,7 +790,7 @@ purple_account_presence_new(PurpleAccoun
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
 	return g_object_new(PURPLE_TYPE_ACCOUNT_PRESENCE,
-			ACPRES_PROP_ACCOUNT_S, account,
+			"account", account,
 			NULL);
 }
 
@@ -883,9 +875,6 @@ purple_buddy_presence_get_buddy(const Pu
  * GObject code for PurpleBuddyPresence
  **************************************************************************/
 
-/* GObject Property names */
-#define BUDPRES_PROP_BUDDY_S  "buddy"
-
 /* Set method for GObject properties */
 static void
 purple_buddy_presence_set_property(GObject *obj, guint param_id, const GValue *value,
@@ -954,7 +943,7 @@ static void purple_buddy_presence_class_
 	obj_class->set_property = purple_buddy_presence_set_property;
 
 	g_object_class_install_property(obj_class, BUDPRES_PROP_BUDDY,
-			g_param_spec_object(BUDPRES_PROP_BUDDY_S, _("Buddy"),
+			g_param_spec_object("buddy", _("Buddy"),
 				_("The buddy that this presence is of."), PURPLE_TYPE_BUDDY,
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
 			);
@@ -995,6 +984,6 @@ purple_buddy_presence_new(PurpleBuddy *b
 	g_return_val_if_fail(PURPLE_IS_BUDDY(buddy), NULL);
 
 	return g_object_new(PURPLE_TYPE_BUDDY_PRESENCE,
-			BUDPRES_PROP_BUDDY_S, buddy,
+			"buddy", buddy,
 			NULL);
 }
diff --git a/libpurple/roomlist.c b/libpurple/roomlist.c
--- a/libpurple/roomlist.c
+++ b/libpurple/roomlist.c
@@ -117,6 +117,8 @@ void purple_roomlist_set_fields(PurpleRo
 
 	if (ops && ops->set_fields)
 		ops->set_fields(list, fields);
+
+	g_object_notify(G_OBJECT(list), "fields");
 }
 
 void purple_roomlist_set_in_progress(PurpleRoomlist *list, gboolean in_progress)
@@ -129,6 +131,8 @@ void purple_roomlist_set_in_progress(Pur
 
 	if (ops && ops->in_progress)
 		ops->in_progress(list, in_progress);
+
+	g_object_notify(G_OBJECT(list), "in-progress");
 }
 
 gboolean purple_roomlist_get_in_progress(PurpleRoomlist *list)
@@ -267,11 +271,6 @@ void purple_roomlist_set_ui_data(PurpleR
 /**************************************************************************/
 /*@{*/
 
-/* GObject Property names */
-#define PROP_ACCOUNT_S      "account"
-#define PROP_FIELDS_S       "fields"
-#define PROP_IN_PROGRESS_S  "in-progress"
-
 /* Set method for GObject properties */
 static void
 purple_roomlist_set_property(GObject *obj, guint param_id, const GValue *value,
@@ -372,20 +371,20 @@ purple_roomlist_class_init(PurpleRoomlis
 	obj_class->set_property = purple_roomlist_set_property;
 
 	g_object_class_install_property(obj_class, PROP_ACCOUNT,
-			g_param_spec_object(PROP_ACCOUNT_S, _("Account"),
+			g_param_spec_object("account", _("Account"),
 				_("The account for the room list."),
 				PURPLE_TYPE_ACCOUNT,
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
 			);
 
 	g_object_class_install_property(obj_class, PROP_FIELDS,
-			g_param_spec_pointer(PROP_FIELDS_S, _("Fields"),
+			g_param_spec_pointer("fields", _("Fields"),
 				_("The list of fields for a roomlist."),
 				G_PARAM_READWRITE)
 			);
 
 	g_object_class_install_property(obj_class, PROP_IN_PROGRESS,
-			g_param_spec_boolean(PROP_IN_PROGRESS_S, _("In progress"),
+			g_param_spec_boolean("in-progress", _("In progress"),
 				_("Whether the room list is being fetched."), FALSE,
 				G_PARAM_READWRITE)
 			);
@@ -424,7 +423,7 @@ PurpleRoomlist *purple_roomlist_new(Purp
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
 	return g_object_new(PURPLE_TYPE_ROOMLIST,
-		PROP_ACCOUNT_S, account,
+		"account", account,
 		NULL
 	);
 }
diff --git a/libpurple/smiley.c b/libpurple/smiley.c
--- a/libpurple/smiley.c
+++ b/libpurple/smiley.c
@@ -285,9 +285,6 @@ enum
 	PROP_IMGSTORE
 };
 
-#define PROP_SHORTCUT_S "shortcut"
-#define PROP_IMGSTORE_S "image"
-
 enum
 {
 	SIG_DESTROY,
@@ -356,7 +353,7 @@ purple_smiley_set_property(GObject *obje
 					priv->checksum = NULL;
 				}
 
-				g_object_notify(object, PROP_IMGSTORE_S);
+				g_object_notify(object, "image");
 			}
 			break;
 		default:
@@ -410,14 +407,14 @@ purple_smiley_class_init(PurpleSmileyCla
 	gobj_class->dispose = purple_smiley_dispose;
 
 	/* Shortcut */
-	pspec = g_param_spec_string(PROP_SHORTCUT_S, _("Shortcut"),
+	pspec = g_param_spec_string("shortcut", _("Shortcut"),
 			_("The text-shortcut for the smiley"),
 			NULL,
 			G_PARAM_READWRITE);
 	g_object_class_install_property(gobj_class, PROP_SHORTCUT, pspec);
 
 	/* Stored Image */
-	pspec = g_param_spec_pointer(PROP_IMGSTORE_S, _("Stored Image"),
+	pspec = g_param_spec_pointer("image", _("Stored Image"),
 			_("Stored Image. (that'll have to do for now)"),
 			G_PARAM_READWRITE);
 	g_object_class_install_property(gobj_class, PROP_IMGSTORE, pspec);
@@ -640,7 +637,7 @@ purple_smiley_set_data_impl(PurpleSmiley
 
 	new_img = purple_smiley_data_new(smiley_data, smiley_data_len);
 
-	g_object_set(G_OBJECT(smiley), PROP_IMGSTORE_S, new_img, NULL);
+	g_object_set(G_OBJECT(smiley), "image", new_img, NULL);
 
 	/* If the old and new image files have different names we need
 	 * to unstore old image file. */
@@ -665,7 +662,7 @@ purple_smiley_create(const char *shortcu
 {
 	PurpleSmiley *smiley;
 
-	smiley = PURPLE_SMILEY(g_object_new(PURPLE_TYPE_SMILEY, PROP_SHORTCUT_S, shortcut, NULL));
+	smiley = PURPLE_SMILEY(g_object_new(PURPLE_TYPE_SMILEY, "shortcut", shortcut, NULL));
 
 	return smiley;
 }
@@ -686,7 +683,7 @@ purple_smiley_new(PurpleStoredImage *img
 	if (!smiley)
 		return NULL;
 
-	g_object_set(G_OBJECT(smiley), PROP_IMGSTORE_S, img, NULL);
+	g_object_set(G_OBJECT(smiley), "image", img, NULL);
 
 	return smiley;
 }
@@ -769,7 +766,7 @@ purple_smiley_set_shortcut(PurpleSmiley 
 	g_free(priv->shortcut);
 	priv->shortcut = g_strdup(shortcut);
 
-	g_object_notify(G_OBJECT(smiley), PROP_SHORTCUT_S);
+	g_object_notify(G_OBJECT(smiley), "shortcut");
 
 	purple_smileys_save();
 
diff --git a/libpurple/status.c b/libpurple/status.c
--- a/libpurple/status.c
+++ b/libpurple/status.c
@@ -593,6 +593,9 @@ status_has_changed(PurpleStatus *status)
 		if (old_status != NULL && (old_status != status))
 			PURPLE_STATUS_GET_PRIVATE(old_status)->active = FALSE;
 		g_object_set(presence, "active-status", status, NULL);
+
+		g_object_notify(G_OBJECT(old_status), "active");
+		g_object_notify(G_OBJECT(status), "active");
 	}
 	else
 		old_status = NULL;
@@ -1111,11 +1114,6 @@ purple_mood_get_type(void)
 * GObject code
 **************************************************************************/
 
-/* GObject Property names */
-#define PROP_STATUS_TYPE_S  "status-type"
-#define PROP_PRESENCE_S     "presence"
-#define PROP_ACTIVE_S       "active"
-
 /* Set method for GObject properties */
 static void
 purple_status_set_property(GObject *obj, guint param_id, const GValue *value,
@@ -1228,19 +1226,19 @@ purple_status_class_init(PurpleStatusCla
 	obj_class->set_property = purple_status_set_property;
 
 	g_object_class_install_property(obj_class, PROP_STATUS_TYPE,
-			g_param_spec_pointer(PROP_STATUS_TYPE_S, _("Status type"),
+			g_param_spec_pointer("status-type", _("Status type"),
 				_("The PurpleStatusType of the status."),
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
 			);
 



More information about the Commits mailing list