From 2269139ef937dfd92c39cef15b5385b0070c7883 Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Wed, 16 Mar 2016 15:00:47 +0100 Subject: Changed code to get root icon, tests added --- src/service.vala | 50 +++++++++----------------------------------------- 1 file changed, 9 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index bdc4d40..651ec73 100644 --- a/src/service.vala +++ b/src/service.vala @@ -290,48 +290,16 @@ public class IndicatorSound.Service: Object { private bool block_info_notifications = false; - private static unowned string get_volume_root_icon_by_volume (double volume, VolumeControl.ActiveOutput active_output) { - switch (active_output) { - case VolumeControl.ActiveOutput.SPEAKERS: - case VolumeControl.ActiveOutput.HEADPHONES: - case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: - case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: - case VolumeControl.ActiveOutput.USB_SPEAKER: - case VolumeControl.ActiveOutput.USB_HEADPHONES: - case VolumeControl.ActiveOutput.HDMI_SPEAKER: - case VolumeControl.ActiveOutput.HDMI_HEADPHONES: - if (volume <= 0.0) - return "audio-volume-muted-panel"; - if (volume <= 0.3) - return "audio-volume-low-panel"; - if (volume <= 0.7) - return "audio-volume-medium-panel"; - return "audio-volume-high-panel"; - - default: - return ""; - } - } - private unowned string get_volume_root_icon (double volume, bool mute, VolumeControl.ActiveOutput active_output) { - switch (active_output) { - case VolumeControl.ActiveOutput.SPEAKERS: - case VolumeControl.ActiveOutput.HEADPHONES: - case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: - case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: - case VolumeControl.ActiveOutput.USB_SPEAKER: - case VolumeControl.ActiveOutput.USB_HEADPHONES: - case VolumeControl.ActiveOutput.HDMI_SPEAKER: - case VolumeControl.ActiveOutput.HDMI_HEADPHONES: - if (mute || volume <= 0.0) - return this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; - if (this.accounts_service != null && this.accounts_service.silentMode) - return "audio-volume-muted-panel"; - return get_volume_root_icon_by_volume (volume, active_output); - - default: - return ""; - } + if (mute || volume <= 0.0) + return this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; + if (this.accounts_service != null && this.accounts_service.silentMode) + return "audio-volume-muted-panel"; + if (volume <= 0.3) + return "audio-volume-low-panel"; + if (volume <= 0.7) + return "audio-volume-medium-panel"; + return "audio-volume-high-panel"; } private void update_notification () { -- cgit v1.2.3