aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-idle.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2009-01-09 18:06:00 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-01-09 18:06:00 +0800
commitc2a1dec002eb9a8c0372bc6fc920a54e36b7e991 (patch)
treeeab79909cfb1550b494c5a81056301bbf2698204 /libempathy/empathy-idle.c
parent4100a5f538bf8f2c22658a579a80c909162dc46c (diff)
downloadgsoc2013-empathy-c2a1dec002eb9a8c0372bc6fc920a54e36b7e991.tar
gsoc2013-empathy-c2a1dec002eb9a8c0372bc6fc920a54e36b7e991.tar.gz
gsoc2013-empathy-c2a1dec002eb9a8c0372bc6fc920a54e36b7e991.tar.bz2
gsoc2013-empathy-c2a1dec002eb9a8c0372bc6fc920a54e36b7e991.tar.lz
gsoc2013-empathy-c2a1dec002eb9a8c0372bc6fc920a54e36b7e991.tar.xz
gsoc2013-empathy-c2a1dec002eb9a8c0372bc6fc920a54e36b7e991.tar.zst
gsoc2013-empathy-c2a1dec002eb9a8c0372bc6fc920a54e36b7e991.zip
Port EmpathyIdle to the new singleton policy.
svn path=/trunk/; revision=2114
Diffstat (limited to 'libempathy/empathy-idle.c')
-rw-r--r--libempathy/empathy-idle.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c
index 9eea49771..2751f7cfa 100644
--- a/libempathy/empathy-idle.c
+++ b/libempathy/empathy-idle.c
@@ -76,7 +76,9 @@ enum {
PROP_USE_NM
};
-G_DEFINE_TYPE (EmpathyIdle, empathy_idle, G_TYPE_OBJECT)
+G_DEFINE_TYPE (EmpathyIdle, empathy_idle, G_TYPE_OBJECT);
+
+static EmpathyIdle * idle_singleton = NULL;
static void
idle_presence_changed_cb (MissionControl *mc,
@@ -271,6 +273,26 @@ idle_finalize (GObject *object)
idle_ext_away_stop (EMPATHY_IDLE (object));
}
+static GObject *
+idle_constructor (GType type,
+ guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *retval;
+
+ if (idle_singleton) {
+ retval = g_object_ref (idle_singleton);
+ } else {
+ retval = G_OBJECT_CLASS (empathy_idle_parent_class)->constructor
+ (type, n_props, props);
+ g_object_add_weak_pointer (retval, (gpointer *) &retval);
+
+ idle_singleton = EMPATHY_IDLE (retval);
+ }
+
+ return retval;
+}
+
static void
idle_get_property (GObject *object,
guint param_id,
@@ -345,6 +367,7 @@ empathy_idle_class_init (EmpathyIdleClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = idle_finalize;
+ object_class->constructor = idle_constructor;
object_class->get_property = idle_get_property;
object_class->set_property = idle_set_property;
@@ -465,18 +488,9 @@ empathy_idle_init (EmpathyIdle *idle)
}
EmpathyIdle *
-empathy_idle_new (void)
+empathy_idle_dup_singleton (void)
{
- static EmpathyIdle *idle = NULL;
-
- if (!idle) {
- idle = g_object_new (EMPATHY_TYPE_IDLE, NULL);
- g_object_add_weak_pointer (G_OBJECT (idle), (gpointer) &idle);
- } else {
- g_object_ref (idle);
- }
-
- return idle;
+ return g_object_new (EMPATHY_TYPE_IDLE, NULL);
}
McPresence