empathy r2181 - in trunk: libempathy src
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r2181 - in trunk: libempathy src
- Date: Fri, 9 Jan 2009 16:15:02 +0000 (UTC)
Author: xclaesse
Date: Fri Jan 9 16:15:02 2009
New Revision: 2181
URL: http://svn.gnome.org/viewvc/empathy?rev=2181&view=rev
Log:
Move the dispatcher to the new singleton policy
Signed-off-by: Sjoerd Simons <sjoerd simons collabora co uk>
Modified:
trunk/libempathy/empathy-dispatcher.c
trunk/libempathy/empathy-dispatcher.h
trunk/src/empathy-event-manager.c
trunk/src/empathy.c
Modified: trunk/libempathy/empathy-dispatcher.c
==============================================================================
--- trunk/libempathy/empathy-dispatcher.c (original)
+++ trunk/libempathy/empathy-dispatcher.c Fri Jan 9 16:15:02 2009
@@ -786,6 +786,29 @@
dispatcher_update_account (dispatcher, account);
}
+
+static GObject*
+dispatcher_constructor (GType type, guint n_construct_params,
+ GObjectConstructParam *construct_params)
+{
+ GObject *retval;
+
+ if (dispatcher == NULL)
+ {
+ retval = G_OBJECT_CLASS (empathy_dispatcher_parent_class)->constructor
+ (type, n_construct_params, construct_params);
+
+ dispatcher = EMPATHY_DISPATCHER (retval);
+ g_object_add_weak_pointer (retval, (gpointer *) &dispatcher);
+ }
+ else
+ {
+ retval = g_object_ref (dispatcher);
+ }
+
+ return retval;
+}
+
static void
dispatcher_finalize (GObject *object)
{
@@ -808,6 +831,7 @@
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = dispatcher_finalize;
+ object_class->constructor = dispatcher_constructor;
signals[OBSERVE] =
g_signal_new ("observe",
@@ -879,16 +903,9 @@
}
EmpathyDispatcher *
-empathy_get_dispatcher (void)
+empathy_dispatcher_dup_singleton (void)
{
- if (!dispatcher) {
- dispatcher = g_object_new (EMPATHY_TYPE_DISPATCHER, NULL);
- g_object_add_weak_pointer (G_OBJECT (dispatcher), (gpointer) &dispatcher);
- } else {
- g_object_ref (dispatcher);
- }
-
- return dispatcher;
+ return EMPATHY_DISPATCHER (g_object_new (EMPATHY_TYPE_DISPATCHER, NULL));
}
static void
@@ -1006,7 +1023,7 @@
empathy_dispatcher_call_with_contact ( EmpathyContact *contact,
EmpathyDispatcherRequestCb *callback, gpointer user_data)
{
- EmpathyDispatcher *dispatcher = empathy_get_dispatcher();
+ EmpathyDispatcher *dispatcher = empathy_dispatcher_dup_singleton();
EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
McAccount *account;
TpConnection *connection;
@@ -1052,7 +1069,7 @@
ConnectionData *connection_data;
DispatcherRequestData *request_data;
- dispatcher = empathy_get_dispatcher();
+ dispatcher = empathy_dispatcher_dup_singleton();
priv = GET_PRIV (dispatcher);
account = empathy_contact_get_account (contact);
@@ -1078,7 +1095,7 @@
empathy_dispatcher_chat_with_contact_id (McAccount *account, const gchar
*contact_id, EmpathyDispatcherRequestCb *callback, gpointer user_data)
{
- EmpathyDispatcher *dispatcher = empathy_get_dispatcher ();
+ EmpathyDispatcher *dispatcher = empathy_dispatcher_dup_singleton ();
EmpathyContactFactory *factory;
EmpathyContact *contact;
@@ -1135,7 +1152,7 @@
ConnectionData *connection_data;
const gchar *names[] = { roomname, NULL };
- dispatcher = empathy_get_dispatcher();
+ dispatcher = empathy_dispatcher_dup_singleton();
priv = GET_PRIV (dispatcher);
connection = g_hash_table_lookup (priv->accounts, account);
@@ -1199,7 +1216,7 @@
const gchar *content_type, EmpathyDispatcherRequestCb *callback,
gpointer user_data)
{
- EmpathyDispatcher *dispatcher = empathy_get_dispatcher();
+ EmpathyDispatcher *dispatcher = empathy_dispatcher_dup_singleton();
EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
McAccount *account = empathy_contact_get_account (contact);
TpConnection *connection = g_hash_table_lookup (priv->accounts, account);
Modified: trunk/libempathy/empathy-dispatcher.h
==============================================================================
--- trunk/libempathy/empathy-dispatcher.h (original)
+++ trunk/libempathy/empathy-dispatcher.h Fri Jan 9 16:15:02 2009
@@ -91,7 +91,7 @@
gpointer user_data);
/* Get the dispatcher singleton */
-EmpathyDispatcher * empathy_get_dispatcher (void);
+EmpathyDispatcher * empathy_dispatcher_dup_singleton (void);
GType empathy_dispatcher_tube_get_type (void);
/* tube stuff */
Modified: trunk/src/empathy-event-manager.c
==============================================================================
--- trunk/src/empathy-event-manager.c (original)
+++ trunk/src/empathy-event-manager.c Fri Jan 9 16:15:02 2009
@@ -592,7 +592,7 @@
manager->priv = priv;
- priv->dispatcher = empathy_get_dispatcher ();
+ priv->dispatcher = empathy_dispatcher_dup_singleton ();
priv->contact_manager = empathy_contact_manager_dup_singleton ();
g_signal_connect (priv->dispatcher, "approve",
G_CALLBACK (event_manager_approve_channel_cb), manager);
Modified: trunk/src/empathy.c
==============================================================================
--- trunk/src/empathy.c (original)
+++ trunk/src/empathy.c Fri Jan 9 16:15:02 2009
@@ -513,7 +513,7 @@
}
/* Handle channels */
- dispatcher = empathy_get_dispatcher ();
+ dispatcher = empathy_dispatcher_dup_singleton ();
g_signal_connect (dispatcher, "dispatch", G_CALLBACK (dispatch_cb), NULL);
gtk_main ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]