diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-06-17 12:18:36 -0400 |
---|---|---|
committer | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-06-17 12:18:36 -0400 |
commit | a0fae2ec3183d1d9a651b38d0e2980c029cd7d28 (patch) | |
tree | 985abb977dbc92724e945bb744e8022ce1593c58 /src/service.vala | |
parent | 9b3162f7aeb23197f6bde643a897c64bd1133986 (diff) | |
download | ayatana-indicator-sound-a0fae2ec3183d1d9a651b38d0e2980c029cd7d28.tar.gz ayatana-indicator-sound-a0fae2ec3183d1d9a651b38d0e2980c029cd7d28.tar.bz2 ayatana-indicator-sound-a0fae2ec3183d1d9a651b38d0e2980c029cd7d28.zip |
Export playback menu item
Diffstat (limited to 'src/service.vala')
-rw-r--r-- | src/service.vala | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/service.vala b/src/service.vala index fe95ab8..ad9698e 100644 --- a/src/service.vala +++ b/src/service.vala @@ -61,7 +61,7 @@ public class IndicatorSound.Service { const ActionEntry[] action_entries = { { "root", null, null, "{ 'icon': <'audio-volume-high-panel'> }", null }, - { "settings", activate_settings, null, null, null } + { "settings", activate_settings, null, null, null }, }; MainLoop loop; @@ -200,8 +200,15 @@ public class IndicatorSound.Service { player_item.set_attribute ("x-canonical-type", "s", "com.canonical.unity.media-player"); player_item.set_attribute_value ("icon", g_icon_serialize (player.icon)); + var playback_item = new MenuItem (null, null); + playback_item.set_attribute ("x-canonical-type", "s", "com.canonical.unity.playback-item"); + playback_item.set_attribute ("x-canonical-play-action", "s", "indicator.play." + player.id); + playback_item.set_attribute ("x-canonical-next-action", "s", "indicator.next." + player.id); + playback_item.set_attribute ("x-canonical-previous-action", "s", "indicator.previous." + player.id); + var section = new Menu (); section.append_item (player_item); + section.append_item (playback_item); this.menu.insert_section (this.menu.get_n_items () -1, null, section); @@ -209,6 +216,18 @@ public class IndicatorSound.Service { action.activate.connect ( () => { player.launch (); }); this.actions.insert (action); + var play_action = new SimpleAction.stateful ("play." + player.id, null, player.is_playing); + play_action.activate.connect ( () => player.play_pause () ); + this.actions.insert (play_action); + + var next_action = new SimpleAction ("next." + player.id, null); + next_action.activate.connect ( () => player.next () ); + this.actions.insert (next_action); + + var prev_action = new SimpleAction ("previous." + player.id, null); + prev_action.activate.connect ( () => player.previous () ); + this.actions.insert (prev_action); + player.notify.connect (this.eventually_update_player_actions); this.update_preferred_players (); @@ -216,6 +235,9 @@ public class IndicatorSound.Service { void player_removed (MediaPlayer player) { this.actions.remove (player.id); + this.actions.remove ("play." + player.id); + this.actions.remove ("next." + player.id); + this.actions.remove ("previous." + player.id); int n = this.menu.get_n_items (); for (int i = 0; i < n; i++) { |