diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-03-03 15:45:05 +0000 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-03-03 15:45:05 +0000 |
commit | 52976fc65cc974e481722acc68e44857a737599a (patch) | |
tree | b816caf83d7fe31dc99ae8e655f8a631ca38fb2c /src/playlists-menu-item.vala | |
parent | 8716e591859e3a6a15723a2bf1ee9c9d8fb0545a (diff) | |
download | ayatana-indicator-sound-52976fc65cc974e481722acc68e44857a737599a.tar.gz ayatana-indicator-sound-52976fc65cc974e481722acc68e44857a737599a.tar.bz2 ayatana-indicator-sound-52976fc65cc974e481722acc68e44857a737599a.zip |
fixes two playlists bugs plus a little code tidy up in the indicator-sound
Diffstat (limited to 'src/playlists-menu-item.vala')
-rw-r--r-- | src/playlists-menu-item.vala | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index 8a2ccac..bc39129 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,25 @@ 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){ + this.root_item.child_delete (item); + } + } } public void update_individual_playlist (PlaylistDetails new_detail) @@ -65,6 +82,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 +97,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) |