Author: jannis
Date: 2008-06-21 12:38:04 +0000 (Sat, 21 Jun 2008)
New Revision: 27105
Modified:
xfce4-mixer/trunk/ChangeLog
xfce4-mixer/trunk/panel-plugin/xfce-mixer-plugin.c
xfce4-mixer/trunk/xfce4-mixer/xfce-mixer.c
Log:
* panel-plugin/xfce-mixer-plugin.c: Add support for
xfce_mixer_card_connect() so that the volume button is updated
whenever the volume of the current mixer track is changed by
another program.
* panel-plugin/xfce-mixer.c: Parse GST_MESSAGE_VOLUME_CHANGED
messages, but don't handle them yet. In the mixer it's much more
complicated than in the plugin, gonna do that later.
Modified: xfce4-mixer/trunk/ChangeLog
===================================================================
--- xfce4-mixer/trunk/ChangeLog 2008-06-21 12:31:48 UTC (rev 27104)
+++ xfce4-mixer/trunk/ChangeLog 2008-06-21 12:38:04 UTC (rev 27105)
@@ -1,5 +1,15 @@
2008-06-21 Jannis Pohlmann <[EMAIL PROTECTED]>
+ * panel-plugin/xfce-mixer-plugin.c: Add support for
+ xfce_mixer_card_connect() so that the volume button is updated
+ whenever the volume of the current mixer track is changed by
+ another program.
+ * panel-plugin/xfce-mixer.c: Parse GST_MESSAGE_VOLUME_CHANGED
+ messages, but don't handle them yet. In the mixer it's much more
+ complicated than in the plugin, gonna do that later.
+
+2008-06-21 Jannis Pohlmann <[EMAIL PROTECTED]>
+
* icons/: Add volume level icons (1x muted, 5x different sound
wave icons). I'm not exactly satisfied, but it's better than
before.
Modified: xfce4-mixer/trunk/panel-plugin/xfce-mixer-plugin.c
===================================================================
--- xfce4-mixer/trunk/panel-plugin/xfce-mixer-plugin.c 2008-06-21 12:31:48 UTC
(rev 27104)
+++ xfce4-mixer/trunk/panel-plugin/xfce-mixer-plugin.c 2008-06-21 12:38:04 UTC
(rev 27105)
@@ -77,6 +77,11 @@
static void xfce_mixer_plugin_replace_values (XfceMixerPlugin
*mixer_plugin,
const gchar
*card_name,
const gchar
*track_name);
+#ifdef HAVE_GST_MIXER_NOTIFICATION
+static gboolean xfce_mixer_plugin_bus_message (GstBus
*bus,
+ GstMessage
*message,
+ XfceMixerPlugin
*mixer_plugin);
+#endif
@@ -359,6 +364,10 @@
g_object_unref (G_OBJECT (mixer_plugin->track));
mixer_plugin->card = XFCE_MIXER_CARD (xfce_mixer_utilities_get_card_by_name
(mixer_plugin->card_name));
+#ifdef HAVE_GST_MIXER_NOTIFICATION
+ xfce_mixer_card_connect (mixer_plugin->card, G_CALLBACK
(xfce_mixer_plugin_bus_message), mixer_plugin);
+#endif
+
mixer_plugin->track = xfce_mixer_card_get_track_by_name (mixer_plugin->card,
mixer_plugin->track_name);
volumes = g_new (gint, mixer_plugin->track->num_channels);
@@ -389,3 +398,34 @@
mixer_plugin->card_name = g_strdup (card_name);
mixer_plugin->track_name = g_strdup (track_name);
}
+
+
+
+#ifdef HAVE_GST_MIXER_NOTIFICATION
+static gboolean
+xfce_mixer_plugin_bus_message (GstBus *bus,
+ GstMessage *message,
+ XfceMixerPlugin *mixer_plugin)
+{
+ GstMixerTrack *track = NULL;
+ gdouble volume;
+ gint *volumes;
+ gint num_channels;
+
+ if (G_UNLIKELY (!xfce_mixer_card_get_message_owner (mixer_plugin->card,
message)))
+ return TRUE;
+
+ g_debug ("Message from card received: %s", GST_MESSAGE_TYPE_NAME (message));
+
+ if (G_LIKELY (gst_mixer_message_get_type (message) ==
GST_MIXER_MESSAGE_VOLUME_CHANGED))
+ {
+ gst_mixer_message_parse_volume_changed (message, &track, &volumes,
&num_channels);
+
+ if (G_UNLIKELY (g_utf8_collate (track->label,
mixer_plugin->track->label) == 0))
+ {
+ volume = ((gdouble) volumes[0]) / mixer_plugin->track->max_volume;
+ xfce_volume_button_set_volume (XFCE_VOLUME_BUTTON
(mixer_plugin->button), volume);
+ }
+ }
+}
+#endif
Modified: xfce4-mixer/trunk/xfce4-mixer/xfce-mixer.c
===================================================================
--- xfce4-mixer/trunk/xfce4-mixer/xfce-mixer.c 2008-06-21 12:31:48 UTC (rev
27104)
+++ xfce4-mixer/trunk/xfce4-mixer/xfce-mixer.c 2008-06-21 12:38:04 UTC (rev
27105)
@@ -321,6 +321,8 @@
gboolean muted;
gboolean record;
const gchar *option;
+ gint *volumes;
+ gint num_channels;
if (G_UNLIKELY (!xfce_mixer_card_get_message_owner (mixer->card, message)))
return TRUE;
@@ -341,6 +343,8 @@
}
else if (type == GST_MIXER_MESSAGE_VOLUME_CHANGED)
{
+ gst_mixer_message_parse_volume_changed (message, &track, &volumes,
&num_channels);
+ g_debug ("Volume on track '%s' changed to %i", track->label, volumes[0]);
}
else if (type == GST_MIXER_MESSAGE_OPTION_CHANGED)
{
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits