aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-12-21 14:53:56 +0000
committerConor Curran <conor.curran@canonical.com>2010-12-21 14:53:56 +0000
commit4843ae15f1ce4111c03b0fc24f5a8989d0619697 (patch)
tree55c320b02c23bedfc750ea25702d461402205520 /src
parentc8c7681e7b9e2995d29fa58c931aa09e451c4fee (diff)
downloadayatana-indicator-sound-4843ae15f1ce4111c03b0fc24f5a8989d0619697.tar.gz
ayatana-indicator-sound-4843ae15f1ce4111c03b0fc24f5a8989d0619697.tar.bz2
ayatana-indicator-sound-4843ae15f1ce4111c03b0fc24f5a8989d0619697.zip
playlists ready to go into trunk
Diffstat (limited to 'src')
-rw-r--r--src/mpris2-controller.vala27
-rw-r--r--src/music-player-bridge.vala2
-rw-r--r--src/playlists-menu-item.vala13
-rw-r--r--src/sound-service.c4
4 files changed, 22 insertions, 24 deletions
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 35dc4e4..5f98541 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -97,6 +97,7 @@ public class Mpris2Controller : GLib.Object
Variant? playlist_v = changed_properties.lookup("ActivePlaylist");
if ( playlist_v != null ){
this.fetch_active_playlist();
+ //Timeout.add ( 200, fetch_active_playlist );
}
}
@@ -154,6 +155,7 @@ public class Mpris2Controller : GLib.Object
this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata,
MetadataMenuitem.attributes_format());
this.fetch_playlists();
+ this.fetch_active_playlist();
}
public void transport_update(TransportMenuitem.action command)
@@ -172,10 +174,8 @@ public class Mpris2Controller : GLib.Object
public void fetch_playlists()
{
- if (this.playlists == null){
- warning("Playlists object is null");
- return;
- }
+ if (this.playlists == null) return;
+
PlaylistDetails[] current_playlists = this.playlists.GetPlaylists(0,
10,
"Alphabetical",
@@ -184,30 +184,17 @@ public class Mpris2Controller : GLib.Object
debug( "Size of the playlist array = %i", current_playlists.length );
PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
playlists_item.update(current_playlists);
- /*foreach(PlaylistDetails detail in current_playlists){
- debug(" \n \n ");
- debug( "Playlist Name = %s", detail.name);
- debug( "Playlist path = %s", detail.path);
- debug( "Playlist icon path = %s", detail.icon_path);
- debug(" \n \n ");
- }*/
}
+ return;
}
- public void fetch_active_playlist()
+ private void fetch_active_playlist()
{
- if (this.playlists == null && this.playlists.ActivePlaylist.valid == true){
+ if (this.playlists == null && this.playlists.ActivePlaylist.valid == false){
warning("Playlists object is null or we don't have an active playlist");
- return;
}
PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
playlists_item.update_active_playlist ( this.playlists.ActivePlaylist.details );
- /*debug(" \n \n ");
- debug( "Active Playlist Name = %s", active_details.name);
- debug( "Active Playlist path = %s", active_details.path);
- debug( "Active Playlist icon path = %s", active_details.icon_path);
- debug(" \n \n ");
- */
}
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index 239a40b..de8609d 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -76,7 +76,7 @@ public class MusicPlayerBridge : GLib.Object
}
}
- public void client_has_become_available ( string desktop, string dbus_name )
+ public void client_has_become_available ( string desktop, string dbus_name )
{
if (desktop == null || desktop == ""){
warning("Client %s attempting to register without desktop entry being set on the mpris root",
diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala
index 30ffdc7..024839c 100644
--- a/src/playlists-menu-item.vala
+++ b/src/playlists-menu-item.vala
@@ -38,6 +38,7 @@ 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");
@@ -50,9 +51,19 @@ public class PlaylistsMenuitem : PlayerItem
}
}
+ private bool already_observed (PlaylistDetails new_detail)
+ {
+ foreach ( PlaylistDetails detail in this.current_playlists.values ){
+ if (new_detail.path == detail.path) return true;
+ }
+ return false;
+ }
+
public void update_active_playlist(PlaylistDetails detail)
{
- this.root_item.property_set ( MENUITEM_PROP_LABEL, detail.name );
+ var update = detail.name;
+ if ( update == "" ) update = "Choose Playlist";
+ this.root_item.property_set ( MENUITEM_PROP_LABEL, update );
}
private void submenu_item_activated (int menu_item_id)
diff --git a/src/sound-service.c b/src/sound-service.c
index defcb94..98f1881 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -40,8 +40,8 @@ service_shutdown (IndicatorService *service, gpointer user_data)
{
if (mainloop != NULL) {
g_debug("Service shutdown !");
- //close_pulse_activites();
- //g_main_loop_quit(mainloop);
+ close_pulse_activites();
+ g_main_loop_quit(mainloop);
}
return;
}