/soc/2013/ankitkv/gobjectification: f39c64847a3d: Move ui_data t...

Ankit Vani a at nevitus.org
Sat Jun 29 13:35:52 EDT 2013


Changeset: f39c64847a3d30bf1d33d8679ce9eb078e7f9882
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-29 23:05 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/f39c64847a3d

Description:

Move ui_data to the object struct and remove getters and setters. It will be used as UI pleases.
Added ui_data field to the following structs:
- PurpleAccount
- PurpleConversation
- PurpleChatUser

diffstat:

 finch/gntconv.c                               |   4 +-
 finch/gntconv.h                               |   2 +-
 libpurple/account.h                           |   5 ++++
 libpurple/conversation.c                      |  21 --------------------
 libpurple/conversation.h                      |  24 ++++------------------
 libpurple/conversationtypes.c                 |  23 ----------------------
 libpurple/conversationtypes.h                 |  24 ++++------------------
 libpurple/plugins/perl/common/Conversation.xs |   5 ----
 pidgin/gtkconv.c                              |  28 ++++++++++++++------------
 pidgin/gtkconv.h                              |   2 +-
 10 files changed, 34 insertions(+), 104 deletions(-)

diffs (truncated from 362 to 300 lines):

diff --git a/finch/gntconv.c b/finch/gntconv.c
--- a/finch/gntconv.c
+++ b/finch/gntconv.c
@@ -409,7 +409,7 @@ static void
 conv_updated(PurpleConversation *conv, PurpleConversationUpdateType type)
 {
 	if (type == PURPLE_CONVERSATION_UPDATE_FEATURES) {
-		gg_extended_menu(purple_conversation_get_ui_data(conv));
+		gg_extended_menu(conv->ui_data);
 	}
 }
 
@@ -796,7 +796,7 @@ finch_create_conversation(PurpleConversa
 
 	ggc->list = g_list_prepend(ggc->list, conv);
 	ggc->active_conv = conv;
-	purple_conversation_set_ui_data(conv, ggc);
+	conv->ui_data = ggc;
 
 	if (cc && FINCH_CONV(cc) && cc != conv) {
 		finch_conversation_set_active(conv);
diff --git a/finch/gntconv.h b/finch/gntconv.h
--- a/finch/gntconv.h
+++ b/finch/gntconv.h
@@ -33,7 +33,7 @@
 #include "conversation.h"
 
 /* Grabs the conv out of a PurpleConverstation */
-#define FINCH_CONV(conv) ((FinchConv *)purple_conversation_get_ui_data(conv))
+#define FINCH_CONV(conv) ((FinchConv *)((conv)->ui_data))
 
 /***************************************************************************
  * @name GNT Conversations API
diff --git a/libpurple/account.h b/libpurple/account.h
--- a/libpurple/account.h
+++ b/libpurple/account.h
@@ -97,6 +97,11 @@ struct _PurpleAccount
 	/*< private >*/
 	GObject gparent;
 
+	/** The UI data associated with this account. This is a convenience
+	 *  field provided to the UIs -- it is not used by the libpurple core.
+	 */
+	gpointer ui_data;
+
 	void (*_purple_reserved1)(void);
 	void (*_purple_reserved2)(void);
 	void (*_purple_reserved3)(void);
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -57,7 +57,6 @@ struct _PurpleConversationPrivate
 	GList *logs;                      /**< This conversation's logs          */
 
 	PurpleConversationUiOps *ui_ops;  /**< UI-specific operations.           */
-	void *ui_data;                    /**< UI-specific data.                 */
 
 	PurpleConnectionFlags features;   /**< The supported features            */
 	GList *message_history;           /**< Message history, as a GList of
@@ -309,7 +308,6 @@ purple_conversation_set_ui_ops(PurpleCon
 	if (priv->ui_ops != NULL && priv->ui_ops->destroy_conversation != NULL)
 		priv->ui_ops->destroy_conversation(conv);
 
-	priv->ui_data = NULL;
 	priv->ui_ops = ops;
 }
 
@@ -861,24 +859,6 @@ purple_conversation_message_get_type(voi
 	return type;
 }
 
-void purple_conversation_set_ui_data(PurpleConversation *conv, gpointer ui_data)
-{
-	PurpleConversationPrivate *priv = PURPLE_CONVERSATION_GET_PRIVATE(conv);
-
-	g_return_if_fail(priv != NULL);
-
-	priv->ui_data = ui_data;
-}
-
-gpointer purple_conversation_get_ui_data(const PurpleConversation *conv)
-{
-	PurpleConversationPrivate *priv = PURPLE_CONVERSATION_GET_PRIVATE(conv);
-
-	g_return_val_if_fail(priv != NULL, NULL);
-
-	return priv->ui_data;
-}
-
 gboolean
 purple_conversation_do_command(PurpleConversation *conv, const gchar *cmdline,
 				const gchar *markup, gchar **error)
@@ -1013,7 +993,6 @@ purple_conversation_finalize(GObject *ob
 
 	if (ops != NULL && ops->destroy_conversation != NULL)
 		ops->destroy_conversation(conv);
-	priv->ui_data = NULL;
 
 	parent_class->finalize(object);
 }
diff --git a/libpurple/conversation.h b/libpurple/conversation.h
--- a/libpurple/conversation.h
+++ b/libpurple/conversation.h
@@ -119,6 +119,11 @@ struct _PurpleConversation
 	/*< private >*/
 	GObject gparent;
 
+	/** The UI data associated with this conversation. This is a convenience
+	 *  field provided to the UIs -- it is not used by the libpurple core.
+	 */
+	gpointer ui_data;
+
 	void (*_purple_reserved1)(void);
 	void (*_purple_reserved2)(void);
 	void (*_purple_reserved3)(void);
@@ -503,25 +508,6 @@ GList *purple_conversation_get_message_h
 void purple_conversation_clear_message_history(PurpleConversation *conv);
 
 /**
- * Set the UI data associated with this conversation.
- *
- * @param conv			The conversation.
- * @param ui_data		A pointer to associate with this conversation.
- */
-void purple_conversation_set_ui_data(PurpleConversation *conv, gpointer ui_data);
-
-/**
- * Get the UI data associated with this conversation.
- *
- * @param conv			The conversation.
- *
- * @return The UI data associated with this conversation.  This is a
- *         convenience field provided to the UIs--it is not
- *         used by the libpurple core.
- */
-gpointer purple_conversation_get_ui_data(const PurpleConversation *conv);
-
-/**
  * Sends a message to a conversation after confirming with
  * the user.
  *
diff --git a/libpurple/conversationtypes.c b/libpurple/conversationtypes.c
--- a/libpurple/conversationtypes.c
+++ b/libpurple/conversationtypes.c
@@ -111,7 +111,6 @@ struct _PurpleChatUserPrivate
 	PurpleChatUserFlags flags;     /**< A bitwise OR of flags for this
 	                                    participant, such as whether they
 	                                    are a channel operator.               */
-	gpointer ui_data;              /**< UI can put whatever it wants here.    */
 };
 
 /* Chat User Property enums */
@@ -1750,28 +1749,6 @@ purple_chat_user_get_flags(const PurpleC
 }
 
 void
-purple_chat_user_set_ui_data(PurpleChatUser *cb, gpointer ui_data)
-{
-	PurpleChatUserPrivate *priv;
-	priv = PURPLE_CHAT_USER_GET_PRIVATE(cb);
-
-	g_return_if_fail(priv != NULL);
-
-	priv->ui_data = ui_data;
-}
-
-gpointer
-purple_chat_user_get_ui_data(const PurpleChatUser *cb)
-{
-	PurpleChatUserPrivate *priv;
-	priv = PURPLE_CHAT_USER_GET_PRIVATE(cb);
-
-	g_return_val_if_fail(priv != NULL, NULL);
-
-	return priv->ui_data;
-}
-
-void
 purple_chat_user_set_chat(PurpleChatUser *cb,
 		PurpleChatConversation *chat)
 {
diff --git a/libpurple/conversationtypes.h b/libpurple/conversationtypes.h
--- a/libpurple/conversationtypes.h
+++ b/libpurple/conversationtypes.h
@@ -155,6 +155,11 @@ struct _PurpleChatUser
 	/*< private >*/
 	GObject gparent;
 
+	/** The UI data associated with this chat user. This is a convenience
+	 *  field provided to the UIs -- it is not used by the libpurple core.
+	 */
+	gpointer ui_data;
+
 	void (*_purple_reserved1)(void);
 	void (*_purple_reserved2)(void);
 	void (*_purple_reserved3)(void);
@@ -640,25 +645,6 @@ PurpleChatUser *purple_chat_user_new(Pur
 		const char *name, const char *alias, PurpleChatUserFlags flags);
 
 /**
- * Set the UI data associated with this chat user.
- *
- * @param cb			The chat user
- * @param ui_data		A pointer to associate with this chat user.
- */
-void purple_chat_user_set_ui_data(PurpleChatUser *cb, gpointer ui_data);
-
-/**
- * Get the UI data associated with this chat user.
- *
- * @param cb			The chat user.
- *
- * @return The UI data associated with this chat user.  This is a
- *         convenience field provided to the UIs--it is not
- *         used by the libpurple core.
- */
-gpointer purple_chat_user_get_ui_data(const PurpleChatUser *cb);
-
-/**
  * Get the alias of a chat user
  *
  * @param cb    The chat user.
diff --git a/libpurple/plugins/perl/common/Conversation.xs b/libpurple/plugins/perl/common/Conversation.xs
--- a/libpurple/plugins/perl/common/Conversation.xs
+++ b/libpurple/plugins/perl/common/Conversation.xs
@@ -188,11 +188,6 @@ gboolean
 purple_conversation_is_logging(conv)
 	Purple::Conversation conv
 
-gpointer
-purple_conversation_get_data(conv, key)
-	Purple::Conversation conv
-	const char * key
-
 Purple::ConnectionFlags
 purple_conversation_get_features(conv)
 	Purple::Conversation conv
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -1370,6 +1370,7 @@ hide_conv(PidginConversation *gtkconv, g
 #if 0
 		/* I will miss you */
 		purple_conversation_set_ui_ops(conv, NULL);
+		conv->ui_data = NULL;
 #else
 		pidgin_conv_window_remove_gtkconv(gtkconv->win, gtkconv);
 		pidgin_conv_window_add_gtkconv(hidden_convwin, gtkconv);
@@ -4119,11 +4120,11 @@ get_chat_user_status_icon(PurpleChatConv
 static void
 deleting_chat_user_cb(PurpleChatUser *cb)
 {
-	GtkTreeRowReference *ref = purple_chat_user_get_ui_data(cb);
+	GtkTreeRowReference *ref = cb->ui_data;
 
 	if (ref) {
 		gtk_tree_row_reference_free(ref);
-		purple_chat_user_set_ui_data(cb, NULL);
+		cb->ui_data = NULL;
 	}
 }
 
@@ -4208,13 +4209,13 @@ add_chat_user_common(PurpleChatConversat
 			CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
 			-1);
 
-	if (purple_chat_user_get_ui_data(cb)) {
-		GtkTreeRowReference *ref = purple_chat_user_get_ui_data(cb);
+	if (cb->ui_data) {
+		GtkTreeRowReference *ref = cb->ui_data;
 		gtk_tree_row_reference_free(ref);
 	}
 
 	newpath = gtk_tree_model_get_path(tm, &iter);
-	purple_chat_user_set_ui_data(cb, gtk_tree_row_reference_new(tm, newpath));
+	cb->ui_data = gtk_tree_row_reference_new(tm, newpath);
 	gtk_tree_path_free(newpath);
 
 	if (is_me && color)
@@ -5745,7 +5746,7 @@ private_gtkconv_new(PurpleConversation *
 	GtkTargetList *targets;
 
 	if (!is_chat && (gtkconv = pidgin_conv_find_gtkconv(conv))) {
-		purple_conversation_set_ui_data(conv, gtkconv);
+		conv->ui_data = gtkconv;
 		if (!g_list_find(gtkconv->convs, conv))
 			gtkconv->convs = g_list_prepend(gtkconv->convs, conv);
 		pidgin_conv_switch_active_conversation(conv);
@@ -5753,7 +5754,7 @@ private_gtkconv_new(PurpleConversation *
 	}
 
 	gtkconv = g_new0(PidginConversation, 1);
-	purple_conversation_set_ui_data(conv, gtkconv);
+	conv->ui_data = gtkconv;
 	gtkconv->active_conv = conv;
 	gtkconv->convs = g_list_prepend(gtkconv->convs, conv);
 	gtkconv->send_history = g_list_append(NULL, NULL);
@@ -5784,7 +5785,7 @@ private_gtkconv_new(PurpleConversation *
 			g_free(gtkconv->u.im);
 



More information about the Commits mailing list