aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-smiley-manager.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2009-01-09 18:06:10 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-01-09 18:06:10 +0800
commite8499acc40dc33d78df27d1b8ac14c296098fc9e (patch)
tree2b6bc50b310ddc21ef33f908d337b6a4fbee89cc /libempathy-gtk/empathy-smiley-manager.c
parenteba974e2a304815ebd8287d6696aaa9803a19bb2 (diff)
downloadgsoc2013-empathy-e8499acc40dc33d78df27d1b8ac14c296098fc9e.tar
gsoc2013-empathy-e8499acc40dc33d78df27d1b8ac14c296098fc9e.tar.gz
gsoc2013-empathy-e8499acc40dc33d78df27d1b8ac14c296098fc9e.tar.bz2
gsoc2013-empathy-e8499acc40dc33d78df27d1b8ac14c296098fc9e.tar.lz
gsoc2013-empathy-e8499acc40dc33d78df27d1b8ac14c296098fc9e.tar.xz
gsoc2013-empathy-e8499acc40dc33d78df27d1b8ac14c296098fc9e.tar.zst
gsoc2013-empathy-e8499acc40dc33d78df27d1b8ac14c296098fc9e.zip
Port EmpathySmileyManager to the new singleton policy.
svn path=/trunk/; revision=2116
Diffstat (limited to 'libempathy-gtk/empathy-smiley-manager.c')
-rw-r--r--libempathy-gtk/empathy-smiley-manager.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/libempathy-gtk/empathy-smiley-manager.c b/libempathy-gtk/empathy-smiley-manager.c
index 4137db63d..3f6ea25c3 100644
--- a/libempathy-gtk/empathy-smiley-manager.c
+++ b/libempathy-gtk/empathy-smiley-manager.c
@@ -44,6 +44,8 @@ struct _SmileyManagerTree {
G_DEFINE_TYPE (EmpathySmileyManager, empathy_smiley_manager, G_TYPE_OBJECT);
+static EmpathySmileyManager *manager_singleton = NULL;
+
static SmileyManagerTree *
smiley_manager_tree_new (gunichar c)
{
@@ -115,12 +117,33 @@ smiley_manager_finalize (GObject *object)
g_slist_free (priv->smileys);
}
+static GObject *
+smiley_manager_constructor (GType type,
+ guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *retval;
+
+ if (manager_singleton) {
+ retval = g_object_ref (manager_singleton);
+ } else {
+ retval = G_OBJECT_CLASS (empathy_smiley_manager_parent_class)->constructor
+ (type, n_props, props);
+ g_object_add_weak_pointer (retval, (gpointer *) &retval);
+
+ manager_singleton = EMPATHY_SMILEY_MANAGER (retval);
+ }
+
+ return retval;
+}
+
static void
empathy_smiley_manager_class_init (EmpathySmileyManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = smiley_manager_finalize;
+ object_class->constructor = smiley_manager_constructor;
g_type_class_add_private (object_class, sizeof (EmpathySmileyManagerPriv));
}
@@ -134,22 +157,14 @@ empathy_smiley_manager_init (EmpathySmileyManager *manager)
manager->priv = priv;
priv->tree = smiley_manager_tree_new ('\0');
priv->smileys = NULL;
+
+ empathy_smiley_manager_load (manager);
}
EmpathySmileyManager *
-empathy_smiley_manager_new (void)
+empathy_smiley_manager_dup_singleton (void)
{
- static EmpathySmileyManager *manager = NULL;
-
- if (!manager) {
- manager = g_object_new (EMPATHY_TYPE_SMILEY_MANAGER, NULL);
- g_object_add_weak_pointer (G_OBJECT (manager), (gpointer) &manager);
- empathy_smiley_manager_load (manager);
- } else {
- g_object_ref (manager);
- }
-
- return manager;
+ return g_object_new (EMPATHY_TYPE_SMILEY_MANAGER, NULL);
}
static SmileyManagerTree *