empathy r845 - trunk/libempathy-gtk



Author: xclaesse
Date: Wed Apr  2 10:42:02 2008
New Revision: 845
URL: http://svn.gnome.org/viewvc/empathy?rev=845&view=rev

Log:
Add a tooltip property on EmpathyChat


Modified:
   trunk/libempathy-gtk/empathy-chat.c
   trunk/libempathy-gtk/empathy-chat.h

Modified: trunk/libempathy-gtk/empathy-chat.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat.c	(original)
+++ trunk/libempathy-gtk/empathy-chat.c	Wed Apr  2 10:42:02 2008
@@ -63,6 +63,7 @@
 	McAccount         *account;
 	gchar             *name;
 	gchar             *subject;
+	gchar             *tooltip;
 	EmpathyContact    *selected_contact;
 	gchar             *id;
 
@@ -111,6 +112,7 @@
 	PROP_ACCOUNT,
 	PROP_NAME,
 	PROP_SUBJECT,
+	PROP_TOOLTIP,
 	PROP_SELECTED_CONTACT,
 	PROP_ID
 };
@@ -140,6 +142,9 @@
 	case PROP_SUBJECT:
 		g_value_set_string (value, priv->subject);
 		break;
+	case PROP_TOOLTIP:
+		g_value_set_string (value, priv->tooltip);
+		break;
 	case PROP_SELECTED_CONTACT:
 		g_value_set_object (value, priv->selected_contact);
 		break;
@@ -260,58 +265,6 @@
 }
 
 static void
-chat_finalize (GObject *object)
-{
-	EmpathyChat     *chat;
-	EmpathyChatPriv *priv;
-
-	chat = EMPATHY_CHAT (object);
-	priv = GET_PRIV (chat);
-
-	empathy_debug (DEBUG_DOMAIN, "Finalized: %p", object);
-
-	g_slist_foreach (priv->sent_messages, (GFunc) g_free, NULL);
-	g_slist_free (priv->sent_messages);
-
-	g_list_foreach (priv->compositors, (GFunc) g_object_unref, NULL);
-	g_list_free (priv->compositors);
-
-	g_list_foreach (priv->backlog_messages, (GFunc) g_object_unref, NULL);
-	g_list_free (priv->backlog_messages);
-
-	chat_composing_remove_timeout (chat);
-
-	dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->mc), "AccountStatusChanged",
-					G_CALLBACK (chat_status_changed_cb),
-					chat);
-	g_object_unref (priv->mc);
-	g_object_unref (priv->log_manager);
-
-
-	if (priv->tp_chat) {
-		g_object_unref (priv->tp_chat);
-	}
-
-	if (priv->account) {
-		g_object_unref (priv->account);
-	}
-
-	if (priv->selected_contact) {
-		g_object_unref (priv->selected_contact);
-	}
-
-	if (priv->block_events_timeout_id) {
-		g_source_remove (priv->block_events_timeout_id);
-	}
-
-	g_free (priv->id);
-	g_free (priv->name);
-	g_free (priv->subject);
-
-	G_OBJECT_CLASS (empathy_chat_parent_class)->finalize (object);
-}
-
-static void
 chat_destroy_cb (EmpathyTpChat *tp_chat,
 		 EmpathyChat    *chat)
 {
@@ -643,7 +596,31 @@
 		g_free (priv->name);
 		priv->name = g_value_dup_string (value);
 		g_object_notify (G_OBJECT (chat), "name");
+	} else {
+		return;
 	}
+
+	g_free (priv->tooltip);
+	priv->tooltip = g_strconcat (priv->name, "\n",
+				     _("Topic: "), priv->subject, NULL);
+	g_object_notify (G_OBJECT (chat), "tooltip");
+}
+
+static void
+chat_selected_contact_notify_cb (EmpathyChat *chat)
+{
+	EmpathyChatPriv *priv = GET_PRIV (chat);
+
+	g_free (priv->name);
+	priv->name = g_strdup (empathy_contact_get_name (priv->selected_contact));
+	g_object_notify (G_OBJECT (chat), "name");		
+
+	g_free (priv->tooltip);
+	priv->tooltip = g_strconcat (empathy_contact_get_id (priv->selected_contact),
+				     "\n",
+				     empathy_contact_get_status (priv->selected_contact),
+				     NULL);
+	g_object_notify (G_OBJECT (chat), "tooltip");
 }
 
 static void
@@ -658,15 +635,19 @@
 	}
 
 	if (priv->selected_contact) {
+		g_signal_handlers_disconnect_by_func (contact,
+						      chat_selected_contact_notify_cb,
+						      chat);
 		g_object_unref (priv->selected_contact);
 		priv->selected_contact = NULL;
 	}
 
 	if (contact) {
-		g_free (priv->name);
 		priv->selected_contact = g_object_ref (contact);
-		priv->name = g_strdup (empathy_contact_get_name (contact));
-		g_object_notify (G_OBJECT (chat), "name");		
+		g_signal_connect_swapped (contact, "notify",
+					  G_CALLBACK (chat_selected_contact_notify_cb),
+					  chat);
+		chat_selected_contact_notify_cb (chat);
 	}
 
 	g_object_notify (G_OBJECT (chat), "selected-contact");
@@ -1350,6 +1331,62 @@
 }
 
 static void
+chat_finalize (GObject *object)
+{
+	EmpathyChat     *chat;
+	EmpathyChatPriv *priv;
+
+	chat = EMPATHY_CHAT (object);
+	priv = GET_PRIV (chat);
+
+	empathy_debug (DEBUG_DOMAIN, "Finalized: %p", object);
+
+	g_slist_foreach (priv->sent_messages, (GFunc) g_free, NULL);
+	g_slist_free (priv->sent_messages);
+
+	g_list_foreach (priv->compositors, (GFunc) g_object_unref, NULL);
+	g_list_free (priv->compositors);
+
+	g_list_foreach (priv->backlog_messages, (GFunc) g_object_unref, NULL);
+	g_list_free (priv->backlog_messages);
+
+	chat_composing_remove_timeout (chat);
+
+	dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->mc), "AccountStatusChanged",
+					G_CALLBACK (chat_status_changed_cb),
+					chat);
+	g_object_unref (priv->mc);
+	g_object_unref (priv->log_manager);
+
+
+	if (priv->tp_chat) {
+		g_object_unref (priv->tp_chat);
+	}
+
+	if (priv->account) {
+		g_object_unref (priv->account);
+	}
+
+	if (priv->selected_contact) {
+		g_signal_handlers_disconnect_by_func (priv->selected_contact,
+						      chat_selected_contact_notify_cb,
+						      chat);
+		g_object_unref (priv->selected_contact);
+	}
+
+	if (priv->block_events_timeout_id) {
+		g_source_remove (priv->block_events_timeout_id);
+	}
+
+	g_free (priv->id);
+	g_free (priv->name);
+	g_free (priv->subject);
+	g_free (priv->tooltip);
+
+	G_OBJECT_CLASS (empathy_chat_parent_class)->finalize (object);
+}
+
+static void
 chat_constructed (GObject *object)
 {
 	chat_add_logs (EMPATHY_CHAT (object));
@@ -1397,6 +1434,13 @@
 							      NULL,
 							      G_PARAM_READABLE));
 	g_object_class_install_property (object_class,
+					 PROP_TOOLTIP,
+					 g_param_spec_string ("tooltip",
+							      "Chat's tooltip",
+							      "The tooltip of the chat",
+							      NULL,
+							      G_PARAM_READABLE));
+	g_object_class_install_property (object_class,
 					 PROP_SELECTED_CONTACT,
 					 g_param_spec_object ("selected-contact",
 							      "The selected contact",
@@ -1614,6 +1658,16 @@
 	return priv->subject;
 }
 
+const gchar *
+empathy_chat_get_tooltip (EmpathyChat *chat)
+{
+	EmpathyChatPriv *priv = GET_PRIV (chat);
+
+	g_return_val_if_fail (EMPATHY_IS_CHAT (chat), NULL);
+
+	return priv->tooltip;
+}
+
 EmpathyContact *
 empathy_chat_get_selected_contact (EmpathyChat *chat)
 {

Modified: trunk/libempathy-gtk/empathy-chat.h
==============================================================================
--- trunk/libempathy-gtk/empathy-chat.h	(original)
+++ trunk/libempathy-gtk/empathy-chat.h	Wed Apr  2 10:42:02 2008
@@ -69,6 +69,7 @@
 McAccount *        empathy_chat_get_account          (EmpathyChat   *chat);
 const gchar *      empathy_chat_get_name             (EmpathyChat   *chat);
 const gchar *      empathy_chat_get_subject          (EmpathyChat   *chat);
+const gchar *      empathy_chat_get_tooltip          (EmpathyChat   *chat);
 EmpathyContact *   empathy_chat_get_selected_contact (EmpathyChat   *chat);
 const gchar *      empathy_chat_get_id               (EmpathyChat   *chat);
 void               empathy_chat_clear                (EmpathyChat   *chat);



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