empathy r2121 - in trunk: libempathy libempathy-gtk megaphone/src src tests
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r2121 - in trunk: libempathy libempathy-gtk megaphone/src src tests
- Date: Fri, 9 Jan 2009 10:06:32 +0000 (UTC)
Author: xclaesse
Date: Fri Jan 9 10:06:32 2009
New Revision: 2121
URL: http://svn.gnome.org/viewvc/empathy?rev=2121&view=rev
Log:
Port EmpathyContactManager to the new singleton policy.
Modified:
trunk/libempathy-gtk/empathy-contact-dialogs.c
trunk/libempathy-gtk/empathy-contact-widget.c
trunk/libempathy-gtk/empathy-new-message-dialog.c
trunk/libempathy/empathy-contact-manager.c
trunk/libempathy/empathy-contact-manager.h
trunk/megaphone/src/megaphone-applet.c
trunk/src/empathy-event-manager.c
trunk/src/empathy-main-window.c
trunk/tests/contact-manager.c
trunk/tests/contact-run-until-ready-2.c
Modified: trunk/libempathy-gtk/empathy-contact-dialogs.c
==============================================================================
--- trunk/libempathy-gtk/empathy-contact-dialogs.c (original)
+++ trunk/libempathy-gtk/empathy-contact-dialogs.c Fri Jan 9 10:06:32 2009
@@ -68,7 +68,7 @@
EmpathyContactManager *manager;
EmpathyContact *contact;
- manager = empathy_contact_manager_new ();
+ manager = empathy_contact_manager_dup_singleton ();
contact = empathy_contact_widget_get_contact (contact_widget);
if (response == GTK_RESPONSE_YES) {
@@ -242,7 +242,7 @@
EmpathyContactManager *mgr;
gboolean result;
- mgr = empathy_contact_manager_new ();
+ mgr = empathy_contact_manager_dup_singleton ();
result = empathy_contact_manager_can_add (mgr, account);
g_object_unref (mgr);
@@ -257,7 +257,7 @@
EmpathyContactManager *manager;
EmpathyContact *contact;
- manager = empathy_contact_manager_new ();
+ manager = empathy_contact_manager_dup_singleton ();
contact = empathy_contact_widget_get_contact (contact_widget);
if (contact && response == GTK_RESPONSE_OK) {
Modified: trunk/libempathy-gtk/empathy-contact-widget.c
==============================================================================
--- trunk/libempathy-gtk/empathy-contact-widget.c (original)
+++ trunk/libempathy-gtk/empathy-contact-widget.c Fri Jan 9 10:06:32 2009
@@ -828,7 +828,7 @@
{
if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_GROUPS)
{
- information->manager = empathy_contact_manager_new ();
+ information->manager = empathy_contact_manager_dup_singleton ();
contact_widget_model_setup (information);
}
}
Modified: trunk/libempathy-gtk/empathy-new-message-dialog.c
==============================================================================
--- trunk/libempathy-gtk/empathy-new-message-dialog.c (original)
+++ trunk/libempathy-gtk/empathy-new-message-dialog.c Fri Jan 9 10:06:32 2009
@@ -233,7 +233,7 @@
dialog = g_new0 (EmpathyNewMessageDialog, 1);
/* create a contact manager */
- dialog->contact_manager = empathy_contact_manager_new ();
+ dialog->contact_manager = empathy_contact_manager_dup_singleton ();
filename = empathy_file_lookup ("empathy-new-message-dialog.glade",
"libempathy-gtk");
Modified: trunk/libempathy/empathy-contact-manager.c
==============================================================================
--- trunk/libempathy/empathy-contact-manager.c (original)
+++ trunk/libempathy/empathy-contact-manager.c Fri Jan 9 10:06:32 2009
@@ -47,6 +47,8 @@
G_IMPLEMENT_INTERFACE (EMPATHY_TYPE_CONTACT_LIST,
contact_manager_iface_init));
+static EmpathyContactManager *manager_singleton = NULL;
+
static void
contact_manager_members_changed_cb (EmpathyTpContactList *list,
EmpathyContact *contact,
@@ -196,12 +198,33 @@
}
}
+static GObject *
+contact_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_contact_manager_parent_class)->constructor
+ (type, n_props, props);
+
+ manager_singleton = EMPATHY_CONTACT_MANAGER (retval);
+ g_object_add_weak_pointer (retval, (gpointer *) &manager_singleton);
+ }
+
+ return retval;
+}
+
static void
empathy_contact_manager_class_init (EmpathyContactManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = contact_manager_finalize;
+ object_class->constructor = contact_manager_constructor;
g_type_class_add_private (object_class, sizeof (EmpathyContactManagerPriv));
}
@@ -240,18 +263,9 @@
}
EmpathyContactManager *
-empathy_contact_manager_new (void)
+empathy_contact_manager_dup_singleton (void)
{
- static EmpathyContactManager *manager = NULL;
-
- if (!manager) {
- manager = g_object_new (EMPATHY_TYPE_CONTACT_MANAGER, NULL);
- g_object_add_weak_pointer (G_OBJECT (manager), (gpointer) &manager);
- } else {
- g_object_ref (manager);
- }
-
- return manager;
+ return g_object_new (EMPATHY_TYPE_CONTACT_MANAGER, NULL);
}
EmpathyTpContactList *
Modified: trunk/libempathy/empathy-contact-manager.h
==============================================================================
--- trunk/libempathy/empathy-contact-manager.h (original)
+++ trunk/libempathy/empathy-contact-manager.h Fri Jan 9 10:06:32 2009
@@ -52,7 +52,7 @@
};
GType empathy_contact_manager_get_type (void) G_GNUC_CONST;
-EmpathyContactManager *empathy_contact_manager_new (void);
+EmpathyContactManager *empathy_contact_manager_dup_singleton (void);
EmpathyTpContactList * empathy_contact_manager_get_list (EmpathyContactManager *manager,
McAccount *account);
gboolean empathy_contact_manager_can_add (EmpathyContactManager *manager,
Modified: trunk/megaphone/src/megaphone-applet.c
==============================================================================
--- trunk/megaphone/src/megaphone-applet.c (original)
+++ trunk/megaphone/src/megaphone-applet.c Fri Jan 9 10:06:32 2009
@@ -354,7 +354,7 @@
NULL);
/* Show all contacts, even offline and sort alphabetically */
- contact_manager = empathy_contact_manager_new ();
+ contact_manager = empathy_contact_manager_dup_singleton ();
contact_store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (contact_manager));
g_object_set (contact_store,
"is-compact", TRUE,
Modified: trunk/src/empathy-event-manager.c
==============================================================================
--- trunk/src/empathy-event-manager.c (original)
+++ trunk/src/empathy-event-manager.c Fri Jan 9 10:06:32 2009
@@ -460,7 +460,7 @@
manager->priv = priv;
priv->dispatcher = empathy_dispatcher_new ();
- priv->contact_manager = empathy_contact_manager_new ();
+ priv->contact_manager = empathy_contact_manager_dup_singleton ();
g_signal_connect (priv->dispatcher, "filter-channel",
G_CALLBACK (event_manager_filter_channel_cb),
manager);
Modified: trunk/src/empathy-main-window.c
==============================================================================
--- trunk/src/empathy-main-window.c (original)
+++ trunk/src/empathy-main-window.c Fri Jan 9 10:06:32 2009
@@ -599,7 +599,7 @@
/* Set up contact list. */
empathy_status_presets_get_all ();
- list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_new ());
+ list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_dup_singleton ());
monitor = empathy_contact_list_get_monitor (list_iface);
window->list_store = empathy_contact_list_store_new (list_iface);
window->list_view = empathy_contact_list_view_new (window->list_store,
Modified: trunk/tests/contact-manager.c
==============================================================================
--- trunk/tests/contact-manager.c (original)
+++ trunk/tests/contact-manager.c Fri Jan 9 10:06:32 2009
@@ -23,7 +23,7 @@
empathy_debug_set_flags (g_getenv ("EMPATHY_DEBUG"));
main_loop = g_main_loop_new (NULL, FALSE);
- manager = empathy_contact_manager_new ();
+ manager = empathy_contact_manager_dup_singleton ();
store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (manager));
empathy_contact_list_store_set_is_compact (store, TRUE);
empathy_contact_list_store_set_show_groups (store, FALSE);
Modified: trunk/tests/contact-run-until-ready-2.c
==============================================================================
--- trunk/tests/contact-run-until-ready-2.c (original)
+++ trunk/tests/contact-run-until-ready-2.c Fri Jan 9 10:06:32 2009
@@ -41,7 +41,7 @@
{
EmpathyContactManager *manager;
- manager = empathy_contact_manager_new ();
+ manager = empathy_contact_manager_dup_singleton ();
g_signal_connect (manager, "pendings-changed",
G_CALLBACK (pending_cb),
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]