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/service.vala | 4 ++-- src/sound-menu.vala | 27 +++++++++++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index 93e6a51..51060d4 100644 --- a/src/service.vala +++ b/src/service.vala @@ -53,9 +53,9 @@ public class IndicatorSound.Service: Object { this.menus = new HashTable (str_hash, str_equal); this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS)); - this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS | SoundMenu.DisplayFlags.HIGH_VOLUME_WARNING)); + this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS)); this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE)); - this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.HIGH_VOLUME_WARNING)); + this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS)); this.menus.@foreach ( (profile, menu) => { this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE); 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