From a87ed3b20459a9f067718e0212306008f2dfdaef Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 22 Nov 2023 21:28:00 +0100 Subject: Use different code path for Lomiri notifications --- src/info-notification.vala | 47 ++++++++++++++++++++++++++++------------------ src/warn-notification.vala | 5 +++++ 2 files changed, 34 insertions(+), 18 deletions(-) mode change 100644 => 100755 src/info-notification.vala (limited to 'src') diff --git a/src/info-notification.vala b/src/info-notification.vala old mode 100644 new mode 100755 index 5e67be1..3915ebb --- 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 (); }); -- cgit v1.2.3