summaryrefslogtreecommitdiff
path: root/mate-volume-control/gvc-channel-bar.c
diff options
context:
space:
mode:
authorGordon Norman Squash <[email protected]>2022-07-28 21:28:22 -0400
committerLuke from DC <[email protected]>2022-08-14 00:08:54 +0000
commit44df49d11121858b4235a427376410eb091c31c5 (patch)
tree5fd4afa99858745805e2299a0cfa8822d8c50478 /mate-volume-control/gvc-channel-bar.c
parent3499a5ffe1ea234e3beedd9615a66470026ae2dc (diff)
downloadmate-media-44df49d11121858b4235a427376410eb091c31c5.tar.bz2
mate-media-44df49d11121858b4235a427376410eb091c31c5.tar.xz
Add setting for adjustment of audio volume above 100 per cent: Part 2
There is often a need for the user to increase the audio playback volume above the volume level known as "100% volume". While increasing the audio volume above 100% can result in degraded audio quality, sometimes the audio was, for example, originally recorded at an extremely low volume, and the user has no other option to clearly hear the audio. Unfortunately, most MATE applications with volume controls do not allow the user to set the volume level above 100%. For example, the main MATE Sound Preferences dialog lets you set the audio volume beyond 100% (when possible), whereas the Volume Control Applet, Volume Control status icon, and special "multimedia" volume control keys do not. In fact, if the user even tries to change the volume using any of the latter methods, and the current volume level is above 100%, these latter methods will all reduce the volume to 100%, even if the user tried to increase the volume! This is part 2 of a patch to change this situation. This patch adds this capability to the MATE Volume Control Applet and the MATE Volume Control status icon. It also adds a check box to the MATE Volume Control Preferences dialog to enable or disable this capability, and for consistency, the main volume control at the top of that dialog also obeys the current setting of that check box. This commit is by far the largest one, and is the main part of the patch.
Diffstat (limited to 'mate-volume-control/gvc-channel-bar.c')
-rw-r--r--mate-volume-control/gvc-channel-bar.c75
1 files changed, 73 insertions, 2 deletions
diff --git a/mate-volume-control/gvc-channel-bar.c b/mate-volume-control/gvc-channel-bar.c
index e787474..7feb0dd 100644
--- a/mate-volume-control/gvc-channel-bar.c
+++ b/mate-volume-control/gvc-channel-bar.c
@@ -52,6 +52,7 @@ struct _GvcChannelBarPrivate
gboolean show_icons;
gboolean show_mute;
gboolean show_marks;
+ gboolean show_mark_text;
gboolean extended;
GtkSizeGroup *size_group;
gboolean symmetric;
@@ -67,6 +68,7 @@ enum {
PROP_SHOW_ICONS,
PROP_SHOW_MUTE,
PROP_SHOW_MARKS,
+ PROP_SHOW_MARK_TEXT,
PROP_EXTENDED,
PROP_NAME,
PROP_ICON_NAME,
@@ -287,6 +289,28 @@ update_layout (GvcChannelBar *bar)
}
static void
+update_scale_size (GvcChannelBar *bar)
+{
+ gdouble normal_volume;
+ gdouble maximum_volume;
+ int calculated_scale_size = SCALE_SIZE;
+
+ if (bar->priv->extended && bar->priv->control != NULL)
+ {
+ normal_volume = mate_mixer_stream_control_get_normal_volume (bar->priv->control);
+ maximum_volume = mate_mixer_stream_control_get_max_volume (bar->priv->control);
+ calculated_scale_size = (maximum_volume / normal_volume) * SCALE_SIZE;
+ }
+
+ if (bar->priv->orientation == GTK_ORIENTATION_VERTICAL)
+ gtk_widget_set_size_request (bar->priv->scale,
+ -1, calculated_scale_size);
+ else
+ gtk_widget_set_size_request (bar->priv->scale,
+ calculated_scale_size, -1);
+}
+
+static void
update_marks (GvcChannelBar *bar)
{
gdouble base;
@@ -307,7 +331,11 @@ update_marks (GvcChannelBar *bar)
return;
if (base < normal) {
- gchar *str = g_strdup_printf ("<small>%s</small>", C_("volume", "Unamplified"));
+ gchar *str = NULL;
+
+ if (bar->priv->show_mark_text)
+ str = g_strdup_printf ("<small>%s</small>",
+ C_("volume", "Unamplified"));
gtk_scale_add_mark (GTK_SCALE (bar->priv->scale),
base,
@@ -320,7 +348,11 @@ update_marks (GvcChannelBar *bar)
/* Only show 100% mark if the scale is extended beyond 100% and
* there is no unamplified mark or it is below the normal volume */
if (bar->priv->extended && (base == normal || base < normal)) {
- gchar *str = g_strdup_printf ("<small>%s</small>", C_("volume", "100%"));
+ gchar *str = NULL;
+
+ if (bar->priv->show_mark_text)
+ str = g_strdup_printf ("<small>%s</small>",
+ C_("volume", "100%"));
gtk_scale_add_mark (GTK_SCALE (bar->priv->scale),
normal,
@@ -584,6 +616,7 @@ gvc_channel_bar_set_control (GvcChannelBar *bar, MateMixerStreamControl *control
update_mute_button (bar);
update_adjustment_limits (bar);
update_adjustment_value (bar);
+ update_scale_size (bar);
}
GtkOrientation
@@ -683,6 +716,28 @@ gvc_channel_bar_set_show_marks (GvcChannelBar *bar, gboolean show_marks)
}
gboolean
+gvc_channel_bar_get_show_mark_text (GvcChannelBar *bar)
+{
+ g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), FALSE);
+
+ return bar->priv->show_mark_text;
+}
+
+void
+gvc_channel_bar_set_show_mark_text (GvcChannelBar *bar, gboolean show_mark_text)
+{
+ g_return_if_fail (GVC_IS_CHANNEL_BAR (bar));
+
+ if (show_mark_text == bar->priv->show_mark_text)
+ return;
+
+ bar->priv->show_mark_text = show_mark_text;
+ update_marks (bar);
+
+ g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_SHOW_MARK_TEXT]);
+}
+
+gboolean
gvc_channel_bar_get_extended (GvcChannelBar *bar)
{
g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), FALSE);
@@ -704,6 +759,7 @@ gvc_channel_bar_set_extended (GvcChannelBar *bar, gboolean extended)
* limit at the end of the scale */
update_marks (bar);
update_adjustment_limits (bar);
+ update_scale_size (bar);
g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_EXTENDED]);
}
@@ -940,6 +996,9 @@ gvc_channel_bar_set_property (GObject *object,
case PROP_SHOW_MARKS:
gvc_channel_bar_set_show_marks (self, g_value_get_boolean (value));
break;
+ case PROP_SHOW_MARK_TEXT:
+ gvc_channel_bar_set_show_mark_text (self, g_value_get_boolean (value));
+ break;
case PROP_EXTENDED:
gvc_channel_bar_set_extended (self, g_value_get_boolean (value));
break;
@@ -985,6 +1044,9 @@ gvc_channel_bar_get_property (GObject *object,
case PROP_SHOW_MARKS:
g_value_set_boolean (value, self->priv->show_marks);
break;
+ case PROP_SHOW_MARK_TEXT:
+ g_value_set_boolean (value, self->priv->show_mark_text);
+ break;
case PROP_EXTENDED:
g_value_set_boolean (value, self->priv->extended);
break;
@@ -1050,6 +1112,15 @@ gvc_channel_bar_class_init (GvcChannelBarClass *klass)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS);
+ properties[PROP_SHOW_MARK_TEXT] =
+ g_param_spec_boolean ("show-mark-text",
+ "Show mark-text",
+ "Whether to show a volume level label next to each scale mark",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS);
+
properties[PROP_EXTENDED] =
g_param_spec_boolean ("extended",
"Extended",