diff options
author | Jonny Lamb <jonnylamb@gnome.org> | 2011-05-17 16:36:33 +0800 |
---|---|---|
committer | Jonny Lamb <jonnylamb@gnome.org> | 2011-05-17 16:36:33 +0800 |
commit | 2950825a4452bc984c0dd356c5bf17c3a674c451 (patch) | |
tree | c562a901727f1548105acf75884f350d9dfd7192 /libempathy-gtk/empathy-chat.c | |
parent | 38e5925b90ca5864907aaef09cbaa4c963b1be98 (diff) | |
parent | 9e1914959b7e26e82ca4042ad5f7f042cb5a34a2 (diff) | |
download | gsoc2013-empathy-2950825a4452bc984c0dd356c5bf17c3a674c451.tar gsoc2013-empathy-2950825a4452bc984c0dd356c5bf17c3a674c451.tar.gz gsoc2013-empathy-2950825a4452bc984c0dd356c5bf17c3a674c451.tar.bz2 gsoc2013-empathy-2950825a4452bc984c0dd356c5bf17c3a674c451.tar.lz gsoc2013-empathy-2950825a4452bc984c0dd356c5bf17c3a674c451.tar.xz gsoc2013-empathy-2950825a4452bc984c0dd356c5bf17c3a674c451.tar.zst gsoc2013-empathy-2950825a4452bc984c0dd356c5bf17c3a674c451.zip |
Merge branch 'ack'
Diffstat (limited to 'libempathy-gtk/empathy-chat.c')
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 034cd9ea7..e76998065 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -174,6 +174,7 @@ enum { PROP_SHOW_CONTACTS, PROP_SMS_CHANNEL, PROP_N_MESSAGES_SENDING, + PROP_NB_UNREAD_MESSAGES, }; static guint signals[LAST_SIGNAL] = { 0 }; @@ -220,6 +221,10 @@ chat_get_property (GObject *object, g_value_set_uint (value, empathy_chat_get_n_messages_sending (chat)); break; + case PROP_NB_UNREAD_MESSAGES: + g_value_set_uint (value, + empathy_chat_get_nb_unread_messages (chat)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -1326,7 +1331,11 @@ chat_message_received (EmpathyChat *chat, TP_CHANNEL_CHAT_STATE_ACTIVE, chat); - priv->unread_messages++; + if (empathy_message_is_incoming (message)) { + priv->unread_messages++; + g_object_notify (G_OBJECT (chat), "nb-unread-messages"); + } + g_signal_emit (chat, signals[NEW_MESSAGE], 0, message, pending); } @@ -1339,6 +1348,20 @@ chat_message_received_cb (EmpathyTpChat *tp_chat, } static void +chat_message_acknowledged_cb (EmpathyTpChat *tp_chat, + EmpathyMessage *message, + EmpathyChat *chat) +{ + EmpathyChatPriv *priv = GET_PRIV (chat); + + empathy_chat_view_message_acknowledged (chat->view, + message); + + priv->unread_messages--; + g_object_notify (G_OBJECT (chat), "nb-unread-messages"); +} + +static void chat_send_error_cb (EmpathyTpChat *tp_chat, const gchar *message_body, TpChannelTextSendError error_code, @@ -2927,6 +2950,8 @@ chat_finalize (GObject *object) g_signal_handlers_disconnect_by_func (priv->tp_chat, chat_message_received_cb, chat); g_signal_handlers_disconnect_by_func (priv->tp_chat, + chat_message_acknowledged_cb, chat); + g_signal_handlers_disconnect_by_func (priv->tp_chat, chat_send_error_cb, chat); g_signal_handlers_disconnect_by_func (priv->tp_chat, chat_state_changed_cb, chat); @@ -3062,6 +3087,14 @@ empathy_chat_class_init (EmpathyChatClass *klass) 0, G_MAXUINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, + PROP_NB_UNREAD_MESSAGES, + g_param_spec_uint ("nb-unread-messages", + "Num Unread Messages", + "The number of unread messages", + 0, G_MAXUINT, 0, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + signals[COMPOSING] = g_signal_new ("composing", G_OBJECT_CLASS_TYPE (object_class), @@ -3630,6 +3663,9 @@ empathy_chat_set_tp_chat (EmpathyChat *chat, g_signal_connect (tp_chat, "message-received", G_CALLBACK (chat_message_received_cb), chat); + g_signal_connect (tp_chat, "message_acknowledged", + G_CALLBACK (chat_message_acknowledged_cb), + chat); g_signal_connect (tp_chat, "send-error", G_CALLBACK (chat_send_error_cb), chat); @@ -3957,12 +3993,9 @@ empathy_chat_messages_read (EmpathyChat *self) if (priv->retrieving_backlogs) return; - if (priv->tp_chat != NULL ) { + if (priv->tp_chat != NULL) { empathy_tp_chat_acknowledge_all_messages (priv->tp_chat); } - priv->unread_messages = 0; - - empathy_chat_view_focus_toggled (self->view, TRUE); } /* Return TRUE if on of the contacts in this chat is composing */ |