aboutsummaryrefslogtreecommitdiff
path: root/src/service.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/service.vala')
-rw-r--r--src/service.vala93
1 files changed, 67 insertions, 26 deletions
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;