/soc/2013/ankitkv/gobjectification: e07a9b9c6bda: Cleaned up pro...

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


Changeset: e07a9b9c6bdadcb78a6eb3bdc94d39ebcf88f695
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-10-11 14:51 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/e07a9b9c6bda

Description:

Cleaned up properties and added g_object_notify calls for PurpleConnection and PurpleConversation's

diffstat:

 libpurple/connection.c        |  39 ++++++++--------
 libpurple/conversation.c      |  21 +++-----
 libpurple/conversation.h      |   1 +
 libpurple/conversationtypes.c |  97 +++++++++++++++---------------------------
 libpurple/conversationtypes.h |   8 ---
 5 files changed, 64 insertions(+), 102 deletions(-)

diffs (truncated from 485 to 300 lines):

diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -246,6 +246,8 @@ purple_connection_set_state(PurpleConnec
 		if (ops != NULL && ops->disconnected != NULL)
 			ops->disconnected(gc);
 	}
+
+	g_object_notify(G_OBJECT(gc), "state");
 }
 
 void
@@ -256,6 +258,8 @@ purple_connection_set_flags(PurpleConnec
 	g_return_if_fail(priv != NULL);
 
 	priv->flags = flags;
+
+	g_object_notify(G_OBJECT(gc), "flags");
 }
 
 void
@@ -267,6 +271,8 @@ purple_connection_set_display_name(Purpl
 
 	g_free(priv->display_name);
 	priv->display_name = g_strdup(name);
+
+	g_object_notify(G_OBJECT(gc), "display-name");
 }
 
 void
@@ -592,13 +598,6 @@ purple_connection_error_info_get_type(vo
 /**************************************************************************
  * GObject code
  **************************************************************************/
-/* GObject Property names */
-#define PROP_PRPL_S          "prpl"
-#define PROP_FLAGS_S         "flags"
-#define PROP_STATE_S         "state"
-#define PROP_ACCOUNT_S       "account"
-#define PROP_PASSWORD_S      "password"
-#define PROP_DISPLAY_NAME_S  "display-name"
 
 /* Set method for GObject properties */
 static void
@@ -687,7 +686,7 @@ purple_connection_constructed(GObject *o
 
 	G_OBJECT_CLASS(parent_class)->constructed(object);
 
-	g_object_get(gc, PROP_ACCOUNT_S, &account, NULL);
+	g_object_get(gc, "account", &account, NULL);
 	purple_account_set_connection(account, gc);
 	g_object_unref(account);
 
@@ -782,39 +781,39 @@ static void purple_connection_class_init
 	obj_class->set_property = purple_connection_set_property;
 
 	g_object_class_install_property(obj_class, PROP_PRPL,
-			g_param_spec_pointer(PROP_PRPL_S, _("Protocol plugin"),
+			g_param_spec_pointer("prpl", _("Protocol plugin"),
 				_("The prpl that is using the connection."),
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
 			);
 
 	g_object_class_install_property(obj_class, PROP_FLAGS,
-			g_param_spec_flags(PROP_FLAGS_S, _("Connection flags"),
+			g_param_spec_flags("flags", _("Connection flags"),
 				_("The flags of the connection."),
 				PURPLE_TYPE_CONNECTION_FLAGS, 0,
 				G_PARAM_READWRITE)
 			);
 
 	g_object_class_install_property(obj_class, PROP_STATE,
-			g_param_spec_enum(PROP_STATE_S, _("Connection state"),
+			g_param_spec_enum("state", _("Connection state"),
 				_("The current state of the connection."),
 				PURPLE_TYPE_CONNECTION_STATE, PURPLE_CONNECTION_DISCONNECTED,
 				G_PARAM_READWRITE)
 			);
 
 	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 using the connection."), PURPLE_TYPE_ACCOUNT,
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
 			);
 
 	g_object_class_install_property(obj_class, PROP_PASSWORD,
-			g_param_spec_string(PROP_PASSWORD_S, _("Password"),
+			g_param_spec_string("password", _("Password"),
 				_("The password used for connection."), NULL,
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
 			);
 
 	g_object_class_install_property(obj_class, PROP_DISPLAY_NAME,
-			g_param_spec_string(PROP_DISPLAY_NAME_S, _("Display name"),
+			g_param_spec_string("display-name", _("Display name"),
 				_("Your name that appears to other people."), NULL,
 				G_PARAM_READWRITE)
 			);
@@ -894,9 +893,9 @@ void
 	}
 
 	gc = g_object_new(PURPLE_TYPE_CONNECTION,
-			PROP_PRPL_S,      prpl,
-			PROP_PASSWORD_S,  password,
-			PROP_ACCOUNT_S,   account,
+			"prpl",      prpl,
+			"password",  password,
+			"account",   account,
 			NULL);
 
 	if (regist)
@@ -958,9 +957,9 @@ void
 	}
 
 	gc = g_object_new(PURPLE_TYPE_CONNECTION,
-			PROP_PRPL_S,      prpl,
-			PROP_PASSWORD_S,  password,
-			PROP_ACCOUNT_S,   account,
+			"prpl",      prpl,
+			"password",  password,
+			"account",   account,
 			NULL);
 
 	purple_debug_info("connection", "Unregistering.  gc = %p\n", gc);
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -425,6 +425,8 @@ purple_conversation_set_name(PurpleConve
 	priv->name = g_strdup(name);
 
 	purple_conversation_autoset_title(conv);
+
+	purple_conversation_update(conv, PURPLE_CONVERSATION_UPDATE_NAME);
 }
 
 const char *
@@ -914,13 +916,6 @@ purple_conversation_get_max_message_size
  * GObject code
  **************************************************************************/
 
-/* GObject Property names */
-#define PROP_ACCOUNT_S   "account"
-#define PROP_NAME_S      "name"
-#define PROP_TITLE_S     "title"
-#define PROP_LOGGING_S   "logging"
-#define PROP_FEATURES_S  "features"
-
 /* Set method for GObject properties */
 static void
 purple_conversation_set_property(GObject *obj, guint param_id, const GValue *value,
@@ -993,7 +988,7 @@ purple_conversation_constructed(GObject 
 
 	parent_class->constructed(object);
 
-	g_object_get(object, PROP_ACCOUNT_S, &account, NULL);
+	g_object_get(object, "account", &account, NULL);
 	gc = purple_account_get_connection(account);
 
 	/* copy features from the connection. */
@@ -1067,31 +1062,31 @@ purple_conversation_class_init(PurpleCon
 	obj_class->set_property = purple_conversation_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 conversation."), PURPLE_TYPE_ACCOUNT,
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
 			);
 
 	g_object_class_install_property(obj_class, PROP_NAME,
-			g_param_spec_string(PROP_NAME_S, _("Name"),
+			g_param_spec_string("name", _("Name"),
 				_("The name of the conversation."), NULL,
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
 			);
 
 	g_object_class_install_property(obj_class, PROP_TITLE,
-			g_param_spec_string(PROP_TITLE_S, _("Title"),
+			g_param_spec_string("title", _("Title"),
 				_("The title of the conversation."), NULL,
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
 			);
 
 	g_object_class_install_property(obj_class, PROP_LOGGING,
-			g_param_spec_boolean(PROP_LOGGING_S, _("Logging status"),
+			g_param_spec_boolean("logging", _("Logging status"),
 				_("Whether logging is enabled or not."), FALSE,
 				G_PARAM_READWRITE)
 			);
 
 	g_object_class_install_property(obj_class, PROP_FEATURES,
-			g_param_spec_flags(PROP_FEATURES_S, _("Connection features"),
+			g_param_spec_flags("features", _("Connection features"),
 				_("The connection features of the conversation."),
 				PURPLE_TYPE_CONNECTION_FLAGS, 0,
 				G_PARAM_READWRITE)
diff --git a/libpurple/conversation.h b/libpurple/conversation.h
--- a/libpurple/conversation.h
+++ b/libpurple/conversation.h
@@ -72,6 +72,7 @@ typedef enum
 	PURPLE_CONVERSATION_ACCOUNT_OFFLINE, /**< One of the user's accounts went offline. */
 	PURPLE_CONVERSATION_UPDATE_AWAY,     /**< The other user went away.                */
 	PURPLE_CONVERSATION_UPDATE_ICON,     /**< The other user's buddy icon changed.     */
+	PURPLE_CONVERSATION_UPDATE_NAME,
 	PURPLE_CONVERSATION_UPDATE_TITLE,
 	PURPLE_CONVERSATION_UPDATE_CHATLEFT,
 
diff --git a/libpurple/conversationtypes.c b/libpurple/conversationtypes.c
--- a/libpurple/conversationtypes.c
+++ b/libpurple/conversationtypes.c
@@ -119,7 +119,6 @@ enum {
 	CU_PROP_CHAT,
 	CU_PROP_NAME,
 	CU_PROP_ALIAS,
-	CU_PROP_BUDDY,
 	CU_PROP_FLAGS,
 	CU_PROP_LAST
 };
@@ -374,10 +373,6 @@ im_conversation_write_message(PurpleConv
  * GObject code for IMs
  **************************************************************************/
 
-/* GObject Property names */
-#define IM_PROP_TYPING_STATE_S  "typing-state"
-#define IM_PROP_ICON_S          "icon"
-
 /* Set method for GObject properties */
 static void
 purple_im_conversation_set_property(GObject *obj, guint param_id, const GValue *value,
@@ -517,14 +512,14 @@ static void purple_im_conversation_class
 	conv_class->write_message = im_conversation_write_message;
 
 	g_object_class_install_property(obj_class, IM_PROP_TYPING_STATE,
-			g_param_spec_enum(IM_PROP_TYPING_STATE_S, _("Typing state"),
+			g_param_spec_enum("typing-state", _("Typing state"),
 				_("Status of the user's typing of a message."),
 				PURPLE_TYPE_IM_TYPING_STATE, PURPLE_IM_NOT_TYPING,
 				G_PARAM_READWRITE)
 			);
 
 	g_object_class_install_property(obj_class, IM_PROP_ICON,
-			g_param_spec_pointer(IM_PROP_ICON_S, _("Buddy icon"),
+			g_param_spec_pointer("icon", _("Buddy icon"),
 				_("The buddy icon for the IM."),
 				G_PARAM_READWRITE)
 			);
@@ -763,6 +758,8 @@ purple_chat_conversation_set_id(PurpleCh
 	g_return_if_fail(priv != NULL);
 
 	priv->id = id;
+
+	g_object_notify(G_OBJECT(chat), "chat-id");
 }
 
 int
@@ -893,7 +890,6 @@ purple_chat_conversation_add_users(Purpl
 				purple_chat_conversation_is_ignored_user(chat, user);
 
 		chatuser = purple_chat_user_new(chat, user, alias, flag);
-		purple_chat_user_set_buddy(chatuser, purple_blist_find_buddy(account, user) != NULL);
 
 		priv->in_room = g_list_prepend(priv->in_room, chatuser);
 		g_hash_table_replace(priv->users,
@@ -993,7 +989,6 @@ purple_chat_conversation_rename_user(Pur
 
 	flags = purple_chat_user_get_flags(purple_chat_conversation_find_user(chat, old_user));
 	cb = purple_chat_user_new(chat, new_user, new_alias, flags);
-	purple_chat_user_set_buddy(cb, purple_blist_find_buddy(account, new_user) != NULL);
 
 	priv->in_room = g_list_prepend(priv->in_room, cb);
 	g_hash_table_replace(priv->users,
@@ -1198,6 +1193,8 @@ void purple_chat_conversation_set_nick(P
 	g_free(priv->nick);
 	priv->nick = g_strdup(purple_normalize(
 			purple_conversation_get_account(PURPLE_CONVERSATION(chat)), nick));
+
+	g_object_notify(G_OBJECT(chat), "nick");
 }
 
 const char *purple_chat_conversation_get_nick(PurpleChatConversation *chat) {
@@ -1342,13 +1339,6 @@ purple_chat_conversation_find_user(Purpl
  * GObject code for chats
  **************************************************************************/
 
-/* GObject Property names */
-#define CHAT_PROP_TOPIC_WHO_S  "topic-who"
-#define CHAT_PROP_TOPIC_S      "topic"
-#define CHAT_PROP_ID_S         "chat-id"
-#define CHAT_PROP_NICK_S       "nick"
-#define CHAT_PROP_LEFT_S       "left"
-
 /* Set method for GObject properties */
 static void
 purple_chat_conversation_set_property(GObject *obj, guint param_id, const GValue *value,
@@ -1550,31 +1540,31 @@ static void purple_chat_conversation_cla
 	conv_class->write_message = chat_conversation_write_message;
 
 	g_object_class_install_property(obj_class, CHAT_PROP_TOPIC_WHO,
-			g_param_spec_string(CHAT_PROP_TOPIC_WHO_S, _("Who set topic"),



More information about the Commits mailing list