diff options
author | Ken VanDine <ken.vandine@canonical.com> | 2011-01-11 16:44:38 -0600 |
---|---|---|
committer | Ken VanDine <ken.vandine@canonical.com> | 2011-01-11 16:44:38 -0600 |
commit | 412bffad64182bfae1e2408b89f9488f0da38481 (patch) | |
tree | 1617f11e230dcd76678196fd1fde6b95a1742bcd /src/mpris2-controller.vala | |
parent | 13d392dab3f0fcba861bd6607ce17d68990b9228 (diff) | |
parent | 714c7c49776e8a341254a3e4297b465d181206cd (diff) | |
download | ayatana-indicator-sound-412bffad64182bfae1e2408b89f9488f0da38481.tar.gz ayatana-indicator-sound-412bffad64182bfae1e2408b89f9488f0da38481.tar.bz2 ayatana-indicator-sound-412bffad64182bfae1e2408b89f9488f0da38481.zip |
Import upstream version 0.5.5
Diffstat (limited to 'src/mpris2-controller.vala')
-rw-r--r-- | src/mpris2-controller.vala | 55 |
1 files changed, 21 insertions, 34 deletions
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 5f98541..fc61c12 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -18,12 +18,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. */ using Dbusmenu; -[DBus (name = "org.freedesktop.DBus.Properties")] -public interface FreeDesktopProperties : Object{ - public signal void PropertiesChanged (string source, HashTable<string, Variant?> changed_properties, - string[] invalid ); -} - /* This class will entirely replace mpris-controller.vala hence why there is no point in trying to get encorporate both into the same object model. @@ -50,10 +44,11 @@ public class Mpris2Controller : GLib.Object this.player = Bus.get_proxy_sync ( BusType.SESSION, this.owner.dbus_name, "/org/mpris/MediaPlayer2" ); - this.playlists = Bus.get_proxy_sync ( BusType.SESSION, - this.owner.dbus_name, - "/org/mpris/MediaPlayer2" ); - + if ( this.owner.use_playlists == true ){ + this.playlists = Bus.get_proxy_sync ( BusType.SESSION, + this.owner.dbus_name, + "/org/mpris/MediaPlayer2" ); + } this.properties_interface = Bus.get_proxy_sync ( BusType.SESSION, "org.freedesktop.Properties.PropertiesChanged", "/org/mpris/MediaPlayer2" ); @@ -70,7 +65,7 @@ public class Mpris2Controller : GLib.Object { debug("properties-changed for interface %s and owner %s", interface_source, this.owner.dbus_name); if ( changed_properties == null || - interface_source.has_prefix ( Mpris2Watcher.MPRIS_PREFIX ) == false ){ + interface_source.has_prefix ( MPRIS_PREFIX ) == false ){ warning("Property-changed hash is null or this is an interface that doesn't concerns us"); return; } @@ -95,19 +90,10 @@ public class Mpris2Controller : GLib.Object metadata.populated(MetadataMenuitem.attributes_format())); } Variant? playlist_v = changed_properties.lookup("ActivePlaylist"); - if ( playlist_v != null ){ + if ( playlist_v != null && this.owner.use_playlists == true ){ this.fetch_active_playlist(); - //Timeout.add ( 200, fetch_active_playlist ); } } - - public bool playlists_support_exist() - { - if (this.playlists == null) return false; - uint32? count = this.playlists.PlaylistCount; - if ( count == null || count <= 0 ) return false; - return true; - } private bool ensure_correct_playback_status(){ debug("TEST playback status = %s", this.player.PlaybackStatus); @@ -154,8 +140,11 @@ 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_active_playlist(); + + if ( this.owner.use_playlists == true ){ + this.fetch_playlists(); + this.fetch_active_playlist(); + } } public void transport_update(TransportMenuitem.action command) @@ -174,8 +163,6 @@ public class Mpris2Controller : GLib.Object public void fetch_playlists() { - if (this.playlists == null) return; - PlaylistDetails[] current_playlists = this.playlists.GetPlaylists(0, 10, "Alphabetical", @@ -185,13 +172,17 @@ public class Mpris2Controller : GLib.Object PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; playlists_item.update(current_playlists); } + else{ + warning(" Playlists are on but its returning no current_playlists" ); + this.owner.use_playlists = false; + } return; } private void fetch_active_playlist() - { - if (this.playlists == null && this.playlists.ActivePlaylist.valid == false){ - warning("Playlists object is null or we don't have an active playlist"); + { + if (this.playlists.ActivePlaylist.valid == false){ + debug("We don't have an active playlist"); } PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; playlists_item.update_active_playlist ( this.playlists.ActivePlaylist.details ); @@ -202,7 +193,7 @@ public class Mpris2Controller : GLib.Object { return (this.player != null && this.mpris2_root != null); } - + public void expose() { if(this.connected() == true){ @@ -212,15 +203,11 @@ public class Mpris2Controller : GLib.Object 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 |