gobjectification: cd5571c4: GObjectified PBlist

aluink at soc.pidgin.im aluink at soc.pidgin.im
Wed Jun 24 03:55:29 EDT 2009


-----------------------------------------------------------------
Revision: cd5571c4fe8193525f4460ec321fc7a0d5f1e1f2
Ancestor: 89f00aa1f4346e58e81a2a36ee93091333f9ce80
Author: aluink at soc.pidgin.im
Date: 2009-06-24T07:52:54
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/cd5571c4fe8193525f4460ec321fc7a0d5f1e1f2

Modified files:
        libpurple/blist.c libpurple/blist.h

ChangeLog: 

GObjectified PBlist

-------------- next part --------------
============================================================
--- libpurple/blist.c	f7225321b42f1a8b1ec6274cd18f57a27ad79101
+++ libpurple/blist.c	ebb38e6846cc3e5864db04a7c2e3760080fb506a
@@ -312,7 +312,7 @@ PurpleBuddyList *purple_blist_new()
 {
 	PurpleBlistUiOps *ui_ops;
 	GList *account;
-	PurpleBuddyList *gbl = g_new0(PurpleBuddyList, 1);
+	PurpleBuddyList *gbl = g_object_new(PURPLE_BLIST_TYPE, NULL);
 	PURPLE_DBUS_REGISTER_POINTER(gbl, PurpleBuddyList);
 
 	ui_ops = purple_blist_get_ui_ops();
@@ -1106,6 +1106,7 @@ purple_blist_init(void)
 void
 purple_blist_init(void)
 {
+  #warning: Should this be moved to the PurpleBlistClass init func?
 	void *handle = purple_blist_get_handle();
 
 	purple_signal_register(handle, "buddy-status-changed",
@@ -1226,3 +1227,46 @@ purple_blist_uninit(void)
 	purple_signals_disconnect_by_handle(purple_blist_get_handle());
 	purple_signals_unregister_by_instance(purple_blist_get_handle());
 };
+
+/******************/
+/*  GObject Code  */
+/******************/
+
+static void
+purple_blist_class_init(PurpleBuddyListClass *klass)
+{
+
+}
+
+static void
+purple_blist_instance_init(GTypeInstance *instance, gpointer class)
+{
+
+}
+
+GType
+purple_blist_get_gtype(void)
+{
+	static GType type = 0;
+
+	if(type == 0) {
+		static const GTypeInfo info = {
+			sizeof(PurpleBuddyListClass),
+			NULL,					/* base_init		*/
+			NULL,					/* base_finalize	*/
+			(GClassInitFunc)purple_blist_class_init,
+			NULL,
+			NULL,					/* class_data		*/
+			sizeof(PurpleBuddyList),
+			0,						/* n_preallocs		*/
+			purple_blist_instance_init,					/* instance_init	*/
+			NULL					/* value_table		*/
+		};
+
+		type = g_type_register_static(PURPLE_TYPE_OBJECT,
+									  "PurpleBlist",
+									  &info, G_TYPE_FLAG_ABSTRACT);
+	}
+
+	return type;
+}
============================================================
--- libpurple/blist.h	bdd4ac50d1b8d7e7a6b754898ea5eca8d0b985ff
+++ libpurple/blist.h	2180898a33a62073ef708d22edf3c01bce1fa301
@@ -31,8 +31,6 @@
 
 #include <glib.h>
 
-/** @copydoc _PurpleBuddyList */
-typedef struct _PurpleBuddyList PurpleBuddyList;
 /** @copydoc _PurpleBlistUiOps */
 typedef struct _PurpleBlistUiOps PurpleBlistUiOps;
 
@@ -123,7 +121,17 @@ typedef struct _PurpleChatClass PurpleCh
 #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))
 
+/** @copydoc _PurpleBlist */
+typedef struct _PurpleBuddyList PurpleBuddyList;
+typedef struct _PurpleBuddyListClass PurpleBuddyListClass;
+#define PURPLE_BLIST_TYPE                  (purple_blist_get_gtype ())
+#define PURPLE_BLIST(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), PURPLE_BLIST_TYPE, PurpleBlist))
+#define PURPLE_BLIST_IS(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PURPLE_BLIST_TYPE))
+#define PURPLE_BLIST_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), PURPLE_BLIST_TYPE, PurpleBlistClass))
+#define PURPLE_BLIST_IS_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), PURPLE_BLIST_TYPE))
+#define PURPLE_BLIST_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), PURPLE_BLIST_TYPE, PurpleBlistClass))
 
+
 #include "account.h"
 #include "buddyicon.h"
 #include "status.h"
@@ -244,6 +252,7 @@ struct _PurpleBuddyList {
  * The Buddy List
  */
 struct _PurpleBuddyList {
+  PurpleObject parent;
 	PurpleBlistNode *root;          /**< The first node in the buddy list */
 	GHashTable *buddies;          /**< Every buddy in this list */
   
@@ -259,6 +268,10 @@ struct _PurpleBuddyList {
 	void *ui_data;                /**< UI-specific data. */
 };
 
+struct _PurpleBuddyListClass {
+  PurpleObjectClass parent;
+};
+
 #endif /* PURPLE_HIDE_STRUCTS && PURPLE_BLIST_STRUCTS */
 
 /**
@@ -1334,6 +1347,11 @@ GType purple_chat_get_gtype(void);
  */
 GType purple_chat_get_gtype(void);
 
+/**
+ * Get the GType for PurpleChat
+ */
+GType purple_blist_get_gtype(void);
+
 /*@}*/
 
 #ifdef __cplusplus


More information about the Commits mailing list