diff options
Diffstat (limited to 'src/player-controller.vala')
-rw-r--r-- | src/player-controller.vala | 99 |
1 files changed, 10 insertions, 89 deletions
diff --git a/src/player-controller.vala b/src/player-controller.vala index 33a5b1a..2aa4382 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -23,7 +23,7 @@ using Gee; public class PlayerController : GLib.Object { - public const int WIDGET_QUANTITY = 6; + public const int WIDGET_QUANTITY = 5; public static enum widget_order{ SEPARATOR, @@ -31,7 +31,6 @@ public class PlayerController : GLib.Object METADATA, SCRUB, TRANSPORT, - PLAYLIST } public enum state{ @@ -43,20 +42,16 @@ public class PlayerController : GLib.Object } public int current_state = state.OFFLINE; - - + private Dbusmenu.Menuitem root_menu; public string name { get; set;} public ArrayList<PlayerItem> custom_items; - public Mpris2Controller mpris2_adaptor; - public MprisController mpris_adaptor; - public bool mpris2; + public MprisBridge mpris_bridge; public AppInfo? app_info { get; set;} public int menu_offset { get; set;} public PlayerController(Dbusmenu.Menuitem root, string client_name, int offset, state initial_state) { - this.mpris2 = false; this.root_menu = root; this.name = format_client_name(client_name.strip()); this.custom_items = new ArrayList<PlayerItem>(); @@ -77,7 +72,6 @@ public class PlayerController : GLib.Object public void activate() { this.establish_mpris_connection(); - //this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, true); } /* @@ -104,14 +98,7 @@ public class PlayerController : GLib.Object debug("establish_mpris_connection - Not ready to connect"); return; } - if(this.name == "Vlc"){ - debug("establishing a vlc mpris controller"); - this.mpris2_adaptor = new Mpris2Controller(this); - this.mpris2 = true; - } - else{ - this.mpris_adaptor = new MprisController(this); - } + this.mpris_bridge = new MprisBridge(this); this.determine_state(); } @@ -140,25 +127,14 @@ public class PlayerController : GLib.Object false); this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, false); - this.custom_items[widget_order.PLAYLIST].property_set_bool(MENUITEM_PROP_VISIBLE, - false); return; } - debug("update layout - metadata %s", this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format()).to_string()); this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, - this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format())); - //debug("metadata id %i", this.custom_items[widget_order.METADATA].id); - - debug("update layout - scrub %s", this.custom_items[widget_order.SCRUB].populated(ScrubMenuitem.attributes_format()).to_string()); + this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format())); this.custom_items[widget_order.SCRUB].property_set_bool(MENUITEM_PROP_VISIBLE, this.custom_items[widget_order.SCRUB].populated(ScrubMenuitem.attributes_format())); - - this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, true); - - this.custom_items[widget_order.PLAYLIST].property_set_bool(MENUITEM_PROP_VISIBLE, - true); } private void construct_widgets() @@ -181,34 +157,11 @@ public class PlayerController : GLib.Object // Transport item TransportMenuitem transport_item = new TransportMenuitem(this); this.custom_items.add(transport_item); - - this.custom_items.add(create_playlist()); - + foreach(PlayerItem item in this.custom_items){ root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); } } - - private PlayerItem create_playlist() - { - PlayerItem playlist_root = new PlayerItem(CLIENT_TYPES_DEFAULT); - playlist_root.property_set(MENUITEM_PROP_LABEL, "Choose Playlist"); - - PlayerItem subentry_1 = new PlayerItem(CLIENT_TYPES_DEFAULT); - subentry_1.property_set(MENUITEM_PROP_LABEL, "Raster-noton selection"); - - PlayerItem subentry_2 = new PlayerItem(CLIENT_TYPES_DEFAULT); - subentry_2.property_set(MENUITEM_PROP_LABEL, "Rune Grammofon selection"); - - PlayerItem subentry_3 = new PlayerItem(CLIENT_TYPES_DEFAULT); - subentry_3.property_set(MENUITEM_PROP_LABEL, "Kranky selection"); - - playlist_root.child_append(subentry_1); - playlist_root.child_append(subentry_2); - playlist_root.child_append(subentry_3); - - return playlist_root; - } private static string format_client_name(string client_name) { @@ -223,45 +176,13 @@ public class PlayerController : GLib.Object // Temporarily we will need to handle to different mpris implemenations // Do it for now - a couple of weeks should see this messy carry on out of // the codebase. - public void set_track_position(double pos) - { - if(this.mpris2 == true){ - this.mpris2_adaptor.set_position(pos); - } - else{ - this.mpris_adaptor.set_position(pos); - } - } - - public void transport_update(TransportMenuitem.action update) - { - if(this.mpris2 == true){ - this.mpris2_adaptor.transport_event(update); - } - else{ - this.mpris_adaptor.transport_event(update); - } - } - public void determine_state() { - if(this.mpris2 == true){ - if(this.mpris2_adaptor.connected() == true){ - debug("yup I'm connected"); - this.update_state(state.CONNECTED); - } - else{ - this.update_state(state.DISCONNECTED); - } + if(this.mpris_bridge.connected() == true){ + this.update_state(state.CONNECTED); } else{ - if(this.mpris_adaptor.connected() == true){ - debug("yup I'm connected"); - this.update_state(state.CONNECTED); - } - else{ - this.update_state(state.DISCONNECTED); - } - } + this.update_state(state.DISCONNECTED); + } } }
\ No newline at end of file |