diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-02-08 18:58:10 +0000 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-02-08 18:58:10 +0000 |
commit | 800023f7ab5854c19bdaf426ba86d24feea014ec (patch) | |
tree | 89e59a92f8823b3e50e68290e1698a08a5baec0c | |
parent | 1691ba2e034d688d58fba39fa88d8ef10bf67fe6 (diff) | |
download | ayatana-indicator-sound-800023f7ab5854c19bdaf426ba86d24feea014ec.tar.gz ayatana-indicator-sound-800023f7ab5854c19bdaf426ba86d24feea014ec.tar.bz2 ayatana-indicator-sound-800023f7ab5854c19bdaf426ba86d24feea014ec.zip |
work done around playlist changed
-rw-r--r-- | src/common-defs.h | 2 | ||||
-rw-r--r-- | src/mpris2-controller.vala | 9 | ||||
-rw-r--r-- | src/mpris2-interfaces.vala | 3 | ||||
-rw-r--r-- | src/playlists-menu-item.vala | 35 | ||||
-rw-r--r-- | src/sound-service.c | 4 | ||||
-rw-r--r-- | vapi/common-defs.vapi | 4 |
6 files changed, 44 insertions, 13 deletions
diff --git a/src/common-defs.h b/src/common-defs.h index 5458dc5..63d9d40 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -64,4 +64,6 @@ typedef enum { #define DBUSMENU_PLAYLISTS_MENUITEM_TITLE "x-canonical-sound-menu-player-playlists-title" #define DBUSMENU_PLAYLISTS_MENUITEM_PLAYLISTS "x-canonical-sound-menu-player-playlists-playlists" +#define DBUSMENU_PLAYLIST_MENUITEM_PATH "x-canonical-sound-menu-player-playlist-path" + #endif diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index d4cdc0c..444bdf6 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -48,6 +48,7 @@ public class Mpris2Controller : GLib.Object this.playlists = Bus.get_proxy_sync ( BusType.SESSION, this.owner.dbus_name, "/org/mpris/MediaPlayer2" ); + this.playlists.PlaylistChanged.connect (on_playlistdetails_changed); } this.properties_interface = Bus.get_proxy_sync ( BusType.SESSION, "org.freedesktop.Properties.PropertiesChanged", @@ -109,7 +110,7 @@ public class Mpris2Controller : GLib.Object title.alter_label (this.mpris2_root.Identity); } } - + private bool ensure_correct_playback_status(){ debug("TEST playback status = %s", this.player.PlaybackStatus); TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(this.player.PlaybackStatus); @@ -185,7 +186,6 @@ public class Mpris2Controller : GLib.Object } } - public bool connected() { return (this.player != null && this.mpris2_root != null); @@ -198,6 +198,11 @@ public class Mpris2Controller : GLib.Object } } + private void on_playlistdetails_changed (PlaylistDetails details) + { + + } + public async void fetch_playlists() { PlaylistDetails[] current_playlists = null; diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala index 0a0909f..5506a47 100644 --- a/src/mpris2-interfaces.vala +++ b/src/mpris2-interfaces.vala @@ -72,4 +72,7 @@ public interface MprisPlaylists : Object { uint32 max_count, string order, bool reverse_order ) throws IOError; + //signals + public signal void PlaylistChanged (PlaylistDetails details); + }
\ No newline at end of file diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index b8c6e7d..8a2ccac 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -19,18 +19,20 @@ with this program. If not, see <http://www.gnu.org/licenses/>. using Dbusmenu; using DbusmenuPlaylists; +using DbusmenuPlaylist; using Gee; public class PlaylistsMenuitem : PlayerItem { - private HashMap<int, PlaylistDetails?> current_playlists; + private HashMap<int, Dbusmenu.Menuitem> current_playlists; public Menuitem root_item; + public PlaylistsMenuitem ( PlayerController parent ) { Object ( item_type: MENUITEM_TYPE, owner: parent ); } construct{ - this.current_playlists = new HashMap<int, PlaylistDetails?>(); + this.current_playlists = new HashMap<int, Dbusmenu.Menuitem>(); this.root_item = new Menuitem(); this.root_item.property_set ( MENUITEM_PROP_LABEL, "Choose Playlist" ); } @@ -38,23 +40,38 @@ public class PlaylistsMenuitem : PlayerItem public new void update (PlaylistDetails[] playlists) { foreach ( PlaylistDetails detail in playlists ){ + if (this.already_observed(detail)) continue; + 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 (MENUITEM_PROP_ICON_NAME, detail.icon_path); + menuitem.property_set (MENUITEM_PATH, (string)detail.path); 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.current_playlists.set( menuitem.id, menuitem ); this.root_item.child_append( menuitem ); } } - + + public void update_individual_playlist (PlaylistDetails new_detail) + { + foreach ( Dbusmenu.Menuitem item in this.current_playlists.values ){ + if (new_detail.path == item.property_get (MENUITEM_PATH)){ + item.property_set (MENUITEM_PROP_LABEL, new_detail.name); + item.property_set (MENUITEM_PROP_ICON_NAME, new_detail.icon_path); + } + } + } + private bool already_observed (PlaylistDetails new_detail) { - foreach ( PlaylistDetails detail in this.current_playlists.values ){ - if (new_detail.path == detail.path) return true; + foreach ( Dbusmenu.Menuitem item in this.current_playlists.values ){ + var path = item.property_get (MENUITEM_PATH); + if (new_detail.path == path) return true; } return false; } @@ -68,12 +85,12 @@ public class PlaylistsMenuitem : PlayerItem private void submenu_item_activated (int menu_item_id) { - if(!this.current_playlists.has_key(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 ); + this.owner.mpris_bridge.activate_playlist ( (GLib.ObjectPath)this.current_playlists[menu_item_id].property_get (MENUITEM_PATH) ); } public static HashSet<string> attributes_format() diff --git a/src/sound-service.c b/src/sound-service.c index cfc0b7e..b5e6224 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -39,8 +39,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) { if (mainloop != NULL) { g_debug("Service shutdown !"); - close_pulse_activites(); - g_main_loop_quit(mainloop); + //close_pulse_activites(); + //g_main_loop_quit(mainloop); } return; } diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi index 2946d25..7b38e9c 100644 --- a/vapi/common-defs.vapi +++ b/vapi/common-defs.vapi @@ -53,4 +53,8 @@ namespace DbusmenuPlaylists{ public const string MENUITEM_TYPE; public const string MENUITEM_TITLE; public const string MENUITEM_PLAYLISTS; +} +[CCode (cheader_filename = "common-defs.h")] +namespace DbusmenuPlaylist{ + public const string MENUITEM_PATH; }
\ No newline at end of file |