aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-09-02 23:21:00 +0100
committerConor Curran <conor.curran@canonical.com>2010-09-02 23:21:00 +0100
commit0d231118f14f622ca025ac29db0b2cd0eeaec004 (patch)
treeedb146c5fbd7e0874148b34e2ee2a1be21ad2f5b
parent0125f59bd6229cc8c98314b86795814ca5df6c42 (diff)
downloadayatana-indicator-sound-0d231118f14f622ca025ac29db0b2cd0eeaec004.tar.gz
ayatana-indicator-sound-0d231118f14f622ca025ac29db0b2cd0eeaec004.tar.bz2
ayatana-indicator-sound-0d231118f14f622ca025ac29db0b2cd0eeaec004.zip
tidied the transport backend
-rw-r--r--src/mpris2-controller.vala22
-rw-r--r--src/player-controller.vala2
-rw-r--r--src/transport-menu-item.vala11
3 files changed, 22 insertions, 13 deletions
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index dd6a312..41c8ca8 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -105,7 +105,7 @@ public class Mpris2Controller : GLib.Object
if(play_v != null){
string state = play_v.get_string();
debug("new playback state = %s", state);
- int p = this.determine_play_state(state);
+ TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(state);
(this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(p);
}
@@ -143,29 +143,29 @@ public class Mpris2Controller : GLib.Object
}
- private int determine_play_state(string status){
+ private TransportMenuitem.state determine_play_state(string status){
if(status == null)
- return 1;
+ return TransportMenuitem.state.PAUSED;
if(status != null && status == "Playing"){
debug("determine play state - state = %s", status);
- return 0;
+ return TransportMenuitem.state.PLAYING;
}
- return 1;
+ return TransportMenuitem.state.PAUSED;
}
public void initial_update()
{
- int32 status;
+ TransportMenuitem.state update;
if(this.player.PlaybackStatus == null){
- status = 1;
+ update = TransportMenuitem.state.PAUSED;
}
else{
- status = determine_play_state(this.player.PlaybackStatus);
+ update = determine_play_state(this.player.PlaybackStatus);
}
- debug("initial update - play state %i", status);
+ debug("initial update - play state %i", (int)update);
- (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(status);
+ (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(update);
GLib.HashTable<string, Value?> cleaned_metadata = this.clean_metadata();
this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata,
MetadataMenuitem.attributes_format());
@@ -260,7 +260,7 @@ public class Mpris2Controller : GLib.Object
this.mpris2_root.Raise();
}
catch(DBus.Error e){
- error("Exception thrown while calling root function Raise - %s", e.message);
+ error("Exception thrown while calling function Raise - %s", e.message);
}
}
}
diff --git a/src/player-controller.vala b/src/player-controller.vala
index 2ea9331..f5ec205 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -176,6 +176,8 @@ public class PlayerController : GLib.Object
this.update_state(state.CONNECTED);
TitleMenuitem title = this.custom_items[widget_order.TITLE] as TitleMenuitem;
title.toggle_active_triangle(true);
+ TransportMenuitem transport = this.custom_items[widget_order.TRANSPORT] as TransportMenuitem;
+ transport.change_play_state(TransportMenuitem.state.PAUSED);
}
else{
this.update_state(state.DISCONNECTED);
diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala
index 8bdd2c8..7faadb5 100644
--- a/src/transport-menu-item.vala
+++ b/src/transport-menu-item.vala
@@ -28,6 +28,11 @@ public class TransportMenuitem : PlayerItem
PLAY_PAUSE,
NEXT
}
+
+ public enum state{
+ PLAYING,
+ PAUSED
+ }
public TransportMenuitem(PlayerController parent)
{
@@ -35,9 +40,9 @@ public class TransportMenuitem : PlayerItem
this.property_set_int(MENUITEM_PLAY_STATE, 1);
}
- public void change_play_state(int state)
+ public void change_play_state(state update)
{
- this.property_set_int(MENUITEM_PLAY_STATE, state);
+ this.property_set_int(MENUITEM_PLAY_STATE, update);
}
public override void handle_event(string name, GLib.Value input_value, uint timestamp)
@@ -54,4 +59,6 @@ public class TransportMenuitem : PlayerItem
attrs.add(MENUITEM_PLAY_STATE);
return attrs;
}
+
+
} \ No newline at end of file