diff options
author | Ken VanDine <ken.vandine@canonical.com> | 2011-02-10 13:19:22 -0500 |
---|---|---|
committer | Ken VanDine <ken.vandine@canonical.com> | 2011-02-10 13:19:22 -0500 |
commit | 817f8e1a86aaa026c8de8acee40c5c9664d358d0 (patch) | |
tree | d74ee9e8911c0d7b2ecf6b3df98e1bcdff73fe06 /src/playlists-menu-item.vala | |
parent | d668df547af9a4add8c18e3614d344b80e0bd6c8 (diff) | |
parent | b4b1c772dc57c3034cc80b785e4b472b8fe1b404 (diff) | |
download | ayatana-indicator-sound-817f8e1a86aaa026c8de8acee40c5c9664d358d0.tar.gz ayatana-indicator-sound-817f8e1a86aaa026c8de8acee40c5c9664d358d0.tar.bz2 ayatana-indicator-sound-817f8e1a86aaa026c8de8acee40c5c9664d358d0.zip |
releasing version 0.5.9-0ubuntu1
Diffstat (limited to 'src/playlists-menu-item.vala')
-rw-r--r-- | src/playlists-menu-item.vala | 33 |
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() |