From 6da94f6bce71e0d2c1b44260da986eecd089defa Mon Sep 17 00:00:00 2001 From: Jonas Bonn Date: Fri, 5 Mar 2010 12:55:25 +0100 Subject: Add option to make chatroom "always urgent" (#611894) Often a user wants to be immediately notified of posts to a chatroom even when the post does not address them directly by name. This patch adds a room option to make all posts to the room "urgent", meaning that the system-specific urgency action should be taken -- notification, window urgency hint, etc. Two specific use cases for when one may want this: i) Low-traffic rooms (so that one does not have to go check the room all the time) ii) Error-logging room (room to which errors from some other system(s) are logged) The "always urgent" option is off by default when joining a room. --- src/empathy-chat-window.c | 56 +++++++++++++++++++++++++++++++++++++++++++--- src/empathy-chat-window.ui | 7 ++++++ 2 files changed, 60 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 39711e2cd..97b7026c5 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -94,6 +94,7 @@ typedef struct { GtkUIManager *ui_manager; GtkAction *menu_conv_insert_smiley; GtkAction *menu_conv_favorite; + GtkAction *menu_conv_always_urgent; GtkAction *menu_conv_toggle_contacts; GtkAction *menu_edit_cut; @@ -785,6 +786,13 @@ chat_window_conv_activate_cb (GtkAction *action, DEBUG ("This room %s favorite", found ? "is" : "is not"); gtk_toggle_action_set_active ( GTK_TOGGLE_ACTION (priv->menu_conv_favorite), found); + + if (chatroom != NULL) + found = empathy_chatroom_is_always_urgent (chatroom); + + gtk_toggle_action_set_active ( + GTK_TOGGLE_ACTION (priv->menu_conv_always_urgent), + found); } gtk_action_set_visible (priv->menu_conv_favorite, is_room); @@ -838,6 +846,30 @@ chat_window_favorite_toggled_cb (GtkToggleAction *toggle_action, g_object_unref(chatroom); } +static void +chat_window_always_urgent_toggled_cb (GtkToggleAction *toggle_action, + EmpathyChatWindow *window) +{ + EmpathyChatWindowPriv *priv = GET_PRIV (window); + gboolean active; + TpAccount *account; + 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); + + chatroom = empathy_chatroom_manager_ensure_chatroom ( + priv->chatroom_manager, + account, + room, + empathy_chat_get_name (priv->current_chat)); + + empathy_chatroom_set_always_urgent (chatroom, active); + g_object_unref(chatroom); +} + static void chat_window_contacts_toggled_cb (GtkToggleAction *toggle_action, EmpathyChatWindow *window) @@ -1350,11 +1382,27 @@ chat_window_new_message_cb (EmpathyChat *chat, /* If empathy_chat_is_room () returns TRUE, that means it's a named MUC. * If empathy_chat_get_remote_contact () returns NULL, that means it's * an unamed MUC (msn-like). - * In case of a MUC, we set urgency only if the message contains our - * alias. */ + * In case of a MUC, we set urgency if either: + * a) the chatroom's always_urgent property is TRUE + * b) the message contains our alias + */ if (empathy_chat_is_room (chat) || empathy_chat_get_remote_contact (chat) == NULL) { - needs_urgency = empathy_message_should_highlight (message); + TpAccount *account; + const gchar *room; + EmpathyChatroom *chatroom; + + account = empathy_chat_get_account (chat); + room = empathy_chat_get_id (chat); + + chatroom = empathy_chatroom_manager_find (priv->chatroom_manager, + account, room); + + if (empathy_chatroom_is_always_urgent (chatroom)) { + needs_urgency = TRUE; + } else { + needs_urgency = empathy_message_should_highlight (message); + } } else { needs_urgency = TRUE; } @@ -1855,6 +1903,7 @@ empathy_chat_window_init (EmpathyChatWindow *window) "ui_manager", &priv->ui_manager, "menu_conv_insert_smiley", &priv->menu_conv_insert_smiley, "menu_conv_favorite", &priv->menu_conv_favorite, + "menu_conv_always_urgent", &priv->menu_conv_always_urgent, "menu_conv_toggle_contacts", &priv->menu_conv_toggle_contacts, "menu_edit_cut", &priv->menu_edit_cut, "menu_edit_copy", &priv->menu_edit_copy, @@ -1873,6 +1922,7 @@ empathy_chat_window_init (EmpathyChatWindow *window) "menu_conv", "activate", chat_window_conv_activate_cb, "menu_conv_clear", "activate", chat_window_clear_activate_cb, "menu_conv_favorite", "toggled", chat_window_favorite_toggled_cb, + "menu_conv_always_urgent", "toggled", chat_window_always_urgent_toggled_cb, "menu_conv_toggle_contacts", "toggled", chat_window_contacts_toggled_cb, "menu_conv_invite_participant", "activate", chat_window_invite_participant_activate_cb, "menu_conv_close", "activate", chat_window_close_activate_cb, diff --git a/src/empathy-chat-window.ui b/src/empathy-chat-window.ui index 362286a09..9b4c3d825 100644 --- a/src/empathy-chat-window.ui +++ b/src/empathy-chat-window.ui @@ -31,6 +31,12 @@ _Favorite Chat Room + + + menu_conv_always_urgent + _Notify Always + + menu_conv_toggle_contacts @@ -166,6 +172,7 @@ + -- cgit v1.2.3