[empathy] EmpathyTpChat: get rid of the destroy signal



commit 5079e73c8edf3b460ed11edc02ffb2cb6b705eac
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri Apr 29 09:20:02 2011 +0200

    EmpathyTpChat: get rid of the destroy signal
    
    We should just use invalidated.

 libempathy-gtk/empathy-chat.c         |   15 +++++++-----
 libempathy/empathy-chatroom-manager.c |   11 +++++----
 libempathy/empathy-tp-chat.c          |   39 ---------------------------------
 3 files changed, 15 insertions(+), 50 deletions(-)
---
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index cf3336b..1dbaf5d 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -2605,7 +2605,10 @@ chat_remote_contact_changed_cb (EmpathyChat *chat)
 }
 
 static void
-chat_destroy_cb (EmpathyTpChat *tp_chat,
+chat_invalidated_cb (EmpathyTpChat *tp_chat,
+		 guint domain,
+		 gint code,
+		 gchar *message,
 		 EmpathyChat   *chat)
 {
 	EmpathyChatPriv *priv;
@@ -2938,7 +2941,7 @@ chat_finalize (GObject *object)
 
 	if (priv->tp_chat) {
 		g_signal_handlers_disconnect_by_func (priv->tp_chat,
-			chat_destroy_cb, chat);
+			chat_invalidated_cb, chat);
 		g_signal_handlers_disconnect_by_func (priv->tp_chat,
 			chat_message_received_cb, chat);
 		g_signal_handlers_disconnect_by_func (priv->tp_chat,
@@ -3439,7 +3442,7 @@ password_entry_changed_cb (GtkEditable *entry,
 }
 
 static void
-chat_invalidated_cb (TpProxy       *proxy,
+infobar_chat_invalidated_cb (TpProxy       *proxy,
 			   guint          domain,
 			   gint           code,
 			   gchar         *message,
@@ -3533,7 +3536,7 @@ display_password_info_bar (EmpathyChat *self)
 	gtk_widget_show_all (hbox);
 
 	tp_g_signal_connect_object (priv->tp_chat,
-				  "invalidated", G_CALLBACK (chat_invalidated_cb),
+				  "invalidated", G_CALLBACK (infobar_chat_invalidated_cb),
 				  info_bar, 0);
 
 	data->response_id = g_signal_connect (info_bar, "response",
@@ -3648,8 +3651,8 @@ empathy_chat_set_tp_chat (EmpathyChat   *chat,
 	priv->tp_chat = g_object_ref (tp_chat);
 	priv->account = g_object_ref (empathy_tp_chat_get_account (priv->tp_chat));
 
-	g_signal_connect (tp_chat, "destroy",
-			  G_CALLBACK (chat_destroy_cb),
+	g_signal_connect (tp_chat, "invalidated",
+			  G_CALLBACK (chat_invalidated_cb),
 			  chat);
 	g_signal_connect (tp_chat, "message-received-empathy",
 			  G_CALLBACK (chat_message_received_cb),
diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c
index 00b5420..212c5d8 100644
--- a/libempathy/empathy-chatroom-manager.c
+++ b/libempathy/empathy-chatroom-manager.c
@@ -840,7 +840,10 @@ empathy_chatroom_manager_get_chatrooms (EmpathyChatroomManager *manager,
 }
 
 static void
-chatroom_manager_chat_destroyed_cb (EmpathyTpChat *chat,
+chatroom_manager_chat_invalidated_cb (EmpathyTpChat *chat,
+  guint domain,
+  gint code,
+  gchar *message,
   gpointer manager)
 {
   EmpathyChatroomManagerPriv *priv = GET_PRIV (manager);
@@ -905,10 +908,8 @@ observe_channels_cb (TpSimpleObserver *observer,
 
       empathy_chatroom_set_tp_chat (chatroom, tp_chat);
 
-      /* A TpChat is always destroyed as it only gets unreffed after the channel
-       * has been invalidated in the dispatcher..  */
-      g_signal_connect (tp_chat, "destroy",
-        G_CALLBACK (chatroom_manager_chat_destroyed_cb),
+      g_signal_connect (tp_chat, "invalidated",
+        G_CALLBACK (chatroom_manager_chat_invalidated_cb),
         self);
     }
 
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 7117058..f60b5ef 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -80,7 +80,6 @@ enum {
 	SEND_ERROR,
 	CHAT_STATE_CHANGED,
 	PROPERTY_CHANGED,
-	DESTROY,
 	MESSAGE_ACKNOWLEDGED,
 	LAST_SIGNAL
 };
@@ -130,17 +129,6 @@ static void tp_chat_prepare_ready_async (TpProxy *proxy,
 	gpointer user_data);
 
 static void
-tp_chat_invalidated_cb (TpProxy       *proxy,
-			guint          domain,
-			gint           code,
-			gchar         *message,
-			EmpathyTpChat *self)
-{
-	DEBUG ("Channel invalidated: %s", message);
-	g_signal_emit (self, signals[DESTROY], 0);
-}
-
-static void
 tp_chat_async_cb (TpChannel *proxy,
 		  const GError *error,
 		  gpointer user_data,
@@ -1323,21 +1311,6 @@ get_sms_channel_cb (TpProxy      *channel,
 	check_almost_ready (EMPATHY_TP_CHAT (chat));
 }
 
-static GObject *
-tp_chat_constructor (GType                  type,
-		     guint                  n_props,
-		     GObjectConstructParam *props)
-{
-	GObject           *object;
-
-	object = G_OBJECT_CLASS (empathy_tp_chat_parent_class)->constructor (type, n_props, props);
-
-	tp_g_signal_connect_object (object, "invalidated",
-			  G_CALLBACK (tp_chat_invalidated_cb), object, 0);
-
-	return object;
-}
-
 static void
 tp_chat_get_property (GObject    *object,
 		      guint       param_id,
@@ -1421,7 +1394,6 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
 
 	object_class->dispose = tp_chat_dispose;
 	object_class->finalize = tp_chat_finalize;
-	object_class->constructor = tp_chat_constructor;
 	object_class->get_property = tp_chat_get_property;
 	object_class->set_property = tp_chat_set_property;
 
@@ -1510,17 +1482,6 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
 			      G_TYPE_NONE,
 			      2, G_TYPE_STRING, G_TYPE_VALUE);
 
-	/* TODO: remove, should just use invalidated */
-	signals[DESTROY] =
-		g_signal_new ("destroy",
-			      G_TYPE_FROM_CLASS (klass),
-			      G_SIGNAL_RUN_LAST,
-			      0,
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__VOID,
-			      G_TYPE_NONE,
-			      0);
-
 	signals[MESSAGE_ACKNOWLEDGED] =
 		g_signal_new ("message-acknowledged",
 			      G_TYPE_FROM_CLASS (klass),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]