Author: jannis
Date: 2008-06-21 12:57:24 +0000 (Sat, 21 Jun 2008)
New Revision: 27106
Modified:
xfce4-mixer/trunk/ChangeLog
xfce4-mixer/trunk/TODO
xfce4-mixer/trunk/panel-plugin/xfce-mixer-plugin.c
xfce4-mixer/trunk/panel-plugin/xfce-volume-button.c
xfce4-mixer/trunk/panel-plugin/xfce-volume-button.h
Log:
* panel-plugin/xfce-volume-button.{c,h}: Add "mute-toggled"
signal for when the middle mouse button is clicked. Add
xfce_volume_button_set_muted() method for manually changing
the mute state of the button (does not affect the actual sound
settings).
* panel-plugin/xfce-mixer-plugin.c: Handle
GST_MESSAGE_MUTE_TOGGLED messages by setting the muted state
of the plugin button.
Modified: xfce4-mixer/trunk/ChangeLog
===================================================================
--- xfce4-mixer/trunk/ChangeLog 2008-06-21 12:38:04 UTC (rev 27105)
+++ xfce4-mixer/trunk/ChangeLog 2008-06-21 12:57:24 UTC (rev 27106)
@@ -1,5 +1,16 @@
2008-06-21 Jannis Pohlmann <[EMAIL PROTECTED]>
+ * panel-plugin/xfce-volume-button.{c,h}: Add "mute-toggled"
+ signal for when the middle mouse button is clicked. Add
+ xfce_volume_button_set_muted() method for manually changing
+ the mute state of the button (does not affect the actual sound
+ settings).
+ * panel-plugin/xfce-mixer-plugin.c: Handle
+ GST_MESSAGE_MUTE_TOGGLED messages by setting the muted state
+ of the plugin button.
+
+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
Modified: xfce4-mixer/trunk/TODO
===================================================================
--- xfce4-mixer/trunk/TODO 2008-06-21 12:38:04 UTC (rev 27105)
+++ xfce4-mixer/trunk/TODO 2008-06-21 12:57:24 UTC (rev 27106)
@@ -3,8 +3,5 @@
2) Extend xfce_mixer_bus_message() to handle all types of messages
by updating the corresponding mixer widgets
-* Write panel plugin
- 1) Monitor GStreamer for changes
-
* Allow changing controls from the console, probably via something like:
--change-control=SOUNDCARD NAME:TRACK NAME:NEW VALUE
Modified: xfce4-mixer/trunk/panel-plugin/xfce-mixer-plugin.c
===================================================================
--- xfce4-mixer/trunk/panel-plugin/xfce-mixer-plugin.c 2008-06-21 12:38:04 UTC
(rev 27105)
+++ xfce4-mixer/trunk/panel-plugin/xfce-mixer-plugin.c 2008-06-21 12:57:24 UTC
(rev 27106)
@@ -69,6 +69,8 @@
gint
size);
static void xfce_mixer_plugin_volume_changed (XfceMixerPlugin
*mixer_plugin,
gdouble
volume);
+static void xfce_mixer_plugin_mute_toggled (XfceMixerPlugin
*mixer_plugin,
+ gboolean
mute);
static void xfce_mixer_plugin_configure (XfceMixerPlugin
*mixer_plugin);
static void xfce_mixer_plugin_clicked (XfceMixerPlugin
*mixer_plugin);
static void xfce_mixer_plugin_read_config (XfceMixerPlugin
*mixer_plugin);
@@ -113,6 +115,7 @@
mixer_plugin->button = xfce_volume_button_new ();
xfce_panel_plugin_add_action_widget (plugin, mixer_plugin->button);
g_signal_connect_swapped (G_OBJECT (mixer_plugin->button), "volume-changed",
G_CALLBACK (xfce_mixer_plugin_volume_changed), mixer_plugin);
+ g_signal_connect_swapped (G_OBJECT (mixer_plugin->button), "mute-toggled",
G_CALLBACK (xfce_mixer_plugin_mute_toggled), mixer_plugin);
g_signal_connect_swapped (G_OBJECT (mixer_plugin->button), "clicked",
G_CALLBACK (xfce_mixer_plugin_clicked), mixer_plugin);
gtk_container_add (GTK_CONTAINER (mixer_plugin->hvbox),
mixer_plugin->button);
gtk_widget_show (mixer_plugin->button);
@@ -224,6 +227,19 @@
static void
+xfce_mixer_plugin_mute_toggled (XfceMixerPlugin *mixer_plugin,
+ gboolean mute)
+{
+ g_return_if_fail (mixer_plugin != NULL);
+ g_return_if_fail (IS_XFCE_MIXER_CARD (mixer_plugin->card));
+ g_return_if_fail (GST_IS_MIXER_TRACK (mixer_plugin->track));
+
+ xfce_mixer_card_set_track_muted (mixer_plugin->card, mixer_plugin->track,
mute);
+}
+
+
+
+static void
xfce_mixer_plugin_clicked (XfceMixerPlugin *mixer_plugin)
{
g_return_if_fail (mixer_plugin != NULL);
@@ -411,21 +427,30 @@
gdouble volume;
gint *volumes;
gint num_channels;
+ gboolean mute;
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))
+ switch (gst_mixer_message_get_type (message))
{
- gst_mixer_message_parse_volume_changed (message, &track, &volumes,
&num_channels);
+ case 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);
- }
+ 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);
+ }
+ break;
+ case GST_MIXER_MESSAGE_MUTE_TOGGLED:
+ gst_mixer_message_parse_mute_toggled (message, &track, &mute);
+
+ if (G_UNLIKELY (g_utf8_collate (track->label,
mixer_plugin->track->label) == 0))
+ xfce_volume_button_set_muted (XFCE_VOLUME_BUTTON
(mixer_plugin->button), mute);
+ break;
}
}
#endif
Modified: xfce4-mixer/trunk/panel-plugin/xfce-volume-button.c
===================================================================
--- xfce4-mixer/trunk/panel-plugin/xfce-volume-button.c 2008-06-21 12:38:04 UTC
(rev 27105)
+++ xfce4-mixer/trunk/panel-plugin/xfce-volume-button.c 2008-06-21 12:57:24 UTC
(rev 27106)
@@ -36,6 +36,7 @@
enum
{
VOLUME_CHANGED,
+ MUTE_TOGGLED,
LAST_SIGNAL,
};
@@ -74,6 +75,8 @@
XfceVolumeButton
*button);
static void xfce_volume_button_volume_changed (XfceVolumeButton
*button,
gdouble
volume);
+static void xfce_volume_button_mute_toggled (XfceVolumeButton
*button,
+ gboolean
mute);
@@ -84,6 +87,9 @@
/* Signals */
void (*volume_changed) (XfceVolumeButton *button,
gdouble volume);
+
+ void (*mute_toggled) (XfceVolumeButton *button,
+ gboolean mute);
};
struct _XfceVolumeButton
@@ -94,9 +100,9 @@
GtkObject *adjustment;
- gdouble previous_value;
+ gint icon_size;
- gint icon_size;
+ gboolean is_muted;
};
@@ -147,6 +153,7 @@
gobject_class->finalize = xfce_volume_button_finalize;
klass->volume_changed = xfce_volume_button_volume_changed;
+ klass->mute_toggled = xfce_volume_button_mute_toggled;
button_signals[VOLUME_CHANGED] = g_signal_new ("volume-changed",
G_TYPE_FROM_CLASS (klass),
@@ -158,6 +165,17 @@
G_TYPE_NONE,
1,
G_TYPE_DOUBLE);
+
+ button_signals[MUTE_TOGGLED] = g_signal_new ("mute-toggled",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST |
G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET
(XfceVolumeButtonClass, mute_toggled),
+ NULL,
+ NULL,
+
g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_BOOLEAN);
}
@@ -165,6 +183,8 @@
static void
xfce_volume_button_init (XfceVolumeButton *button)
{
+ button->is_muted = FALSE;
+
button->adjustment = gtk_adjustment_new (0.0, 0.0, 1.0, 0.05, 0.05, 0.2);
button->image = xfce_scaled_image_new ();
@@ -252,8 +272,6 @@
break;
}
- button->previous_value = value;
-
xfce_volume_button_update (button);
g_signal_emit_by_name (button, "volume-changed", gtk_adjustment_get_value
(GTK_ADJUSTMENT (button->adjustment)));
@@ -266,35 +284,21 @@
GdkEventButton *event,
XfceVolumeButton *button)
{
- gboolean handled = FALSE;
- gdouble value;
- gdouble min_value;
-
+ gboolean mute;
g_return_if_fail (IS_XFCE_VOLUME_BUTTON (button));
- g_object_get (G_OBJECT (button->adjustment), "value", &value, "lower",
&min_value, NULL);
-
if (event->button == 2)
{
- if (gtk_adjustment_get_value (GTK_ADJUSTMENT (button->adjustment)) ==
min_value)
- {
- gtk_adjustment_set_value (GTK_ADJUSTMENT (button->adjustment),
button->previous_value);
- button->previous_value = value;
- }
- else
- {
- gtk_adjustment_set_value (GTK_ADJUSTMENT (button->adjustment),
min_value);
- button->previous_value = value;
- }
+ mute = !button->is_muted;
- handled = TRUE;
- }
+ xfce_volume_button_set_muted (button, mute);
- xfce_volume_button_update (button);
+ g_signal_emit_by_name (button, "mute-toggled", mute);
- g_signal_emit_by_name (button, "volume-changed", gtk_adjustment_get_value
(GTK_ADJUSTMENT (button->adjustment)));
+ return TRUE;
+ }
- return handled;
+ return FALSE;
}
@@ -382,7 +386,7 @@
range = (upper - lower) / (G_N_ELEMENTS (icons) - 2);
- if (value == 0)
+ if (G_UNLIKELY (value == 0 || button->is_muted))
pixbuf = xfce_themed_icon_load (icons[0], button->icon_size);
else
{
@@ -411,6 +415,17 @@
+void
+xfce_volume_button_set_muted (XfceVolumeButton *button,
+ gboolean muted)
+{
+ g_return_if_fail (IS_XFCE_VOLUME_BUTTON (button));
+ button->is_muted = muted;
+ xfce_volume_button_update (button);
+}
+
+
+
void
xfce_volume_button_set_volume (XfceVolumeButton *button,
gdouble volume)
@@ -429,3 +444,11 @@
g_return_if_fail (size >= 0);
button->icon_size = size;
}
+
+
+
+static void
+xfce_volume_button_mute_toggled (XfceVolumeButton *button,
+ gboolean mute)
+{
+}
Modified: xfce4-mixer/trunk/panel-plugin/xfce-volume-button.h
===================================================================
--- xfce4-mixer/trunk/panel-plugin/xfce-volume-button.h 2008-06-21 12:38:04 UTC
(rev 27105)
+++ xfce4-mixer/trunk/panel-plugin/xfce-volume-button.h 2008-06-21 12:57:24 UTC
(rev 27106)
@@ -39,6 +39,8 @@
GtkWidget *xfce_volume_button_new (void);
+void xfce_volume_button_set_muted (XfceVolumeButton *button,
+ gboolean muted);
void xfce_volume_button_set_volume (XfceVolumeButton *button,
gdouble volume);
void xfce_volume_button_update (XfceVolumeButton *button);
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits