diff options
Diffstat (limited to 'src/sound-menu.vala')
-rw-r--r-- | src/sound-menu.vala | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/src/sound-menu.vala b/src/sound-menu.vala index 7a6044b..686d3c1 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -46,7 +46,7 @@ public class SoundMenu: Object volume_section.append_item (this.create_slider_menu_item (_("Volume"), "indicator.volume(0)", 0.0, 1.0, 0.01, "audio-volume-low-zero-panel", - "audio-volume-high-panel")); + "audio-volume-high-panel", true)); this.menu = new Menu (); this.menu.append_section (null, volume_section); @@ -71,6 +71,7 @@ public class SoundMenu: Object this.notify_handlers = new HashTable<MediaPlayer, ulong> (direct_hash, direct_equal); this.greeter_players = (flags & DisplayFlags.GREETER_PLAYERS) != 0; + } ~SoundMenu () { @@ -100,7 +101,7 @@ public class SoundMenu: Object if (value && !this.mic_volume_shown) { var slider = this.create_slider_menu_item (_("Microphone Volume"), "indicator.mic-volume", 0.0, 1.0, 0.01, "audio-input-microphone-low-zero-panel", - "audio-input-microphone-high-panel"); + "audio-input-microphone-high-panel", false); volume_section.append_item (slider); this.mic_volume_shown = true; } @@ -193,6 +194,43 @@ public class SoundMenu: Object this.notify_handlers.remove (player); } + public void update_volume_slider (VolumeControl.ActiveOutput active_output) { + int index = find_action (this.volume_section, "indicator.volume"); + if (index != -1) { + string label = "Volume"; + switch (active_output) { + case VolumeControl.ActiveOutput.SPEAKERS: + label = _("Volume"); + break; + case VolumeControl.ActiveOutput.HEADPHONES: + label = _("Volume (Headphones)"); + break; + case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: + label = _("Volume (Bluetooth)"); + break; + case VolumeControl.ActiveOutput.USB_SPEAKER: + label = _("Volume (Usb)"); + break; + case VolumeControl.ActiveOutput.HDMI_SPEAKER: + label = _("Volume (HDMI)"); + break; + case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: + label = _("Volume (Bluetooth headphones)"); + break; + case VolumeControl.ActiveOutput.USB_HEADPHONES: + label = _("Volume (Usb headphones)"); + break; + case VolumeControl.ActiveOutput.HDMI_HEADPHONES: + label = _("Volume (HDMI headphones)"); + break; + } + this.volume_section.remove (index); + this.volume_section.insert_item (index, this.create_slider_menu_item (_(label), "indicator.volume(0)", 0.0, 1.0, 0.01, + "audio-volume-low-zero-panel", + "audio-volume-high-panel", true)); + } + } + public Menu root; public Menu menu; Menu volume_section; @@ -348,7 +386,7 @@ public class SoundMenu: Object } } - MenuItem create_slider_menu_item (string label, string action, double min, double max, double step, string min_icon_name, string max_icon_name) { + MenuItem create_slider_menu_item (string label, string action, double min, double max, double step, string min_icon_name, string max_icon_name, bool sync_action) { var min_icon = new ThemedIcon.with_default_fallbacks (min_icon_name); var max_icon = new ThemedIcon.with_default_fallbacks (max_icon_name); @@ -359,6 +397,9 @@ public class SoundMenu: Object slider.set_attribute ("min-value", "d", min); slider.set_attribute ("max-value", "d", max); slider.set_attribute ("step", "d", step); + if (sync_action) { + slider.set_attribute ("x-canonical-sync-action", "s", "volume-sync"); + } return slider; } |