diff options
author | Robert Tari <robert@tari.in> | 2023-11-22 21:28:00 +0100 |
---|---|---|
committer | Robert Tari <robert@tari.in> | 2023-11-28 20:33:25 +0100 |
commit | a87ed3b20459a9f067718e0212306008f2dfdaef (patch) | |
tree | c35fb032ebcfc90658c863164d55e7bc9a20a48a /src | |
parent | 3e8aab9eaf85ec528d6a0465a162c017934b3b5d (diff) | |
download | ayatana-indicator-sound-a87ed3b20459a9f067718e0212306008f2dfdaef.tar.gz ayatana-indicator-sound-a87ed3b20459a9f067718e0212306008f2dfdaef.tar.bz2 ayatana-indicator-sound-a87ed3b20459a9f067718e0212306008f2dfdaef.zip |
Use different code path for Lomiri notifications
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 (); }); |