aboutsummaryrefslogtreecommitdiffstats
path: root/src/empathy-chat-window.c
diff options
context:
space:
mode:
authorJonas Bonn <jonas@southpole.se>2010-03-05 19:55:25 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-05-27 22:59:58 +0800
commit6da94f6bce71e0d2c1b44260da986eecd089defa (patch)
tree73d11d049066e4cd14e13cd815ff6df642c088f8 /src/empathy-chat-window.c
parent2f9166bf42462e44b40462cbd9fc562f6cf507af (diff)
downloadgsoc2013-empathy-6da94f6bce71e0d2c1b44260da986eecd089defa.tar
gsoc2013-empathy-6da94f6bce71e0d2c1b44260da986eecd089defa.tar.gz
gsoc2013-empathy-6da94f6bce71e0d2c1b44260da986eecd089defa.tar.bz2
gsoc2013-empathy-6da94f6bce71e0d2c1b44260da986eecd089defa.tar.lz
gsoc2013-empathy-6da94f6bce71e0d2c1b44260da986eecd089defa.tar.xz
gsoc2013-empathy-6da94f6bce71e0d2c1b44260da986eecd089defa.tar.zst
gsoc2013-empathy-6da94f6bce71e0d2c1b44260da986eecd089defa.zip
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.
Diffstat (limited to 'src/empathy-chat-window.c')
-rw-r--r--src/empathy-chat-window.c56
1 files changed, 53 insertions, 3 deletions
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);
@@ -839,6 +847,30 @@ chat_window_favorite_toggled_cb (GtkToggleAction *toggle_action,
}
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,