aboutsummaryrefslogtreecommitdiff
path: root/src/player-controller.vala
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-07-08 17:47:28 +0100
committerConor Curran <conor.curran@canonical.com>2010-07-08 17:47:28 +0100
commit0f2a6b2736713951fb4b88848e79849a8f1dc72a (patch)
tree100e2d6235254bad950ca2262f3b72f815f1f152 /src/player-controller.vala
parente4f900efd1e48814a70e4351cc3d878312daef37 (diff)
downloadayatana-indicator-sound-0f2a6b2736713951fb4b88848e79849a8f1dc72a.tar.gz
ayatana-indicator-sound-0f2a6b2736713951fb4b88848e79849a8f1dc72a.tar.bz2
ayatana-indicator-sound-0f2a6b2736713951fb4b88848e79849a8f1dc72a.zip
constants replaced and enums and title image now fetched from the mono theme
Diffstat (limited to 'src/player-controller.vala')
-rw-r--r--src/player-controller.vala37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/player-controller.vala b/src/player-controller.vala
index dfbf6d3..3fb4750 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -26,13 +26,15 @@ public class PlayerController : GLib.Object
public const int METADATA = 2;
private const int TRANSPORT = 3;
- public static const int OFFLINE = 0;
- public static const int INSTANTIATING = 1;
- public static const int READY = 2;
- public static const int CONNECTED = 3;
- public static const int DISCONNECTED = 4;
+ public enum state{
+ OFFLINE,
+ INSTANTIATING,
+ READY,
+ CONNECTED,
+ DISCONNECTED
+ }
- public int current_state = OFFLINE;
+ public int current_state = state.OFFLINE;
private Dbusmenu.Menuitem root_menu;
@@ -41,18 +43,18 @@ public class PlayerController : GLib.Object
public MprisController mpris_adaptor;
public AppInfo? app_info { get; set;}
- public PlayerController(Dbusmenu.Menuitem root, string client_name, int state = OFFLINE)
+ public PlayerController(Dbusmenu.Menuitem root, string client_name, state initial_state)
{
this.root_menu = root;
this.name = format_client_name(client_name.strip());
this.custom_items = new ArrayList<PlayerItem>();
- this.update_state(state);
+ this.update_state(initial_state);
construct_widgets();
establish_mpris_connection();
update_layout();
}
- public void update_state(int new_state)
+ public void update_state(state new_state)
{
debug("update_state : new state %i", new_state);
this.current_state = new_state;
@@ -72,13 +74,18 @@ public class PlayerController : GLib.Object
*/
public void instantiate()
{
- this.app_info.launch(null, null);
- this.update_state(INSTANTIATING);
+ try{
+ this.app_info.launch(null, null);
+ this.update_state(state.INSTANTIATING);
+ }
+ catch(GLib.Error error){
+ warning("Failed to launch app %s with error message: %s", this.name, error.message);
+ }
}
private void establish_mpris_connection()
{
- if(this.current_state != READY){
+ if(this.current_state != state.READY){
debug("establish_mpris_connection - Not ready to connect");
return;
}
@@ -89,10 +96,10 @@ public class PlayerController : GLib.Object
this.mpris_adaptor = new MprisController(this.name, this);
}
if(this.mpris_adaptor.connected() == true){
- this.update_state(CONNECTED);
+ this.update_state(state.CONNECTED);
}
else{
- this.update_state(DISCONNECTED);
+ this.update_state(state.DISCONNECTED);
}
this.update_layout();
}
@@ -107,7 +114,7 @@ public class PlayerController : GLib.Object
private void update_layout()
{
bool visibility = true;
- if(this.current_state != CONNECTED){
+ if(this.current_state != state.CONNECTED){
visibility = false;
}
debug("about the set the visibility on both the transport and metadata widget to %s", visibility.to_string());