[Xfce4-commits] [panel-plugins/xfce4-pulseaudio-plugin] 03/12: Added support for muting output devices

noreply at xfce.org noreply at xfce.org
Tue Feb 17 00:12:42 CET 2015


This is an automated email from the git hooks/post-receive script.

andrzejr pushed a commit to branch master
in repository panel-plugins/xfce4-pulseaudio-plugin.

commit 5a6bb479f0a61bee2a0f147dcb1e66c98bf2976e
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Sat Apr 26 16:36:48 2014 +0100

    Added support for muting output devices
---
 panel-plugin/pulseaudio-button.c |    2 +-
 panel-plugin/pulseaudio-volume.c |   67 ++++++++++++++++++++++++++++++++++----
 panel-plugin/pulseaudio-volume.h |    6 +++-
 3 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/panel-plugin/pulseaudio-button.c b/panel-plugin/pulseaudio-button.c
index b61f38f..d145ea3 100644
--- a/panel-plugin/pulseaudio-button.c
+++ b/panel-plugin/pulseaudio-button.c
@@ -211,7 +211,7 @@ pulseaudio_button_button_release (GtkWidget      *widget,
 
   if (event->button == 2) /* middle button */
     {
-      // toggle mute
+      pulseaudio_volume_toggle_muted (button->volume);
       return TRUE;
     }
 
diff --git a/panel-plugin/pulseaudio-volume.c b/panel-plugin/pulseaudio-volume.c
index dba4f73..797582f 100644
--- a/panel-plugin/pulseaudio-volume.c
+++ b/panel-plugin/pulseaudio-volume.c
@@ -91,8 +91,8 @@ pulseaudio_volume_class_init (PulseaudioVolumeClass *klass)
                   G_TYPE_FROM_CLASS (gobject_class),
                   G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
-                  g_cclosure_marshal_VOID__DOUBLE,
-                  G_TYPE_NONE, 1, G_TYPE_DOUBLE);
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
 
 }
 
@@ -143,14 +143,14 @@ pulseaudio_volume_sink_info_cb (pa_context         *context,
   if (volume->muted != muted)
     {
       volume->muted = muted;
-      g_signal_emit (G_OBJECT (volume), pulseaudio_volume_signals [VOLUME_CHANGED], 0, volume->volume);
+      g_signal_emit (G_OBJECT (volume), pulseaudio_volume_signals [VOLUME_CHANGED], 0);
       //g_debug ("Muted: %d", muted);
     }
 
   if (volume->volume != vol)
     {
       volume->volume = vol;
-      g_signal_emit (G_OBJECT (volume), pulseaudio_volume_signals [VOLUME_CHANGED], 0, volume->volume);
+      g_signal_emit (G_OBJECT (volume), pulseaudio_volume_signals [VOLUME_CHANGED], 0);
       //g_debug ("Volume: %f", vol);
     }
 }
@@ -305,13 +305,68 @@ pulseaudio_volume_d2v (gdouble vol)
 gboolean
 pulseaudio_volume_get_muted (PulseaudioVolume *volume)
 {
-  g_return_val_if_fail (IS_PULSEAUDIO_VOLUME (volume), 0.0);
+  g_return_val_if_fail (IS_PULSEAUDIO_VOLUME (volume), FALSE);
 
   return volume->muted;
 }
 
 
 
+/* muted setting callbacks */
+/* pa_context_success_cb_t */
+static void
+pulseaudio_volume_set_muted_cb2 (pa_context *context,
+                                 int         success,
+                                 void       *userdata)
+{
+  PulseaudioVolume *volume = PULSEAUDIO_VOLUME (userdata);
+
+  if (success)
+    g_signal_emit (G_OBJECT (volume), pulseaudio_volume_signals [VOLUME_CHANGED], 0);
+}
+
+/* pa_sink_info_cb_t */
+static void
+pulseaudio_volume_set_muted_cb1 (pa_context         *context,
+                                 const pa_sink_info *i,
+                                 int                 eol,
+                                 void               *userdata)
+{
+  PulseaudioVolume *volume = PULSEAUDIO_VOLUME (userdata);
+  if (i == NULL) return;
+
+  pa_context_set_sink_mute_by_index (context, i->index, volume->muted, pulseaudio_volume_set_muted_cb2, volume);
+}
+
+
+
+void
+pulseaudio_volume_set_muted (PulseaudioVolume *volume,
+                             gboolean          muted)
+{
+  g_return_if_fail (IS_PULSEAUDIO_VOLUME (volume));
+  g_return_if_fail (pa_context_get_state (volume->pa_context) == PA_CONTEXT_READY);
+
+  if (volume->muted != muted)
+    {
+      volume->muted = muted;
+      pa_context_get_sink_info_list (volume->pa_context, pulseaudio_volume_set_muted_cb1, volume);
+    }
+}
+
+
+
+void
+pulseaudio_volume_toggle_muted (PulseaudioVolume *volume)
+{
+  g_return_if_fail (IS_PULSEAUDIO_VOLUME (volume));
+
+  pulseaudio_volume_set_muted (volume, !volume->muted);
+}
+
+
+
+
 gdouble
 pulseaudio_volume_get_volume (PulseaudioVolume *volume)
 {
@@ -332,7 +387,7 @@ pulseaudio_volume_set_volume_cb3 (pa_context *context,
   PulseaudioVolume *volume = PULSEAUDIO_VOLUME (userdata);
 
   if (success)
-    g_signal_emit (G_OBJECT (volume), pulseaudio_volume_signals [VOLUME_CHANGED], 0, volume->volume);
+    g_signal_emit (G_OBJECT (volume), pulseaudio_volume_signals [VOLUME_CHANGED], 0);
 }
 
 /* pa_sink_info_cb_t */
diff --git a/panel-plugin/pulseaudio-volume.h b/panel-plugin/pulseaudio-volume.h
index b240cd4..666c03a 100644
--- a/panel-plugin/pulseaudio-volume.h
+++ b/panel-plugin/pulseaudio-volume.h
@@ -37,9 +37,13 @@ GType                   pulseaudio_volume_get_type        (void) G_GNUC_CONST;
 PulseaudioVolume       *pulseaudio_volume_new             ();
 
 gdouble                 pulseaudio_volume_get_volume      (PulseaudioVolume *volume);
-void                    pulseaudio_volume_set_volume      (PulseaudioVolume *volume, gdouble vol);
+void                    pulseaudio_volume_set_volume      (PulseaudioVolume *volume,
+                                                           gdouble           vol);
 
 gboolean                pulseaudio_volume_get_muted       (PulseaudioVolume *volume);
+void                    pulseaudio_volume_set_muted       (PulseaudioVolume *volume,
+                                                           gboolean          muted);
+void                    pulseaudio_volume_toggle_muted    (PulseaudioVolume *volume);
 
 G_END_DECLS
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list