From a964487e2fcd11946b5f95ab36b20cbd1bea4a57 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 9 Dec 2010 11:36:33 +0000 Subject: moving towards testing proposed playlists api --- src/player-controller.vala | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/player-controller.vala') diff --git a/src/player-controller.vala b/src/player-controller.vala index 0b540f9..b9e275f 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -23,13 +23,14 @@ using Gee; public class PlayerController : GLib.Object { - public const int WIDGET_QUANTITY = 4; + public const int WIDGET_QUANTITY = 5; public static enum widget_order{ SEPARATOR, TITLE, METADATA, TRANSPORT, + PLAYLISTS } public enum state{ @@ -158,7 +159,11 @@ public class PlayerController : GLib.Object // Transport item TransportMenuitem transport_item = new TransportMenuitem(this); this.custom_items.add(transport_item); - + + // Playlist item + PlaylistsMenuitem playlist_menuitem = new PlaylistsMenuitem(this); + this.custom_items.add(playlist_menuitem); + foreach(PlayerItem item in this.custom_items){ root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); } @@ -184,7 +189,7 @@ 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); - this.mpris_bridge.initial_update(); + this.mpris_bridge.initial_update(); } else{ this.update_state(state.DISCONNECTED); -- cgit v1.2.3 From f3b321919e3390f3d3af2eea33ad71611616ce61 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 10 Dec 2010 13:02:16 +0000 Subject: playlist widget population --- src/player-controller.vala | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/player-controller.vala') diff --git a/src/player-controller.vala b/src/player-controller.vala index b9e275f..450ecd6 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -141,6 +141,10 @@ public class PlayerController : GLib.Object this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format())); this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, true); + this.custom_items[widget_order.PLAYLISTS].property_set_bool(MENUITEM_PROP_VISIBLE, + true); + this.custom_items[widget_order.PLAYLISTS].property_set_bool ( MENUITEM_PROP_ENABLED, + true ); } private void construct_widgets() @@ -160,12 +164,18 @@ public class PlayerController : GLib.Object TransportMenuitem transport_item = new TransportMenuitem(this); this.custom_items.add(transport_item); - // Playlist item + // Playlist item PlaylistsMenuitem playlist_menuitem = new PlaylistsMenuitem(this); this.custom_items.add(playlist_menuitem); foreach(PlayerItem item in this.custom_items){ - root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); + if (this.custom_items.index_of(item) != 4) { + root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); + } + else{ + PlaylistsMenuitem playlists_menuitem = item as PlaylistsMenuitem; + root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item)); + } } } @@ -188,11 +198,11 @@ public class PlayerController : GLib.Object if(this.mpris_bridge.connected() == true){ this.update_state(state.CONNECTED); TitleMenuitem title = this.custom_items[widget_order.TITLE] as TitleMenuitem; - title.toggle_active_triangle(true); - this.mpris_bridge.initial_update(); + title.toggle_active_triangle(true); + this.mpris_bridge.initial_update(); } else{ this.update_state(state.DISCONNECTED); } - } + } } -- cgit v1.2.3 From c8c7681e7b9e2995d29fa58c931aa09e451c4fee Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 20 Dec 2010 18:02:50 +0000 Subject: playlists working --- src/player-controller.vala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/player-controller.vala') diff --git a/src/player-controller.vala b/src/player-controller.vala index 24fd090..638c44d 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -131,21 +131,23 @@ public class PlayerController : GLib.Object public void update_layout() { + PlaylistsMenuitem playlists_menuitem = this.custom_items[widget_order.PLAYLISTS] as PlaylistsMenuitem; + if(this.current_state != state.CONNECTED){ this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, false); this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, false); - this.custom_items[widget_order.PLAYLISTS].property_set_bool ( MENUITEM_PROP_ENABLED, - false ); + playlists_menuitem.root_item.property_set_bool ( MENUITEM_PROP_VISIBLE, + false ); return; } this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format())); this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, true); - this.custom_items[widget_order.PLAYLISTS].property_set_bool(MENUITEM_PROP_VISIBLE, - true); + playlists_menuitem.root_item.property_set_bool ( MENUITEM_PROP_VISIBLE, + this.mpris_bridge.playlists_support_exist() ); } private void construct_widgets() -- cgit v1.2.3 From f9afcd6bddae52bad5c5d8e7179fe360fcbf6de2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 4 Jan 2011 15:16:04 +0000 Subject: removed the need for a name instance variable on the player controller obj, now always use the name set in app info --- src/player-controller.vala | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/player-controller.vala') diff --git a/src/player-controller.vala b/src/player-controller.vala index 638c44d..58e3b47 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -44,7 +44,7 @@ public class PlayerController : GLib.Object public int current_state = state.OFFLINE; private Dbusmenu.Menuitem root_menu; - public string name { get; set;} + //public string name { get; set;} public string dbus_name { get; set;} public ArrayList custom_items; public Mpris2Controller mpris_bridge; @@ -62,7 +62,7 @@ public class PlayerController : GLib.Object this.root_menu = root; this.app_info = app; this.dbus_name = dbus_name; - this.name = format_player_name(this.app_info.get_name()); + //this.name = this.app_info.get_name(); this.icon_name = icon_name; this.custom_items = new ArrayList(); this.current_state = initial_state; @@ -74,7 +74,8 @@ public class PlayerController : GLib.Object public void update_state(state new_state) { - debug("update_state - player controller %s : new state %i", this.name, new_state); + debug("update_state - player controller %s : new state %i", this.app_info.get_name(), + new_state); this.current_state = new_state; this.update_layout(); } @@ -93,13 +94,14 @@ public class PlayerController : GLib.Object */ public void instantiate() { - debug("instantiate in player controller for %s", this.name); + debug("instantiate in player controller for %s", this.app_info.get_name() ); 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); + warning("Failed to launch app %s with error message: %s", this.app_info.get_name(), + error.message ); } } @@ -181,6 +183,7 @@ public class PlayerController : GLib.Object } } } + private static string format_player_name(owned string app_info_name) { -- cgit v1.2.3 From b8e5c4267c5c5db7889b18441a2fc733dd48cbdd Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 5 Jan 2011 16:06:52 +0000 Subject: blacklisting working plus bug fixed --- src/player-controller.vala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/player-controller.vala') diff --git a/src/player-controller.vala b/src/player-controller.vala index 58e3b47..3922ecf 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -44,7 +44,6 @@ public class PlayerController : GLib.Object public int current_state = state.OFFLINE; private Dbusmenu.Menuitem root_menu; - //public string name { get; set;} public string dbus_name { get; set;} public ArrayList custom_items; public Mpris2Controller mpris_bridge; @@ -62,7 +61,6 @@ public class PlayerController : GLib.Object this.root_menu = root; this.app_info = app; this.dbus_name = dbus_name; - //this.name = this.app_info.get_name(); this.icon_name = icon_name; this.custom_items = new ArrayList(); this.current_state = initial_state; @@ -128,7 +126,8 @@ public class PlayerController : GLib.Object this.custom_items[widget_order.TRANSPORT].reset(TransportMenuitem.attributes_format()); this.custom_items[widget_order.METADATA].reset(MetadataMenuitem.attributes_format()); TitleMenuitem title = this.custom_items[widget_order.TITLE] as TitleMenuitem; - title.toggle_active_triangle(false); + title.toggle_active_triangle(false); + this.mpris_bridge = null; } public void update_layout() -- cgit v1.2.3 From 6599f962aacdb311322305234d3746ac27533f5e Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Sun, 9 Jan 2011 14:20:41 +0000 Subject: found the way around banshee dbus peculiar --- src/player-controller.vala | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/player-controller.vala') diff --git a/src/player-controller.vala b/src/player-controller.vala index 3922ecf..adefb65 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -45,19 +45,22 @@ public class PlayerController : GLib.Object private Dbusmenu.Menuitem root_menu; public string dbus_name { get; set;} - public ArrayList custom_items; + public ArrayList custom_items; public Mpris2Controller mpris_bridge; public AppInfo? app_info { get; set;} public int menu_offset { get; set;} public string icon_name { get; set; } - + public bool? use_playlists; + public PlayerController(Dbusmenu.Menuitem root, GLib.AppInfo app, string? dbus_name, string icon_name, int offset, + bool? use_playlists, state initial_state) { + this.use_playlists = use_playlists; this.root_menu = root; this.app_info = app; this.dbus_name = dbus_name; @@ -67,7 +70,7 @@ public class PlayerController : GLib.Object this.menu_offset = offset; this.construct_widgets(); this.establish_mpris_connection(); - this.update_layout(); + this.update_layout(); } public void update_state(state new_state) @@ -81,7 +84,7 @@ public class PlayerController : GLib.Object public void activate( string dbus_name ) { this.dbus_name = dbus_name; - this.establish_mpris_connection(); + this.establish_mpris_connection(); } /* @@ -109,6 +112,9 @@ public class PlayerController : GLib.Object debug("establish_mpris_connection - Not ready to connect"); return; } + debug ( " establish mpris connection - use playlists value = %s ", + this.use_playlists.to_string() ); + this.mpris_bridge = new Mpris2Controller(this); this.determine_state(); } @@ -148,7 +154,7 @@ public class PlayerController : GLib.Object this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, true); playlists_menuitem.root_item.property_set_bool ( MENUITEM_PROP_VISIBLE, - this.mpris_bridge.playlists_support_exist() ); + this.use_playlists ); } private void construct_widgets() @@ -181,9 +187,8 @@ public class PlayerController : GLib.Object root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item)); } } - } + } - private static string format_player_name(owned string app_info_name) { string result = app_info_name.down().strip(); -- cgit v1.2.3