diff options
Diffstat (limited to 'src')
-rwxr-xr-x[-rw-r--r--] | src/info-notification.vala | 47 | ||||
-rw-r--r-- | src/warn-notification.vala | 5 |
2 files changed, 34 insertions, 18 deletions
diff --git a/src/info-notification.vala b/src/info-notification.vala index 5e67be1..3915ebb 100644..100755 --- a/src/info-notification.vala +++ b/src/info-notification.vala @@ -25,10 +25,12 @@ public class IndicatorSound.InfoNotification: Notification { private string sReaderSchema = "org.gnome.desktop.a11y.applications"; private string sReaderKey = "screen-reader-enabled"; + private bool bHints = false; protected override Notify.Notification create_notification () { string sUser = GLib.Environment.get_user_name (); + this.bHints = notify_server_supports ("x-lomiri-private-synchronous"); if (sUser == "lightdm") { @@ -39,6 +41,7 @@ public class IndicatorSound.InfoNotification: Notification return new Notify.Notification (_("Volume"), "", "audio-volume-muted"); } + public void show (VolumeControl.ActiveOutput active_output, double volume, bool is_high_volume) { @@ -51,37 +54,45 @@ public class IndicatorSound.InfoNotification: Notification /* Reset the notification */ var n = _notification; - volume_label += "\n"; int32 nValue = ((int32)((volume * 100.0) + 0.5)).clamp(0, 100); - SettingsSchemaSource pSource = SettingsSchemaSource.get_default (); - SettingsSchema pSchema = pSource.lookup (this.sReaderSchema, false); - bool bOrcaActive = false; - if (pSchema != null) + if (!this.bHints) { - Settings pSettings = new Settings (this.sReaderSchema); - bOrcaActive = pSettings.get_boolean (this.sReaderKey); - } + volume_label += "\n"; + SettingsSchemaSource pSource = SettingsSchemaSource.get_default (); + SettingsSchema pSchema = pSource.lookup (this.sReaderSchema, false); + bool bOrcaActive = false; - if (bOrcaActive) - { - string sValue = nValue.to_string (); - volume_label += sValue + "%"; - } - else - { - uint nChars = ((int32)((volume * 20) + 0.5)).clamp(0, 20); + if (pSchema != null) + { + Settings pSettings = new Settings (this.sReaderSchema); + bOrcaActive = pSettings.get_boolean (this.sReaderKey); + } - for (uint nChar = 0; nChar < nChars; nChar++) + if (bOrcaActive) { - volume_label += "◼"; + string sValue = nValue.to_string (); + volume_label += sValue + "%"; + } + else + { + uint nChars = ((int32)((volume * 20) + 0.5)).clamp(0, 20); + + for (uint nChar = 0; nChar < nChars; nChar++) + { + volume_label += "◼"; + } } } n.update (_("Volume"), volume_label, icon); n.clear_hints(); + n.set_hint ("x-lomiri-non-shaped-icon", "true"); + n.set_hint ("x-lomiri-private-synchronous", "true"); + n.set_hint ("x-lomiri-value-bar-tint", is_high_volume ? "true" : "false"); n.set_hint ("value", nValue); + show_notification (); } diff --git a/src/warn-notification.vala b/src/warn-notification.vala index 203758e..ae19571 100644 --- a/src/warn-notification.vala +++ b/src/warn-notification.vala @@ -33,6 +33,11 @@ public class IndicatorSound.WarnNotification: Notification _("Volume"), _("Allow volume above safe level?\nHigh volume can damage your hearing."), "audio-volume-high"); + + n.set_hint ("x-lomiri-non-shaped-icon", "true"); + n.set_hint ("x-lomiri-snap-decisions", "true"); + n.set_hint ("x-lomiri-private-affirmative-tint", "true"); + n.closed.connect ((n) => { n.clear_actions (); }); |