diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2019-08-13 11:11:05 +1200 |
---|---|---|
committer | Robert Ancell <robert.ancell@gmail.com> | 2019-08-25 09:51:31 +0000 |
commit | 9d612ff1c7e2d58211e25e8584bc86c5d2598eac (patch) | |
tree | ddd47409bc3fe780e35c3e50491df78ece641bd8 /panels/sound/cc-volume-slider.c | |
parent | 299647f970a5123e9f462327214c11ec758822d6 (diff) | |
download | gnome-control-center-9d612ff1c7e2d58211e25e8584bc86c5d2598eac.tar.gz |
sound: Fix volume sliders regression
GVC added additional checks that break where we were using a NULL value instead
of a GvcMixerControl. Solution is to pass this object where appropriate.
(gnome-control-center:833): Gvc-CRITICAL **: 11:09:33.818: gvc_mixer_control_get_vol_max_norm: assertion 'GVC_IS_MIXER_CONTROL (control)' failed
Fixes #636
Diffstat (limited to 'panels/sound/cc-volume-slider.c')
-rw-r--r-- | panels/sound/cc-volume-slider.c | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/panels/sound/cc-volume-slider.c b/panels/sound/cc-volume-slider.c index ca2f70b90..7e061e540 100644 --- a/panels/sound/cc-volume-slider.c +++ b/panels/sound/cc-volume-slider.c @@ -34,6 +34,8 @@ struct _CcVolumeSlider GtkAdjustment *volume_adjustment; GtkScale *volume_scale; + gboolean is_amplified; + GvcMixerControl *mixer_control; GvcMixerStream *stream; guint notify_volume_handler_id; guint notify_is_muted_handler_id; @@ -42,6 +44,32 @@ struct _CcVolumeSlider G_DEFINE_TYPE (CcVolumeSlider, cc_volume_slider, GTK_TYPE_BOX) static void +update_ranges (CcVolumeSlider *self) +{ + gdouble vol_max_norm; + + if (self->mixer_control == NULL) + return; + + vol_max_norm = gvc_mixer_control_get_vol_max_norm (self->mixer_control); + + gtk_scale_clear_marks (self->volume_scale); + if (self->is_amplified) + { + gtk_adjustment_set_upper (self->volume_adjustment, gvc_mixer_control_get_vol_max_amplified (self->mixer_control)); + gtk_scale_add_mark (self->volume_scale, + vol_max_norm, + GTK_POS_BOTTOM, + C_("volume", "100%")); + } + else + { + 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; @@ -94,6 +122,7 @@ cc_volume_slider_dispose (GObject *object) { CcVolumeSlider *self = CC_VOLUME_SLIDER (object); + g_clear_object (&self->mixer_control); g_clear_object (&self->stream); G_OBJECT_CLASS (cc_volume_slider_parent_class)->dispose (object); @@ -121,15 +150,20 @@ cc_volume_slider_class_init (CcVolumeSliderClass *klass) void cc_volume_slider_init (CcVolumeSlider *self) { - gdouble vol_max_norm; - g_resources_register (cc_sound_get_resource ()); gtk_widget_init_template (GTK_WIDGET (self)); +} - vol_max_norm = gvc_mixer_control_get_vol_max_norm (NULL); - gtk_adjustment_set_upper (self->volume_adjustment, vol_max_norm); - gtk_adjustment_set_page_increment (self->volume_adjustment, vol_max_norm / 100.0); +void +cc_volume_slider_set_mixer_control (CcVolumeSlider *self, + GvcMixerControl *mixer_control) +{ + g_return_if_fail (CC_IS_VOLUME_SLIDER (self)); + + g_set_object (&self->mixer_control, mixer_control); + + update_ranges (self); } void @@ -190,17 +224,7 @@ cc_volume_slider_set_is_amplified (CcVolumeSlider *self, { g_return_if_fail (CC_IS_VOLUME_SLIDER (self)); - gtk_scale_clear_marks (self->volume_scale); - if (is_amplified) - { - gtk_adjustment_set_upper (self->volume_adjustment, gvc_mixer_control_get_vol_max_amplified (NULL)); - gtk_scale_add_mark (self->volume_scale, - gvc_mixer_control_get_vol_max_norm (NULL), - GTK_POS_BOTTOM, - C_("volume", "100%")); - } - else - { - gtk_adjustment_set_upper (self->volume_adjustment, gvc_mixer_control_get_vol_max_norm (NULL)); - } + self->is_amplified = is_amplified; + + update_ranges (self); } |