[evolution] Message filters not playing sounds
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Message filters not playing sounds
- Date: Mon, 3 Aug 2020 07:16:07 +0000 (UTC)
commit c9e7d068e4e99a55653055be396a7f06fec8251f
Author: Milan Crha <mcrha redhat com>
Date: Mon Aug 3 09:12:12 2020 +0200
Message filters not playing sounds
- The mail session sound is played in its own canberra context, similarly
as the mail notification, thus it is not disabled when the gtk+ sound
theme is disabled in the system preferences.
- Added debugging, which can be enabled by `ECA_DEBUG=1 evolution`.
Reported on the mailing list:
https://mail.gnome.org/archives/evolution-list/2020-August/msg00004.html
src/mail/e-mail-ui-session.c | 42 ++++++++++++++++++++---
src/plugins/mail-notification/mail-notification.c | 31 ++++++++++++++---
2 files changed, 64 insertions(+), 9 deletions(-)
---
diff --git a/src/mail/e-mail-ui-session.c b/src/mail/e-mail-ui-session.c
index 291d87988f..54ed8d329f 100644
--- a/src/mail/e-mail-ui-session.c
+++ b/src/mail/e-mail-ui-session.c
@@ -63,6 +63,11 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_MAIL_UI_SESSION, EMailUISessionPrivate))
+#ifdef HAVE_CANBERRA
+static ca_context *cactx = NULL;
+static gint eca_debug = -1;
+#endif
+
typedef struct _SourceContext SourceContext;
struct _EMailUISessionPrivate {
@@ -179,12 +184,34 @@ static gboolean
session_play_sound_cb (const gchar *filename)
{
#ifdef HAVE_CANBERRA
- if (filename != NULL && *filename != '\0')
- ca_context_play (
- ca_gtk_context_get (), 0,
+ if (filename && *filename) {
+ gint err;
+
+ if (eca_debug == -1)
+ eca_debug = g_strcmp0 (g_getenv ("ECA_DEBUG"), "1") == 0 ? 1 : 0;
+
+ if (!cactx) {
+ ca_context_create (&cactx);
+ ca_context_change_props (cactx,
+ CA_PROP_APPLICATION_NAME, "Evolution",
+ NULL);
+ }
+
+ err = ca_context_play (
+ cactx, 0,
CA_PROP_MEDIA_FILENAME, filename,
NULL);
- else
+
+ if (eca_debug) {
+ if (err != 0)
+ e_util_debug_print ("ECA", "Session Play Sound: Failed to play '%s': %s\n",
filename, ca_strerror (err));
+ else
+ e_util_debug_print ("ECA", "Session Play Sound: Played file '%s'\n",
filename);
+ }
+ } else
+#else
+ if (eca_debug)
+ e_util_debug_print ("ECA", "Session Play Sound: Cannot play sound, not compiled with
libcanberra\n");
#endif
gdk_display_beep (gdk_display_get_default ());
@@ -453,6 +480,13 @@ mail_ui_session_finalize (GObject *object)
g_mutex_clear (&priv->address_cache_mutex);
+#ifdef HAVE_CANBERRA
+ if (cactx) {
+ ca_context_destroy (cactx);
+ cactx = NULL;
+ }
+#endif
+
/* Chain up to parent's method. */
G_OBJECT_CLASS (e_mail_ui_session_parent_class)->finalize (object);
}
diff --git a/src/plugins/mail-notification/mail-notification.c
b/src/plugins/mail-notification/mail-notification.c
index 5865131322..371b4af2fb 100644
--- a/src/plugins/mail-notification/mail-notification.c
+++ b/src/plugins/mail-notification/mail-notification.c
@@ -629,6 +629,7 @@ read_notify_status (EMEventTargetMessage *t)
#ifdef HAVE_CANBERRA
static ca_context *mailnotification = NULL;
+static gint eca_debug = -1;
#endif
static void
@@ -638,16 +639,35 @@ do_play_sound (gboolean beep,
{
if (!beep) {
#ifdef HAVE_CANBERRA
+ gint err;
+
+ if (eca_debug == -1)
+ eca_debug = g_strcmp0 (g_getenv ("ECA_DEBUG"), "1") == 0 ? 1 : 0;
+
if (!use_theme && file && *file)
- ca_context_play (
+ err = ca_context_play (
mailnotification, 0,
CA_PROP_MEDIA_FILENAME, file,
NULL);
else
- ca_context_play (
+ err = ca_context_play (
mailnotification, 0,
- CA_PROP_EVENT_ID,"message-new-email",
+ CA_PROP_EVENT_ID, "message-new-email",
NULL);
+
+ if (eca_debug) {
+ if (err != 0 && file && *file)
+ e_util_debug_print ("ECA", "Mail Notification: Failed to play '%s': %s\n",
file, ca_strerror (err));
+ else if (err != 0)
+ e_util_debug_print ("ECA", "Mail Notification: Failed to play
'message-new-email' sound: %s\n", ca_strerror (err));
+ else if (file && *file)
+ e_util_debug_print ("ECA", "Mail Notification: Played file '%s'\n", file);
+ else
+ e_util_debug_print ("ECA", "Mail Notification: Played 'message-new-email'
sound\n");
+ }
+#else
+ if (eca_debug)
+ e_util_debug_print ("ECA", "Mail Notification: Cannot play sound, not compiled with
libcanberra\n");
#endif
} else
gdk_display_beep (gdk_display_get_default ());
@@ -763,9 +783,10 @@ enable_sound (gint enable)
CA_PROP_APPLICATION_NAME,
"mailnotification Plugin",
NULL);
- }
- else
+ } else {
ca_context_destroy (mailnotification);
+ mailnotification = NULL;
+ }
#endif
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]