diff options
author | Ken VanDine <ken.vandine@canonical.com> | 2011-03-04 13:38:16 -0500 |
---|---|---|
committer | Ken VanDine <ken.vandine@canonical.com> | 2011-03-04 13:38:16 -0500 |
commit | f2b815cf615ba4532a7e04254ddb4acd1bbb75ff (patch) | |
tree | eda29e8b8c389b0c06148337f56d58b65da97591 /src/playlists-menu-item.vala | |
parent | 4eea1b645a81b5fa99963b3d9c8353a545b68232 (diff) | |
parent | 73772e6ea7f0ca55bd3df65a031ddb48fba66104 (diff) | |
download | ayatana-indicator-sound-f2b815cf615ba4532a7e04254ddb4acd1bbb75ff.tar.gz ayatana-indicator-sound-f2b815cf615ba4532a7e04254ddb4acd1bbb75ff.tar.bz2 ayatana-indicator-sound-f2b815cf615ba4532a7e04254ddb4acd1bbb75ff.zip |
releasing version 0.6.2-0ubuntu1
Diffstat (limited to 'src/playlists-menu-item.vala')
-rw-r--r-- | src/playlists-menu-item.vala | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index 8a2ccac..f4d7233 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -34,7 +34,9 @@ public class PlaylistsMenuitem : PlayerItem construct{ this.current_playlists = new HashMap<int, Dbusmenu.Menuitem>(); this.root_item = new Menuitem(); + this.root_item.property_set ( MENUITEM_PROP_LABEL, "Choose Playlist" ); + this.root_item.property_set ( MENUITEM_PATH, "" ); } public new void update (PlaylistDetails[] playlists) @@ -51,10 +53,28 @@ public class PlaylistsMenuitem : PlayerItem menuitem.property_set_bool (MENUITEM_PROP_ENABLED, true); menuitem.item_activated.connect(() => { - submenu_item_activated (menuitem.id );}); - this.current_playlists.set( menuitem.id, menuitem ); + submenu_item_activated (menuitem.id ); + } + ); + this.current_playlists.set( menuitem.id, menuitem ); this.root_item.child_append( menuitem ); } + // Finally remove any that might have been deleted + foreach (Dbusmenu.Menuitem item in this.current_playlists.values) { + bool within = false; + foreach (PlaylistDetails detail in playlists){ + if (detail.path == item.property_get (MENUITEM_PATH)) { + within = true; + break; + } + } + if (within == false){ + if (this.root_item.property_get (MENUITEM_PATH) == item.property_get (MENUITEM_PATH)){ + this.root_item.property_set (MENUITEM_PROP_LABEL, "Choose Playlist"); + } + this.root_item.child_delete (item); + } + } } public void update_individual_playlist (PlaylistDetails new_detail) @@ -65,6 +85,10 @@ public class PlaylistsMenuitem : PlayerItem item.property_set (MENUITEM_PROP_ICON_NAME, new_detail.icon_path); } } + // If its active make sure the name is updated on the root item. + if (this.root_item.property_get (MENUITEM_PATH) == new_detail.path) { + this.root_item.property_set (MENUITEM_PROP_LABEL, new_detail.name); + } } private bool already_observed (PlaylistDetails new_detail) @@ -76,11 +100,12 @@ public class PlaylistsMenuitem : PlayerItem return false; } - public void update_active_playlist(PlaylistDetails detail) + public void active_playlist_update (PlaylistDetails detail) { var update = detail.name; if ( update == "" ) update = "Choose Playlist"; - this.root_item.property_set ( MENUITEM_PROP_LABEL, update ); + this.root_item.property_set (MENUITEM_PROP_LABEL, update); + this.root_item.property_set (MENUITEM_PATH, detail.path); } private void submenu_item_activated (int menu_item_id) |