diff options
| author | Ted Gould <ted@gould.cx> | 2014-11-05 17:56:17 +0000 |
|---|---|---|
| committer | CI bot <ps-jenkins@lists.canonical.com> | 2014-11-05 17:56:17 +0000 |
| commit | b9caf5671da45dad55e69f59fc3ce016057567fa (patch) | |
| tree | 05f4c79c23bff1fd757a06592f1d71e16c6a4994 /src/sound-menu.vala | |
| parent | dec2d5350f47e52539941b45d394516066a19678 (diff) | |
| parent | 08bcdc3b069c4c5ce7cb2a769daa8573fce5cd5d (diff) | |
| download | ayatana-indicator-sound-b9caf5671da45dad55e69f59fc3ce016057567fa.tar.gz ayatana-indicator-sound-b9caf5671da45dad55e69f59fc3ce016057567fa.tar.bz2 ayatana-indicator-sound-b9caf5671da45dad55e69f59fc3ce016057567fa.zip | |
Manually merging branches to resolve conflicts Fixes: 1358340, 1373404, 1378564, 1378961, 1381871
Approved by: PS Jenkins bot
Diffstat (limited to 'src/sound-menu.vala')
| -rw-r--r-- | src/sound-menu.vala | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/sound-menu.vala b/src/sound-menu.vala index f245a1f..3881faf 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -93,12 +93,49 @@ public class SoundMenu: Object this.mic_volume_shown = true; } else if (!value && this.mic_volume_shown) { - this.volume_section.remove (this.volume_section.get_n_items () -1); + int location = -1; + while ((location = find_action(this.volume_section, "indicator.mic-volume")) != -1) { + this.volume_section.remove (location); + } this.mic_volume_shown = false; } } } + public bool show_high_volume_warning { + get { + return this.high_volume_warning_shown; + } + set { + if (value && !this.high_volume_warning_shown) { + /* NOTE: Action doesn't really exist, just used to find below when removing */ + var item = new MenuItem(_("High volume can damage your hearing."), "indicator.high-volume-warning-item"); + volume_section.append_item (item); + this.high_volume_warning_shown = true; + } + else if (!value && this.high_volume_warning_shown) { + int location = -1; + while ((location = find_action(this.volume_section, "indicator.high-volume-warning-item")) != -1) { + this.volume_section.remove (location); + } + this.high_volume_warning_shown = false; + } + } + } + + int find_action (Menu menu, string in_action) { + int n = menu.get_n_items (); + for (int i = 0; i < n; i++) { + string action; + menu.get_item_attribute (i, "action", "s", out action); + if (in_action == action) + return i; + } + + return -1; + } + + public void add_player (MediaPlayer player) { if (this.notify_handlers.contains (player)) return; @@ -141,6 +178,7 @@ public class SoundMenu: Object Menu volume_section; bool mic_volume_shown; bool settings_shown = false; + bool high_volume_warning_shown = false; bool hide_inactive; bool hide_players = false; HashTable<MediaPlayer, ulong> notify_handlers; |
