aboutsummaryrefslogtreecommitdiff
path: root/src/playlists-menu-item.vala
diff options
context:
space:
mode:
authorKen VanDine <ken.vandine@canonical.com>2011-02-10 11:52:58 -0500
committerKen VanDine <ken.vandine@canonical.com>2011-02-10 11:52:58 -0500
commitb4b1c772dc57c3034cc80b785e4b472b8fe1b404 (patch)
tree6121e6d4e7b7bef8fe6c4f71e0b1064d32db3668 /src/playlists-menu-item.vala
parent868c3e3d18c5de79c679c57ae468f52a504dffd7 (diff)
parentc963e37be35b53d6f9da68a92b2bb9f1d42a788d (diff)
downloadayatana-indicator-sound-b4b1c772dc57c3034cc80b785e4b472b8fe1b404.tar.gz
ayatana-indicator-sound-b4b1c772dc57c3034cc80b785e4b472b8fe1b404.tar.bz2
ayatana-indicator-sound-b4b1c772dc57c3034cc80b785e4b472b8fe1b404.zip
Import upstream version 0.5.9
Diffstat (limited to 'src/playlists-menu-item.vala')
-rw-r--r--src/playlists-menu-item.vala33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala
index 024839c..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()