aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dbus-menu-manager.c1
-rw-r--r--src/mpris2-controller.vala8
-rw-r--r--src/mpris2-interfaces.vala22
-rw-r--r--src/player-controller.vala20
-rw-r--r--src/player-item.vala4
-rw-r--r--src/playlists-menu-item.vala29
6 files changed, 62 insertions, 22 deletions
diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c
index 37e1c18..f92c324 100644
--- a/src/dbus-menu-manager.c
+++ b/src/dbus-menu-manager.c
@@ -214,6 +214,7 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service
// Sound preferences dialog
DbusmenuMenuitem *settings_mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(settings_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sound Preferences..."));
+
//_("Sound Preferences..."));
dbusmenu_menuitem_child_append(root, settings_mi);
g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 2c19606..0bd5562 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -138,7 +138,6 @@ public class Mpris2Controller : GLib.Object
{
debug("transport_event input = %i", (int)command);
if(command == TransportMenuitem.action.PLAY_PAUSE){
- this.fetch_playlists();
this.player.PlayPause.begin();
}
else if(command == TransportMenuitem.action.PREVIOUS){
@@ -160,12 +159,13 @@ public class Mpris2Controller : GLib.Object
debug( "Size of the playlist array = %i", current_playlists.length );
PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
playlists_item.update(current_playlists);
- /*foreach(PlaylistDetails detail in current_playlists){
+ foreach(PlaylistDetails detail in current_playlists){
+ debug(" \n \n ");
debug( "Playlist Name = %s", detail.name);
debug( "Playlist path = %s", detail.path);
debug( "Playlist icon path = %s", detail.icon_path);
- debug(" \n \n \n \n \n ");
- }*/
+ debug(" \n \n ");
+ }
}
}
diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala
index 3f5519b..ab8ac95 100644
--- a/src/mpris2-interfaces.vala
+++ b/src/mpris2-interfaces.vala
@@ -1,6 +1,5 @@
/*
Copyright 2010 Canonical Ltd.
-
Authors:
Conor Curran <conor.curran@canonical.com>
@@ -45,7 +44,6 @@ public interface MprisPlayer : Object {
public signal void Seeked(int64 new_position);
}
-
// Playlist container
public struct PlaylistDetails{
public ObjectPath path;
@@ -54,8 +52,18 @@ public struct PlaylistDetails{
}
[DBus (name = "org.mpris.MediaPlayer2.Playlists")]
+
// TODO: API criticisms
-// get playlists should be able to be async => pass in struct to be populated or pass in callback
+// 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
+// should be asyncable.
+// => Need to be able to query get_playlist using ordered by last modified.
+// => Need a signal to inform that the active playlist has changed
+
public interface MprisPlaylists : Object {
//properties
public abstract string[] Orderings{owned get; set;}
@@ -63,8 +71,8 @@ public interface MprisPlaylists : Object {
//methods
public abstract async void ActivatePlaylist(ObjectPath playlist_id) throws IOError;
- public abstract PlaylistDetails[] GetPlaylists ( uint32 index,
- uint32 max_count,
- string order,
- bool reverse_order ) throws IOError;
+ public abstract PlaylistDetails[] GetPlaylists ( uint32 index,
+ uint32 max_count,
+ string order,
+ bool reverse_order ) throws IOError;
} \ No newline at end of file
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);
}
- }
+ }
}
diff --git a/src/player-item.vala b/src/player-item.vala
index c80a17d..75f673b 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -28,7 +28,7 @@ public class PlayerItem : Dbusmenu.Menuitem
public PlayerItem(string type)
{
- Object(item_type: type);
+ Object(item_type: type);
}
construct {
@@ -54,7 +54,7 @@ public class PlayerItem : Dbusmenu.Menuitem
if(data == null){
debug("PlayerItem::Update -> The hashtable was null - just leave it!");
return;
- }
+ }
foreach(string property in attributes){
string[] input_keys = property.split("-");
diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala
index 8106600..4b81e48 100644
--- a/src/playlists-menu-item.vala
+++ b/src/playlists-menu-item.vala
@@ -23,18 +23,39 @@ using Gee;
public class PlaylistsMenuitem : PlayerItem
{
+
+ 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.root_item = new Menuitem();
+ this.root_item.property_set ( MENUITEM_PROP_LABEL, "Choose Playlist" );
+ }
- public void update (PlaylistDetails[] playlists)
+ public new void update (PlaylistDetails[] playlists)
{
- foreach ( PlaylistDetail detail in playlists ){
-
+ foreach ( PlaylistDetails detail in playlists ){
+ Dbusmenu.Menuitem menuitem = new Menuitem();
+ menuitem.property_set (MENUITEM_PROP_LABEL, detail.name);
+ 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);
+
+ 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);
+ }
+
public static HashSet<string> attributes_format()
{
HashSet<string> attrs = new HashSet<string>();