aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--libempathy/empathy-chatroom.c48
-rw-r--r--libempathy/empathy-chatroom.h3
-rw-r--r--src/empathy-chat-window.c56
-rw-r--r--src/empathy-chat-window.ui7
4 files changed, 110 insertions, 4 deletions
diff --git a/libempathy/empathy-chatroom.c b/libempathy/empathy-chatroom.c
index 5d43a3ec1..5e3784ae7 100644
--- a/libempathy/empathy-chatroom.c
+++ b/libempathy/empathy-chatroom.c
@@ -41,6 +41,7 @@ typedef struct {
guint members_count;
gboolean invite_only;
gboolean need_password;
+ gboolean always_urgent;
} EmpathyChatroomPriv;
@@ -65,7 +66,8 @@ enum {
PROP_SUBJECT,
PROP_MEMBERS_COUNT,
PROP_NEED_PASSWORD,
- PROP_INVITE_ONLY
+ PROP_INVITE_ONLY,
+ PROP_ALWAYS_URGENT,
};
G_DEFINE_TYPE (EmpathyChatroom, empathy_chatroom, G_TYPE_OBJECT);
@@ -121,6 +123,14 @@ empathy_chatroom_class_init (EmpathyChatroomClass *klass)
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
+ PROP_ALWAYS_URGENT,
+ g_param_spec_boolean ("always_urgent",
+ "Always Urgent",
+ "TRUE if every message should be considered urgent",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
PROP_TP_CHAT,
g_param_spec_object ("tp-chat",
"Chatroom channel wrapper",
@@ -233,6 +243,9 @@ chatroom_get_property (GObject *object,
case PROP_FAVORITE:
g_value_set_boolean (value, priv->favorite);
break;
+ case PROP_ALWAYS_URGENT:
+ g_value_set_boolean (value, priv->always_urgent);
+ break;
case PROP_TP_CHAT:
g_value_set_object (value, priv->tp_chat);
break;
@@ -285,6 +298,10 @@ chatroom_set_property (GObject *object,
empathy_chatroom_set_favorite (EMPATHY_CHATROOM (object),
g_value_get_boolean (value));
break;
+ case PROP_ALWAYS_URGENT:
+ empathy_chatroom_set_always_urgent (EMPATHY_CHATROOM (object),
+ g_value_get_boolean (value));
+ break;
case PROP_TP_CHAT:
empathy_chatroom_set_tp_chat (EMPATHY_CHATROOM (object),
g_value_get_object (value));
@@ -663,3 +680,32 @@ empathy_chatroom_set_favorite (EmpathyChatroom *chatroom,
g_object_notify (G_OBJECT (chatroom), "favorite");
}
+gboolean
+empathy_chatroom_is_always_urgent (EmpathyChatroom *chatroom)
+{
+ EmpathyChatroomPriv *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_CHATROOM (chatroom), FALSE);
+
+ priv = GET_PRIV (chatroom);
+
+ return priv->always_urgent;
+}
+
+void
+empathy_chatroom_set_always_urgent (EmpathyChatroom *chatroom,
+ gboolean always_urgent)
+{
+ EmpathyChatroomPriv *priv;
+
+ g_return_if_fail (EMPATHY_IS_CHATROOM (chatroom));
+
+ priv = GET_PRIV (chatroom);
+
+ if (priv->always_urgent == always_urgent)
+ return;
+
+ priv->always_urgent = always_urgent;
+ g_object_notify (G_OBJECT (chatroom), "always_urgent");
+}
+
diff --git a/libempathy/empathy-chatroom.h b/libempathy/empathy-chatroom.h
index 3048aded7..f86f8ca9e 100644
--- a/libempathy/empathy-chatroom.h
+++ b/libempathy/empathy-chatroom.h
@@ -89,6 +89,9 @@ void empathy_chatroom_set_tp_chat (EmpathyChatroom *chatroom,
gboolean empathy_chatroom_is_favorite (EmpathyChatroom *chatroom);
void empathy_chatroom_set_favorite (EmpathyChatroom *chatroom,
gboolean favorite);
+gboolean empathy_chatroom_is_always_urgent (EmpathyChatroom *chatroom);
+void empathy_chatroom_set_always_urgent (EmpathyChatroom *chatroom,
+ gboolean always_urgent);
G_END_DECLS
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,
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
@@ -32,6 +32,12 @@
</object>
</child>
<child>
+ <object class="GtkToggleAction" id="menu_conv_always_urgent">
+ <property name="name">menu_conv_always_urgent</property>
+ <property name="label" translatable="yes">_Notify Always</property>
+ </object>
+ </child>
+ <child>
<object class="GtkToggleAction" id="menu_conv_toggle_contacts">
<property name="name">menu_conv_toggle_contacts</property>
<property name="active">TRUE</property>
@@ -166,6 +172,7 @@
<menuitem action="menu_conv_clear"/>
<menuitem action="menu_conv_insert_smiley"/>
<menuitem action="menu_conv_favorite"/>
+ <menuitem action="menu_conv_always_urgent"/>
<menuitem action="menu_conv_toggle_contacts"/>
<menuitem action="menu_conv_invite_participant"/>
<separator/>