G_CALLBACK (avatar_chooser_clicked_cb),
chooser);
- priv->contact_factory = empathy_contact_factory_new ();
+ priv->contact_factory = empathy_contact_factory_dup_singleton ();
empathy_avatar_chooser_set (chooser, NULL);
}
id);
strv = g_strsplit (id, "/", 2);
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
account = mc_account_lookup (strv[0]);
if (account) {
contact = empathy_contact_factory_get_from_id (factory,
information = g_slice_new0 (EmpathyContactWidget);
information->flags = flags;
- information->factory = empathy_contact_factory_new ();
+ information->factory = empathy_contact_factory_dup_singleton ();
filename = empathy_file_lookup ("empathy-contact-widget.glade",
"libempathy-gtk");
G_DEFINE_TYPE (EmpathyContactFactory, empathy_contact_factory, G_TYPE_OBJECT);
+static EmpathyContactFactory * factory_singleton = NULL;
+
EmpathyTpContactFactory *
empathy_contact_factory_get_tp_factory (EmpathyContactFactory *factory,
McAccount *account)
G_OBJECT_CLASS (empathy_contact_factory_parent_class)->finalize (object);
}
+static GObject *
+contact_factory_constructor (GType type,
+ guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *retval;
+
+ if (factory_singleton) {
+ retval = g_object_ref (factory_singleton);
+ } else {
+ retval = G_OBJECT_CLASS (empathy_contact_factory_parent_class)->constructor
+ (type, n_props, props);
+ g_object_add_weak_pointer (retval, (gpointer *) &retval);
+
+ factory_singleton = EMPATHY_CONTACT_FACTORY (retval);
+ }
+
+ return retval;
+}
+
static void
empathy_contact_factory_class_init (EmpathyContactFactoryClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = contact_factory_finalize;
+ object_class->constructor = contact_factory_constructor;
g_type_class_add_private (object_class, sizeof (EmpathyContactFactoryPriv));
}
}
EmpathyContactFactory *
-empathy_contact_factory_new (void)
+empathy_contact_factory_dup_singleton (void)
{
- static EmpathyContactFactory *factory = NULL;
-
- if (!factory) {
- factory = g_object_new (EMPATHY_TYPE_CONTACT_FACTORY, NULL);
- g_object_add_weak_pointer (G_OBJECT (factory), (gpointer) &factory);
- } else {
- g_object_ref (factory);
- }
-
- return factory;
+ return g_object_new (EMPATHY_TYPE_CONTACT_FACTORY, NULL);
}
};
GType empathy_contact_factory_get_type (void) G_GNUC_CONST;
-EmpathyContactFactory *empathy_contact_factory_new (void);
+EmpathyContactFactory *empathy_contact_factory_dup_singleton (void);
EmpathyTpContactFactory *empathy_contact_factory_get_tp_factory (EmpathyContactFactory *factory,
McAccount *account);
EmpathyContact * empathy_contact_factory_get_user (EmpathyContactFactory *factory,
tube = g_slice_new (DispatcherTube);
tube->ref_count = 1;
tube->handled = FALSE;
- tube->factory = empathy_contact_factory_new ();
+ tube->factory = empathy_contact_factory_dup_singleton ();
tube->bus_name = empathy_tube_handler_build_bus_name (type, service);
tube->object_path = empathy_tube_handler_build_object_path (type, service);
tube->public.activatable = FALSE;
group = empathy_tp_group_new (channel);
empathy_run_until_ready (group);
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
self_contact = empathy_contact_factory_get_user (factory, account);
empathy_contact_run_until_ready (self_contact,
EMPATHY_CONTACT_READY_HANDLE,
EmpathyContactFactory *factory;
EmpathyContact *contact;
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
contact = empathy_contact_factory_get_from_id (factory, account, contact_id);
empathy_contact_run_until_ready (contact, EMPATHY_CONTACT_READY_HANDLE, NULL);
EmpathyContactFactory *factory;
EmpathyContact *contact;
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
contact = empathy_contact_factory_get_from_id (factory, account, contact_id);
empathy_contact_run_until_ready (contact, EMPATHY_CONTACT_READY_HANDLE, NULL);
priv = GET_PRIV (chat);
priv->account = empathy_channel_get_account (priv->channel);
- priv->factory = empathy_contact_factory_new ();
+ priv->factory = empathy_contact_factory_dup_singleton ();
priv->user = empathy_contact_factory_get_user (priv->factory, priv->account);
g_signal_connect (priv->channel, "invalidated",
tp_file = EMPATHY_TP_FILE (file_obj);
- tp_file->priv->factory = empathy_contact_factory_new ();
+ tp_file->priv->factory = empathy_contact_factory_dup_singleton ();
tp_file->priv->mc = empathy_mission_control_new ();
g_signal_connect (tp_file->priv->channel, "invalidated",
EmpathyTpGroupPriv *priv = GET_PRIV (group);
gboolean channel_ready;
- priv->factory = empathy_contact_factory_new ();
+ priv->factory = empathy_contact_factory_dup_singleton ();
priv->account = empathy_channel_get_account (priv->channel);
g_signal_connect (priv->channel, "invalidated",
tube->priv = priv;
- priv->factory = empathy_contact_factory_new ();
+ priv->factory = empathy_contact_factory_dup_singleton ();
}
EmpathyTpTube *
MEGAPHONE_TYPE_APPLET, MegaphoneAppletPriv);
applet->priv = priv;
- priv->factory = empathy_contact_factory_new ();
+ priv->factory = empathy_contact_factory_dup_singleton ();
priv->gconf = gconf_client_get_default ();
/* Image holds the contact avatar */
McAccount *account;
EmpathyContactFactory *factory;
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
handle = tp_channel_get_handle (channel, NULL);
account = empathy_channel_get_account (channel);
McAccount *account;
account = accounts->data;
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
contact = empathy_contact_factory_get_user (factory, account);
empathy_contact_run_until_ready (contact,
EMPATHY_CONTACT_READY_HANDLE |
EmpathyContact *contact;
EmpathyContactReady ready_flags;
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
account = mc_account_lookup ("jabber0");
contact = empathy_contact_factory_get_from_handle (factory, account, 2);