diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-09-15 20:39:49 +0200 |
---|---|---|
committer | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-09-15 20:39:49 +0200 |
commit | f23473220d279171d4659fe5400fc95982de3e86 (patch) | |
tree | 0d9c3bed43f6f6e9e22c4d5fd9d3cf55a1dc0e12 /src | |
parent | f0b5cc08bb303864981d8c011faab495aa4e6781 (diff) | |
download | ayatana-indicator-sound-f23473220d279171d4659fe5400fc95982de3e86.tar.gz ayatana-indicator-sound-f23473220d279171d4659fe5400fc95982de3e86.tar.bz2 ayatana-indicator-sound-f23473220d279171d4659fe5400fc95982de3e86.zip |
sound-menu.vala: make the logic for showing the mic volume more explicit
Before, this was done by counting the items that are currently in the volume
section. This broke with the last commit, because with that, the section might
not contain a mute menu item.
Diffstat (limited to 'src')
-rw-r--r-- | src/sound-menu.vala | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/sound-menu.vala b/src/sound-menu.vala index 251f2f5..fe61cdf 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -59,17 +59,19 @@ class SoundMenu: Object public bool show_mic_volume { get { - return this.volume_section.get_n_items () == 3; + return this.mic_volume_shown; } set { - if (value && this.volume_section.get_n_items () < 3) { + if (value && !this.mic_volume_shown) { var slider = this.create_slider_menu_item ("indicator.mic-volume", 0.0, 1.0, 0.01, "audio-input-microphone-low-zero-panel", "audio-input-microphone-high-panel"); volume_section.append_item (slider); + this.mic_volume_shown = true; } - else if (!value && this.volume_section.get_n_items () > 2) { - this.volume_section.remove (2); + else if (!value && this.mic_volume_shown) { + this.volume_section.remove (this.volume_section.get_n_items () -1); + this.mic_volume_shown = false; } } } @@ -106,6 +108,7 @@ class SoundMenu: Object Menu root; Menu menu; Menu volume_section; + bool mic_volume_shown; /* returns the position in this.menu of the section that's associated with @player */ int find_player_section (MediaPlayer player) { |