diff options
author | Conor Curran <conor.curran@canonical.com> | 2010-12-17 12:48:03 +0000 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2010-12-17 12:48:03 +0000 |
commit | 032797fd7a92bc8a4fd979ddc12cacb0918ca73b (patch) | |
tree | d4fd4c0600312500c6b620a092148634fce676c2 | |
parent | 93190886959bfa16b835794a4a12a9a945e7777e (diff) | |
download | ayatana-indicator-sound-032797fd7a92bc8a4fd979ddc12cacb0918ca73b.tar.gz ayatana-indicator-sound-032797fd7a92bc8a4fd979ddc12cacb0918ca73b.tar.bz2 ayatana-indicator-sound-032797fd7a92bc8a4fd979ddc12cacb0918ca73b.zip |
proved active-playlist prop use-case
-rw-r--r-- | src/mpris2-controller.vala | 26 | ||||
-rw-r--r-- | src/mpris2-interfaces.vala | 18 |
2 files changed, 30 insertions, 14 deletions
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 94e82d5..d6f27ec 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -18,9 +18,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>. */ using Dbusmenu; - [DBus (name = "org.freedesktop.DBus.Properties")] - public interface FreeDesktopProperties : Object{ +public interface FreeDesktopProperties : Object{ public signal void PropertiesChanged (string source, HashTable<string, Variant?> changed_properties, string[] invalid ); } @@ -91,6 +90,11 @@ public class Mpris2Controller : GLib.Object metadata.property_set_bool ( MENUITEM_PROP_VISIBLE, metadata.populated(MetadataMenuitem.attributes_format())); } + Variant? playlist_v = changed_properties.lookup("ActivePlaylist"); + if ( playlist_v != null ){ + debug (" WE HAVE PLAYLIST CHANGE EVENT DETECTED "); + this.fetch_active_playlist(); + } } private GLib.HashTable<string, Variant?>? clean_metadata() @@ -131,7 +135,7 @@ public class Mpris2Controller : GLib.Object GLib.HashTable<string, Value?>? cleaned_metadata = this.clean_metadata(); this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata, MetadataMenuitem.attributes_format()); - this.fetch_playlists(); + this.fetch_playlists(); } public void transport_update(TransportMenuitem.action command) @@ -169,6 +173,22 @@ public class Mpris2Controller : GLib.Object } } + public void fetch_active_playlist() + { + if (this.playlists == null && this.playlists.ActivePlaylist.valid == true){ + warning("Playlists object is null and we have an active playlist"); + return; + } + + PlaylistDetails active_details = this.playlists.ActivePlaylist.active_playlist; + debug(" \n \n "); + debug( "Active Playlist Name = %s", active_details.name); + debug( "Active Playlist path = %s", active_details.path); + debug( "Active Playlist icon path = %s", active_details.icon_path); + debug(" \n \n "); + } + + public bool connected() { return (this.player != null && this.mpris2_root != null); diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala index 160f454..578b6c8 100644 --- a/src/mpris2-interfaces.vala +++ b/src/mpris2-interfaces.vala @@ -50,23 +50,19 @@ public struct PlaylistDetails{ public string name; public string icon_path; } +// Active playlist property container +public struct ActivePlaylistContainer{ + public bool valid; + public PlaylistDetails active_playlist; +} [DBus (name = "org.mpris.MediaPlayer2.Playlists")] - -// TODO: API criticisms -// Get_playlists should be able to be async => pass in callback pointer -// => 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;} public abstract uint32 PlaylistCount{owned get; set;} - + public abstract ActivePlaylistContainer ActivePlaylist {owned get; set;} + //methods public abstract async void ActivatePlaylist(ObjectPath playlist_id) throws IOError; public abstract PlaylistDetails[] GetPlaylists ( uint32 index, |