From ee2c55379cb2360da8a5adae46e634f31100c1a4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 20 May 2020 15:04:44 -0400 Subject: [PATCH 1/3] mediacontrols: Make volume control react to has-audio --- gtk/gtkmediacontrols.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gtk/gtkmediacontrols.c b/gtk/gtkmediacontrols.c index 4f09d59feb..417f2d0ff7 100644 --- a/gtk/gtkmediacontrols.c +++ b/gtk/gtkmediacontrols.c @@ -51,6 +51,7 @@ struct _GtkMediaControls GtkWidget *time_label; GtkWidget *seek_scale; GtkWidget *duration_label; + GtkWidget *volume_button; }; enum @@ -288,6 +289,7 @@ gtk_media_controls_class_init (GtkMediaControlsClass *klass) gtk_widget_class_bind_template_child (widget_class, GtkMediaControls, time_label); gtk_widget_class_bind_template_child (widget_class, GtkMediaControls, seek_scale); gtk_widget_class_bind_template_child (widget_class, GtkMediaControls, duration_label); + gtk_widget_class_bind_template_child (widget_class, GtkMediaControls, volume_button); gtk_widget_class_bind_template_callback (widget_class, play_button_clicked); gtk_widget_class_bind_template_callback (widget_class, time_adjustment_changed); @@ -439,6 +441,10 @@ update_volume (GtkMediaControls *controls) volume = gtk_media_stream_get_volume (controls->stream); gtk_adjustment_set_value (controls->volume_adjustment, volume); + + gtk_widget_set_sensitive (controls->volume_button, + controls->stream == NULL || + gtk_media_stream_has_audio (controls->stream)); } static void @@ -468,6 +474,8 @@ gtk_media_controls_notify_cb (GtkMediaStream *stream, update_volume (controls); else if (g_str_equal (pspec->name, "volume")) update_volume (controls); + else if (g_str_equal (pspec->name, "has-audio")) + update_volume (controls); } /** From 87d2e864292e8571fde4958575e469d9520c37a5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 20 May 2020 15:05:13 -0400 Subject: [PATCH 2/3] mediastream: Some properties were meant to be readonly These properties aren't covered by set_property(), and it doesn't make sense to do so. They were just declared as read-write by mistake. --- gtk/gtkmediastream.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtk/gtkmediastream.c b/gtk/gtkmediastream.c index 1222277143..22bbd916c9 100644 --- a/gtk/gtkmediastream.c +++ b/gtk/gtkmediastream.c @@ -313,7 +313,7 @@ gtk_media_stream_class_init (GtkMediaStreamClass *class) P_("Error"), P_("Error the stream is in"), G_TYPE_ERROR, - G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); + G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); /** * GtkMediaStream:has-audio: @@ -325,7 +325,7 @@ gtk_media_stream_class_init (GtkMediaStreamClass *class) P_("Has audio"), P_("Whether the stream contains audio"), FALSE, - G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); + G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); /** * GtkMediaStream:has-video: @@ -337,7 +337,7 @@ gtk_media_stream_class_init (GtkMediaStreamClass *class) P_("Has video"), P_("Whether the stream contains video"), FALSE, - G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); + G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); /** * GtkMediaStream:playing: From 9a1b4a766fd9c7ee6f834df9d1fe6b467334a693 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 20 May 2020 15:07:58 -0400 Subject: [PATCH 3/3] mediastream: Volume is a double Another obvious copy-paste error in the property declarations of GtkMediaStream. Volume should be a double, with range [0, 1], not a boolean. --- gtk/gtkmediastream.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gtk/gtkmediastream.c b/gtk/gtkmediastream.c index 22bbd916c9..09c1230595 100644 --- a/gtk/gtkmediastream.c +++ b/gtk/gtkmediastream.c @@ -441,11 +441,11 @@ gtk_media_stream_class_init (GtkMediaStreamClass *class) * Volume of the audio stream. */ properties[PROP_VOLUME] = - g_param_spec_boolean ("volume", - P_("Volume"), - P_("Volume of the audio stream."), - 1.0, - G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); + g_param_spec_double ("volume", + P_("Volume"), + P_("Volume of the audio stream."), + 0.0, 1.0, 1.0, + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); g_object_class_install_properties (gobject_class, N_PROPS, properties); }