aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-26 01:25:07 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-27 23:25:00 +0800
commit761a836a296d32c4af5200d8efc80f3fa9cb33e0 (patch)
treeb99dd60cc7a3a12451b50256e70fe3d1830d22eb
parent06dc17735c9966d9b2ecab4f0257bfa9c2eb1742 (diff)
downloadgsoc2013-empathy-761a836a296d32c4af5200d8efc80f3fa9cb33e0.tar
gsoc2013-empathy-761a836a296d32c4af5200d8efc80f3fa9cb33e0.tar.gz
gsoc2013-empathy-761a836a296d32c4af5200d8efc80f3fa9cb33e0.tar.bz2
gsoc2013-empathy-761a836a296d32c4af5200d8efc80f3fa9cb33e0.tar.lz
gsoc2013-empathy-761a836a296d32c4af5200d8efc80f3fa9cb33e0.tar.xz
gsoc2013-empathy-761a836a296d32c4af5200d8efc80f3fa9cb33e0.tar.zst
gsoc2013-empathy-761a836a296d32c4af5200d8efc80f3fa9cb33e0.zip
display the number of unread message in the window title (#548701)
-rw-r--r--src/empathy-chat-window.c67
1 files changed, 62 insertions, 5 deletions
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 818fc2aa3..4a4e1c1be 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -356,27 +356,84 @@ chat_window_contact_menu_update (EmpathyChatWindowPriv *priv,
}
}
+static guint
+get_all_unread_messages (EmpathyChatWindowPriv *priv)
+{
+ GList *l;
+ guint nb = 0;
+
+ for (l = priv->chats_new_msg; l != NULL; l = g_list_next (l)) {
+ EmpathyChat *chat = l->data;
+
+ nb += empathy_chat_get_nb_unread_messages (chat);
+ }
+
+ return nb;
+}
+
static gchar *
get_window_title_name (EmpathyChatWindowPriv *priv)
{
const gchar *active_name;
guint nb_chats;
+ guint current_unread_msgs;
nb_chats = g_list_length (priv->chats);
g_assert (nb_chats > 0);
active_name = empathy_chat_get_name (priv->current_chat);
+ current_unread_msgs = empathy_chat_get_nb_unread_messages (
+ priv->current_chat);
+
if (nb_chats == 1) {
/* only one tab */
- return g_strdup (active_name);
+ if (current_unread_msgs == 0)
+ return g_strdup (active_name);
+ else
+ return g_strdup_printf (ngettext (
+ "%s (%d unread)",
+ "%s (%d unread)", current_unread_msgs),
+ active_name, current_unread_msgs);
} else {
guint nb_others = nb_chats - 1;
+ guint all_unread_msgs;
- return g_strdup_printf (ngettext (
- "%s (and %u other)",
- "%s (and %u others)", nb_others),
- active_name, nb_others);
+ all_unread_msgs = get_all_unread_messages (priv);
+
+ if (all_unread_msgs == 0) {
+ /* no unread message */
+ return g_strdup_printf (ngettext (
+ "%s (and %u other)",
+ "%s (and %u others)", nb_others),
+ active_name, nb_others);
+ }
+
+ else if (all_unread_msgs == current_unread_msgs) {
+ /* unread messages are in the current tab */
+ return g_strdup_printf (ngettext (
+ "%s (%d unread)",
+ "%s (%d unread)", current_unread_msgs),
+ active_name, current_unread_msgs);
+ }
+
+ else if (current_unread_msgs == 0) {
+ /* unread messages are in others tab */
+ return g_strdup_printf (ngettext (
+ "%s (%d unread from others)",
+ "%s (%d unread from others)",
+ all_unread_msgs),
+ active_name, all_unread_msgs);
+ }
+
+ else {
+ /* unread messages are in all the tabs */
+ return g_strdup_printf (ngettext (
+ "%s (%d unread from everyone)",
+ "%s (%d unread from everyone)",
+ all_unread_msgs),
+ active_name, all_unread_msgs);
+ }
}
}