aboutsummaryrefslogtreecommitdiff
path: root/src/service.vala
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2013-06-18 15:00:27 -0400
committerLars Uebernickel <lars.uebernickel@canonical.com>2013-06-18 15:00:27 -0400
commite2d1ed2cb0b066a7b34db15e42af0a4b49626ec8 (patch)
tree134c39e677f4c75e79fa975227978dea03050bfb /src/service.vala
parentcb8cb6ef16fc0884d2499421fbeeca12e3288b56 (diff)
downloadayatana-indicator-sound-e2d1ed2cb0b066a7b34db15e42af0a4b49626ec8.tar.gz
ayatana-indicator-sound-e2d1ed2cb0b066a7b34db15e42af0a4b49626ec8.tar.bz2
ayatana-indicator-sound-e2d1ed2cb0b066a7b34db15e42af0a4b49626ec8.zip
Allow setting the microphone volume if an app using it is running
Diffstat (limited to 'src/service.vala')
-rw-r--r--src/service.vala38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/service.vala b/src/service.vala
index 269ddd7..83d0d17 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -25,6 +25,7 @@ public class IndicatorSound.Service {
this.settings = new Settings ("com.canonical.indicator.sound");
this.volume_control = new VolumeControl ();
+ this.volume_control.notify["active-mic"].connect (active_mic_changed);
this.players = new MediaPlayerList ();
this.players.player_added.connect (this.player_added);
@@ -34,6 +35,7 @@ public class IndicatorSound.Service {
this.actions.add_entries (action_entries, this);
this.actions.add_action (this.create_mute_action ());
this.actions.add_action (this.create_volume_action ());
+ this.actions.add_action (this.create_mic_volume_action ());
this.menu = create_menu ();
this.root_menu = create_root_menu (this.menu);
@@ -112,6 +114,26 @@ public class IndicatorSound.Service {
return menu;
}
+ void active_mic_changed () {
+ var volume_section = this.menu.get_item_link (0, "section") as Menu;
+ if (this.volume_control.active_mic) {
+ if (volume_section.get_n_items () < 3) {
+ var slider = new MenuItem (null, "indicator.mic-volume");
+ slider.set_attribute ("x-canonical-type", "s", "com.canonical.unity.slider");
+ slider.set_attribute_value ("min-icon", g_icon_serialize (new ThemedIcon ("audio-input-microphone-low-zero-panel")));
+ slider.set_attribute_value ("max-icon", g_icon_serialize (new ThemedIcon ("audio-input-microphone-high-panel")));
+ slider.set_attribute ("min-value", "d", 0.0);
+ slider.set_attribute ("max-value", "d", 1.0);
+ slider.set_attribute ("step", "d", 0.01);
+ volume_section.append_item (slider);
+ }
+ }
+ else {
+ if (volume_section.get_n_items () > 2)
+ volume_section.remove (2);
+ }
+ }
+
Action create_mute_action () {
var mute_action = new SimpleAction.stateful ("mute", null, this.volume_control.mute);
@@ -146,6 +168,22 @@ public class IndicatorSound.Service {
return volume_action;
}
+ Action create_mic_volume_action () {
+ var volume_action = new SimpleAction.stateful ("mic-volume", null, this.volume_control.get_mic_volume ());
+
+ volume_action.change_state.connect ( (action, val) => {
+ volume_control.set_mic_volume (val.get_double ());
+ });
+
+ this.volume_control.mic_volume_changed.connect ( (volume) => {
+ volume_action.set_state (volume);
+ });
+
+ this.volume_control.bind_property ("ready", volume_action, "enabled", BindingFlags.SYNC_CREATE);
+
+ return volume_action;
+ }
+
void bus_acquired (DBusConnection connection, string name) {
try {
connection.export_action_group ("/com/canonical/indicator/sound", this.actions);