From 29576aceb257c868e5871972a1440b8602f2880b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 08:06:55 -0500 Subject: Adding a high volume warning menu item --- src/sound-menu.vala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/sound-menu.vala') diff --git a/src/sound-menu.vala b/src/sound-menu.vala index f245a1f..0094c22 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -25,7 +25,9 @@ public class SoundMenu: Object HIDE_INACTIVE_PLAYERS = 2, HIDE_PLAYERS = 4, GREETER_PLAYERS = 8, - SHOW_SILENT_MODE = 16 + SHOW_SILENT_MODE = 16, + HIGH_VOLUME_WARNING = 32 /* Everyone should get this eventually, but we don't + want it in the desktop initially because of freezes */ } public SoundMenu (string? settings_action, DisplayFlags flags) { @@ -48,6 +50,9 @@ public class SoundMenu: Object "audio-volume-low-zero-panel", "audio-volume-high-panel")); + if ((flags & DisplayFlags.HIGH_VOLUME_WARNING) != 0) + volume_section.append (_("High volume can damage your hearing."), "indicator.high-volume-menu"); + this.menu = new Menu (); this.menu.append_section (null, volume_section); -- cgit v1.2.3 From 16828d0102efae82bf760097988474e434b884fd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 10:07:30 -0500 Subject: Changing tact to change the menu when we want to show the warning --- src/sound-menu.vala | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/sound-menu.vala') diff --git a/src/sound-menu.vala b/src/sound-menu.vala index 0094c22..e1c4e98 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -25,9 +25,7 @@ public class SoundMenu: Object HIDE_INACTIVE_PLAYERS = 2, HIDE_PLAYERS = 4, GREETER_PLAYERS = 8, - SHOW_SILENT_MODE = 16, - HIGH_VOLUME_WARNING = 32 /* Everyone should get this eventually, but we don't - want it in the desktop initially because of freezes */ + SHOW_SILENT_MODE = 16 } public SoundMenu (string? settings_action, DisplayFlags flags) { @@ -50,9 +48,6 @@ public class SoundMenu: Object "audio-volume-low-zero-panel", "audio-volume-high-panel")); - if ((flags & DisplayFlags.HIGH_VOLUME_WARNING) != 0) - volume_section.append (_("High volume can damage your hearing."), "indicator.high-volume-menu"); - this.menu = new Menu (); this.menu.append_section (null, volume_section); @@ -98,12 +93,31 @@ public class SoundMenu: Object this.mic_volume_shown = true; } else if (!value && this.mic_volume_shown) { + /* TODO: Make smarter */ this.volume_section.remove (this.volume_section.get_n_items () -1); 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) { + var item = new MenuItem(_("High volume can damage your hearing."), null); + volume_section.append_item (item); + this.high_volume_warning_shown = true; + } + else if (!value && this.high_volume_warning_shown) { + /* TODO: Make smarter */ + this.volume_section.remove (this.volume_section.get_n_items () -1); + this.high_volume_warning_shown = false; + } + } + } + public void add_player (MediaPlayer player) { if (this.notify_handlers.contains (player)) return; @@ -146,6 +160,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 notify_handlers; -- cgit v1.2.3