aboutsummaryrefslogtreecommitdiff
path: root/src/playlists-menu-item.vala
diff options
context:
space:
mode:
authorKen VanDine <ken.vandine@canonical.com>2011-03-04 13:07:39 -0500
committerKen VanDine <ken.vandine@canonical.com>2011-03-04 13:07:39 -0500
commit73772e6ea7f0ca55bd3df65a031ddb48fba66104 (patch)
treeebaa28ae0383e776de40d2db06f01b727c1ee68c /src/playlists-menu-item.vala
parentd3690d4cb191711ae77abb3b599d1a02b7fcd1df (diff)
parentbcf0cc17469edbb8b882884bdd6ae2155a809d01 (diff)
downloadayatana-indicator-sound-73772e6ea7f0ca55bd3df65a031ddb48fba66104.tar.gz
ayatana-indicator-sound-73772e6ea7f0ca55bd3df65a031ddb48fba66104.tar.bz2
ayatana-indicator-sound-73772e6ea7f0ca55bd3df65a031ddb48fba66104.zip
Import upstream version 0.6.2
Diffstat (limited to 'src/playlists-menu-item.vala')
-rw-r--r--src/playlists-menu-item.vala33
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)