N_("Voice call ended"), NULL },
};
+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;
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) {
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;
+}
+
void empathy_sound_play (GtkWidget *widget,
EmpathySound sound_id);
+/* Notifications */
+gboolean empathy_notification_should_show (void);
+
G_END_DECLS
#endif /* __EMPATHY_UI_UTILS_H__ */
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,
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) {
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