summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mate-volume-control/dialog-main.c2
-rw-r--r--mate-volume-control/gvc-channel-bar.c84
-rw-r--r--mate-volume-control/gvc-channel-bar.h4
-rw-r--r--mate-volume-control/gvc-mixer-dialog.c65
-rw-r--r--mate-volume-control/gvc-stream-applet-icon.c16
-rw-r--r--mate-volume-control/gvc-stream-status-icon.c23
-rw-r--r--mate-volume-control/status-icon-main.c2
7 files changed, 177 insertions, 19 deletions
diff --git a/mate-volume-control/dialog-main.c b/mate-volume-control/dialog-main.c
index b213b3d..c731261 100644
--- a/mate-volume-control/dialog-main.c
+++ b/mate-volume-control/dialog-main.c
@@ -192,7 +192,7 @@ main (int argc, char **argv)
{ "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, N_("Enable debug"), NULL },
{ "page", 'p', 0, G_OPTION_ARG_STRING, &page, N_("Startup page"), "effects|hardware|input|output|applications" },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL },
- { NULL }
+ { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
};
bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
diff --git a/mate-volume-control/gvc-channel-bar.c b/mate-volume-control/gvc-channel-bar.c
index e787474..89fa3a5 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,
@@ -369,18 +401,11 @@ update_adjustment_value (GvcChannelBar *bar)
else
value = mate_mixer_stream_control_get_volume (bar->priv->control);
- gdouble maximum = gtk_adjustment_get_upper (bar->priv->adjustment);
- gdouble minimum = gtk_adjustment_get_lower (bar->priv->adjustment);
- gdouble range = maximum - minimum;
-
- /* round value to nearest hundreth of the range */
- gdouble new_value = minimum + round (((value - minimum) / range) * 100) * (range / 100);
-
g_signal_handlers_block_by_func (G_OBJECT (bar->priv->adjustment),
on_adjustment_value_changed,
bar);
- gtk_adjustment_set_value (bar->priv->adjustment, new_value);
+ gtk_adjustment_set_value (bar->priv->adjustment, value);
g_signal_handlers_unblock_by_func (G_OBJECT (bar->priv->adjustment),
on_adjustment_value_changed,
@@ -584,6 +609,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 +709,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 +752,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 +989,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 +1037,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 +1105,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",
diff --git a/mate-volume-control/gvc-channel-bar.h b/mate-volume-control/gvc-channel-bar.h
index d7a0cbc..7fc0ed2 100644
--- a/mate-volume-control/gvc-channel-bar.h
+++ b/mate-volume-control/gvc-channel-bar.h
@@ -95,6 +95,10 @@ gboolean gvc_channel_bar_get_show_marks (GvcChannelBar *bar
void gvc_channel_bar_set_show_marks (GvcChannelBar *bar,
gboolean show_marks);
+gboolean gvc_channel_bar_get_show_mark_text (GvcChannelBar *bar);
+void gvc_channel_bar_set_show_mark_text (GvcChannelBar *bar,
+ gboolean show_mark_text);
+
gboolean gvc_channel_bar_get_extended (GvcChannelBar *bar);
void gvc_channel_bar_set_extended (GvcChannelBar *bar,
gboolean extended);
diff --git a/mate-volume-control/gvc-mixer-dialog.c b/mate-volume-control/gvc-mixer-dialog.c
index 759995b..a71a12f 100644
--- a/mate-volume-control/gvc-mixer-dialog.c
+++ b/mate-volume-control/gvc-mixer-dialog.c
@@ -41,9 +41,11 @@
struct _GvcMixerDialogPrivate
{
+ GSettings *sound_settings;
MateMixerContext *context;
MateMixerBackendFlags backend_flags;
GHashTable *bars;
+ GtkWidget *volume_overamplifiable_button;
GtkWidget *notebook;
GtkWidget *output_bar;
GtkWidget *input_bar;
@@ -369,6 +371,39 @@ update_output_settings (GvcMixerDialog *dialog)
gtk_widget_hide (dialog->priv->output_settings_frame);
}
+/*
+ * Enable or disable the checkbox allowing the user to set the volume above
+ * 100%, depending on whether the maximum volume is greater than the
+ * "normal" volume. If the maximum volume is greater than the normal
+ * volume, then enable the checkbox; otherwise, over-amplification is not
+ * possible with this control, so disable the checkbox.
+ */
+static void
+update_overamplify_sensitivity (GvcMixerDialog *dialog)
+{
+ MateMixerStreamControl *control;
+ guint normal_volume;
+ guint maximum_volume;
+
+ control = gvc_channel_bar_get_control (GVC_CHANNEL_BAR (dialog->priv->output_bar));
+ if (control == NULL)
+ {
+ gtk_widget_set_sensitive (dialog->priv->volume_overamplifiable_button,
+ FALSE);
+ return;
+ }
+
+ normal_volume = mate_mixer_stream_control_get_normal_volume (control);
+ maximum_volume = mate_mixer_stream_control_get_max_volume (control);
+
+ if (maximum_volume > normal_volume)
+ gtk_widget_set_sensitive (dialog->priv->volume_overamplifiable_button,
+ TRUE);
+ else
+ gtk_widget_set_sensitive (dialog->priv->volume_overamplifiable_button,
+ FALSE);
+}
+
static void
set_output_stream (GvcMixerDialog *dialog, MateMixerStream *stream)
{
@@ -420,6 +455,7 @@ set_output_stream (GvcMixerDialog *dialog, MateMixerStream *stream)
update_default_tree_item (dialog, model, stream);
update_output_settings (dialog);
+ update_overamplify_sensitivity (dialog);
}
static void
@@ -628,8 +664,7 @@ create_bar (GvcMixerDialog *dialog, gboolean use_size_group, gboolean symmetric)
"orientation", GTK_ORIENTATION_HORIZONTAL,
"show-mute", TRUE,
"show-icons", TRUE,
- "show-marks", TRUE,
- "extended", TRUE, NULL);
+ "show-marks", TRUE, NULL);
return bar;
}
@@ -861,6 +896,7 @@ add_stream (GvcMixerDialog *dialog, MateMixerStream *stream)
bar_set_stream (dialog, dialog->priv->output_bar, stream);
update_output_settings (dialog);
+ update_overamplify_sensitivity (dialog);
is_default = TRUE;
}
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->output_treeview));
@@ -1954,6 +1990,8 @@ gvc_mixer_dialog_constructor (GType type,
self = GVC_MIXER_DIALOG (object);
+ self->priv->sound_settings = g_settings_new ("org.mate.sound");
+
gtk_dialog_add_button (GTK_DIALOG (self), "gtk-close", GTK_RESPONSE_OK);
main_vbox = gtk_dialog_get_content_area (GTK_DIALOG (self));
@@ -1961,8 +1999,8 @@ gvc_mixer_dialog_constructor (GType type,
gtk_container_set_border_width (GTK_CONTAINER (self), 6);
- self->priv->output_stream_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_widget_set_margin_top (self->priv->output_stream_box, 12);
+ self->priv->output_stream_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (self->priv->output_stream_box), 12);
gtk_box_pack_start (GTK_BOX (main_vbox),
self->priv->output_stream_box,
@@ -1972,11 +2010,26 @@ gvc_mixer_dialog_constructor (GType type,
gvc_channel_bar_set_name (GVC_CHANNEL_BAR (self->priv->output_bar),
_("_Output volume: "));
+ g_settings_bind (self->priv->sound_settings, "volume-overamplifiable",
+ self->priv->output_bar, "extended",
+ G_SETTINGS_BIND_GET);
+
gtk_widget_show (self->priv->output_bar);
gtk_widget_set_sensitive (self->priv->output_bar, FALSE);
gtk_box_pack_start (GTK_BOX (self->priv->output_stream_box),
- self->priv->output_bar, TRUE, TRUE, 12);
+ self->priv->output_bar, TRUE, TRUE, 0);
+
+ self->priv->volume_overamplifiable_button =
+ gtk_check_button_new_with_mnemonic (_("Allow volume to e_xceed 100%"));
+
+ g_settings_bind (self->priv->sound_settings, "volume-overamplifiable",
+ self->priv->volume_overamplifiable_button, "active",
+ G_SETTINGS_BIND_GET|G_SETTINGS_BIND_SET);
+
+ gtk_box_pack_start (GTK_BOX (self->priv->output_stream_box),
+ self->priv->volume_overamplifiable_button,
+ FALSE, FALSE, 0);
self->priv->notebook = gtk_notebook_new ();
@@ -2346,6 +2399,8 @@ gvc_mixer_dialog_dispose (GObject *object)
g_clear_object (&dialog->priv->context);
}
+ g_clear_object (&dialog->priv->sound_settings);
+
G_OBJECT_CLASS (gvc_mixer_dialog_parent_class)->dispose (object);
}
diff --git a/mate-volume-control/gvc-stream-applet-icon.c b/mate-volume-control/gvc-stream-applet-icon.c
index d2b7337..c910150 100644
--- a/mate-volume-control/gvc-stream-applet-icon.c
+++ b/mate-volume-control/gvc-stream-applet-icon.c
@@ -37,6 +37,7 @@
struct _GvcStreamAppletIconPrivate
{
+ GSettings *sound_settings;
gchar **icon_names;
GtkImage *image;
GtkWidget *dock;
@@ -680,6 +681,8 @@ gvc_stream_applet_icon_init (GvcStreamAppletIcon *icon)
icon->priv = gvc_stream_applet_icon_get_instance_private (icon);
+ icon->priv->sound_settings = g_settings_new ("org.mate.sound");
+
icon->priv->image = GTK_IMAGE (gtk_image_new ());
gtk_container_add (GTK_CONTAINER (icon), GTK_WIDGET (icon->priv->image));
@@ -731,6 +734,17 @@ gvc_stream_applet_icon_init (GvcStreamAppletIcon *icon)
gvc_channel_bar_set_orientation (GVC_CHANNEL_BAR (icon->priv->bar),
GTK_ORIENTATION_VERTICAL);
+ gvc_channel_bar_set_show_mark_text (GVC_CHANNEL_BAR (icon->priv->bar),
+ FALSE);
+
+ g_settings_bind (icon->priv->sound_settings, "volume-overamplifiable",
+ icon->priv->bar, "show-marks",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (icon->priv->sound_settings, "volume-overamplifiable",
+ icon->priv->bar, "extended",
+ G_SETTINGS_BIND_GET);
+
/* Set volume control frame, slider and toplevel window to follow panel theme */
GtkWidget *toplevel = gtk_widget_get_toplevel (icon->priv->dock);
GtkStyleContext *context;
@@ -769,6 +783,8 @@ gvc_stream_applet_icon_finalize (GObject *object)
on_icon_theme_change,
icon);
+ g_clear_object (&icon->priv->sound_settings);
+
G_OBJECT_CLASS (gvc_stream_applet_icon_parent_class)->finalize (object);
}
diff --git a/mate-volume-control/gvc-stream-status-icon.c b/mate-volume-control/gvc-stream-status-icon.c
index 8ca2849..0f7ee2b 100644
--- a/mate-volume-control/gvc-stream-status-icon.c
+++ b/mate-volume-control/gvc-stream-status-icon.c
@@ -35,6 +35,7 @@
struct _GvcStreamStatusIconPrivate
{
+ GSettings *sound_settings;
gchar **icon_names;
GtkWidget *dock;
GtkWidget *bar;
@@ -380,6 +381,7 @@ static void
update_icon (GvcStreamStatusIcon *icon)
{
guint volume = 0;
+ guint volume_percent = 0;
gdouble decibel = 0;
guint normal = 0;
gboolean muted = FALSE;
@@ -407,7 +409,7 @@ update_icon (GvcStreamStatusIcon *icon)
/* Select an icon, they are expected to be sorted, the lowest index being
* the mute icon and the rest being volume increments */
- if (volume <= 0 || muted)
+ if (volume == 0 || muted)
n = 0;
else
n = CLAMP (3 * volume / normal + 1, 1, 3);
@@ -424,7 +426,9 @@ update_icon (GvcStreamStatusIcon *icon)
description = mate_mixer_stream_control_get_label (icon->priv->control);
- guint volume_percent = (guint) round (100.0 * volume / normal);
+ if (normal != 0)
+ volume_percent = (guint) (100.0 * ((double) volume) / ((double) normal));
+
if (muted) {
markup = g_strdup_printf ("<b>%s: %s %u%%</b>\n<small>%s</small>",
icon->priv->display_name,
@@ -689,6 +693,8 @@ gvc_stream_status_icon_init (GvcStreamStatusIcon *icon)
icon->priv = gvc_stream_status_icon_get_instance_private (icon);
+ icon->priv->sound_settings = g_settings_new ("org.mate.sound");
+
g_signal_connect (G_OBJECT (icon),
"activate",
G_CALLBACK (on_status_icon_activate),
@@ -745,6 +751,17 @@ gvc_stream_status_icon_init (GvcStreamStatusIcon *icon)
gvc_channel_bar_set_orientation (GVC_CHANNEL_BAR (icon->priv->bar),
GTK_ORIENTATION_VERTICAL);
+ gvc_channel_bar_set_show_mark_text (GVC_CHANNEL_BAR (icon->priv->bar),
+ FALSE);
+
+ g_settings_bind (icon->priv->sound_settings, "volume-overamplifiable",
+ icon->priv->bar, "show-marks",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (icon->priv->sound_settings, "volume-overamplifiable",
+ icon->priv->bar, "extended",
+ G_SETTINGS_BIND_GET);
+
/* Set volume control frame, slider and toplevel window to follow panel theme */
GtkWidget *toplevel = gtk_widget_get_toplevel (icon->priv->dock);
GtkStyleContext *context;
@@ -781,6 +798,8 @@ gvc_stream_status_icon_finalize (GObject *object)
on_icon_theme_change,
icon);
+ g_clear_object (&icon->priv->sound_settings);
+
G_OBJECT_CLASS (gvc_stream_status_icon_parent_class)->finalize (object);
}
diff --git a/mate-volume-control/status-icon-main.c b/mate-volume-control/status-icon-main.c
index e3dd684..6bf192a 100644
--- a/mate-volume-control/status-icon-main.c
+++ b/mate-volume-control/status-icon-main.c
@@ -45,7 +45,7 @@ main (int argc, char **argv)
GOptionEntry entries[] = {
{ "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL },
{ "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, N_("Enable debug"), NULL },
- { NULL }
+ { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
};
bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);