[gnome-control-center/wip/laney/sound-volume-slider-set-mixer: 8/8] sound: Pass a GvcMixerControl to the stream volume sliders
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/laney/sound-volume-slider-set-mixer: 8/8] sound: Pass a GvcMixerControl to the stream volume sliders
- Date: Mon, 9 Sep 2019 15:23:50 +0000 (UTC)
commit ad39840066ac35b7d1f556cd65662e341388505a
Author: Iain Lane <iainl gnome org>
Date: Mon Sep 2 15:38:10 2019 +0100
sound: Pass a GvcMixerControl to the stream volume sliders
Since 9d612ff1c7e2d58211e25e8584bc86c5d2598eac this is required,
otherwise we never set up the GtkAdjustment and so the scales don't
display any values or widget to make adjustments, meaning they can't be
used.
Also call `notify_volume_cb()` from `update_ranges()` to initialise the
adjustment, since when we set the mixer control we now might not have
set the value.
Closes #652
panels/sound/cc-stream-list-box.c | 2 +-
panels/sound/cc-stream-row.c | 10 ++++---
panels/sound/cc-stream-row.h | 10 ++++---
panels/sound/cc-volume-slider.c | 61 ++++++++++++++++++++-------------------
4 files changed, 45 insertions(+), 38 deletions(-)
---
diff --git a/panels/sound/cc-stream-list-box.c b/panels/sound/cc-stream-list-box.c
index fcc249a25..ca914ef94 100644
--- a/panels/sound/cc-stream-list-box.c
+++ b/panels/sound/cc-stream-list-box.c
@@ -99,7 +99,7 @@ stream_added_cb (CcStreamListBox *self,
return;
}
- row = cc_stream_row_new (self->label_size_group, stream, id, self->stream_type);
+ row = cc_stream_row_new (self->label_size_group, stream, id, self->stream_type, self->mixer_control);
gtk_widget_show (GTK_WIDGET (row));
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), FALSE);
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (row));
diff --git a/panels/sound/cc-stream-row.c b/panels/sound/cc-stream-row.c
index 31d6be79e..4a465fdd5 100644
--- a/panels/sound/cc-stream-row.c
+++ b/panels/sound/cc-stream-row.c
@@ -73,10 +73,11 @@ cc_stream_row_init (CcStreamRow *self)
}
CcStreamRow *
-cc_stream_row_new (GtkSizeGroup *size_group,
- GvcMixerStream *stream,
- guint id,
- CcStreamType stream_type)
+cc_stream_row_new (GtkSizeGroup *size_group,
+ GvcMixerStream *stream,
+ guint id,
+ CcStreamType stream_type,
+ GvcMixerControl *mixer_control)
{
CcStreamRow *self;
g_autoptr(GtkIconInfo) icon_info = NULL;
@@ -110,6 +111,7 @@ cc_stream_row_new (GtkSizeGroup *size_group,
gtk_label_set_label (self->name_label, gvc_mixer_stream_get_name (stream));
cc_volume_slider_set_stream (self->volume_slider, stream, stream_type);
+ cc_volume_slider_set_mixer_control (self->volume_slider, mixer_control);
gtk_size_group_add_widget (size_group, GTK_WIDGET (self->label_box));
diff --git a/panels/sound/cc-stream-row.h b/panels/sound/cc-stream-row.h
index 3819eef18..9e4de9bde 100644
--- a/panels/sound/cc-stream-row.h
+++ b/panels/sound/cc-stream-row.h
@@ -20,6 +20,7 @@
#include <gtk/gtk.h>
#include <pulse/pulseaudio.h>
+#include <gvc-mixer-control.h>
#include <gvc-mixer-stream.h>
#include "cc-sound-enums.h"
@@ -29,10 +30,11 @@ G_BEGIN_DECLS
#define CC_TYPE_STREAM_ROW (cc_stream_row_get_type ())
G_DECLARE_FINAL_TYPE (CcStreamRow, cc_stream_row, CC, STREAM_ROW, GtkListBoxRow)
-CcStreamRow *cc_stream_row_new (GtkSizeGroup *size_group,
- GvcMixerStream *stream,
- guint id,
- CcStreamType stream_type);
+CcStreamRow *cc_stream_row_new (GtkSizeGroup *size_group,
+ GvcMixerStream *stream,
+ guint id,
+ CcStreamType stream_type,
+ GvcMixerControl *mixer_control);
GvcMixerStream *cc_stream_row_get_stream (CcStreamRow *row);
diff --git a/panels/sound/cc-volume-slider.c b/panels/sound/cc-volume-slider.c
index 7e061e540..9f0610f63 100644
--- a/panels/sound/cc-volume-slider.c
+++ b/panels/sound/cc-volume-slider.c
@@ -43,6 +43,36 @@ struct _CcVolumeSlider
G_DEFINE_TYPE (CcVolumeSlider, cc_volume_slider, GTK_TYPE_BOX)
+static void
+volume_changed_cb (CcVolumeSlider *self)
+{
+ gdouble volume, rounded;
+
+ if (self->stream == NULL)
+ return;
+
+ volume = gtk_adjustment_get_value (self->volume_adjustment);
+ rounded = round (volume);
+
+ gtk_toggle_button_set_active (self->mute_button, volume == 0.0);
+
+ if (gvc_mixer_stream_set_volume (self->stream, (pa_volume_t) rounded))
+ gvc_mixer_stream_push_volume (self->stream);
+}
+
+static void
+notify_volume_cb (CcVolumeSlider *self)
+{
+ g_signal_handlers_block_by_func (self->volume_adjustment, volume_changed_cb, self);
+
+ if (gtk_toggle_button_get_active (self->mute_button))
+ gtk_adjustment_set_value (self->volume_adjustment, 0.0);
+ else
+ gtk_adjustment_set_value (self->volume_adjustment, gvc_mixer_stream_get_volume (self->stream));
+
+ g_signal_handlers_unblock_by_func (self->volume_adjustment, volume_changed_cb, self);
+}
+
static void
update_ranges (CcVolumeSlider *self)
{
@@ -67,25 +97,9 @@ update_ranges (CcVolumeSlider *self)
gtk_adjustment_set_upper (self->volume_adjustment, vol_max_norm);
}
gtk_adjustment_set_page_increment (self->volume_adjustment, vol_max_norm / 100.0);
-}
-
-static void
-volume_changed_cb (CcVolumeSlider *self)
-{
- gdouble volume, rounded;
- if (self->stream == NULL)
- return;
-
- volume = gtk_adjustment_get_value (self->volume_adjustment);
- rounded = round (volume);
-
- gtk_toggle_button_set_active (self->mute_button, volume == 0.0);
- if (gvc_mixer_stream_set_volume (self->stream,
- (pa_volume_t) rounded))
- {
- gvc_mixer_stream_push_volume (self->stream);
- }
+ if (self->stream)
+ notify_volume_cb (self);
}
static void
@@ -97,17 +111,6 @@ mute_button_toggled_cb (CcVolumeSlider *self)
gvc_mixer_stream_change_is_muted (self->stream, gtk_toggle_button_get_active (self->mute_button));
}
-static void
-notify_volume_cb (CcVolumeSlider *self)
-{
- g_signal_handlers_block_by_func (self->volume_adjustment, volume_changed_cb, self);
- if (gtk_toggle_button_get_active (self->mute_button))
- gtk_adjustment_set_value (self->volume_adjustment, 0.0);
- else
- gtk_adjustment_set_value (self->volume_adjustment, gvc_mixer_stream_get_volume (self->stream));
- g_signal_handlers_unblock_by_func (self->volume_adjustment, volume_changed_cb, self);
-}
-
static void
notify_is_muted_cb (CcVolumeSlider *self)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]