/soc/2013/ankitkv/gobjectification: 28b0f26f011f: Added GObject ...

Ankit Vani a at nevitus.org
Sat Jun 22 09:45:18 EDT 2013


Changeset: 28b0f26f011f83c83624e6c3e3e283232d879ad9
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-22 19:15 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/28b0f26f011f

Description:

Added GObject boilerplate code for headers, also _new() and _get_type() functions.

diffstat:

 libpurple/conversation.h                      |  33 +++-------
 libpurple/conversationtypes.h                 |  84 +++++++++++++++++++++++++++
 libpurple/plugins/perl/common/Conversation.xs |  22 ++++--
 3 files changed, 108 insertions(+), 31 deletions(-)

diffs (236 lines):

diff --git a/libpurple/conversation.h b/libpurple/conversation.h
--- a/libpurple/conversation.h
+++ b/libpurple/conversation.h
@@ -26,6 +26,13 @@
 #ifndef _PURPLE_CONVERSATION_H_
 #define _PURPLE_CONVERSATION_H_
 
+#define PURPLE_TYPE_CONVERSATION             (purple_conversation_get_type())
+#define PURPLE_CONVERSATION(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_CONVERSATION, PurpleConversation))
+#define PURPLE_CONVERSATION_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_CONVERSATION, PurpleConversationClass))
+#define PURPLE_IS_CONVERSATION(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_CONVERSATION))
+#define PURPLE_IS_CONVERSATION_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_CONVERSATION))
+#define PURPLE_CONVERSATION_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_CONVERSATION, PurpleConversationClass))
+
 /**************************************************************************/
 /** Data Structures                                                       */
 /**************************************************************************/
@@ -242,19 +249,10 @@ G_BEGIN_DECLS
 /**************************************************************************/
 /*@{*/
 
-/** TODO GObjectify
- * Creates a new conversation of the specified type.
- *
- * @param type    The type of conversation.
- * @param account The account opening the conversation window on the purple
- *                user's end.
- * @param name    The name of the conversation. For PURPLE_CONVERSATION_TYPE_IM,
- *                this is the name of the buddy.
- *
- * @return The new conversation.
+/** TODO
+ * Returns the GType for the Conversation object.
  */
-PurpleConversation *purple_conversation_new(GType type, PurpleAccount *account,
-		const char *name);
+GType purple_conversation_get_type(void);
 
 /** TODO dispose/fnalize
  * Destroys the specified conversation and removes it from the parent
@@ -267,7 +265,6 @@ PurpleConversation *purple_conversation_
  */
 void purple_conversation_destroy(PurpleConversation *conv);
 
-
 /**
  * Present a conversation to the user. This allows core code to initiate a
  * conversation by displaying the IM dialog.
@@ -275,16 +272,6 @@ void purple_conversation_destroy(PurpleC
  */
 void purple_conversation_present(PurpleConversation *conv);
 
-
-/** TODO REMOVE, return the GObject GType
- * Returns the specified conversation's type.
- *
- * @param conv The conversation.
- *
- * @return The conversation's type.
- */
-/*PurpleConversationType purple_conversation_get_type(const PurpleConversation *conv);*/
-
 /**
  * Sets the specified conversation's UI operations structure.
  *
diff --git a/libpurple/conversationtypes.h b/libpurple/conversationtypes.h
--- a/libpurple/conversationtypes.h
+++ b/libpurple/conversationtypes.h
@@ -30,16 +30,61 @@
 /** Data Structures                                                       */
 /**************************************************************************/
 
+#define PURPLE_TYPE_IM_CONVERSATION       (purple_im_conversation_get_type())
+#define PURPLE_IM_CONVERSATION(obj)       (G_TYPE_CHECK_INSTANCE_CAST((obj),  \
+                                           PURPLE_TYPE_IM_CONVERSATION,       \
+                                           PurpleIMConversation))
+#define PURPLE_IM_CONVERSATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \
+                                           PURPLE_TYPE_IM_CONVERSATION,       \
+                                           PurpleIMConversationClass))
+#define PURPLE_IS_IM_CONVERSATION(obj)    (G_TYPE_CHECK_INSTANCE_TYPE((obj),  \
+                                           PURPLE_TYPE_IM_CONVERSATION))
+#define PURPLE_IS_IM_CONVERSATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\
+                                           PURPLE_TYPE_IM_CONVERSATION))
+#define PURPLE_IM_CONVERSATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),\
+                                           PURPLE_TYPE_IM_CONVERSATION,       \
+                                           PurpleIMConversationClass))
+
 /** @copydoc _PurpleIMConversation */
 typedef struct _PurpleIMConversation         PurpleIMConversation;
 /** @copydoc _PurpleIMConversationClass */
 typedef struct _PurpleIMConversationClass    PurpleIMConversationClass;
 
+#define PURPLE_TYPE_CHAT_CONVERSATION     (purple_chat_conversation_get_type())
+#define PURPLE_CHAT_CONVERSATION(obj)     (G_TYPE_CHECK_INSTANCE_CAST((obj),  \
+                                           PURPLE_TYPE_CHAT_CONVERSATION,     \
+                                           PurpleChatConversation))
+#define PURPLE_CHAT_CONVERSATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\
+                                           PURPLE_TYPE_CHAT_CONVERSATION,     \
+                                           PurpleChatConversationClass))
+#define PURPLE_IS_CHAT_CONVERSATION(obj)  (G_TYPE_CHECK_INSTANCE_TYPE((obj),  \
+                                           PURPLE_TYPE_CHAT_CONVERSATION))
+#define PURPLE_IS_CHAT_CONVERSATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\
+                                           PURPLE_TYPE_CHAT_CONVERSATION))
+#define PURPLE_CHAT_CONVERSATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),\
+                                           PURPLE_TYPE_CHAT_CONVERSATION,     \
+                                           PurpleChatConversationClass))
+
 /** @copydoc _PurpleChatConversation */
 typedef struct _PurpleChatConversation       PurpleChatConversation;
 /** @copydoc _PurpleChatConversationClass */
 typedef struct _PurpleChatConversationClass  PurpleChatConversationClass;
 
+#define PURPLE_TYPE_CHAT_CONVERSATION_BUDDY (purple_chat_conversation_buddy_get_type())
+#define PURPLE_CHAT_CONVERSATION_BUDDY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+                                           PURPLE_TYPE_CHAT_CONVERSATION_BUDDY,\
+                                           PurpleChatConversationBuddy))
+#define PURPLE_CHAT_CONVERSATION_BUDDY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\
+                                           PURPLE_TYPE_CHAT_CONVERSATION_BUDDY,\
+                                           PurpleChatConversationBuddyClass))
+#define PURPLE_IS_CHAT_CONVERSATION_BUDDY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
+                                           PURPLE_TYPE_CHAT_CONVERSATION_BUDDY))
+#define PURPLE_IS_CHAT_CONVERSATION_BUDDY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\
+                                           PURPLE_TYPE_CHAT_CONVERSATION_BUDDY))
+#define PURPLE_CHAT_CONVERSATION_BUDDY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),\
+                                           PURPLE_TYPE_CHAT_CONVERSATION_BUDDY,\
+                                           PurpleChatConversationBuddyClass))
+
 /** @copydoc _PurpleChatConversationBuddy */
 typedef struct _PurpleChatConversationBuddy       PurpleChatConversationBuddy;
 /** @copydoc _PurpleChatConversationBuddyClass */
@@ -158,6 +203,23 @@ G_BEGIN_DECLS
 /**************************************************************************/
 /*@{*/
 
+/** TODO
+ * Returns the GType for the IMConversation object.
+ */
+GType purple_im_conversation_get_type(void);
+
+/** TODO take from conversation.c purple_conversation_new()
+ * Creates a new IM conversation.
+ *
+ * @param account The account opening the conversation window on the purple
+ *                user's end.
+ * @param name    Name of the buddy.
+ *
+ * @return The new conversation.
+ */
+PurpleIMConversation *purple_im_conversation_new(PurpleAccount *account,
+		const char *name);
+
 /**
  * Sets the IM's buddy icon.
  *
@@ -313,6 +375,23 @@ void purple_im_conversation_send_with_fl
 /**************************************************************************/
 /*@{*/
 
+/** TODO
+ * Returns the GType for the ChatConversation object.
+ */
+GType purple_chat_conversation_get_type(void);
+
+/** TODO take from conversation.c purple_conversation_new()
+ * Creates a new chat conversation.
+ *
+ * @param account The account opening the conversation window on the purple
+ *                user's end.
+ * @param name    The name of the conversation.
+ *
+ * @return The new conversation.
+ */
+PurpleChatConversation *purple_chat_conversation_new(PurpleAccount *account,
+		const char *name);
+
 /**
  * Returns a list of users in the chat room.  The members of the list
  * are PurpleChatConversationBuddy objects.
@@ -622,6 +701,11 @@ gboolean purple_chat_conversation_has_le
 /**************************************************************************/
 /*@{*/
 
+/** TODO
+ * Returns the GType for the ChatConversationBuddy object.
+ */
+GType purple_chat_conversation_buddy_get_type(void);
+
 /**
  * Get an attribute of a chat buddy
  *
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
@@ -183,14 +183,6 @@ purple_conversation_update(conv, type)
 	Purple::Conversation conv
 	Purple::Conversation::UpdateType type
 
-Purple::Conversation
-purple_conversation_new(class, type, account, name)
-	GType type
-	Purple::Account account
-	const char *name
-    C_ARGS:
-	type, account, name
-
 void
 purple_conversation_set_account(conv, account);
 	Purple::Conversation conv
@@ -214,6 +206,13 @@ purple_conversation_do_command(conv, cmd
 MODULE = Purple::Conversation  PACKAGE = Purple::IMConversation  PREFIX = purple_im_conversation_
 PROTOTYPES: ENABLE
 
+Purple::IMConversation
+purple_im_conversation_new(class, account, name)
+	Purple::Account account
+	const char *name
+    C_ARGS:
+	account, name
+
 void
 purple_im_conversation_set_icon(im, icon)
 	Purple::IMConversation im
@@ -309,6 +308,13 @@ purple_conversation_custom_smiley_close(
 MODULE = Purple::Conversation  PACKAGE = Purple::ChatConversation  PREFIX = purple_chat_conversation_
 PROTOTYPES: ENABLE
 
+Purple::ChatConversation
+purple_chat_conversation_new(class, account, name)
+	Purple::Account account
+	const char *name
+    C_ARGS:
+	account, name
+
 void
 purple_chat_conversation_get_users(chat)
 	Purple::ChatConversation chat



More information about the Commits mailing list