aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-log-manager.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2009-01-09 18:06:05 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-01-09 18:06:05 +0800
commiteba974e2a304815ebd8287d6696aaa9803a19bb2 (patch)
treeaf6f6326e21a3d8eefe72d26f72a57fdf1b63fbb /libempathy/empathy-log-manager.c
parentc2a1dec002eb9a8c0372bc6fc920a54e36b7e991 (diff)
downloadgsoc2013-empathy-eba974e2a304815ebd8287d6696aaa9803a19bb2.tar
gsoc2013-empathy-eba974e2a304815ebd8287d6696aaa9803a19bb2.tar.gz
gsoc2013-empathy-eba974e2a304815ebd8287d6696aaa9803a19bb2.tar.bz2
gsoc2013-empathy-eba974e2a304815ebd8287d6696aaa9803a19bb2.tar.lz
gsoc2013-empathy-eba974e2a304815ebd8287d6696aaa9803a19bb2.tar.xz
gsoc2013-empathy-eba974e2a304815ebd8287d6696aaa9803a19bb2.tar.zst
gsoc2013-empathy-eba974e2a304815ebd8287d6696aaa9803a19bb2.zip
Port EmpathyLogManager to the new singleton policy.
svn path=/trunk/; revision=2115
Diffstat (limited to 'libempathy/empathy-log-manager.c')
-rw-r--r--libempathy/empathy-log-manager.c49
1 files changed, 31 insertions, 18 deletions
diff --git a/libempathy/empathy-log-manager.c b/libempathy/empathy-log-manager.c
index aa70b49da..f3d17c248 100644
--- a/libempathy/empathy-log-manager.c
+++ b/libempathy/empathy-log-manager.c
@@ -55,7 +55,6 @@ typedef struct {
gchar *basedir;
} EmpathyLogManagerPriv;
-static void log_manager_finalize (GObject *object);
static const gchar * log_manager_get_basedir (EmpathyLogManager *manager);
static GList * log_manager_get_all_files (EmpathyLogManager *manager,
const gchar *dir);
@@ -83,15 +82,7 @@ static void log_manager_search_hit_free (EmpathyLogSe
G_DEFINE_TYPE (EmpathyLogManager, empathy_log_manager, G_TYPE_OBJECT);
-static void
-empathy_log_manager_class_init (EmpathyLogManagerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = log_manager_finalize;
-
- g_type_class_add_private (object_class, sizeof (EmpathyLogManagerPriv));
-}
+static EmpathyLogManager * manager_singleton = NULL;
static void
empathy_log_manager_init (EmpathyLogManager *manager)
@@ -112,19 +103,41 @@ log_manager_finalize (GObject *object)
g_free (priv->basedir);
}
-EmpathyLogManager *
-empathy_log_manager_new (void)
+static GObject *
+log_manager_constructor (GType type,
+ guint n_props,
+ GObjectConstructParam *props)
{
- static EmpathyLogManager *manager = NULL;
+ GObject *retval;
- if (!manager) {
- manager = g_object_new (EMPATHY_TYPE_LOG_MANAGER, NULL);
- g_object_add_weak_pointer (G_OBJECT (manager), (gpointer) &manager);
+ if (manager_singleton) {
+ retval = g_object_ref (manager_singleton);
} else {
- g_object_ref (manager);
+ retval = G_OBJECT_CLASS (empathy_log_manager_parent_class)->constructor
+ (type, n_props, props);
+ g_object_add_weak_pointer (retval, (gpointer *) &retval);
+
+ manager_singleton = EMPATHY_LOG_MANAGER (retval);
}
- return manager;
+ return retval;
+}
+
+static void
+empathy_log_manager_class_init (EmpathyLogManagerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = log_manager_finalize;
+ object_class->constructor = log_manager_constructor;
+
+ g_type_class_add_private (object_class, sizeof (EmpathyLogManagerPriv));
+}
+
+EmpathyLogManager *
+empathy_log_manager_dup_singleton (void)
+{
+ return g_object_new (EMPATHY_TYPE_LOG_MANAGER, NULL);
}
void