/soc/2013/ankitkv/gobjectification: 1b2233f987cb: Backed out cha...

Ankit Vani a at nevitus.org
Sun Jun 30 06:24:10 EDT 2013


Changeset: 1b2233f987cbf94d9a862c07f6c8ab1851e229c6
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-30 15:37 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/1b2233f987cb

Description:

Backed out changeset f39c64847a3d

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, 104 insertions(+), 34 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(conv->ui_data);
+		gg_extended_menu(purple_conversation_get_ui_data(conv));
 	}
 }
 
@@ -796,7 +796,7 @@ finch_create_conversation(PurpleConversa
 
 	ggc->list = g_list_prepend(ggc->list, conv);
 	ggc->active_conv = conv;
-	conv->ui_data = ggc;
+	purple_conversation_set_ui_data(conv, 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 *)((conv)->ui_data))
+#define FINCH_CONV(conv) ((FinchConv *)purple_conversation_get_ui_data(conv))
 
 /***************************************************************************
  * @name GNT Conversations API
diff --git a/libpurple/account.h b/libpurple/account.h
--- a/libpurple/account.h
+++ b/libpurple/account.h
@@ -97,11 +97,6 @@ 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,6 +57,7 @@ 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
@@ -308,6 +309,7 @@ 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;
 }
 
@@ -859,6 +861,24 @@ 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)
@@ -993,6 +1013,7 @@ 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,11 +119,6 @@ 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);
@@ -508,6 +503,25 @@ 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,6 +111,7 @@ 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 */
@@ -1749,6 +1750,28 @@ 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,11 +155,6 @@ 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);
@@ -645,6 +640,25 @@ 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,6 +188,11 @@ 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,7 +1370,6 @@ 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);
@@ -4120,11 +4119,11 @@ get_chat_user_status_icon(PurpleChatConv
 static void
 deleting_chat_user_cb(PurpleChatUser *cb)
 {
-	GtkTreeRowReference *ref = cb->ui_data;
+	GtkTreeRowReference *ref = purple_chat_user_get_ui_data(cb);
 
 	if (ref) {
 		gtk_tree_row_reference_free(ref);
-		cb->ui_data = NULL;
+		purple_chat_user_set_ui_data(cb, NULL);
 	}
 }
 
@@ -4209,13 +4208,13 @@ add_chat_user_common(PurpleChatConversat
 			CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
 			-1);
 
-	if (cb->ui_data) {
-		GtkTreeRowReference *ref = cb->ui_data;
+	if (purple_chat_user_get_ui_data(cb)) {
+		GtkTreeRowReference *ref = purple_chat_user_get_ui_data(cb);
 		gtk_tree_row_reference_free(ref);
 	}
 
 	newpath = gtk_tree_model_get_path(tm, &iter);
-	cb->ui_data = gtk_tree_row_reference_new(tm, newpath);
+	purple_chat_user_set_ui_data(cb, gtk_tree_row_reference_new(tm, newpath));
 	gtk_tree_path_free(newpath);
 
 	if (is_me && color)
@@ -5746,7 +5745,7 @@ private_gtkconv_new(PurpleConversation *
 	GtkTargetList *targets;
 
 	if (!is_chat && (gtkconv = pidgin_conv_find_gtkconv(conv))) {
-		conv->ui_data = gtkconv;
+		purple_conversation_set_ui_data(conv, gtkconv);
 		if (!g_list_find(gtkconv->convs, conv))
 			gtkconv->convs = g_list_prepend(gtkconv->convs, conv);
 		pidgin_conv_switch_active_conversation(conv);
@@ -5754,7 +5753,7 @@ private_gtkconv_new(PurpleConversation *
 	}
 
 	gtkconv = g_new0(PidginConversation, 1);
-	conv->ui_data = gtkconv;
+	purple_conversation_set_ui_data(conv, gtkconv);
 	gtkconv->active_conv = conv;
 	gtkconv->convs = g_list_prepend(gtkconv->convs, conv);
 	gtkconv->send_history = g_list_append(NULL, NULL);
@@ -5785,7 +5784,7 @@ private_gtkconv_new(PurpleConversation *
 			g_free(gtkconv->u.im);
 



More information about the Commits mailing list