gobjectification: 4cf86b56: Converted most blist objects to GObjects

aluink at soc.pidgin.im aluink at soc.pidgin.im
Tue Jun 23 00:15:31 EDT 2009


-----------------------------------------------------------------
Revision: 4cf86b56db96606d6ead2894d789e1c80b4ff219
Ancestor: 274289d5e03233a0f724775fff66128aec183b98
Author: aluink at soc.pidgin.im
Date: 2009-06-23T04:12:26
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/4cf86b56db96606d6ead2894d789e1c80b4ff219

Modified files:
        libpurple/blist-node.c libpurple/blist.h libpurple/buddy.c
        libpurple/chat.c libpurple/contact.c libpurple/group.c

ChangeLog: 

Converted most blist objects to GObjects

-------------- next part --------------
============================================================
--- libpurple/blist-node.c	480b46f9e12bcac2bf8847e5197a863306b13b80
+++ libpurple/blist-node.c	44dfa0dd50dc64f1eb9a7a953705bd4d249232f0
@@ -669,12 +669,10 @@ purple_blist_node_get_gtype(void)
 			NULL					/* value_table		*/
 		};
 
-		type = g_type_register_static(PURPLE_BLIST_NODE_TYPE,
+		type = g_type_register_static(G_TYPE_OBJECT,
 									  "PurpleBlistNode",
 									  &info, G_TYPE_FLAG_ABSTRACT);
 	}
 
 	return type;
 }
-
-
============================================================
--- libpurple/blist.h	e032a592749e232317437f575e41c7e7a574f643
+++ libpurple/blist.h	ddf776b70c3803bc61b82c41446886bd01b6377b
@@ -35,19 +35,7 @@ typedef struct _PurpleBlistUiOps PurpleB
 typedef struct _PurpleBuddyList PurpleBuddyList;
 /** @copydoc _PurpleBlistUiOps */
 typedef struct _PurpleBlistUiOps PurpleBlistUiOps;
-/** @copydoc _PurpleBlistNode */
-typedef struct _PurpleBlistNode PurpleBlistNode;
-typedef struct _PurpleBlistNodeClass PurpleBlistNodeClass;
 
-/** @copydoc _PurpleChat */
-typedef struct _PurpleChat PurpleChat;
-/** @copydoc _PurpleGroup */
-typedef struct _PurpleGroup PurpleGroup;
-/** @copydoc _PurpleContact */
-typedef struct _PurpleContact PurpleContact;
-/** @copydoc _PurpleBuddy */
-typedef struct _PurpleBuddy PurpleBuddy;
-
 /**************************************************************************/
 /* Enumerations                                                           */
 /**************************************************************************/
@@ -85,38 +73,9 @@ typedef enum
 #define PURPLE_BLIST_NODE_NAME(n) (purple_blist_node_get_type(n) == PURPLE_BLIST_CHAT_NODE  ? purple_chat_get_name((PurpleChat*)n) :        \
 				     purple_blist_node_get_type(n) == PURPLE_BLIST_BUDDY_NODE ? purple_buddy_get_name((PurpleBuddy*)n) : NULL)
 
-/**
- * @since 2.6.0
- */
-#define PURPLE_GROUP(obj) ((PurpleGroup *)(obj))
-
-/**
- * @since 2.6.0
- */
-#define PURPLE_CONTACT(obj) ((PurpleContact *)(obj))
-
-/**
- * @since 2.6.0
- */
-#define PURPLE_BUDDY(obj) ((PurpleBuddy *)(obj))
-
-/**
- * @since 2.6.0
- */
-#define PURPLE_CHAT(obj) ((PurpleChat *)(obj))
-
-/* Template */
-/*
-#define MAMAN_TYPE                  (maman_get_type ())
-#define MAMAN(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAMAN_TYPE, Maman))
-#define MAMAN_IS(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAMAN_TYPE))
-#define MAMAN_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), MAMAN_TYPE, MamanClass))
-#define MAMAN_IS_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), MAMAN_TYPE))
-#define MAMAN_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), MAMAN_TYPE, MamanClass))
-*/
-
-/* GObject macros */
-
+/** @copydoc _PurpleBlistNode */
+typedef struct _PurpleBlistNode PurpleBlistNode;
+typedef struct _PurpleBlistNodeClass PurpleBlistNodeClass;
 #define PURPLE_BLIST_NODE_TYPE                  (purple_blist_node_get_gtype ())
 #define PURPLE_BLIST_NODE(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), PURPLE_BLIST_NODE_TYPE, PurpleBlistNode))
 #define PURPLE_BLIST_NODE_IS(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PURPLE_BLIST_NODE_TYPE))
@@ -124,7 +83,47 @@ typedef enum
 #define PURPLE_BLIST_NODE_IS_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), PURPLE_BLIST_NODE_TYPE))
 #define PURPLE_BLIST_NODE_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), PURPLE_BLIST_NODE_TYPE, PurpleBlistNodeClass))
 
+/** @copydoc _PurpleBuddy */
+typedef struct _PurpleBuddy PurpleBuddy;
+typedef struct _PurpleBuddyClass PurpleBuddyClass;
+#define PURPLE_BUDDY_TYPE                  (purple_buddy_get_gtype ())
+#define PURPLE_BUDDY(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), PURPLE_BUDDY_TYPE, PurpleBuddy))
+#define PURPLE_BUDDY_IS(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PURPLE_BUDDY_TYPE))
+#define PURPLE_BUDDY_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), PURPLE_BUDDY_TYPE, PurpleBuddyClass))
+#define PURPLE_BUDDY_IS_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), PURPLE_BUDDY_TYPE))
+#define PURPLE_BUDDY_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), PURPLE_BUDDY_TYPE, PurpleBuddyClass))
 
+/** @copydoc _PurpleContact */
+typedef struct _PurpleContact PurpleContact;
+typedef struct _PurpleContactClass PurpleContactClass;
+#define PURPLE_CONTACT_TYPE                  (purple_contact_get_gtype ())
+#define PURPLE_CONTACT(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), PURPLE_CONTACT_TYPE, PurpleContact))
+#define PURPLE_CONTACT_IS(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PURPLE_CONTACT_TYPE))
+#define PURPLE_CONTACT_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), PURPLE_CONTACT_TYPE, PurpleContactClass))
+#define PURPLE_CONTACT_IS_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), PURPLE_CONTACT_TYPE))
+#define PURPLE_CONTACT_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), PURPLE_CONTACT_TYPE, PurpleContactClass))
+
+/** @copydoc _PurpleGroup */
+typedef struct _PurpleGroup PurpleGroup;
+typedef struct _PurpleGroupClass PurpleGroupClass;
+#define PURPLE_GROUP_TYPE                  (purple_group_get_gtype ())
+#define PURPLE_GROUP(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), PURPLE_GROUP_TYPE, PurpleGroup))
+#define PURPLE_GROUP_IS(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PURPLE_GROUP_TYPE))
+#define PURPLE_GROUP_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), PURPLE_GROUP_TYPE, PurpleGroupClass))
+#define PURPLE_GROUP_IS_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), PURPLE_GROUP_TYPE))
+#define PURPLE_GROUP_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), PURPLE_GROUP_TYPE, PurpleGroupClass))
+
+/** @copydoc _PurpleChat */
+typedef struct _PurpleChat PurpleChat;
+typedef struct _PurpleChatClass PurpleChatClass;
+#define PURPLE_CHAT_TYPE                  (purple_chat_get_gtype ())
+#define PURPLE_CHAT(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), PURPLE_CHAT_TYPE, PurpleChat))
+#define PURPLE_CHAT_IS(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PURPLE_CHAT_TYPE))
+#define PURPLE_CHAT_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), PURPLE_CHAT_TYPE, PurpleChatClass))
+#define PURPLE_CHAT_IS_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), PURPLE_CHAT_TYPE))
+#define PURPLE_CHAT_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), PURPLE_CHAT_TYPE, PurpleChatClass))
+
+
 #include "account.h"
 #include "buddyicon.h"
 #include "status.h"
@@ -178,6 +177,10 @@ struct _PurpleBuddy {
 	PurplePresence *presence;
 };
 
+struct _PurpleBuddyClass {
+  GObjectClass parent;
+};
+
 #endif
 #if !(defined PURPLE_HIDE_STRUCTS) || (defined _PURPLE_CONTACT_C_)
 
@@ -194,6 +197,10 @@ struct _PurpleContact {
 	gboolean priority_valid; /**< Is priority valid? */
 };
 
+struct _PurpleContactClass {
+  GObjectClass parent;
+};
+
 #endif
 #if !(defined PURPLE_HIDE_STRUCTS) || (defined _PURPLE_GROUP_C_)
 
@@ -208,6 +215,10 @@ struct _PurpleGroup {
 	int online;			       /**< The number of chats and contacts in this group who are currently online */
 };
 
+struct _PurpleGroupClass {
+  GObjectClass parent;
+};
+
 #endif
 #if !(defined PURPLE_HIDE_STRUCTS) || (defined _PURPLE_CHAT_C_)
 
@@ -222,6 +233,10 @@ struct _PurpleChat {
 	PurpleAccount *account; /**< The account this chat is attached to */
 };
 
+struct _PurpleChatClass {
+  GObjectClass parent;
+};
+
 #endif
 #if !(defined PURPLE_HIDE_STRUCTS) || (defined _PURPLE_BLIST_C_)
 
@@ -1299,6 +1314,26 @@ GType purple_blist_node_get_gtype(void);
  */
 GType purple_blist_node_get_gtype(void);
 
+/**
+ * Get the GType for PurpleBuddy
+ */
+GType purple_buddy_get_gtype(void);
+
+/**
+ * Get the GType for PurpleGroup
+ */
+GType purple_group_get_gtype(void);
+
+/**
+ * Get the GType for PurpleContact
+ */
+GType purple_contact_get_gtype(void);
+
+/**
+ * Get the GType for PurpleChat
+ */
+GType purple_chat_get_gtype(void);
+
 /*@}*/
 
 #ifdef __cplusplus
============================================================
--- libpurple/buddy.c	675bf8a5ec6d986afd72d68467c94bd5392d2ca6
+++ libpurple/buddy.c	7b71d55d5d07c1d35828bb5a14b0147d2bf382e8
@@ -292,7 +292,7 @@ PurpleBuddy *purple_buddy_new(PurpleAcco
 	g_return_val_if_fail(account != NULL, NULL);
 	g_return_val_if_fail(name != NULL, NULL);
 
-	buddy = g_new0(PurpleBuddy, 1);
+	buddy = g_object_new(PURPLE_BUDDY_TYPE, NULL);
 	buddy->account  = account;
 	buddy->name     = purple_utf8_strip_unprintables(name);
 	buddy->alias    = purple_utf8_strip_unprintables(alias);
@@ -563,3 +563,46 @@ buddy_to_xmlnode(PurpleBlistNode *bnode)
 
 	return node;
 }
+
+/******************/
+/*  GObject Code  */
+/******************/
+
+static void
+purple_buddy_class_init(PurpleBuddyClass *klass)
+{
+
+}
+
+static void
+purple_buddy_init(GTypeInstance *instance, gpointer class)
+{
+
+}
+
+GType
+purple_buddy_get_gtype(void)
+{
+	static GType type = 0;
+
+	if(type == 0) {
+		static const GTypeInfo info = {
+			sizeof(PurpleBuddyClass),
+			NULL,					/* base_init		*/
+			NULL,					/* base_finalize	*/
+			(GClassInitFunc)purple_buddy_class_init,
+			NULL,
+			NULL,					/* class_data		*/
+			sizeof(PurpleBuddy),
+			0,						/* n_preallocs		*/
+			purple_buddy_init,					/* instance_init	*/
+			NULL					/* value_table		*/
+		};
+
+		type = g_type_register_static(PURPLE_BLIST_NODE_TYPE,
+									  "PurpleBuddy",
+									  &info, G_TYPE_FLAG_ABSTRACT);
+	}
+
+	return type;
+}
============================================================
--- libpurple/chat.c	650d6fd5448bb33ae3d305fd4d914c9227e8e153
+++ libpurple/chat.c	b27838a4ed9642c46e056a7db2c7355b5e980346
@@ -173,7 +173,7 @@ PurpleChat *purple_chat_new(PurpleAccoun
 	g_return_val_if_fail(account != NULL, FALSE);
 	g_return_val_if_fail(components != NULL, FALSE);
 
-	chat = g_new0(PurpleChat, 1);
+	chat = g_object_new(PURPLE_CHAT_TYPE, NULL);
 	chat->account = account;
 	if ((alias != NULL) && (*alias != '\0'))
 		chat->alias = purple_utf8_strip_unprintables(alias);
@@ -304,4 +304,45 @@ purple_chat_get_components(PurpleChat *c
 	return chat->components;
 }
 
+/******************/
+/*  GObject Code  */
+/******************/
 
+static void
+purple_chat_class_init(PurpleChatClass *klass)
+{
+
+}
+
+static void
+purple_chat_init(GTypeInstance *instance, gpointer class)
+{
+
+}
+
+GType
+purple_chat_get_gtype(void)
+{
+  static GType type = 0;
+
+  if(type == 0) {
+    static const GTypeInfo info = {
+      sizeof(PurpleChatClass),
+      NULL,					/* base_init		*/
+      NULL,					/* base_finalize	*/
+      (GClassInitFunc)purple_chat_class_init,
+      NULL,
+      NULL,					/* class_data		*/
+      sizeof(PurpleChat),
+      0,						/* n_preallocs		*/
+      purple_chat_init,					/* instance_init	*/
+      NULL					/* value_table		*/
+    };
+
+    type = g_type_register_static(PURPLE_BLIST_NODE_TYPE,
+                    "PurpleChat",
+                    &info, G_TYPE_FLAG_ABSTRACT);
+  }
+
+  return type;
+}
============================================================
--- libpurple/contact.c	cff020e56535acd584508133fa7acc717f5a733c
+++ libpurple/contact.c	65169629e90a79cf47a08c1ac30984844813e361
@@ -199,7 +199,7 @@ PurpleContact *purple_contact_new()
 {
 	PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
 
-	PurpleContact *contact = g_new0(PurpleContact, 1);
+	PurpleContact *contact = g_object_new(PURPLE_CONTACT_TYPE, NULL);
 	contact->totalsize = 0;
 	contact->currentsize = 0;
 	contact->online = 0;
@@ -264,39 +264,55 @@ void purple_contact_invalidate_priority_
 	contact->priority_valid = FALSE;
 }
 
-PurpleGroup *purple_group_new(const char *name)
+PurpleBuddy *purple_contact_get_priority_buddy(PurpleContact *contact)
 {
-	PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
-	PurpleGroup *group;
+	g_return_val_if_fail(contact != NULL, NULL);
 
-	g_return_val_if_fail(name  != NULL, NULL);
-	g_return_val_if_fail(*name != '\0', NULL);
+	if (!contact->priority_valid)
+		purple_contact_compute_priority_buddy(contact);
 
-	group = purple_find_group(name);
-	if (group != NULL)
-		return group;
+	return contact->priority;
+}
 
-	group = g_new0(PurpleGroup, 1);
-	group->name = purple_utf8_strip_unprintables(name);
-	group->totalsize = 0;
-	group->currentsize = 0;
-	group->online = 0;
-	purple_blist_node_initialize_settings((PurpleBlistNode *)group);
-	((PurpleBlistNode *)group)->type = PURPLE_BLIST_GROUP_NODE;
+/****************/
+/* GObject Code */
+/****************/
 
-	if (ops && ops->new_node)
-		ops->new_node((PurpleBlistNode *)group);
+static void
+purple_contact_class_init(PurpleContactClass *klass)
+{
 
-	PURPLE_DBUS_REGISTER_POINTER(group, PurpleGroup);
-	return group;
 }
 
-PurpleBuddy *purple_contact_get_priority_buddy(PurpleContact *contact)
+static void
+purple_contact_init(GTypeInstance *instance, gpointer class)
 {
-	g_return_val_if_fail(contact != NULL, NULL);
 
-	if (!contact->priority_valid)
-		purple_contact_compute_priority_buddy(contact);
+}
 
-	return contact->priority;
+GType
+purple_contact_get_gtype(void)
+{
+	static GType type = 0;
+
+	if(type == 0) {
+		static const GTypeInfo info = {
+			sizeof(PurpleContactClass),
+			NULL,					/* base_init		*/
+			NULL,					/* base_finalize	*/
+			(GClassInitFunc)purple_contact_class_init,
+			NULL,
+			NULL,					/* class_data		*/
+			sizeof(PurpleContact),
+			0,						/* n_preallocs		*/
+			purple_contact_init,					/* instance_init	*/
+			NULL					/* value_table		*/
+		};
+
+		type = g_type_register_static(PURPLE_BLIST_NODE_TYPE,
+									  "PurpleContact",
+									  &info, G_TYPE_FLAG_ABSTRACT);
+	}
+
+	return type;
 }
============================================================
--- libpurple/group.c	55b23ef42d49ff774c2949cfad4df0575ae6e1de
+++ libpurple/group.c	3d40773e4ab3ec7ada31399601afee4986adb0a9
@@ -282,3 +282,74 @@ int purple_blist_get_group_online_count(
 
 	return group->online;
 }
+
+PurpleGroup *purple_group_new(const char *name)
+{
+  PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
+  PurpleGroup *group;
+
+  g_return_val_if_fail(name  != NULL, NULL);
+  g_return_val_if_fail(*name != '\0', NULL);
+
+  group = purple_find_group(name);
+  if (group != NULL)
+    return group;
+
+  group = g_object_new(PURPLE_GROUP_TYPE, NULL);
+  group->name = purple_utf8_strip_unprintables(name);
+  group->totalsize = 0;
+  group->currentsize = 0;
+  group->online = 0;
+  purple_blist_node_initialize_settings((PurpleBlistNode *)group);
+  ((PurpleBlistNode *)group)->type = PURPLE_BLIST_GROUP_NODE;
+
+  if (ops && ops->new_node)
+    ops->new_node((PurpleBlistNode *)group);
+
+  PURPLE_DBUS_REGISTER_POINTER(group, PurpleGroup);
+  return group;
+}
+
+
+/******************/
+/*  GObject Code  */
+/******************/
+
+static void
+purple_group_class_init(PurpleGroupClass *klass)
+{
+
+}
+
+static void
+purple_group_init(GTypeInstance *instance, gpointer class)
+{
+
+}
+
+GType
+purple_group_get_gtype(void)
+{
+	static GType type = 0;
+
+	if(type == 0) {
+		static const GTypeInfo info = {
+			sizeof(PurpleGroupClass),
+			NULL,					/* base_init		*/
+			NULL,					/* base_finalize	*/
+			(GClassInitFunc)purple_group_class_init,
+			NULL,
+			NULL,					/* class_data		*/
+			sizeof(PurpleGroup),
+			0,						/* n_preallocs		*/
+			purple_group_init,					/* instance_init	*/
+			NULL					/* value_table		*/
+		};
+
+		type = g_type_register_static(PURPLE_BLIST_NODE_TYPE,
+									  "PurpleGroup",
+									  &info, G_TYPE_FLAG_ABSTRACT);
+	}
+
+	return type;
+}


More information about the Commits mailing list