afa315f
diff -up gnome-applets-2.19.1/mixer/applet.c.wakeups gnome-applets-2.19.1/mixer/applet.c
afa315f
--- gnome-applets-2.19.1/mixer/applet.c.wakeups	2007-08-12 23:00:22.000000000 -0400
afa315f
+++ gnome-applets-2.19.1/mixer/applet.c	2007-08-12 23:00:29.000000000 -0400
afa315f
@@ -80,6 +80,11 @@ static void	gnome_volume_applet_orientat
afa315f
 
afa315f
 static void	gnome_volume_applet_refresh	(GnomeVolumeApplet *applet,
afa315f
 						 gboolean           force_refresh);
afa315f
+
afa315f
+#ifdef HAVE_GST_MIXER_NOTIFIES
afa315f
+static void     cb_notify_message (GstBus *bus, GstMessage *message, gpointer data);
afa315f
+#endif
afa315f
+
afa315f
 static gboolean	cb_check			(gpointer   data);
afa315f
 
afa315f
 static void	cb_volume			(GtkAdjustment *adj,
afa315f
@@ -242,6 +247,14 @@ gnome_volume_applet_init (GnomeVolumeApp
afa315f
   /* i18n */
afa315f
   ao = gtk_widget_get_accessible (GTK_WIDGET (applet));
afa315f
   atk_object_set_name (ao, _("Volume Control"));
afa315f
+
afa315f
+  /* Bus for notifications */
afa315f
+#ifdef HAVE_GST_MIXER_NOTIFIES
afa315f
+  applet->bus = gst_bus_new ();
afa315f
+  gst_bus_add_signal_watch (applet->bus);
afa315f
+  g_signal_connect (G_OBJECT (applet->bus), "message::element", 
afa315f
+       (GCallback) cb_notify_message, applet);
afa315f
+#endif
afa315f
 }
afa315f
 
afa315f
 /* Parse the list of tracks that are stored in GConf */
afa315f
@@ -368,12 +381,37 @@ select_element_and_track (GnomeVolumeApp
afa315f
     return FALSE;
afa315f
 
afa315f
   applet->mixer = g_object_ref (active_element);
afa315f
+#ifdef HAVE_GST_MIXER_NOTIFIES
afa315f
+  gst_element_set_bus (GST_ELEMENT (applet->mixer), applet->bus);
afa315f
+#endif
afa315f
   applet->tracks = active_tracks;
afa315f
   g_list_foreach (applet->tracks, (GFunc) g_object_ref, NULL);
afa315f
 
afa315f
   return TRUE;
afa315f
 }
afa315f
 
afa315f
+static void
afa315f
+gnome_volume_applet_setup_timeout (GnomeVolumeApplet *applet)
afa315f
+{
afa315f
+  gboolean need_timeout = TRUE;
afa315f
+#ifdef HAVE_GST_MIXER_NOTIFIES
afa315f
+  need_timeout = ((gst_mixer_get_mixer_flags (GST_MIXER (applet->mixer)) &
afa315f
+      GST_MIXER_FLAG_AUTO_NOTIFICATIONS) == 0);
afa315f
+#endif
afa315f
+
afa315f
+  if (need_timeout) {
afa315f
+    if (applet->timeout == 0) {
afa315f
+      applet->timeout = g_timeout_add (100, cb_check, applet);
afa315f
+    }
afa315f
+  }
afa315f
+  else {
afa315f
+    if (applet->timeout != 0) {
afa315f
+      g_source_remove (applet->timeout);
afa315f
+      applet->timeout = 0;
afa315f
+    }
afa315f
+  }
afa315f
+}
afa315f
+
afa315f
 gboolean
afa315f
 gnome_volume_applet_setup (GnomeVolumeApplet *applet,
afa315f
 			   GList *elements)
afa315f
@@ -436,9 +474,8 @@ gnome_volume_applet_setup (GnomeVolumeAp
afa315f
   g_signal_connect (component, "ui-event", G_CALLBACK (cb_ui_event), applet);
afa315f
 
afa315f
   gnome_volume_applet_refresh (applet, TRUE);
afa315f
-  if (res) {
afa315f
-    applet->timeout = g_timeout_add (100, cb_check, applet);
afa315f
-  }
afa315f
+  if (res)
afa315f
+    gnome_volume_applet_setup_timeout (applet);
afa315f
 
afa315f
   if (res) {
afa315f
     /* gconf */
afa315f
@@ -479,6 +516,13 @@ gnome_volume_applet_dispose (GObject *ob
afa315f
     g_list_free (applet->elements);
afa315f
     applet->elements = NULL;
afa315f
   }
afa315f
+#ifdef HAVE_GST_MIXER_NOTIFIES
afa315f
+  gst_bus_remove_signal_watch (applet->bus);
afa315f
+  if (applet->bus) {
afa315f
+    gst_object_unref (applet->bus);
afa315f
+    applet->bus = NULL;
afa315f
+  }
afa315f
+#endif
afa315f
 
afa315f
   if (applet->tracks) {
afa315f
     g_list_foreach (applet->tracks, (GFunc) g_object_unref, NULL);
afa315f
@@ -1152,6 +1196,38 @@ gnome_volume_applet_refresh (GnomeVolume
afa315f
 				"state", mute ? "1" : "0", NULL);
afa315f
 }
afa315f
 
afa315f
+#ifdef HAVE_GST_MIXER_NOTIFIES
afa315f
+static void
afa315f
+cb_notify_message (GstBus *bus, GstMessage *message, gpointer data)
afa315f
+{
afa315f
+  GnomeVolumeApplet *applet = GNOME_VOLUME_APPLET (data);
afa315f
+  GstMixerMessageType type;
afa315f
+  GstMixerTrack *first_track;
afa315f
+  GstMixerTrack *track = NULL;
afa315f
+
afa315f
+  if (applet->tracks == NULL || 
afa315f
+      GST_MESSAGE_SRC (message) != GST_OBJECT (applet->mixer)) {
afa315f
+    /* No tracks, or not from our mixer - can't update anything anyway */
afa315f
+    return; 
afa315f
+  }
afa315f
+
afa315f
+  first_track = g_list_first (applet->tracks)->data;
afa315f
+
afa315f
+  /* This code only calls refresh if the first_track changes, because the
afa315f
+   * refresh code only retrieves the current value from that track anyway */
afa315f
+  type = gst_mixer_message_get_type (message);
afa315f
+  if (type == GST_MIXER_MESSAGE_MUTE_TOGGLED) {
afa315f
+    gst_mixer_message_parse_mute_toggled (message, &track, NULL);
afa315f
+  }
afa315f
+  else { 
afa315f
+    gst_mixer_message_parse_volume_changed (message, &track, NULL, NULL);
afa315f
+  }
afa315f
+
afa315f
+  if (first_track == track)
afa315f
+    gnome_volume_applet_refresh (GNOME_VOLUME_APPLET (data), FALSE);
afa315f
+}
afa315f
+#endif
afa315f
+
afa315f
 static gboolean
afa315f
 cb_check (gpointer data)
afa315f
 {
afa315f
@@ -1214,6 +1290,8 @@ cb_gconf (GConfClient *client,
afa315f
             /* save */
afa315f
             gst_object_replace ((GstObject **) &applet->mixer, item->data);
afa315f
             gst_element_set_state (old_element, GST_STATE_NULL);
afa315f
+
afa315f
+            gnome_volume_applet_setup_timeout (applet);
afa315f
             newdevice = TRUE;
afa315f
           }
afa315f
           break;
afa315f
diff -up gnome-applets-2.19.1/mixer/applet.h.wakeups gnome-applets-2.19.1/mixer/applet.h
afa315f
--- gnome-applets-2.19.1/mixer/applet.h.wakeups	2007-08-12 23:00:17.000000000 -0400
afa315f
+++ gnome-applets-2.19.1/mixer/applet.h	2007-08-12 23:00:29.000000000 -0400
afa315f
@@ -71,6 +71,7 @@ typedef struct _GnomeVolumeApplet {
afa315f
 
afa315f
   /* element */
afa315f
   GstMixer *mixer;
afa315f
+  GstBus *bus;
afa315f
   gboolean lock;
afa315f
   gint state;
afa315f
   GList *tracks;
afa315f
diff -up gnome-applets-2.19.1/configure.in.wakeups gnome-applets-2.19.1/configure.in
afa315f
--- gnome-applets-2.19.1/configure.in.wakeups	2007-08-12 23:03:29.000000000 -0400
afa315f
+++ gnome-applets-2.19.1/configure.in	2007-08-12 23:03:55.000000000 -0400
afa315f
@@ -479,11 +479,22 @@ esac
afa315f
 
afa315f
 AM_CONDITIONAL(APPLET_MIXER, test "x$HAVE_GST" = "xyes")
afa315f
 AM_CONDITIONAL(HAVE_GST10, test "x$HAVE_GST_VER" = "x0.10")
afa315f
+
afa315f
+HAVE_GST_MIXER_NOTIFIES=no
afa315f
 if test "x$HAVE_GST_VER" = "x0.10" ; then
afa315f
 	AC_DEFINE(HAVE_GST10, 1, [Using Gstreamer 0.10])
afa315f
 	# these don't seem to come from any pkg-config file
afa315f
 	MIXER_LIBS="$MIXER_LIBS -lgstinterfaces-0.10 -lgstaudio-0.10"
afa315f
+
afa315f
+        PKG_CHECK_MODULES(GST_MIXER_NOTIFICATIONS,
afa315f
+            gstreamer-plugins-base-0.10 >= 0.10.13.1, 
afa315f
+            HAVE_GST_MIXER_NOTIFIES=yes, HAVE_GST_MIXER_NOTIFIES=no)
afa315f
+        if test "x$HAVE_GST_MIXER_NOTIFIES" = "xyes"; then
afa315f
+          AC_DEFINE(HAVE_GST_MIXER_NOTIFIES, 1, 
afa315f
+              [Have GStreamer mixer notification API])
afa315f
+        fi
afa315f
 fi
afa315f
+AM_CONDITIONAL(HAVE_GST_MIXER_NOTIFIES, test "x$HAVE_GST_MIXER_NOTIFIES" = "xyes")
afa315f
 
afa315f
 AC_SUBST(MIXER_CFLAGS)
afa315f
 AC_SUBST(MIXER_LIBS)
afa315f
@@ -766,6 +777,7 @@ gnome-applets-$VERSION configure summary
afa315f
 	 - invest-applet		$BUILD_INVEST_APPLET
afa315f
 	 - mini-commander		$enable_mini_commander
afa315f
 	 - mixer			$HAVE_GST
afa315f
+	        - mixer	notifications	$HAVE_GST_MIXER_NOTIFIES
afa315f
 	 - modemlights			$BUILD_MODEM_LIGHTS
afa315f
 	 - multiload			$build_gtop_applets
afa315f
 	 - stickynotes			$enable_stickynotes