aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2023-10-07 04:47:56 +0200
committerRobert Tari <robert@tari.in>2023-10-07 04:47:56 +0200
commitc77a05cbd674615719fe43a869cc7c5d8ebbd054 (patch)
tree2828fa3c8ce6b2737bb9ae947a8b680ce04a1fac /src
parentff70460acbf19702464fcf22dc4c21fc20665d0e (diff)
downloadayatana-indicator-sound-c77a05cbd674615719fe43a869cc7c5d8ebbd054.tar.gz
ayatana-indicator-sound-c77a05cbd674615719fe43a869cc7c5d8ebbd054.tar.bz2
ayatana-indicator-sound-c77a05cbd674615719fe43a869cc7c5d8ebbd054.zip
src/info-notification.vala: Display percentage when Orca is enabled
Diffstat (limited to 'src')
-rw-r--r--src/info-notification.vala28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/info-notification.vala b/src/info-notification.vala
index 4379acf..4e246b2 100644
--- a/src/info-notification.vala
+++ b/src/info-notification.vala
@@ -39,18 +39,36 @@ public class IndicatorSound.InfoNotification: Notification
/* Reset the notification */
var n = _notification;
-
- uint nChars = ((int32)((volume * 20) + 0.5)).clamp(0, 20);
volume_label += "\n";
+ int32 nValue = ((int32)((volume * 100.0) + 0.5)).clamp(0, 100);
+ SettingsSchemaSource pSource = SettingsSchemaSource.get_default ();
+ SettingsSchema pSchema = pSource.lookup ("org.gnome.desktop.a11y.applications", false);
+ bool bOrcaActive = false;
+
+ if (pSchema != null)
+ {
+ Settings pSettings = new Settings ("org.gnome.desktop.a11y.applications");
+ bOrcaActive = pSettings.get_boolean ("screen-reader-enabled");
+ }
- 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 ("value", ((int32)((volume * 100.0) + 0.5)).clamp(0, 100));
+ n.set_hint ("value", nValue);
show_notification ();
}