diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-07-25 16:21:44 +0200 |
---|---|---|
committer | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-07-25 16:21:44 +0200 |
commit | 997864b9fc62596e8cc238f4c4b77d780651ffb4 (patch) | |
tree | 89785ca4dfe0469b6b333e9247e85bf35269c695 /src | |
parent | c416b3463055a0167f2e1412c7442674de5e75d8 (diff) | |
download | ayatana-indicator-sound-997864b9fc62596e8cc238f4c4b77d780651ffb4.tar.gz ayatana-indicator-sound-997864b9fc62596e8cc238f4c4b77d780651ffb4.tar.bz2 ayatana-indicator-sound-997864b9fc62596e8cc238f4c4b77d780651ffb4.zip |
service.vala: store menus in a hash table, keyed by profile name
Diffstat (limited to 'src')
-rw-r--r-- | src/service.vala | 14 | ||||
-rw-r--r-- | src/sound-menu.vala | 8 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/service.vala b/src/service.vala index eeb0a30..c1c6306 100644 --- a/src/service.vala +++ b/src/service.vala @@ -36,8 +36,9 @@ public class IndicatorSound.Service { this.actions.add_action (this.create_volume_action ()); this.actions.add_action (this.create_mic_volume_action ()); - this.menu = new SoundMenu (); - this.volume_control.bind_property ("active-mic", this.menu, "show-mic-volume", BindingFlags.SYNC_CREATE); + this.menus = new HashTable<string, SoundMenu> (str_hash, str_equal); + this.menus.insert ("desktop", new SoundMenu ()); + this.volume_control.bind_property ("active-mic", this.menus.get("desktop"), "show-mic-volume", BindingFlags.SYNC_CREATE); this.players.sync (settings.get_strv ("interested-media-players")); this.settings.changed["interested-media-players"].connect ( () => { @@ -67,7 +68,7 @@ public class IndicatorSound.Service { MainLoop loop; SimpleActionGroup actions; - SoundMenu menu; + HashTable<string, SoundMenu> menus; Settings settings; VolumeControl volume_control; MediaPlayerList players; @@ -174,10 +175,11 @@ public class IndicatorSound.Service { void bus_acquired (DBusConnection connection, string name) { try { connection.export_action_group ("/com/canonical/indicator/sound", this.actions); - this.menu.export (connection, "/com/canonical/indicator/sound/desktop"); } catch (Error e) { critical ("%s", e.message); } + + this.menus.@foreach ( (profile, menu) => menu.export (connection, @"/com/canonical/indicator/sound/$profile")); } void name_lost (DBusConnection connection, string name) { @@ -221,7 +223,7 @@ public class IndicatorSound.Service { } void player_added (MediaPlayer player) { - this.menu.add_player (player); + this.menus.@foreach ( (profile, menu) => menu.add_player (player)); SimpleAction action = new SimpleAction.stateful (player.id, null, this.action_state_for_player (player)); action.activate.connect ( () => { player.launch (); }); @@ -259,7 +261,7 @@ public class IndicatorSound.Service { this.actions.remove ("previous." + player.id); this.actions.remove ("play-playlist." + player.id); - this.menu.remove_player (player); + this.menus.@foreach ( (profile, menu) => menu.remove_player (player)); this.update_preferred_players (); } diff --git a/src/sound-menu.vala b/src/sound-menu.vala index acb9adf..376ef15 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -43,8 +43,12 @@ class SoundMenu: Object root.append_item (root_item); } - public void export (DBusConnection connection, string object_path) throws Error { - connection.export_menu_model (object_path, this.root); + public void export (DBusConnection connection, string object_path) { + try { + connection.export_menu_model (object_path, this.root); + } catch (Error e) { + critical ("%s", e.message); + } } public bool show_mic_volume { |