/soc/2013/ankitkv/gobjectification: 9c2d352b1d96: Cleaned up pro...

Ankit Vani a at nevitus.org
Thu Oct 10 17:37:17 EDT 2013


Changeset: 9c2d352b1d966fcfc6caadc0425efdd3faf88486
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-10-11 03:01 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/9c2d352b1d96

Description:

Cleaned up properties and added g_object_notify calls for PurpleAccount and PurpleBlistNodes

diffstat:

 libpurple/account.c        |  49 +++++++++++++++----------------
 libpurple/blistnode.c      |  51 ++++++++++++--------------------
 libpurple/blistnodetypes.c |  71 +++++++++++++++++++--------------------------
 3 files changed, 74 insertions(+), 97 deletions(-)

diffs (truncated from 576 to 300 lines):

diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -742,6 +742,8 @@ purple_account_set_username(PurpleAccoun
 	g_free(priv->username);
 	priv->username = g_strdup(username);
 
+	g_object_notify(G_OBJECT(account), "username");
+
 	purple_accounts_schedule_save();
 
 	/* if the name changes, we should re-write the buddy list
@@ -820,6 +822,8 @@ purple_account_set_user_info(PurpleAccou
 	g_free(priv->user_info);
 	priv->user_info = g_strdup(user_info);
 
+	g_object_notify(G_OBJECT(account), "user-info");
+
 	purple_accounts_schedule_save();
 }
 
@@ -834,6 +838,8 @@ void purple_account_set_buddy_icon_path(
 	g_free(priv->buddy_icon_path);
 	priv->buddy_icon_path = g_strdup(path);
 
+	g_object_notify(G_OBJECT(account), "buddy-icon-path");
+
 	purple_accounts_schedule_save();
 }
 
@@ -874,6 +880,8 @@ purple_account_set_remember_password(Pur
 	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
 	priv->remember_pass = value;
 
+	g_object_notify(G_OBJECT(account), "remember-password");
+
 	purple_accounts_schedule_save();
 }
 
@@ -883,6 +891,8 @@ purple_account_set_check_mail(PurpleAcco
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
 	purple_account_set_bool(account, "check-mail", value);
+
+	g_object_notify(G_OBJECT(account), "check-mail");
 }
 
 void
@@ -2776,7 +2786,7 @@ purple_account_to_xmlnode(PurpleAccount 
 	if ((tmp = purple_account_get_user_info(account)) != NULL)
 	{
 		/* TODO: Do we need to call purple_str_strip_char(tmp, '\r') here? */
-		child = purple_xmlnode_new_child(node, "userinfo");
+		child = purple_xmlnode_new_child(node, "user-info");
 		purple_xmlnode_insert_data(child, tmp, -1);
 	}
 
@@ -2807,17 +2817,6 @@ purple_account_to_xmlnode(PurpleAccount 
  * GObject Code *
  ****************/
 
-/* GObject Property names */
-#define PROP_USERNAME_S           "username"
-#define PROP_PRIVATE_ALIAS_S      "private-alias"
-#define PROP_ENABLED_S            "enabled"
-#define PROP_CONNECTION_S         "connection"
-#define PROP_PROTOCOL_ID_S        "protocol-id"
-#define PROP_USER_INFO_S          "userinfo"
-#define PROP_BUDDY_ICON_PATH_S    "buddy-icon-path"
-#define PROP_REMEMBER_PASSWORD_S  "remember-password"
-#define PROP_CHECK_MAIL_S         "check-mail"
-
 /* Set method for GObject properties */
 static void
 purple_account_set_property(GObject *obj, guint param_id, const GValue *value,
@@ -2937,8 +2936,8 @@ purple_account_constructed(GObject *obje
 	parent_class->constructed(object);
 
 	g_object_get(object,
-			PROP_USERNAME_S,    &username,
-			PROP_PROTOCOL_ID_S, &protocol_id,
+			"username",    &username,
+			"protocol-id", &protocol_id,
 			NULL);
 
 	purple_signal_emit(purple_accounts_get_handle(), "account-created",
@@ -3063,55 +3062,55 @@ purple_account_class_init(PurpleAccountC
 	obj_class->set_property = purple_account_set_property;
 
 	g_object_class_install_property(obj_class, PROP_USERNAME,
-			g_param_spec_string(PROP_USERNAME_S, _("Username"),
+			g_param_spec_string("username", _("Username"),
 				_("The username for the account."), NULL,
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
 			);
 
 	g_object_class_install_property(obj_class, PROP_PRIVATE_ALIAS,
-			g_param_spec_string(PROP_PRIVATE_ALIAS_S, _("Private Alias"),
+			g_param_spec_string("private-alias", _("Private Alias"),
 				_("The private alias for the account."), NULL,
 				G_PARAM_READWRITE)
 			);
 
 	g_object_class_install_property(obj_class, PROP_USER_INFO,
-			g_param_spec_string(PROP_USER_INFO_S, _("User information"),
+			g_param_spec_string("user-info", _("User information"),
 				_("Detailed user information for the account."), NULL,
 				G_PARAM_READWRITE)
 			);
 
 	g_object_class_install_property(obj_class, PROP_BUDDY_ICON_PATH,
-			g_param_spec_string(PROP_BUDDY_ICON_PATH_S, _("Buddy icon path"),
+			g_param_spec_string("buddy-icon-path", _("Buddy icon path"),
 				_("Path to the buddyicon for the account."), NULL,
 				G_PARAM_READWRITE)
 			);
 
 	g_object_class_install_property(obj_class, PROP_ENABLED,
-			g_param_spec_boolean(PROP_ENABLED_S, _("Enabled"),
+			g_param_spec_boolean("enabled", _("Enabled"),
 				_("Whether the account is enabled or not."), FALSE,
 				G_PARAM_READWRITE)
 			);
 
 	g_object_class_install_property(obj_class, PROP_REMEMBER_PASSWORD,
-			g_param_spec_boolean(PROP_REMEMBER_PASSWORD_S, _("Remember password"),
+			g_param_spec_boolean("remember-password", _("Remember password"),
 				_("Whether to remember and store the password for this account."), FALSE,
 				G_PARAM_READWRITE)
 			);
 
 	g_object_class_install_property(obj_class, PROP_CHECK_MAIL,
-			g_param_spec_boolean(PROP_CHECK_MAIL_S, _("Check mail"),
+			g_param_spec_boolean("check-mail", _("Check mail"),
 				_("Whether to check mails for this account."), FALSE,
 				G_PARAM_READWRITE)
 			);
 
 	g_object_class_install_property(obj_class, PROP_CONNECTION,
-			g_param_spec_object(PROP_CONNECTION_S, _("Connection"),
+			g_param_spec_object("connection", _("Connection"),
 				_("The connection for the account."), PURPLE_TYPE_CONNECTION,
 				G_PARAM_READWRITE)
 			);
 
 	g_object_class_install_property(obj_class, PROP_PROTOCOL_ID,
-			g_param_spec_string(PROP_PROTOCOL_ID_S, _("Protocol ID"),
+			g_param_spec_string("protocol-id", _("Protocol ID"),
 				_("ID of the protocol that is responsible for the account."), NULL,
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
 			);
@@ -3160,8 +3159,8 @@ purple_account_new(const char *username,
 		return account;
 
 	account = g_object_new(PURPLE_TYPE_ACCOUNT,
-					PROP_USERNAME_S,    username,
-					PROP_PROTOCOL_ID_S, protocol_id,
+					"username",    username,
+					"protocol-id", protocol_id,
 					NULL);
 
 	return account;
diff --git a/libpurple/blistnode.c b/libpurple/blistnode.c
--- a/libpurple/blistnode.c
+++ b/libpurple/blistnode.c
@@ -45,7 +45,7 @@ struct _PurpleBlistNodePrivate {
 enum
 {
 	BLNODE_PROP_0,
-	BLNODE_PROP_DONT_SAVE,
+	BLNODE_PROP_TRANSIENT,
 	BLNODE_PROP_LAST
 };
 
@@ -162,6 +162,8 @@ purple_blist_node_set_transient(PurpleBl
 	g_return_if_fail(priv != NULL);
 
 	priv->transient = transient;
+
+	g_object_notify(G_OBJECT(node), "transient");
 }
 
 gboolean
@@ -336,9 +338,6 @@ purple_blist_node_get_extended_menu(Purp
  * GObject code for PurpleBlistNode
  **************************************************************************/
 
-/* GObject Property names */
-#define BLNODE_PROP_DONT_SAVE_S  "dont-save"
-
 /* Set method for GObject properties */
 static void
 purple_blist_node_set_property(GObject *obj, guint param_id, const GValue *value,
@@ -347,7 +346,7 @@ purple_blist_node_set_property(GObject *
 	PurpleBlistNode *node = PURPLE_BLIST_NODE(obj);
 
 	switch (param_id) {
-		case BLNODE_PROP_DONT_SAVE:
+		case BLNODE_PROP_TRANSIENT:
 			purple_blist_node_set_transient(node, g_value_get_boolean(value));
 			break;
 		default:
@@ -364,7 +363,7 @@ purple_blist_node_get_property(GObject *
 	PurpleBlistNode *node = PURPLE_BLIST_NODE(obj);
 
 	switch (param_id) {
-		case BLNODE_PROP_DONT_SAVE:
+		case BLNODE_PROP_TRANSIENT:
 			g_value_set_boolean(value, purple_blist_node_is_transient(node));
 			break;
 		default:
@@ -408,8 +407,8 @@ purple_blist_node_class_init(PurpleBlist
 	obj_class->get_property = purple_blist_node_get_property;
 	obj_class->set_property = purple_blist_node_set_property;
 
-	g_object_class_install_property(obj_class, BLNODE_PROP_DONT_SAVE,
-			g_param_spec_boolean(BLNODE_PROP_DONT_SAVE_S, _("Do not save"),
+	g_object_class_install_property(obj_class, BLNODE_PROP_TRANSIENT,
+			g_param_spec_boolean("transient", _("Transient"),
 				_("Whether node should not be saved with the buddy list."),
 				FALSE, G_PARAM_READWRITE)
 			);
@@ -484,7 +483,7 @@ purple_counting_node_change_total_size(P
 
 	g_return_if_fail(priv != NULL);
 
-	priv->totalsize += delta;
+	purple_counting_node_set_total_size(counter, priv->totalsize + delta);
 }
 
 void
@@ -494,7 +493,7 @@ purple_counting_node_change_current_size
 
 	g_return_if_fail(priv != NULL);
 
-	priv->currentsize += delta;
+	purple_counting_node_set_current_size(counter, priv->currentsize + delta);
 }
 
 void
@@ -504,7 +503,7 @@ purple_counting_node_change_online_count
 
 	g_return_if_fail(priv != NULL);
 
-	priv->onlinecount += delta;
+	purple_counting_node_set_online_count(counter, priv->onlinecount + delta);
 }
 
 void
@@ -515,6 +514,8 @@ purple_counting_node_set_total_size(Purp
 	g_return_if_fail(priv != NULL);
 
 	priv->totalsize = totalsize;
+
+	g_object_notify(G_OBJECT(counter), "total-size");
 }
 
 void
@@ -525,6 +526,8 @@ purple_counting_node_set_current_size(Pu
 	g_return_if_fail(priv != NULL);
 
 	priv->currentsize = currentsize;
+
+	g_object_notify(G_OBJECT(counter), "current-size");
 }
 
 void
@@ -535,17 +538,14 @@ purple_counting_node_set_online_count(Pu
 	g_return_if_fail(priv != NULL);
 
 	priv->onlinecount = onlinecount;
+
+	g_object_notify(G_OBJECT(counter), "online-count");
 }
 
 /**************************************************************************
  * GObject code for PurpleCountingNode
  **************************************************************************/
  
-/* GObject Property names */
-#define CNODE_PROP_TOTAL_SIZE_S    "total-size"
-#define CNODE_PROP_CURRENT_SIZE_S  "current-size"
-#define CNODE_PROP_ONLINE_COUNT_S  "online-count"
-
 /* Set method for GObject properties */
 static void
 purple_counting_node_set_property(GObject *obj, guint param_id, const GValue *value,
@@ -592,17 +592,6 @@ purple_counting_node_get_property(GObjec
 	}
 }
 
-/* GObject initialization function */
-static void
-purple_counting_node_init(GTypeInstance *instance, gpointer klass)
-{
-	PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(instance);
-
-	priv->totalsize   = 0;
-	priv->currentsize = 0;
-	priv->onlinecount = 0;



More information about the Commits mailing list