aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-chatroom-manager.c
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-01-10 00:15:17 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-01-10 00:15:17 +0800
commit1991fd5404adbc78e244cd38c7aa297c4933aef1 (patch)
treebac99eb80423cf7de6e4561b4a3542e4f4097a9c /libempathy/empathy-chatroom-manager.c
parente805d6ba0430bcc5f7bbc400e5152cf36b8d92ff (diff)
downloadgsoc2013-empathy-1991fd5404adbc78e244cd38c7aa297c4933aef1.tar
gsoc2013-empathy-1991fd5404adbc78e244cd38c7aa297c4933aef1.tar.gz
gsoc2013-empathy-1991fd5404adbc78e244cd38c7aa297c4933aef1.tar.bz2
gsoc2013-empathy-1991fd5404adbc78e244cd38c7aa297c4933aef1.tar.lz
gsoc2013-empathy-1991fd5404adbc78e244cd38c7aa297c4933aef1.tar.xz
gsoc2013-empathy-1991fd5404adbc78e244cd38c7aa297c4933aef1.tar.zst
gsoc2013-empathy-1991fd5404adbc78e244cd38c7aa297c4933aef1.zip
Convert EmpathyChatroomManager to the new singleton convention
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk> svn path=/trunk/; revision=2185
Diffstat (limited to 'libempathy/empathy-chatroom-manager.c')
-rw-r--r--libempathy/empathy-chatroom-manager.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c
index 585319604..282d7ed71 100644
--- a/libempathy/empathy-chatroom-manager.c
+++ b/libempathy/empathy-chatroom-manager.c
@@ -42,6 +42,8 @@
#define CHATROOMS_DTD_FILENAME "empathy-chatroom-manager.dtd"
#define SAVE_TIMER 4
+static EmpathyChatroomManager *chatroom_manager_singleton = NULL;
+
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChatroomManager)
typedef struct {
GList *chatrooms;
@@ -126,6 +128,9 @@ empathy_chatroom_manager_constructor (GType type,
EmpathyChatroomManager *self;
EmpathyChatroomManagerPriv *priv;
+ if (chatroom_manager_singleton != NULL)
+ return g_object_ref (chatroom_manager_singleton);
+
/* Parent constructor chain */
obj = G_OBJECT_CLASS (empathy_chatroom_manager_parent_class)->
constructor (type, n_props, props);
@@ -133,6 +138,9 @@ empathy_chatroom_manager_constructor (GType type,
self = EMPATHY_CHATROOM_MANAGER (obj);
priv = GET_PRIV (self);
+ chatroom_manager_singleton = self;
+ g_object_add_weak_pointer (obj, (gpointer *) &chatroom_manager_singleton);
+
if (priv->file == NULL)
{
/* Set the default file path */
@@ -247,21 +255,10 @@ chatroom_manager_finalize (GObject *object)
}
EmpathyChatroomManager *
-empathy_chatroom_manager_new (const gchar *file)
+empathy_chatroom_manager_dup_singleton (const gchar *file)
{
- static EmpathyChatroomManager *manager = NULL;
-
- if (!manager) {
- manager = g_object_new (EMPATHY_TYPE_CHATROOM_MANAGER,
- "file", file,
- NULL);
-
- g_object_add_weak_pointer (G_OBJECT (manager), (gpointer) &manager);
- } else {
- g_object_ref (manager);
- }
-
- return manager;
+ return EMPATHY_CHATROOM_MANAGER (g_object_new (EMPATHY_TYPE_CHATROOM_MANAGER,
+ "file", file, NULL));
}
static gboolean