gnome-media r4205 - in trunk/gnome-volume-control: . src
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-media r4205 - in trunk/gnome-volume-control: . src
- Date: Tue, 17 Feb 2009 21:40:56 +0000 (UTC)
Author: hadess
Date: Tue Feb 17 21:40:56 2009
New Revision: 4205
URL: http://svn.gnome.org/viewvc/gnome-media?rev=4205&view=rev
Log:
2009-02-17 Bastien Nocera <hadess hadess net>
* src/gvc-channel-bar.c (on_scale_scroll_event),
(gvc_channel_bar_set_is_amplified), (gvc_channel_bar_set_property),
(gvc_channel_bar_get_property), (gvc_channel_bar_class_init),
(gvc_channel_bar_init):
* src/gvc-channel-bar.h: Add "is-amplified" property. In this mode,
the volume can be set above 100% (150% tops actually) for inputs
that support giving us the dB information
* src/gvc-mixer-dialog.c (on_mixer_control_default_source_changed),
(add_stream): Disconnect the value-changed signal, and
reconnect it when we're done setting is_amplified for source streams
that support giving dB info
(Closes: #567536)
Modified:
trunk/gnome-volume-control/ChangeLog
trunk/gnome-volume-control/src/gvc-channel-bar.c
trunk/gnome-volume-control/src/gvc-channel-bar.h
trunk/gnome-volume-control/src/gvc-mixer-dialog.c
Modified: trunk/gnome-volume-control/src/gvc-channel-bar.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-channel-bar.c (original)
+++ trunk/gnome-volume-control/src/gvc-channel-bar.c Tue Feb 17 21:40:56 2009
@@ -32,6 +32,9 @@
#include "gvc-channel-bar.h"
#define SCALE_SIZE 128
+#define ADJUSTMENT_MAX_NORMAL 65536.0 /* PA_VOLUME_NORM */
+#define ADJUSTMENT_MAX_AMPLIFIED 98304.0 /* 1.5 * ADJUSTMENT_MAX_NORMAL */
+#define ADJUSTMENT_MAX (bar->priv->is_amplified ? ADJUSTMENT_MAX_AMPLIFIED : ADJUSTMENT_MAX_NORMAL)
#define GVC_CHANNEL_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_CHANNEL_BAR, GvcChannelBarPrivate))
@@ -59,6 +62,7 @@
GtkSizeGroup *size_group;
gboolean symmetric;
gboolean click_lock;
+ gboolean is_amplified;
};
enum
@@ -72,6 +76,7 @@
PROP_ICON_NAME,
PROP_LOW_ICON_NAME,
PROP_HIGH_ICON_NAME,
+ PROP_IS_AMPLIFIED,
};
static void gvc_channel_bar_class_init (GvcChannelBarClass *klass);
@@ -425,16 +430,16 @@
value = gtk_adjustment_get_value (bar->priv->adjustment);
if (event->direction == GDK_SCROLL_UP) {
- if (value + 65536.0/100.0 > 65536.0)
- value = 65536.0;
+ if (value + ADJUSTMENT_MAX/100.0 > ADJUSTMENT_MAX)
+ value = ADJUSTMENT_MAX;
else
- value = value + 65536.0/100.0;
+ value = value + ADJUSTMENT_MAX/100.0;
gtk_adjustment_set_value (bar->priv->adjustment, value);
} else if (event->direction == GDK_SCROLL_DOWN) {
- if (value - 65536.0/100.0 < 0)
+ if (value - ADJUSTMENT_MAX/100.0 < 0)
value = 0.0;
else
- value = value - 65536.0/100.0;
+ value = value - ADJUSTMENT_MAX/100.0;
gtk_adjustment_set_value (bar->priv->adjustment, value);
}
@@ -531,6 +536,16 @@
return bar->priv->show_mute;
}
+void
+gvc_channel_bar_set_is_amplified (GvcChannelBar *bar, gboolean amplified)
+{
+ g_return_if_fail (GVC_IS_CHANNEL_BAR (bar));
+
+ bar->priv->is_amplified = amplified;
+ gtk_adjustment_set_upper (bar->priv->adjustment, ADJUSTMENT_MAX);
+ gtk_adjustment_set_upper (bar->priv->zero_adjustment, ADJUSTMENT_MAX);
+}
+
static void
gvc_channel_bar_set_property (GObject *object,
guint prop_id,
@@ -564,6 +579,9 @@
case PROP_ADJUSTMENT:
gvc_channel_bar_set_adjustment (self, g_value_get_object (value));
break;
+ case PROP_IS_AMPLIFIED:
+ gvc_channel_bar_set_is_amplified (self, g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -604,6 +622,9 @@
case PROP_ADJUSTMENT:
g_value_set_object (value, gvc_channel_bar_get_adjustment (self));
break;
+ case PROP_IS_AMPLIFIED:
+ g_value_set_boolean (value, priv->is_amplified);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -695,6 +716,13 @@
"Name of icon to display for this stream",
"audio-volume-high",
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_IS_AMPLIFIED,
+ g_param_spec_boolean ("is-amplified",
+ "is amplified",
+ "Whether the stream is digitally amplified",
+ FALSE,
+ G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
g_type_class_add_private (klass, sizeof (GvcChannelBarPrivate));
}
@@ -721,17 +749,17 @@
bar->priv->orientation = GTK_ORIENTATION_VERTICAL;
bar->priv->adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0,
0.0,
- 65536.0,
- 65536.0/100.0,
- 65536.0/10.0,
+ ADJUSTMENT_MAX_NORMAL,
+ ADJUSTMENT_MAX_NORMAL/100.0,
+ ADJUSTMENT_MAX_NORMAL/10.0,
0.0));
g_object_ref_sink (bar->priv->adjustment);
bar->priv->zero_adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0,
0.0,
- 65536.0,
- 65536.0/100.0,
- 65536.0/10.0,
+ ADJUSTMENT_MAX_NORMAL,
+ ADJUSTMENT_MAX_NORMAL/100.0,
+ ADJUSTMENT_MAX_NORMAL/10.0,
0.0));
g_object_ref_sink (bar->priv->zero_adjustment);
Modified: trunk/gnome-volume-control/src/gvc-channel-bar.h
==============================================================================
--- trunk/gnome-volume-control/src/gvc-channel-bar.h (original)
+++ trunk/gnome-volume-control/src/gvc-channel-bar.h Tue Feb 17 21:40:56 2009
@@ -73,6 +73,8 @@
void gvc_channel_bar_set_size_group (GvcChannelBar *bar,
GtkSizeGroup *group,
gboolean symmetric);
+void gvc_channel_bar_set_is_amplified (GvcChannelBar *bar,
+ gboolean amplified);
G_END_DECLS
Modified: trunk/gnome-volume-control/src/gvc-mixer-dialog.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-mixer-dialog.c (original)
+++ trunk/gnome-volume-control/src/gvc-mixer-dialog.c Tue Feb 17 21:40:56 2009
@@ -95,6 +95,9 @@
GtkWidget *bar,
GvcMixerStream *stream);
+static void on_adjustment_value_changed (GtkAdjustment *adjustment,
+ GvcMixerDialog *dialog);
+
G_DEFINE_TYPE (GvcMixerDialog, gvc_mixer_dialog, GTK_TYPE_DIALOG)
static void
@@ -381,13 +384,21 @@
GvcMixerDialog *dialog)
{
GvcMixerStream *stream;
+ GtkAdjustment *adj;
g_debug ("GvcMixerDialog: default source changed: %u", id);
stream = gvc_mixer_control_lookup_stream_id (dialog->priv->mixer_control,
id);
+ adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (dialog->priv->input_bar)));
+ g_signal_handlers_disconnect_by_func(adj, on_adjustment_value_changed, dialog);
bar_set_stream (dialog, dialog->priv->input_bar, stream);
-
+ gvc_channel_bar_set_is_amplified (GVC_CHANNEL_BAR (dialog->priv->input_bar),
+ gvc_mixer_stream_get_can_decibel (stream));
+ g_signal_connect (adj,
+ "value-changed",
+ G_CALLBACK (on_adjustment_value_changed),
+ dialog);
create_monitor_stream_for_source (dialog, stream);
update_default_input (dialog);
@@ -666,6 +677,13 @@
bar = dialog->priv->input_bar;
is_default = TRUE;
+ /* Disconnect the adj, otherwise it might change if is_amplified changes */
+ adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (bar)));
+ g_signal_handlers_disconnect_by_func(adj, on_adjustment_value_changed, dialog);
+
+ gvc_channel_bar_set_is_amplified (GVC_CHANNEL_BAR (bar),
+ gvc_mixer_stream_get_can_decibel (stream));
+
create_monitor_stream_for_source (dialog, stream);
} else if (stream == gvc_mixer_control_get_event_sink_input (dialog->priv->mixer_control)) {
bar = dialog->priv->effects_bar;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]