aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2009-01-31 01:07:26 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-01-31 01:07:26 +0800
commit3eb84c8a0312fd0d1be89b091d8d6a4dd315d3d9 (patch)
tree493b443b93bdd6d75d4386c8299a4b5f5e9c39bb
parent973bc4d1197ab108f0236ac2baf48678f20fb2aa (diff)
downloadgsoc2013-empathy-3eb84c8a0312fd0d1be89b091d8d6a4dd315d3d9.tar
gsoc2013-empathy-3eb84c8a0312fd0d1be89b091d8d6a4dd315d3d9.tar.gz
gsoc2013-empathy-3eb84c8a0312fd0d1be89b091d8d6a4dd315d3d9.tar.bz2
gsoc2013-empathy-3eb84c8a0312fd0d1be89b091d8d6a4dd315d3d9.tar.lz
gsoc2013-empathy-3eb84c8a0312fd0d1be89b091d8d6a4dd315d3d9.tar.xz
gsoc2013-empathy-3eb84c8a0312fd0d1be89b091d8d6a4dd315d3d9.tar.zst
gsoc2013-empathy-3eb84c8a0312fd0d1be89b091d8d6a4dd315d3d9.zip
Implement a logic for disabling notifications when away.
svn path=/trunk/; revision=2282
-rw-r--r--libempathy-gtk/empathy-ui-utils.c55
-rw-r--r--libempathy-gtk/empathy-ui-utils.h3
-rw-r--r--src/empathy-status-icon.c21
3 files changed, 70 insertions, 9 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index effeb7a01..7b55587ea 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -1573,12 +1573,28 @@ static EmpathySoundEntry sound_entries[LAST_EMPATHY_SOUND] = {
};
static gboolean
+check_available (void)
+{
+ McPresence presence;
+ EmpathyIdle *idle;
+
+ idle = empathy_idle_dup_singleton ();
+ presence = empathy_idle_get_state (idle);
+ g_object_unref (idle);
+
+ if (presence != MC_PRESENCE_AVAILABLE &&
+ presence != MC_PRESENCE_UNSET) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
empathy_sound_pref_is_enabled (const char *key)
{
EmpathyConf *conf;
- McPresence presence;
gboolean res;
- EmpathyIdle *idle;
conf = empathy_conf_get ();
res = FALSE;
@@ -1589,12 +1605,7 @@ empathy_sound_pref_is_enabled (const char *key)
return FALSE;
}
- idle = empathy_idle_dup_singleton ();
- presence = empathy_idle_get_state (idle);
- g_object_unref (idle);
-
- if (presence != MC_PRESENCE_AVAILABLE &&
- presence != MC_PRESENCE_UNSET) {
+ if (!check_available ()) {
empathy_conf_get_bool (conf, EMPATHY_PREFS_SOUNDS_DISABLED_AWAY,
&res);
if (res) {
@@ -1634,3 +1645,31 @@ empathy_sound_play (GtkWidget *widget,
NULL);
}
}
+
+gboolean
+empathy_notification_should_show (void)
+{
+ EmpathyConf *conf;
+ gboolean res;
+
+ conf = empathy_conf_get ();
+ res = FALSE;
+
+ empathy_conf_get_bool (conf, EMPATHY_PREFS_NOTIFICATIONS_ENABLED, &res);
+
+ if (!res) {
+ return FALSE;
+ }
+
+ if (!check_available ()) {
+ empathy_conf_get_bool (conf,
+ EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY,
+ &res);
+ if (res) {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index 108b7bb89..b3b26f0bb 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -131,6 +131,9 @@ void empathy_send_file_with_file_chooser (EmpathyContact *conta
void empathy_sound_play (GtkWidget *widget,
EmpathySound sound_id);
+/* Notifications */
+gboolean empathy_notification_should_show (void);
+
G_END_DECLS
#endif /* __EMPATHY_UI_UTILS_H__ */
diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c
index a1d3704ea..ea407fd81 100644
--- a/src/empathy-status-icon.c
+++ b/src/empathy-status-icon.c
@@ -222,7 +222,10 @@ status_icon_event_added_cb (EmpathyEventManager *manager,
status_icon_update_icon (icon);
status_icon_update_tooltip (icon);
- status_icon_update_notification (icon);
+
+ if (empathy_notification_should_show ()) {
+ status_icon_update_notification (icon);
+ }
if (!priv->blink_timeout) {
priv->blink_timeout = g_timeout_add (BLINK_TIMEOUT,
@@ -246,6 +249,10 @@ status_icon_event_removed_cb (EmpathyEventManager *manager,
status_icon_update_tooltip (icon);
status_icon_update_icon (icon);
+
+ /* update notification anyway, as it's safe and we might have been
+ * changed presence in the meanwhile
+ */
status_icon_update_notification (icon);
if (!priv->event && priv->blink_timeout) {
@@ -325,8 +332,20 @@ status_icon_toggle_visibility (EmpathyStatusIcon *icon)
static void
status_icon_idle_notify_cb (EmpathyStatusIcon *icon)
{
+ EmpathyStatusIconPriv *priv = GET_PRIV (icon);
+
status_icon_update_icon (icon);
status_icon_update_tooltip (icon);
+
+ if (!empathy_notification_should_show ()) {
+ /* dismiss the outstanding notification if present */
+
+ if (priv->notification) {
+ notify_notification_close (priv->notification, NULL);
+ g_object_unref (priv->notification);
+ priv->notification = NULL;
+ }
+ }
}
static gboolean