From a0069b64b55bd239eb7d4678fb9792b1359210dc Mon Sep 17 00:00:00 2001 From: Danielle Madeley Date: Thu, 7 Apr 2011 11:42:12 +1000 Subject: Set EMPATHY_IMAGE_SMS on sms channels --- src/empathy-chat-window.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 94f93e2bf..31cc07040 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -675,6 +675,9 @@ chat_window_update_chat_tab_full (EmpathyChat *chat, else if (remote_contact && empathy_chat_is_composing (chat)) { icon_name = EMPATHY_IMAGE_TYPING; } + else if (empathy_chat_is_sms_channel (chat)) { + icon_name = EMPATHY_IMAGE_SMS; + } else if (remote_contact) { icon_name = empathy_icon_name_for_contact (remote_contact); } else { @@ -2227,6 +2230,9 @@ empathy_chat_window_add_chat (EmpathyChatWindow *window, g_signal_connect (chat, "notify::remote-contact", G_CALLBACK (chat_window_chat_notify_cb), NULL); + g_signal_connect (chat, "notify::sms-channel", + G_CALLBACK (chat_window_chat_notify_cb), + NULL); chat_window_chat_notify_cb (chat); gtk_notebook_append_page_menu (GTK_NOTEBOOK (priv->notebook), child, label, popup_label); -- cgit v1.2.3 From 19ff66754d0afc6ef10fffba319c781dfc9d0ec9 Mon Sep 17 00:00:00 2001 From: Danielle Madeley Date: Thu, 7 Apr 2011 11:43:07 +1000 Subject: Add "SMS:" to the tooltip --- src/empathy-chat-window.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 31cc07040..038652f03 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -706,6 +706,10 @@ chat_window_update_chat_tab_full (EmpathyChat *chat, id = name; } + if (empathy_chat_is_sms_channel (chat)) { + append_markup_printf (tooltip, "%s ", _("SMS:")); + } + append_markup_printf (tooltip, "%s (%s)", id, -- cgit v1.2.3 From 385dc5af3c16b6de75d92b989585e44f953967f6 Mon Sep 17 00:00:00 2001 From: Danielle Madeley Date: Thu, 7 Apr 2011 11:48:56 +1000 Subject: Change empathy_chat_get_name() from const char * -> char * Change the name to empathy_chat_dup_name() to reflect this change. Note to reviewer: I think I've updated all the callers, but this is the commit to check carefully for new leaks :) --- src/empathy-chat-window.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 038652f03..8fc5d6f3d 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -453,14 +453,14 @@ get_all_unread_messages (EmpathyChatWindowPriv *priv) static gchar * get_window_title_name (EmpathyChatWindowPriv *priv) { - const gchar *active_name; + gchar *active_name, *ret; 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); + active_name = empathy_chat_dup_name (priv->current_chat); current_unread_msgs = empathy_chat_get_nb_unread_messages ( priv->current_chat); @@ -468,9 +468,9 @@ get_window_title_name (EmpathyChatWindowPriv *priv) if (nb_chats == 1) { /* only one tab */ if (current_unread_msgs == 0) - return g_strdup (active_name); + ret = g_strdup (active_name); else - return g_strdup_printf (ngettext ( + ret = g_strdup_printf (ngettext ( "%s (%d unread)", "%s (%d unread)", current_unread_msgs), active_name, current_unread_msgs); @@ -482,7 +482,7 @@ get_window_title_name (EmpathyChatWindowPriv *priv) if (all_unread_msgs == 0) { /* no unread message */ - return g_strdup_printf (ngettext ( + ret = g_strdup_printf (ngettext ( "%s (and %u other)", "%s (and %u others)", nb_others), active_name, nb_others); @@ -490,7 +490,7 @@ get_window_title_name (EmpathyChatWindowPriv *priv) else if (all_unread_msgs == current_unread_msgs) { /* unread messages are in the current tab */ - return g_strdup_printf (ngettext ( + ret = g_strdup_printf (ngettext ( "%s (%d unread)", "%s (%d unread)", current_unread_msgs), active_name, current_unread_msgs); @@ -498,7 +498,7 @@ get_window_title_name (EmpathyChatWindowPriv *priv) else if (current_unread_msgs == 0) { /* unread messages are in other tabs */ - return g_strdup_printf (ngettext ( + ret = g_strdup_printf (ngettext ( "%s (%d unread from others)", "%s (%d unread from others)", all_unread_msgs), @@ -507,13 +507,17 @@ get_window_title_name (EmpathyChatWindowPriv *priv) else { /* unread messages are in all the tabs */ - return g_strdup_printf (ngettext ( + ret = g_strdup_printf (ngettext ( "%s (%d unread from all)", "%s (%d unread from all)", all_unread_msgs), active_name, all_unread_msgs); } } + + g_free (active_name); + + return ret; } static void @@ -637,7 +641,7 @@ chat_window_update_chat_tab_full (EmpathyChat *chat, EmpathyChatWindow *window; EmpathyChatWindowPriv *priv; EmpathyContact *remote_contact; - const gchar *name; + gchar *name; const gchar *id; TpAccount *account; const gchar *subject; @@ -656,7 +660,7 @@ chat_window_update_chat_tab_full (EmpathyChat *chat, priv = GET_PRIV (window); /* Get information */ - name = empathy_chat_get_name (chat); + name = empathy_chat_dup_name (chat); account = empathy_chat_get_account (chat); subject = empathy_chat_get_subject (chat); remote_contact = empathy_chat_get_remote_contact (chat); @@ -745,6 +749,8 @@ chat_window_update_chat_tab_full (EmpathyChat *chat, if (priv->current_chat == chat) { chat_window_update (window, update_contact_menu); } + + g_free (name); } static void @@ -872,21 +878,24 @@ chat_window_favorite_toggled_cb (GtkToggleAction *toggle_action, EmpathyChatWindowPriv *priv = GET_PRIV (window); gboolean active; TpAccount *account; + gchar *name; const gchar *room; EmpathyChatroom *chatroom; active = gtk_toggle_action_get_active (toggle_action); account = empathy_chat_get_account (priv->current_chat); room = empathy_chat_get_id (priv->current_chat); + name = empathy_chat_dup_name (priv->current_chat); chatroom = empathy_chatroom_manager_ensure_chatroom ( priv->chatroom_manager, account, room, - empathy_chat_get_name (priv->current_chat)); + name); empathy_chatroom_set_favorite (chatroom, active); g_object_unref (chatroom); + g_free (name); } static void @@ -896,21 +905,24 @@ chat_window_always_urgent_toggled_cb (GtkToggleAction *toggle_action, EmpathyChatWindowPriv *priv = GET_PRIV (window); gboolean active; TpAccount *account; + gchar *name; const gchar *room; EmpathyChatroom *chatroom; active = gtk_toggle_action_get_active (toggle_action); account = empathy_chat_get_account (priv->current_chat); room = empathy_chat_get_id (priv->current_chat); + name = empathy_chat_dup_name (priv->current_chat); chatroom = empathy_chatroom_manager_ensure_chatroom ( priv->chatroom_manager, account, room, - empathy_chat_get_name (priv->current_chat)); + name); empathy_chatroom_set_always_urgent (chatroom, active); g_object_unref (chatroom); + g_free (name); } static void @@ -1363,15 +1375,16 @@ chat_window_show_or_update_notification (EmpathyChatWindow *window, static void chat_window_set_highlight_room_labels (EmpathyChat *chat) { - gchar *markup; + gchar *markup, *name; GtkWidget *widget; if (!empathy_chat_is_room (chat)) return; + name = empathy_chat_dup_name (chat); markup = g_markup_printf_escaped ( "%s", - empathy_chat_get_name (chat)); + name); widget = g_object_get_data (G_OBJECT (chat), "chat-window-tab-label"); gtk_label_set_markup (GTK_LABEL (widget), markup); @@ -1379,6 +1392,7 @@ chat_window_set_highlight_room_labels (EmpathyChat *chat) widget = g_object_get_data (G_OBJECT (chat), "chat-window-menu-label"); gtk_label_set_markup (GTK_LABEL (widget), markup); + g_free (name); g_free (markup); } -- cgit v1.2.3 From 0fda59487b536e49bfcec7ab1ee6e9c6d7b6f306 Mon Sep 17 00:00:00 2001 From: Danielle Madeley Date: Thu, 5 May 2011 16:22:23 +1000 Subject: Include SMSChannel property in empathy_chat_window_find_chat() The approach in https://bugzilla.gnome.org/show_bug.cgi?id=644085 was wrong because channel paths can change across reconnects. This would cause new chat windows to be created when they were rerequested. A more future-proof solution would be to keep a white/black list of comparable properties, but I think this is overengineering the problem for the time being. Instead we'll just include the SMSChannel property in the comparison. --- src/empathy-chat-manager.c | 3 ++- src/empathy-chat-window.c | 8 +++++--- src/empathy-chat-window.h | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/empathy-chat-manager.c b/src/empathy-chat-manager.c index 6c92c25cb..544ede69f 100644 --- a/src/empathy-chat-manager.c +++ b/src/empathy-chat-manager.c @@ -111,7 +111,8 @@ process_tp_chat (EmpathyChatManager *self, id = empathy_tp_chat_get_id (tp_chat); if (!tp_str_empty (id)) { - chat = empathy_chat_window_find_chat (account, id); + chat = empathy_chat_window_find_chat (account, id, + empathy_tp_chat_is_sms_channel (tp_chat)); } if (chat != NULL) diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 8fc5d6f3d..ac97601ce 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -1786,7 +1786,7 @@ chat_window_drag_data_received (GtkWidget *widget, account = tp_account_manager_ensure_account (account_manager, account_id); if (account != NULL) - chat = empathy_chat_window_find_chat (account, contact_id); + chat = empathy_chat_window_find_chat (account, contact_id, FALSE); } if (account == NULL) { @@ -2354,7 +2354,8 @@ empathy_chat_window_switch_to_chat (EmpathyChatWindow *window, EmpathyChat * empathy_chat_window_find_chat (TpAccount *account, - const gchar *id) + const gchar *id, + gboolean sms_channel) { GList *l; @@ -2374,7 +2375,8 @@ empathy_chat_window_find_chat (TpAccount *account, chat = ll->data; if (account == empathy_chat_get_account (chat) && - !tp_strdiff (id, empathy_chat_get_id (chat))) { + !tp_strdiff (id, empathy_chat_get_id (chat)) && + sms_channel == empathy_chat_is_sms_channel (chat)) { return chat; } } diff --git a/src/empathy-chat-window.h b/src/empathy-chat-window.h index 5477479ac..2112b6647 100644 --- a/src/empathy-chat-window.h +++ b/src/empathy-chat-window.h @@ -59,7 +59,8 @@ struct _EmpathyChatWindowClass { GType empathy_chat_window_get_type (void); EmpathyChat * empathy_chat_window_find_chat (TpAccount *account, - const gchar *id); + const gchar *id, + gboolean sms_channel); void empathy_chat_window_present_chat (EmpathyChat *chat, gint64 timestamp); -- cgit v1.2.3