diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-10-10 15:46:54 +0200 |
---|---|---|
committer | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-10-10 15:46:54 +0200 |
commit | 071576b6e7b3d979c1fcefd611b67bac171f2877 (patch) | |
tree | 57fe5be3dd82bf341d94890ec1b505494e2a9a44 /src | |
parent | 7ffdaac644f29bd1ee63a861f42a4ea8c26e52eb (diff) | |
download | ayatana-indicator-sound-071576b6e7b3d979c1fcefd611b67bac171f2877.tar.gz ayatana-indicator-sound-071576b6e7b3d979c1fcefd611b67bac171f2877.tar.bz2 ayatana-indicator-sound-071576b6e7b3d979c1fcefd611b67bac171f2877.zip |
Replace 'mute' boolean by a flag in the SoundMenu constructor
This makes the code calling the constructor more readable and allows for
extensibility.
Diffstat (limited to 'src')
-rw-r--r-- | src/service.vala | 6 | ||||
-rw-r--r-- | src/sound-menu.vala | 9 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/service.vala b/src/service.vala index 1611608..9c75044 100644 --- a/src/service.vala +++ b/src/service.vala @@ -34,9 +34,9 @@ public class IndicatorSound.Service { this.actions.add_action (this.create_mic_volume_action ()); this.menus = new HashTable<string, SoundMenu> (str_hash, str_equal); - this.menus.insert ("desktop_greeter", new SoundMenu (true, null)); - this.menus.insert ("desktop", new SoundMenu (true, "indicator.desktop-settings")); - this.menus.insert ("phone", new SoundMenu (false, "indicator.phone-settings")); + this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE)); + this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE)); + this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.NONE)); 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 9d0c521..25234d9 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -22,14 +22,19 @@ extern Variant? g_icon_serialize (Icon icon); class SoundMenu: Object { - public SoundMenu (bool show_mute, string? settings_action) { + public enum DisplayFlags { + NONE = 0, + SHOW_MUTE = 1 + } + + public SoundMenu (string? settings_action, DisplayFlags flags) { /* 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 (); - if (show_mute) + if ((flags & DisplayFlags.SHOW_MUTE) != 0) 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", |