From f0b5cc08bb303864981d8c011faab495aa4e6781 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Sun, 15 Sep 2013 20:31:36 +0200 Subject: Don't show the "Mute" menu item in the phone profile --- src/service.vala | 4 ++-- src/sound-menu.vala | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index 1b3a81a..f43a1a1 100644 --- a/src/service.vala +++ b/src/service.vala @@ -34,8 +34,8 @@ public class IndicatorSound.Service { this.actions.add_action (this.create_mic_volume_action ()); this.menus = new HashTable (str_hash, str_equal); - this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings")); - this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings")); + this.menus.insert ("desktop", new SoundMenu (true, "indicator.desktop-settings")); + this.menus.insert ("phone", new SoundMenu (false, "indicator.phone-settings")); 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 b08db93..251f2f5 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -22,14 +22,15 @@ extern Variant? g_icon_serialize (Icon icon); class SoundMenu: Object { - public SoundMenu (string settings_action) { + public SoundMenu (bool show_mute, string settings_action) { /* A sound menu always has at least two sections: the volume section (this.volume_section) * at the start of the menu, and the settings section at the end. Between those two, * it has a dynamic amount of player sections, one for each registered player. */ this.volume_section = new Menu (); - volume_section.append (_("Mute"), "indicator.mute"); + if (show_mute) + volume_section.append (_("Mute"), "indicator.mute"); volume_section.append_item (this.create_slider_menu_item ("indicator.volume", 0.0, 1.0, 0.01, "audio-volume-low-zero-panel", "audio-volume-high-panel")); -- cgit v1.2.3 From f23473220d279171d4659fe5400fc95982de3e86 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Sun, 15 Sep 2013 20:39:49 +0200 Subject: 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. --- src/sound-menu.vala | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') 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) { -- cgit v1.2.3