aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2014-10-02 11:22:20 -0500
committerTed Gould <ted@gould.cx>2014-10-02 11:22:20 -0500
commit4f500f48301cbc7140b87034d3e1326a0a3b917a (patch)
treeb8b12cc6eddb77a35de5948d43d36518975eb207
parentdab455206972c36d086ae97da776ddd00795899a (diff)
downloadayatana-indicator-sound-4f500f48301cbc7140b87034d3e1326a0a3b917a.tar.gz
ayatana-indicator-sound-4f500f48301cbc7140b87034d3e1326a0a3b917a.tar.bz2
ayatana-indicator-sound-4f500f48301cbc7140b87034d3e1326a0a3b917a.zip
Pull complex logic into its own function
-rw-r--r--src/service.vala21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/service.vala b/src/service.vala
index d869053..a78519d 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -227,10 +227,26 @@ public class IndicatorSound.Service: Object {
return icon.serialize ();
}
+ /* This kinda got complex with both mute and silent mode. So we're
+ gonna put it into a function */
+ bool user_sound_output () {
+ if (this.volume_control.mute) {
+ return false;
+ }
+
+ if (this.accounts_service != null) {
+ if (this.accounts_service.silentMode) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
void update_root_icon () {
double volume = this.volume_control.get_volume ();
string icon;
- if (this.volume_control.mute || (this.accounts_service != null && this.accounts_service.silentMode))
+ if (!user_sound_output())
icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel";
else if (volume <= 0.0)
icon = "audio-volume-low-zero-panel";
@@ -242,7 +258,7 @@ public class IndicatorSound.Service: Object {
icon = "audio-volume-high-panel";
string accessible_name;
- if (this.volume_control.mute) {
+ if (!user_sound_output()) {
accessible_name = _("Volume (muted)");
} else {
int volume_int = (int)(volume * 100);
@@ -274,6 +290,7 @@ public class IndicatorSound.Service: Object {
this.accounts_service.notify["silentMode"].connect(() => {
silent_action.set_state(new Variant.boolean(this.accounts_service.silentMode));
+ this.update_root_icon ();
});
silent_action.activate.connect ((action, param) => {