From a7fd579fd1bc6eb02433ccd72e9f54dca2615675 Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Tue, 29 Sep 2015 14:13:45 +0200 Subject: Adding the code to change the icons and label when a bluetooth headset is connected --- src/service.vala | 93 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 67 insertions(+), 26 deletions(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index a08edf3..6215c85 100644 --- a/src/service.vala +++ b/src/service.vala @@ -52,6 +52,7 @@ public class IndicatorSound.Service: Object { this.notify["visible"].connect ( () => this.update_root_icon () ); this.volume_control = volume; + this.volume_control.bluetooth_headset_status_changed.connect (this.update_root_icon); this.accounts_service = accounts; /* If we're on the greeter, don't export */ @@ -90,6 +91,10 @@ public class IndicatorSound.Service: Object { this.volume_control.bind_property ("high-volume", menu, "show-high-volume-warning", BindingFlags.SYNC_CREATE); }); + this.menus.@foreach ( (profile, menu) => { + this.volume_control.bluetooth_headset_status_changed.connect (menu.update_volume_slider); + }); + this.sync_preferred_players (); this.settings.changed["interested-media-players"].connect ( () => { this.sync_preferred_players (); @@ -245,17 +250,7 @@ public class IndicatorSound.Service: Object { void update_root_icon () { double volume = this.volume_control.volume.volume; - string icon; - if (this.volume_control.mute || volume <= 0.0) - icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; - else if (this.accounts_service != null && this.accounts_service.silentMode) - icon = "audio-volume-muted-panel"; - else if (volume <= 0.3) - icon = "audio-volume-low-panel"; - else if (volume <= 0.7) - icon = "audio-volume-medium-panel"; - else - icon = "audio-volume-high-panel"; + string icon = get_volume_root_icon (volume, this.volume_control.mute, volume_control.active_bluetooth_headphone); string accessible_name; if (this.volume_control.mute) { @@ -282,6 +277,66 @@ public class IndicatorSound.Service: Object { private bool notify_server_supports_sync = false; private bool block_info_notifications = false; + private string get_volume_notification_icon (double volume, bool loud, bool is_bluetooth_headset_active) { + string icon = ""; + if (is_bluetooth_headset_active) { + if (loud) { + icon = "audio-volume-high"; + } else { + if (volume <= 0.0) + icon = "audio-volume-muted"; + else if (volume <= 0.3) + icon = "audio-volume-low"; + else if (volume <= 0.7) + icon = "audio-volume-medium"; + else + icon = "audio-volume-high"; + } + } else { + if (loud) { + icon = "audio-volume-high"; + } else { + if (volume <= 0.0) + icon = "audio-volume-muted"; + else if (volume <= 0.3) + icon = "audio-volume-low"; + else if (volume <= 0.7) + icon = "audio-volume-medium"; + else + icon = "audio-volume-high"; + } + } + return icon; + } + + private string get_volume_root_icon (double volume, bool mute, bool is_bluetooth_headset_active) { + string icon; + if (is_bluetooth_headset_active) { + if (mute || volume <= 0.0) + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; + else if (this.accounts_service != null && this.accounts_service.silentMode) + icon = "audio-volume-muted-panel"; + else if (volume <= 0.3) + icon = "audio-volume-low-panel"; + else if (volume <= 0.7) + icon = "audio-volume-medium-panel"; + else + icon = "audio-volume-high-panel"; + } else { + if (mute || volume <= 0.0) + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; + else if (this.accounts_service != null && this.accounts_service.silentMode) + icon = "audio-volume-muted-panel"; + else if (volume <= 0.3) + icon = "audio-volume-low-panel"; + else if (volume <= 0.7) + icon = "audio-volume-medium-panel"; + else + icon = "audio-volume-high-panel"; + } + return icon; + } + private void update_notification () { if (!notify_server_caps_checked) { @@ -328,21 +383,7 @@ public class IndicatorSound.Service: Object { : ""; /* Choose an icon */ - unowned string icon; - if (loud) { - icon = "audio-volume-high"; - } else { - var volume = volume_control.volume.volume; - - if (volume <= 0.0) - icon = "audio-volume-muted"; - else if (volume <= 0.3) - icon = "audio-volume-low"; - else if (volume <= 0.7) - icon = "audio-volume-medium"; - else - icon = "audio-volume-high"; - } + string icon = get_volume_notification_icon (volume_control.volume.volume, loud, volume_control.active_bluetooth_headphone); /* Reset the notification */ var n = this.info_notification; -- cgit v1.2.3 From 33a73fad65c52fc324ad3d35a6d1305a1489958d Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Thu, 1 Oct 2015 09:55:22 +0200 Subject: Changed to show a notification when the active output changes --- src/service.vala | 109 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 71 insertions(+), 38 deletions(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 6215c85..a1850d0 100644 --- a/src/service.vala +++ b/src/service.vala @@ -52,7 +52,8 @@ public class IndicatorSound.Service: Object { this.notify["visible"].connect ( () => this.update_root_icon () ); this.volume_control = volume; - this.volume_control.bluetooth_headset_status_changed.connect (this.update_root_icon); + this.volume_control.active_output_changed.connect (this.update_root_icon); + this.volume_control.active_output_changed.connect (this.update_notification); this.accounts_service = accounts; /* If we're on the greeter, don't export */ @@ -92,7 +93,7 @@ public class IndicatorSound.Service: Object { }); this.menus.@foreach ( (profile, menu) => { - this.volume_control.bluetooth_headset_status_changed.connect (menu.update_volume_slider); + this.volume_control.active_output_changed.connect (menu.update_volume_slider); }); this.sync_preferred_players (); @@ -250,7 +251,7 @@ public class IndicatorSound.Service: Object { void update_root_icon () { double volume = this.volume_control.volume.volume; - string icon = get_volume_root_icon (volume, this.volume_control.mute, volume_control.active_bluetooth_headphone); + string icon = get_volume_root_icon (volume, this.volume_control.mute, volume_control.active_output); string accessible_name; if (this.volume_control.mute) { @@ -277,12 +278,12 @@ public class IndicatorSound.Service: Object { private bool notify_server_supports_sync = false; private bool block_info_notifications = false; - private string get_volume_notification_icon (double volume, bool loud, bool is_bluetooth_headset_active) { + private string get_volume_icon (double volume, VolumeControl.ActiveOutput active_output) + { string icon = ""; - if (is_bluetooth_headset_active) { - if (loud) { - icon = "audio-volume-high"; - } else { + switch (active_output) + { + case VolumeControl.ActiveOutput.SPEAKERS: if (volume <= 0.0) icon = "audio-volume-muted"; else if (volume <= 0.3) @@ -291,11 +292,18 @@ public class IndicatorSound.Service: Object { icon = "audio-volume-medium"; else icon = "audio-volume-high"; - } - } else { - if (loud) { - icon = "audio-volume-high"; - } else { + break; + case VolumeControl.ActiveOutput.HEADPHONES: + if (volume <= 0.0) + icon = "audio-volume-muted"; + else if (volume <= 0.3) + icon = "audio-volume-low"; + else if (volume <= 0.7) + icon = "audio-volume-medium"; + else + icon = "audio-volume-high"; + break; + case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: if (volume <= 0.0) icon = "audio-volume-muted"; else if (volume <= 0.3) @@ -304,35 +312,60 @@ public class IndicatorSound.Service: Object { icon = "audio-volume-medium"; else icon = "audio-volume-high"; + break; + } + return icon; + } + + private string get_volume_notification_icon (double volume, bool loud, VolumeControl.ActiveOutput active_output) { + string icon = ""; + if (loud) { + switch (active_output) + { + case VolumeControl.ActiveOutput.SPEAKERS: + icon = "audio-volume-high"; + break; + case VolumeControl.ActiveOutput.HEADPHONES: + icon = "audio-volume-high"; + break; + case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: + icon = "audio-volume-high"; + break; } + } else { + icon = get_volume_icon (volume, active_output); } return icon; } - private string get_volume_root_icon (double volume, bool mute, bool is_bluetooth_headset_active) { - string icon; - if (is_bluetooth_headset_active) { - if (mute || volume <= 0.0) - icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; - else if (this.accounts_service != null && this.accounts_service.silentMode) - icon = "audio-volume-muted-panel"; - else if (volume <= 0.3) - icon = "audio-volume-low-panel"; - else if (volume <= 0.7) - icon = "audio-volume-medium-panel"; - else - icon = "audio-volume-high-panel"; - } else { - if (mute || volume <= 0.0) - icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; - else if (this.accounts_service != null && this.accounts_service.silentMode) - icon = "audio-volume-muted-panel"; - else if (volume <= 0.3) - icon = "audio-volume-low-panel"; - else if (volume <= 0.7) - icon = "audio-volume-medium-panel"; - else - icon = "audio-volume-high-panel"; + private string get_volume_root_icon (double volume, bool mute, VolumeControl.ActiveOutput active_output) { + string icon = ""; + switch (active_output) + { + case VolumeControl.ActiveOutput.SPEAKERS: + if (mute || volume <= 0.0) + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; + else if (this.accounts_service != null && this.accounts_service.silentMode) + icon = "audio-volume-muted-panel"; + else + icon = get_volume_icon (volume, active_output); + break; + case VolumeControl.ActiveOutput.HEADPHONES: + if (mute || volume <= 0.0) + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; + else if (this.accounts_service != null && this.accounts_service.silentMode) + icon = "audio-volume-muted-panel"; + else + icon = get_volume_icon (volume, active_output); + break; + case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: + if (mute || volume <= 0.0) + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; + else if (this.accounts_service != null && this.accounts_service.silentMode) + icon = "audio-volume-muted-panel"; + else + icon = get_volume_icon (volume, active_output); + break; } return icon; } @@ -383,7 +416,7 @@ public class IndicatorSound.Service: Object { : ""; /* Choose an icon */ - string icon = get_volume_notification_icon (volume_control.volume.volume, loud, volume_control.active_bluetooth_headphone); + string icon = get_volume_notification_icon (volume_control.volume.volume, loud, volume_control.active_output); /* Reset the notification */ var n = this.info_notification; -- cgit v1.2.3 From e49548a7edb0d4d8a3420cc6c0be2b0e15f57bcf Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Fri, 2 Oct 2015 12:46:54 +0200 Subject: Updated to show a label stating the active output --- src/service.vala | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index a1850d0..15fd97e 100644 --- a/src/service.vala +++ b/src/service.vala @@ -411,9 +411,23 @@ public class IndicatorSound.Service: Object { if (notify_server_supports_sync && !block_info_notifications) { /* Determine Label */ - unowned string volume_label = loud + string volume_label = loud ? _("High volume can damage your hearing.") : ""; + + if (volume_label == "") { + if (volume_control.active_output == VolumeControl.ActiveOutput.SPEAKERS) { + volume_label = _("Speakers"); + } + + if (volume_control.active_output == VolumeControl.ActiveOutput.HEADPHONES) { + volume_label = _("Headphones"); + } + + if (volume_control.active_output == VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES) { + volume_label = _("Bluetooth"); + } + } /* Choose an icon */ string icon = get_volume_notification_icon (volume_control.volume.volume, loud, volume_control.active_output); -- cgit v1.2.3 From 24ab28edf43e3ec188d110d08c810567539d8eb4 Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Mon, 5 Oct 2015 12:10:49 +0200 Subject: Added USB and HDMI active outputs --- src/service.vala | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 129 insertions(+), 4 deletions(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 15fd97e..e3e91f5 100644 --- a/src/service.vala +++ b/src/service.vala @@ -313,6 +313,56 @@ public class IndicatorSound.Service: Object { else icon = "audio-volume-high"; break; + case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: + if (volume <= 0.0) + icon = "audio-volume-muted"; + else if (volume <= 0.3) + icon = "audio-volume-low"; + else if (volume <= 0.7) + icon = "audio-volume-medium"; + else + icon = "audio-volume-high"; + break; + case VolumeControl.ActiveOutput.USB_SPEAKER: + if (volume <= 0.0) + icon = "audio-volume-muted"; + else if (volume <= 0.3) + icon = "audio-volume-low"; + else if (volume <= 0.7) + icon = "audio-volume-medium"; + else + icon = "audio-volume-high"; + break; + case VolumeControl.ActiveOutput.USB_HEADPHONES: + if (volume <= 0.0) + icon = "audio-volume-muted"; + else if (volume <= 0.3) + icon = "audio-volume-low"; + else if (volume <= 0.7) + icon = "audio-volume-medium"; + else + icon = "audio-volume-high"; + break; + case VolumeControl.ActiveOutput.HDMI_SPEAKER: + if (volume <= 0.0) + icon = "audio-volume-muted"; + else if (volume <= 0.3) + icon = "audio-volume-low"; + else if (volume <= 0.7) + icon = "audio-volume-medium"; + else + icon = "audio-volume-high"; + break; + case VolumeControl.ActiveOutput.HDMI_HEADPHONES: + if (volume <= 0.0) + icon = "audio-volume-muted"; + else if (volume <= 0.3) + icon = "audio-volume-low"; + else if (volume <= 0.7) + icon = "audio-volume-medium"; + else + icon = "audio-volume-high"; + break; } return icon; } @@ -331,6 +381,21 @@ public class IndicatorSound.Service: Object { case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: icon = "audio-volume-high"; break; + case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: + icon = "audio-volume-high"; + break; + case VolumeControl.ActiveOutput.USB_SPEAKER: + icon = "audio-volume-high"; + break; + case VolumeControl.ActiveOutput.USB_HEADPHONES: + icon = "audio-volume-high"; + break; + case VolumeControl.ActiveOutput.HDMI_SPEAKER: + icon = "audio-volume-high"; + break; + case VolumeControl.ActiveOutput.HDMI_HEADPHONES: + icon = "audio-volume-high"; + break; } } else { icon = get_volume_icon (volume, active_output); @@ -366,6 +431,46 @@ public class IndicatorSound.Service: Object { else icon = get_volume_icon (volume, active_output); break; + case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: + if (mute || volume <= 0.0) + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; + else if (this.accounts_service != null && this.accounts_service.silentMode) + icon = "audio-volume-muted-panel"; + else + icon = get_volume_icon (volume, active_output); + break; + case VolumeControl.ActiveOutput.USB_SPEAKER: + if (mute || volume <= 0.0) + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; + else if (this.accounts_service != null && this.accounts_service.silentMode) + icon = "audio-volume-muted-panel"; + else + icon = get_volume_icon (volume, active_output); + break; + case VolumeControl.ActiveOutput.USB_HEADPHONES: + if (mute || volume <= 0.0) + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; + else if (this.accounts_service != null && this.accounts_service.silentMode) + icon = "audio-volume-muted-panel"; + else + icon = get_volume_icon (volume, active_output); + break; + case VolumeControl.ActiveOutput.HDMI_SPEAKER: + if (mute || volume <= 0.0) + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; + else if (this.accounts_service != null && this.accounts_service.silentMode) + icon = "audio-volume-muted-panel"; + else + icon = get_volume_icon (volume, active_output); + break; + case VolumeControl.ActiveOutput.HDMI_HEADPHONES: + if (mute || volume <= 0.0) + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; + else if (this.accounts_service != null && this.accounts_service.silentMode) + icon = "audio-volume-muted-panel"; + else + icon = get_volume_icon (volume, active_output); + break; } return icon; } @@ -421,12 +526,32 @@ public class IndicatorSound.Service: Object { } if (volume_control.active_output == VolumeControl.ActiveOutput.HEADPHONES) { - volume_label = _("Headphones"); - } + volume_label = _("Headphones"); + } if (volume_control.active_output == VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES) { - volume_label = _("Bluetooth"); - } + volume_label = _("Bluetooth headphones"); + } + + if (volume_control.active_output == VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER) { + volume_label = _("Bluetooth speaker"); + } + + if (volume_control.active_output == VolumeControl.ActiveOutput.USB_SPEAKER) { + volume_label = _("Usb speaker"); + } + + if (volume_control.active_output == VolumeControl.ActiveOutput.USB_HEADPHONES) { + volume_label = _("Usb headphones"); + } + + if (volume_control.active_output == VolumeControl.ActiveOutput.HDMI_SPEAKER) { + volume_label = _("HDMI speaker"); + } + + if (volume_control.active_output == VolumeControl.ActiveOutput.HDMI_HEADPHONES) { + volume_label = _("HDMI headphones"); + } } /* Choose an icon */ -- cgit v1.2.3 From d3802b66c55e50ff1b9e2103cd446cb586d8acb3 Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Mon, 5 Oct 2015 14:20:14 +0200 Subject: fixed panel root panel icons --- src/service.vala | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 97 insertions(+), 8 deletions(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index e3e91f5..8b08dc0 100644 --- a/src/service.vala +++ b/src/service.vala @@ -367,6 +367,95 @@ public class IndicatorSound.Service: Object { return icon; } + private string get_volume_root_icon_by_volume (double volume, VolumeControl.ActiveOutput active_output) + { + string icon = ""; + switch (active_output) + { + case VolumeControl.ActiveOutput.SPEAKERS: + if (volume <= 0.0) + icon = "audio-volume-muted-panel"; + else if (volume <= 0.3) + icon = "audio-volume-low-panel"; + else if (volume <= 0.7) + icon = "audio-volume-medium-panel"; + else + icon = "audio-volume-high-panel"; + break; + case VolumeControl.ActiveOutput.HEADPHONES: + if (volume <= 0.0) + icon = "audio-volume-muted-panel"; + else if (volume <= 0.3) + icon = "audio-volume-low-panel"; + else if (volume <= 0.7) + icon = "audio-volume-medium-panel"; + else + icon = "audio-volume-high-panel"; + break; + case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: + if (volume <= 0.0) + icon = "audio-volume-muted-panel"; + else if (volume <= 0.3) + icon = "audio-volume-low-panel"; + else if (volume <= 0.7) + icon = "audio-volume-medium-panel"; + else + icon = "audio-volume-high-panel"; + break; + case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: + if (volume <= 0.0) + icon = "audio-volume-muted-panel"; + else if (volume <= 0.3) + icon = "audio-volume-low-panel"; + else if (volume <= 0.7) + icon = "audio-volume-medium-panel"; + else + icon = "audio-volume-high-panel"; + break; + case VolumeControl.ActiveOutput.USB_SPEAKER: + if (volume <= 0.0) + icon = "audio-volume-muted-panel"; + else if (volume <= 0.3) + icon = "audio-volume-low-panel"; + else if (volume <= 0.7) + icon = "audio-volume-medium-panel"; + else + icon = "audio-volume-high-panel"; + break; + case VolumeControl.ActiveOutput.USB_HEADPHONES: + if (volume <= 0.0) + icon = "audio-volume-muted-panel"; + else if (volume <= 0.3) + icon = "audio-volume-low-panel"; + else if (volume <= 0.7) + icon = "audio-volume-medium-panel"; + else + icon = "audio-volume-high-panel"; + break; + case VolumeControl.ActiveOutput.HDMI_SPEAKER: + if (volume <= 0.0) + icon = "audio-volume-muted-panel"; + else if (volume <= 0.3) + icon = "audio-volume-low-panel"; + else if (volume <= 0.7) + icon = "audio-volume-medium-panel"; + else + icon = "audio-volume-high-panel"; + break; + case VolumeControl.ActiveOutput.HDMI_HEADPHONES: + if (volume <= 0.0) + icon = "audio-volume-muted-panel"; + else if (volume <= 0.3) + icon = "audio-volume-low-panel"; + else if (volume <= 0.7) + icon = "audio-volume-medium-panel"; + else + icon = "audio-volume-high-panel"; + break; + } + return icon; + } + private string get_volume_notification_icon (double volume, bool loud, VolumeControl.ActiveOutput active_output) { string icon = ""; if (loud) { @@ -413,7 +502,7 @@ public class IndicatorSound.Service: Object { else if (this.accounts_service != null && this.accounts_service.silentMode) icon = "audio-volume-muted-panel"; else - icon = get_volume_icon (volume, active_output); + icon = get_volume_root_icon_by_volume (volume, active_output); break; case VolumeControl.ActiveOutput.HEADPHONES: if (mute || volume <= 0.0) @@ -421,7 +510,7 @@ public class IndicatorSound.Service: Object { else if (this.accounts_service != null && this.accounts_service.silentMode) icon = "audio-volume-muted-panel"; else - icon = get_volume_icon (volume, active_output); + icon = get_volume_root_icon_by_volume (volume, active_output); break; case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: if (mute || volume <= 0.0) @@ -429,7 +518,7 @@ public class IndicatorSound.Service: Object { else if (this.accounts_service != null && this.accounts_service.silentMode) icon = "audio-volume-muted-panel"; else - icon = get_volume_icon (volume, active_output); + icon = get_volume_root_icon_by_volume (volume, active_output); break; case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: if (mute || volume <= 0.0) @@ -437,7 +526,7 @@ public class IndicatorSound.Service: Object { else if (this.accounts_service != null && this.accounts_service.silentMode) icon = "audio-volume-muted-panel"; else - icon = get_volume_icon (volume, active_output); + icon = get_volume_root_icon_by_volume (volume, active_output); break; case VolumeControl.ActiveOutput.USB_SPEAKER: if (mute || volume <= 0.0) @@ -445,7 +534,7 @@ public class IndicatorSound.Service: Object { else if (this.accounts_service != null && this.accounts_service.silentMode) icon = "audio-volume-muted-panel"; else - icon = get_volume_icon (volume, active_output); + icon = get_volume_root_icon_by_volume (volume, active_output); break; case VolumeControl.ActiveOutput.USB_HEADPHONES: if (mute || volume <= 0.0) @@ -453,7 +542,7 @@ public class IndicatorSound.Service: Object { else if (this.accounts_service != null && this.accounts_service.silentMode) icon = "audio-volume-muted-panel"; else - icon = get_volume_icon (volume, active_output); + icon = get_volume_root_icon_by_volume (volume, active_output); break; case VolumeControl.ActiveOutput.HDMI_SPEAKER: if (mute || volume <= 0.0) @@ -461,7 +550,7 @@ public class IndicatorSound.Service: Object { else if (this.accounts_service != null && this.accounts_service.silentMode) icon = "audio-volume-muted-panel"; else - icon = get_volume_icon (volume, active_output); + icon = get_volume_root_icon_by_volume (volume, active_output); break; case VolumeControl.ActiveOutput.HDMI_HEADPHONES: if (mute || volume <= 0.0) @@ -469,7 +558,7 @@ public class IndicatorSound.Service: Object { else if (this.accounts_service != null && this.accounts_service.silentMode) icon = "audio-volume-muted-panel"; else - icon = get_volume_icon (volume, active_output); + icon = get_volume_root_icon_by_volume (volume, active_output); break; } return icon; -- cgit v1.2.3 From cc77ef3dd05a0e52a74b1ac073b95bd041a2f0d1 Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Fri, 16 Oct 2015 16:49:28 +0200 Subject: Fixed race condition connection to the Notifications interface --- src/service.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 8b08dc0..65d5943 100644 --- a/src/service.vala +++ b/src/service.vala @@ -43,7 +43,7 @@ public class IndicatorSound.Service: Object { warn_notification.closed.connect((n) => { n.clear_actions(); }); BusWatcher.watch_namespace (GLib.BusType.SESSION, "org.freedesktop.Notifications", - () => { debug("Notifications name appeared"); notify_server_caps_checked = false; }, + () => { debug("Notifications name appeared"); }, () => { debug("Notifications name vanshed"); notify_server_caps_checked = false; }); this.settings = new Settings ("com.canonical.indicator.sound"); -- cgit v1.2.3 From 86c449a7125f3ff90dcac353c8a4ad5a8c2cc46e Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Wed, 21 Oct 2015 14:53:42 +0200 Subject: Fixed issue with warning notification. Fixed race conditions in tests --- src/service.vala | 108 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 51 deletions(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 65d5943..9749089 100644 --- a/src/service.vala +++ b/src/service.vala @@ -277,6 +277,7 @@ public class IndicatorSound.Service: Object { private bool notify_server_supports_actions = false; private bool notify_server_supports_sync = false; private bool block_info_notifications = false; + private bool waiting_user_approve_warn = false; private string get_volume_icon (double volume, VolumeControl.ActiveOutput active_output) { @@ -594,67 +595,72 @@ public class IndicatorSound.Service: Object { _pre_warn_volume = null; volume_control.volume = tmp; } + waiting_user_approve_warn = false; }); warn_notification.add_action ("cancel", _("Cancel"), (n, a) => { _pre_warn_volume = null; + waiting_user_approve_warn = false; }); + waiting_user_approve_warn = true; show_notification(warn_notification); } else { - close_notification(warn_notification); - - if (notify_server_supports_sync && !block_info_notifications) { - - /* Determine Label */ - string volume_label = loud - ? _("High volume can damage your hearing.") - : ""; + if (!waiting_user_approve_warn) { + close_notification(warn_notification); + + if (notify_server_supports_sync && !block_info_notifications) { + + /* Determine Label */ + string volume_label = loud + ? _("High volume can damage your hearing.") + : ""; - if (volume_label == "") { - if (volume_control.active_output == VolumeControl.ActiveOutput.SPEAKERS) { - volume_label = _("Speakers"); - } - - if (volume_control.active_output == VolumeControl.ActiveOutput.HEADPHONES) { - volume_label = _("Headphones"); - } - - if (volume_control.active_output == VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES) { - volume_label = _("Bluetooth headphones"); - } - - if (volume_control.active_output == VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER) { - volume_label = _("Bluetooth speaker"); - } - - if (volume_control.active_output == VolumeControl.ActiveOutput.USB_SPEAKER) { - volume_label = _("Usb speaker"); - } - - if (volume_control.active_output == VolumeControl.ActiveOutput.USB_HEADPHONES) { - volume_label = _("Usb headphones"); - } + if (volume_label == "") { + if (volume_control.active_output == VolumeControl.ActiveOutput.SPEAKERS) { + volume_label = _("Speakers"); + } + + if (volume_control.active_output == VolumeControl.ActiveOutput.HEADPHONES) { + volume_label = _("Headphones"); + } + + if (volume_control.active_output == VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES) { + volume_label = _("Bluetooth headphones"); + } + + if (volume_control.active_output == VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER) { + volume_label = _("Bluetooth speaker"); + } + + if (volume_control.active_output == VolumeControl.ActiveOutput.USB_SPEAKER) { + volume_label = _("Usb speaker"); + } + + if (volume_control.active_output == VolumeControl.ActiveOutput.USB_HEADPHONES) { + volume_label = _("Usb headphones"); + } + + if (volume_control.active_output == VolumeControl.ActiveOutput.HDMI_SPEAKER) { + volume_label = _("HDMI speaker"); + } - if (volume_control.active_output == VolumeControl.ActiveOutput.HDMI_SPEAKER) { - volume_label = _("HDMI speaker"); - } - - if (volume_control.active_output == VolumeControl.ActiveOutput.HDMI_HEADPHONES) { - volume_label = _("HDMI headphones"); + if (volume_control.active_output == VolumeControl.ActiveOutput.HDMI_HEADPHONES) { + volume_label = _("HDMI headphones"); + } } + + /* Choose an icon */ + string icon = get_volume_notification_icon (volume_control.volume.volume, loud, volume_control.active_output); + + /* Reset the notification */ + var n = this.info_notification; + n.update (_("Volume"), volume_label, icon); + n.clear_hints(); + n.set_hint ("x-canonical-non-shaped-icon", "true"); + n.set_hint ("x-canonical-private-synchronous", "true"); + n.set_hint ("x-canonical-value-bar-tint", loud ? "true" : "false"); + n.set_hint ("value", (int32)Math.round(get_volume_percent() * 100.0)); + show_notification(n); } - - /* Choose an icon */ - string icon = get_volume_notification_icon (volume_control.volume.volume, loud, volume_control.active_output); - - /* Reset the notification */ - var n = this.info_notification; - n.update (_("Volume"), volume_label, icon); - n.clear_hints(); - n.set_hint ("x-canonical-non-shaped-icon", "true"); - n.set_hint ("x-canonical-private-synchronous", "true"); - n.set_hint ("x-canonical-value-bar-tint", loud ? "true" : "false"); - n.set_hint ("value", (int32)Math.round(get_volume_percent() * 100.0)); - show_notification(n); } } } -- cgit v1.2.3