aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mpris2-controller.vala14
-rw-r--r--src/mpris2-interfaces.vala2
-rw-r--r--src/playlists-menu-item.vala14
3 files changed, 23 insertions, 7 deletions
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 0bd5562..94e82d5 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -180,4 +180,18 @@ public class Mpris2Controller : GLib.Object
this.mpris2_root.Raise.begin();
}
}
+
+ public void activate_playlist (ObjectPath path)
+ {
+ if(this.playlists == null){
+ warning("playlists mpris instance is null !");
+ return;
+ }
+ try{
+ this.playlists.ActivatePlaylist.begin(path);
+ }
+ catch(IOError e){
+ debug("Could not activate playlist %s because %s", (string)path, e.message);
+ }
+ }
} \ No newline at end of file
diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala
index ab8ac95..160f454 100644
--- a/src/mpris2-interfaces.vala
+++ b/src/mpris2-interfaces.vala
@@ -55,8 +55,6 @@ public struct PlaylistDetails{
// TODO: API criticisms
// Get_playlists should be able to be async => pass in callback pointer
-// Lacking the ability to query the current playlist (should be asyncable)
-// - needed to keep client and servers in sync
// => get_current_playlist ->
// Should return PlaylistDetails struct with each field nil if there is no active playlist.
// Otherwise a populated PlaylistDetails
diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala
index 4b81e48..f9d681e 100644
--- a/src/playlists-menu-item.vala
+++ b/src/playlists-menu-item.vala
@@ -23,14 +23,14 @@ using Gee;
public class PlaylistsMenuitem : PlayerItem
{
-
+ private HashMap<int, PlaylistDetails?> current_playlists;
public Menuitem root_item;
public PlaylistsMenuitem ( PlayerController parent )
{
Object ( item_type: MENUITEM_TYPE, owner: parent );
}
construct{
- this.property_set ( MENUITEM_PROP_LABEL, "Choose Playlist");
+ this.current_playlists = new HashMap<int, PlaylistDetails?>();
this.root_item = new Menuitem();
this.root_item.property_set ( MENUITEM_PROP_LABEL, "Choose Playlist" );
}
@@ -43,17 +43,21 @@ public class PlaylistsMenuitem : PlayerItem
menuitem.property_set (MENUITEM_PROP_ICON_NAME, "source-smart-playlist");
menuitem.property_set_bool (MENUITEM_PROP_VISIBLE, true);
menuitem.property_set_bool (MENUITEM_PROP_ENABLED, true);
-
+ this.current_playlists.set( menuitem.id, detail );
menuitem.item_activated.connect(() => {
submenu_item_activated (menuitem.id );});
-
this.root_item.child_append( menuitem );
}
}
private void submenu_item_activated (int menu_item_id)
{
- debug("item %i was activated", menu_item_id);
+ if(!this.current_playlists.has_key(menu_item_id)){
+ warning( "item %i was activated but we don't have a corresponding playlist",
+ menu_item_id );
+ return;
+ }
+ this.owner.mpris_bridge.activate_playlist ( this.current_playlists[menu_item_id].path );
}
public static HashSet<string> attributes_format()