[Galago-commits] r2984 - in trunk/notification-daemon: . data
src/daemon
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Sun Apr 29 03:44:23 PDT 2007
Author: chipx86
Date: 2007-04-29 03:44:20 -0700 (Sun, 29 Apr 2007)
New Revision: 2984
Added:
trunk/notification-daemon/src/daemon/sound.c
trunk/notification-daemon/src/daemon/sound.h
Modified:
trunk/notification-daemon/AUTHORS
trunk/notification-daemon/ChangeLog
trunk/notification-daemon/NEWS
trunk/notification-daemon/configure.ac
trunk/notification-daemon/data/notification-daemon.schemas.in
trunk/notification-daemon/src/daemon/Makefile.am
trunk/notification-daemon/src/daemon/daemon.c
trunk/notification-daemon/src/daemon/daemon.h
Log:
Added support for playing sounds when the "sound-file" hint is set or when the default_sound GConf key is set, as well as support for the "suppress-sound" hint. Patch by Jim Ramsay. (Ticket #111)
Modified: trunk/notification-daemon/AUTHORS
===================================================================
--- trunk/notification-daemon/AUTHORS 2007-04-29 09:59:59 UTC (rev 2983)
+++ trunk/notification-daemon/AUTHORS 2007-04-29 10:44:20 UTC (rev 2984)
@@ -3,13 +3,14 @@
John (J5) Palmieri <johnp at redhat.com>
Contributors:
+ driehuis at playbeing.org
Ed Catmur <ed at catmur.co.uk>
felix at hsgheli.de
+ Jim Ramsay <i.am at jimramsay.com>
+ Luca Cavelli <luca.cavelli at gmail.com>
Matt Walton <matthew at matthew-walton.co.uk>
Pawel Worach <pawel.worach at gmail.com>
Rodney Dawes <dobey at novell.com>
- driehuis at playbeing.org
- Luca Cavelli <luca.cavelli at gmail.com>
Translators:
Dutch - Wouter Bolsterlee <uws+gnome at xs4all.nl>
Modified: trunk/notification-daemon/ChangeLog
===================================================================
--- trunk/notification-daemon/ChangeLog 2007-04-29 09:59:59 UTC (rev 2983)
+++ trunk/notification-daemon/ChangeLog 2007-04-29 10:44:20 UTC (rev 2984)
@@ -1,3 +1,16 @@
+Sun Apr 29 03:43:13 PDT 2007 Christian Hammond <chipx86 at chipx86.com>
+
+ * data/notification-daemon.schemas.in:
+ * src/daemon/daemon.c:
+ * src/daemon/daemon.h:
+ * src/daemon/Makefile.am:
+ * AUTHORS:
+ * NEWS:
+ * configure.ac:
+ - Added support for playing sounds when the "sound-file" hint is set or
+ when the default_sound GConf key is set, as well as support for the
+ "suppress-sound" hint. Patch by Jim Ramsay. (Ticket #111)
+
Sun Apr 29 02:38:12 PDT 2007 Christian Hammond <chipx86 at chipx86.com>
* src/themes/standard/theme.c:
Modified: trunk/notification-daemon/NEWS
===================================================================
--- trunk/notification-daemon/NEWS 2007-04-29 09:59:59 UTC (rev 2983)
+++ trunk/notification-daemon/NEWS 2007-04-29 10:44:20 UTC (rev 2984)
@@ -1,5 +1,8 @@
version 0.3.8:
* Bumped up the required minimum version of GTK+ to 2.8.0.
+ * Added support for playing sounds when the "sound-file" hint is set or
+ when the default_sound GConf key is set, as well as support for the
+ "suppress-sound" hint. Patch by Jim Ramsay. (Ticket #111)
* Fixed a bug where we were quitting on theme engine failure, instead of
falling back to the default theme engine. Patch by
driehuis-at-playbeing.org. (Ticket #128)
Modified: trunk/notification-daemon/configure.ac
===================================================================
--- trunk/notification-daemon/configure.ac 2007-04-29 09:59:59 UTC (rev 2983)
+++ trunk/notification-daemon/configure.ac 2007-04-29 10:44:20 UTC (rev 2984)
@@ -162,6 +162,34 @@
AC_SUBST(CFLAGS)
dnl ################################################################
+dnl # Sound Support
+dnl ################################################################
+
+AC_ARG_ENABLE(sound,
+ [[ --enable-sound=[auto,gstreamer,no] Sound support (default=auto)]] )
+
+if test x$enable_sound != xno -a x$enable_sound != xgstreamer; then
+ enable_sound=auto
+fi
+
+if test x$enable_sound != xno; then
+ gstreampkg="gstreamer-0.10"
+
+ if test x$enable_sound = xauto; then
+ PKG_CHECK_MODULES(GSTREAMER, $gstreampkg,
+ [enable_sound=gstreamer], [enable_sound=no])
+ else
+ PKG_CHECK_MODULES(GSTREAMER, $gstreampkg, [enable_sound=gstreamer])
+ fi
+
+ if test x$enable_sound = xgstreamer; then
+ AC_DEFINE([HAVE_GSTREAMER], 1, [Defined if Gstreamer is detected])
+ AC_SUBST(GSTREAMER_CFLAGS)
+ AC_SUBST(GSTREAMER_LIBS)
+ fi
+fi
+
+dnl ################################################################
dnl # Output the Makefiles
dnl ################################################################
AC_CONFIG_FILES([
@@ -184,6 +212,7 @@
echo prefix............... : $prefix
echo dbus-1 system.d dir.. : $DBUS_SYS_DIR
echo dbus-1 services dir.. : $DBUS_SERVICES_DIR
+echo sound support........ : $enable_sound
echo
echo "Now type make to compile"
echo "Then su to root and type: make install"
Modified: trunk/notification-daemon/data/notification-daemon.schemas.in
===================================================================
--- trunk/notification-daemon/data/notification-daemon.schemas.in 2007-04-29 09:59:59 UTC (rev 2983)
+++ trunk/notification-daemon/data/notification-daemon.schemas.in 2007-04-29 10:44:20 UTC (rev 2984)
@@ -25,5 +25,29 @@
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/notification-daemon/sound_enabled</key>
+ <applyto>/apps/notification-daemon/sound_enabled</applyto>
+ <owner>notification-daemon</owner>
+ <type>bool</type>
+ <default>1</default>
+ <locale name="C">
+ <short>Sound Enabled</short>
+ <long>Turns on and off sound support for notifications.</long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/notification-daemon/default_sound</key>
+ <applyto>/apps/notification-daemon/default_sound</applyto>
+ <owner>notification-daemon</owner>
+ <type>string</type>
+ <default></default>
+ <locale name="C">
+ <short>Default Sound</short>
+ <long>The default sound file used unless a notification supplies the 'sound-file' or 'suppress-sound' hint. Leave empty for no default sound.</long>
+ </locale>
+ </schema>
+
</schemalist>
</gconfschemafile>
Modified: trunk/notification-daemon/src/daemon/Makefile.am
===================================================================
--- trunk/notification-daemon/src/daemon/Makefile.am 2007-04-29 09:59:59 UTC (rev 2983)
+++ trunk/notification-daemon/src/daemon/Makefile.am 2007-04-29 10:44:20 UTC (rev 2984)
@@ -6,9 +6,11 @@
engines.c \
engines.h \
stack.c \
- stack.h
+ stack.h \
+ sound.c \
+ sound.h
-notification_daemon_LDADD = $(NOTIFICATION_DAEMON_LIBS)
+notification_daemon_LDADD = $(NOTIFICATION_DAEMON_LIBS) $(GSTREAMER_LIBS)
BUILT_SOURCES = notificationdaemon-dbus-glue.h
@@ -19,6 +21,7 @@
INCLUDES = \
-I$(top_srcdir) \
$(NOTIFICATION_DAEMON_CFLAGS) \
+ $(GSTREAMER_CFLAGS) \
-DENGINES_DIR=\"$(libdir)/notification-daemon-1.0/engines\"
EXTRA_DIST = notificationdaemon.xml
Modified: trunk/notification-daemon/src/daemon/daemon.c
===================================================================
--- trunk/notification-daemon/src/daemon/daemon.c 2007-04-29 09:59:59 UTC (rev 2983)
+++ trunk/notification-daemon/src/daemon/daemon.c 2007-04-29 10:44:20 UTC (rev 2984)
@@ -45,6 +45,7 @@
#include "daemon.h"
#include "engines.h"
#include "stack.h"
+#include "sound.h"
#include "notificationdaemon-dbus-glue.h"
#define IMAGE_SIZE 48
@@ -826,6 +827,8 @@
gint y = 0;
guint return_id;
gchar *sender;
+ gchar *sound_file = NULL;
+ gboolean sound_enabled;
gint i;
if (id > 0)
@@ -879,6 +882,63 @@
}
}
+ /* Deal with sound hints */
+ sound_enabled = gconf_client_get_bool(gconf_client,
+ GCONF_KEY_SOUND_ENABLED, NULL);
+ data = (GValue *)g_hash_table_lookup(hints, "suppress-sound");
+
+ if (data != NULL)
+ {
+ if (G_VALUE_HOLDS_BOOLEAN(data))
+ sound_enabled = !g_value_get_boolean(data);
+ else if (G_VALUE_HOLDS_INT(data))
+ sound_enabled = (g_value_get_int(data) != 0);
+ else
+ {
+ g_warning("suppress-sound is of type %s (expected bool or int)\n",
+ g_type_name(G_VALUE_TYPE(data)));
+ }
+ }
+
+ if (sound_enabled)
+ {
+ data = (GValue *)g_hash_table_lookup(hints, "sound-file");
+
+ if (data != NULL)
+ {
+ sound_file = g_value_dup_string(data);
+
+ if (*sound_file == '\0' ||
+ !g_file_test(sound_file, G_FILE_TEST_EXISTS))
+ {
+ g_free(sound_file);
+ sound_file = NULL;
+ }
+ }
+
+ /*
+ * TODO: If we don't have a sound_file yet, get the urgency hint, then
+ * get the corresponding system event sound
+ *
+ * We will need to parse /etc/sound/events/gnome-2.soundlist
+ * and ~/.gnome2/sound/events/gnome-2.soundlist.
+ */
+
+ /* If we don't have a sound file yet, use our gconf default */
+ if (sound_file == NULL)
+ {
+ sound_file = gconf_client_get_string(gconf_client,
+ GCONF_KEY_DEFAULT_SOUND, NULL);
+ if (sound_file != NULL &&
+ (*sound_file == '\0' ||
+ !g_file_test(sound_file, G_FILE_TEST_EXISTS)))
+ {
+ g_free(sound_file);
+ sound_file = NULL;
+ }
+ }
+ }
+
/* set up action buttons */
for (i = 0; actions[i] != NULL; i += 2)
{
@@ -987,8 +1047,12 @@
!fullscreen_window_exists(GTK_WIDGET(nw)))
{
theme_show_notification(nw);
+ if (sound_file != NULL)
+ sound_play(sound_file);
}
+ g_free(sound_file);
+
return_id = (id == 0 ? _store_notification(daemon, nw, timeout) : id);
#if CHECK_DBUS_VERSION(0, 60)
@@ -1067,6 +1131,8 @@
g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
+ sound_init();
+
gtk_init(&argc, &argv);
gconf_init(argc, argv, NULL);
Modified: trunk/notification-daemon/src/daemon/daemon.h
===================================================================
--- trunk/notification-daemon/src/daemon/daemon.h 2007-04-29 09:59:59 UTC (rev 2983)
+++ trunk/notification-daemon/src/daemon/daemon.h 2007-04-29 10:44:20 UTC (rev 2984)
@@ -32,6 +32,8 @@
#define GCONF_KEY_DAEMON "/apps/notification-daemon"
#define GCONF_KEY_THEME GCONF_KEY_DAEMON "/theme"
#define GCONF_KEY_POPUP_LOCATION GCONF_KEY_DAEMON "/popup_location"
+#define GCONF_KEY_SOUND_ENABLED GCONF_KEY_DAEMON "/sound_enabled"
+#define GCONF_KEY_DEFAULT_SOUND GCONF_KEY_DAEMON "/default_sound"
#define NOTIFY_TYPE_DAEMON (notify_daemon_get_type())
#define NOTIFY_DAEMON(obj) \
@@ -47,6 +49,12 @@
#define NOTIFY_DAEMON_DEFAULT_TIMEOUT 7000
+enum {
+ URGENCY_LOW,
+ URGENCY_NORMAL,
+ URGENCY_CRITICAL
+};
+
typedef struct _NotifyDaemon NotifyDaemon;
typedef struct _NotifyDaemonClass NotifyDaemonClass;
typedef struct _NotifyDaemonPrivate NotifyDaemonPrivate;
Added: trunk/notification-daemon/src/daemon/sound.c
===================================================================
--- trunk/notification-daemon/src/daemon/sound.c 2007-04-29 09:59:59 UTC (rev 2983)
+++ trunk/notification-daemon/src/daemon/sound.c 2007-04-29 10:44:20 UTC (rev 2984)
@@ -0,0 +1,80 @@
+/*
+ * sound.c - Sound support portion of the destop notification spec
+ *
+ * Copyright (C) 2007 Jim Ramsay <i.am at jimramsay.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+#include "config.h"
+
+#include "sound.h"
+
+#ifdef HAVE_GSTREAMER
+#include <gst/gst.h>
+
+static GstElement *player;
+
+static void
+sound_play_uri(const gchar* uri)
+{
+ /*
+ * TODO: Fade out the current sound and then start the new sound?
+ * Right now we just cut off the existing sound, which is kind of
+ * abrupt
+ */
+
+ /* Stop the pipeline */
+ gst_element_set_state(player, GST_STATE_NULL);
+
+ /* Set the input to a local file uri */
+ g_object_set(G_OBJECT(player), "uri", uri, NULL);
+
+ /* Start the pipeline again */
+ gst_element_set_state(player, GST_STATE_PLAYING);
+}
+#endif /* HAVE_GSTREAMER */
+
+void
+sound_init(void)
+{
+#ifdef HAVE_GSTREAMER
+ gst_init(NULL, NULL);
+
+ player = gst_element_factory_make("playbin", "Notification Player");
+
+ /*
+ * Instead of using the default audiosink, use the gconfaudiosink,
+ * which will respect the defaults in gstreamer-properties
+ */
+ g_object_set(G_OBJECT(player), "audio-sink",
+ gst_element_factory_make("gconfaudiosink", "GconfAudioSink"),
+ NULL);
+
+#endif /* HAVE_GSTREAMER */
+}
+
+void
+sound_play(const gchar* filename)
+{
+ /* We are guaranteed here that the file exists */
+#ifdef HAVE_GSTREAMER
+ /* gstreamer's playbin takes uris, so make a file:// uri */
+ gchar* uri = g_strdup_printf("file://%s", filename);
+ sound_play_uri(uri);
+ g_free(uri);
+#endif /* HAVE_GSTREAMER */
+}
+
Added: trunk/notification-daemon/src/daemon/sound.h
===================================================================
--- trunk/notification-daemon/src/daemon/sound.h 2007-04-29 09:59:59 UTC (rev 2983)
+++ trunk/notification-daemon/src/daemon/sound.h 2007-04-29 10:44:20 UTC (rev 2984)
@@ -0,0 +1,30 @@
+/*
+ * sound.h - Sound support portion of the destop notification spec
+ *
+ * Copyright (C) 2007 Jim Ramsay <i.am at jimramsay.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+#ifndef _SOUND_H
+#define _SOUND_H
+
+#include <glib.h>
+
+void sound_init(void);
+
+void sound_play(const gchar *filename);
+
+#endif /* _SOUND_H */
More information about the galago-commits
mailing list