aboutsummaryrefslogtreecommitdiff
path: root/src/mpris-controller.vala
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-07-08 17:52:51 +0100
committerConor Curran <conor.curran@canonical.com>2010-07-08 17:52:51 +0100
commit50b2e070852b5eab299b8c3612a86adf6d21e901 (patch)
tree18c40c1b61ce93552767ef3f02055a3d9e92dfcb /src/mpris-controller.vala
parent41747b032d2032c97fd7f1766157e2d846626880 (diff)
parent0f2a6b2736713951fb4b88848e79849a8f1dc72a (diff)
downloadayatana-indicator-sound-50b2e070852b5eab299b8c3612a86adf6d21e901.tar.gz
ayatana-indicator-sound-50b2e070852b5eab299b8c3612a86adf6d21e901.tar.bz2
ayatana-indicator-sound-50b2e070852b5eab299b8c3612a86adf6d21e901.zip
merged the event handling plus code tidy ups and proper icon loading from the theme
Diffstat (limited to 'src/mpris-controller.vala')
-rw-r--r--src/mpris-controller.vala36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala
index b1e66f3..2194d44 100644
--- a/src/mpris-controller.vala
+++ b/src/mpris-controller.vala
@@ -27,9 +27,9 @@ public class MprisController : GLib.Object
private PlayerController controller;
struct status {
public int32 playback;
- public int32 shuffle;
- public int32 repeat;
- public int32 endless;
+ //public int32 shuffle; // Not used just yet
+ //public int32 repeat;
+ //public int32 endless;
}
public MprisController(string name, PlayerController controller, string mpris_interface="org.freedesktop.MediaPlayer"){
@@ -65,16 +65,30 @@ public class MprisController : GLib.Object
* TRUE => Playing
* FALSE => Paused
**/
- public void toggle_playback(bool state)
+ public void transport_event(TransportMenuitem.action command)
{
- if(state == true){
- debug("about to play");
- this.mpris_player.Play();
+ debug("transport_event input = %i", (int)command);
+ if(command == TransportMenuitem.action.PLAY_PAUSE){
+ status st = this.mpris_player.GetStatus();
+ bool play_state = st.playback == 1;
+ debug("toggle_playback - initial play state %i", (int)play_state);
+ bool new_play_state = !play_state;
+ debug("toggle_playback - new play state %i", (int)new_play_state);
+ if(new_play_state == true){
+ debug("about to play");
+ this.mpris_player.Play();
+ }
+ else{
+ debug("about to pause");
+ this.mpris_player.Pause();
+ }
+ }
+ else if(command == TransportMenuitem.action.PREVIOUS){
+ this.mpris_player.previous();
+ }
+ else if(command == TransportMenuitem.action.NEXT){
+ this.mpris_player.next();
}
- else{
- debug("about to pause");
- this.mpris_player.Pause();
- }
}
public bool connected()