aboutsummaryrefslogtreecommitdiff
path: root/src/service.vala
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2015-08-12 09:25:42 -0500
committerCharles Kerr <charles.kerr@canonical.com>2015-08-12 09:25:42 -0500
commit0f5d5ee7a541aeea9a4dcd6d20a64ea0158b0a52 (patch)
treed4c5ba1922f6dade5b7cb8ce88807ab7ad320147 /src/service.vala
parenta78a8c0394bf2d4050b3748e8e753a8935849879 (diff)
downloadayatana-indicator-sound-0f5d5ee7a541aeea9a4dcd6d20a64ea0158b0a52.tar.gz
ayatana-indicator-sound-0f5d5ee7a541aeea9a4dcd6d20a64ea0158b0a52.tar.bz2
ayatana-indicator-sound-0f5d5ee7a541aeea9a4dcd6d20a64ea0158b0a52.zip
copyediting: in new code, use unowned strings where practical, slightly better comments, more consistent method names
Diffstat (limited to 'src/service.vala')
-rw-r--r--src/service.vala33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/service.vala b/src/service.vala
index 8da44da..f1c37a8 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -318,23 +318,26 @@ public class IndicatorSound.Service: Object {
if (notify_server_supports_sync && !block_info_notifications) {
/* Determine Label */
- string volume_label = "";
- if (loud) {
- volume_label = _("High volume can damage your hearing.");
- }
+ unowned string volume_label = loud
+ ? _("High volume can damage your hearing.")
+ : "";
/* Choose an icon */
- string icon = "";
- if (loud)
- icon = "audio-volume-high";
- else if (volume_control.volume.volume <= 0.0)
- icon = "audio-volume-muted";
- else if (volume_control.volume.volume <= 0.3)
- icon = "audio-volume-low";
- else if (volume_control.volume.volume <= 0.7)
- icon = "audio-volume-medium";
- else
+ 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";
+ }
/* Reset the notification */
var n = this.info_notification;
@@ -634,7 +637,7 @@ public class IndicatorSound.Service: Object {
}
private void clamp_to_high_soon() {
- const uint interval_msec = 200; /* arbitrary, but works */
+ const uint interval_msec = 200;
if (_clamp_to_high_timeout == 0)
_clamp_to_high_timeout = Timeout.add(interval_msec, clamp_to_high_idle);
}