[empathy: 3/7] [chat] expose this property in EmpathyChat



commit 4f37d474725cd006eb627e10349e0361ce9a7b29
Author: Danielle Madeley <danielle madeley collabora co uk>
Date:   Thu Apr 28 15:28:08 2011 +1000

    [chat] expose this property in EmpathyChat

 libempathy-gtk/empathy-chat.c |   44 +++++++++++++++++++++++++++++++++++++++++
 libempathy-gtk/empathy-chat.h |    2 +
 2 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index d4e025f..3e8a9c7 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -172,6 +172,7 @@ enum {
 	PROP_REMOTE_CONTACT,
 	PROP_SHOW_CONTACTS,
 	PROP_SMS_CHANNEL,
+	PROP_N_MESSAGES_SENDING,
 };
 
 static guint signals[LAST_SIGNAL] = { 0 };
@@ -214,6 +215,10 @@ chat_get_property (GObject    *object,
 	case PROP_SMS_CHANNEL:
 		g_value_set_boolean (value, priv->sms_channel);
 		break;
+	case PROP_N_MESSAGES_SENDING:
+		g_value_set_uint (value,
+			empathy_chat_get_n_messages_sending (chat));
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
 		break;
@@ -2992,6 +2997,14 @@ empathy_chat_class_init (EmpathyChatClass *klass)
 							       FALSE,
 							       G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
+	g_object_class_install_property (object_class,
+					 PROP_N_MESSAGES_SENDING,
+					 g_param_spec_uint ("n-messages-sending",
+						 	    "Num Messages Sending",
+							    "The number of messages being sent",
+							    0, G_MAXUINT, 0,
+							    G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
 	signals[COMPOSING] =
 		g_signal_new ("composing",
 			      G_OBJECT_CLASS_TYPE (object_class),
@@ -3497,6 +3510,12 @@ chat_sms_channel_changed_cb (EmpathyChat *self)
 	g_object_notify (G_OBJECT (self), "sms-channel");
 }
 
+static void
+chat_n_messages_sending_changed_cb (EmpathyChat *self)
+{
+	g_object_notify (G_OBJECT (self), "n-messages-sending");
+}
+
 void
 empathy_chat_set_tp_chat (EmpathyChat   *chat,
 			  EmpathyTpChat *tp_chat)
@@ -3549,6 +3568,9 @@ empathy_chat_set_tp_chat (EmpathyChat   *chat,
 	g_signal_connect_swapped (tp_chat, "notify::sms-channel",
 				  G_CALLBACK (chat_sms_channel_changed_cb),
 				  chat);
+	g_signal_connect_swapped (tp_chat, "notify::n-messages-sending",
+				  G_CALLBACK (chat_n_messages_sending_changed_cb),
+				  chat);
 
 	/* Get initial value of properties */
 	properties = empathy_tp_chat_get_properties (priv->tp_chat);
@@ -3873,3 +3895,25 @@ empathy_chat_is_sms_channel (EmpathyChat *self)
 
 	return priv->sms_channel;
 }
+
+guint
+empathy_chat_get_n_messages_sending (EmpathyChat *self)
+{
+	EmpathyChatPriv *priv;
+
+	g_return_val_if_fail (EMPATHY_IS_CHAT (self), 0);
+
+	priv = GET_PRIV (self);
+
+	if (priv->tp_chat == NULL) {
+		return 0;
+	} else {
+		guint n_messages;
+
+		g_object_get (priv->tp_chat,
+			"n-messages-sending", &n_messages,
+			NULL);
+
+		return n_messages;
+	}
+}
diff --git a/libempathy-gtk/empathy-chat.h b/libempathy-gtk/empathy-chat.h
index 8da8004..a5c0148 100644
--- a/libempathy-gtk/empathy-chat.h
+++ b/libempathy-gtk/empathy-chat.h
@@ -96,6 +96,8 @@ void               empathy_chat_messages_read        (EmpathyChat *self);
 gboolean           empathy_chat_is_composing (EmpathyChat *chat);
 
 gboolean           empathy_chat_is_sms_channel       (EmpathyChat *self);
+guint              empathy_chat_get_n_messages_sending (EmpathyChat *self);
+
 G_END_DECLS
 
 #endif /* __EMPATHY_CHAT_H__ */



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