]> git.0d.be Git - empathy.git/commitdiff
[chat] expose this property in EmpathyChat
authorDanielle Madeley <danielle.madeley@collabora.co.uk>
Thu, 28 Apr 2011 05:28:08 +0000 (15:28 +1000)
committerDanielle Madeley <danielle.madeley@collabora.co.uk>
Thu, 5 May 2011 07:24:17 +0000 (17:24 +1000)
libempathy-gtk/empathy-chat.c
libempathy-gtk/empathy-chat.h

index d4e025f8d2261a07bdf6d2a3c8b38c952927f06a..3e8a9c70bcf1c5dfcdd366de714bfb490820550b 100644 (file)
@@ -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;
+       }
+}
index 8da8004ec8f808cee45aea1548844bf8d0511e30..a5c0148a1511a597bbc3f508ded61f066857e785 100644 (file)
@@ -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__ */