aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-12-09 11:36:33 +0000
committerConor Curran <conor.curran@canonical.com>2010-12-09 11:36:33 +0000
commita964487e2fcd11946b5f95ab36b20cbd1bea4a57 (patch)
treea294b7afb203aff91b163d533522e36280d20dfd /src
parent0649b09ccf86ea2a158fb24061fc3a142e02f462 (diff)
downloadayatana-indicator-sound-a964487e2fcd11946b5f95ab36b20cbd1bea4a57.tar.gz
ayatana-indicator-sound-a964487e2fcd11946b5f95ab36b20cbd1bea4a57.tar.bz2
ayatana-indicator-sound-a964487e2fcd11946b5f95ab36b20cbd1bea4a57.zip
moving towards testing proposed playlists api
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/common-defs.h3
-rw-r--r--src/mpris2-controller.vala34
-rw-r--r--src/mpris2-interfaces.vala24
-rw-r--r--src/player-controller.vala11
-rw-r--r--src/playlists-menu-item.vala46
-rw-r--r--src/sound-service.c4
7 files changed, 114 insertions, 9 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 1c381f5..214507b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -64,6 +64,7 @@ music_bridge_VALASOURCES = \
mpris2-watcher.vala \
mpris2-controller.vala \
player-item.vala \
+ playlists-menu-item.vala \
familiar-players-db.vala \
fetch-file.vala
diff --git a/src/common-defs.h b/src/common-defs.h
index 214f60a..8ec69e8 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -49,3 +49,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define DBUSMENU_SCRUB_MENUITEM_POSITION "x-canonical-sound-menu-player-scrub-position"
#define DBUSMENU_SCRUB_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-scrub-play-state"
+#define DBUSMENU_PLAYLISTS_MENUITEM_TYPE "x-canonical-sound-menu-player-playlists-type"
+#define DBUSMENU_PLAYLISTS_MENUITEM_TITLE "x-canonical-sound-menu-player-playlists-title"
+#define DBUSMENU_PLAYLISTS_MENUITEM_PLAYLISTS "x-canonical-sound-menu-player-playlists-playlists" \ No newline at end of file
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 59e3122..2c19606 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -21,8 +21,8 @@ using Dbusmenu;
[DBus (name = "org.freedesktop.DBus.Properties")]
public interface FreeDesktopProperties : Object{
- public signal void PropertiesChanged(string source, HashTable<string, Variant?> changed_properties,
- string[] invalid);
+ public signal void PropertiesChanged (string source, HashTable<string, Variant?> changed_properties,
+ string[] invalid );
}
/*
@@ -34,13 +34,14 @@ public class Mpris2Controller : GLib.Object
public static const string root_interface = "org.mpris.MediaPlayer2" ;
public MprisRoot mpris2_root {get; construct;}
public MprisPlayer player {get; construct;}
+ public MprisPlaylists playlists {get; construct;}
public FreeDesktopProperties properties_interface {get; construct;}
public PlayerController owner {get; construct;}
-
+
public Mpris2Controller(PlayerController ctrl)
{
- GLib.Object(owner: ctrl);
+ GLib.Object(owner: ctrl);
}
construct{
@@ -51,6 +52,9 @@ public class Mpris2Controller : GLib.Object
this.player = Bus.get_proxy_sync ( BusType.SESSION,
root_interface.concat(".").concat(this.owner.mpris_name),
"/org/mpris/MediaPlayer2" );
+ this.playlists = Bus.get_proxy_sync ( BusType.SESSION,
+ root_interface.concat(".").concat(this.owner.mpris_name),
+ "/org/mpris/MediaPlayer2" );
this.properties_interface = Bus.get_proxy_sync ( BusType.SESSION,
"org.freedesktop.Properties.PropertiesChanged",
@@ -127,12 +131,14 @@ public class Mpris2Controller : GLib.Object
GLib.HashTable<string, Value?>? cleaned_metadata = this.clean_metadata();
this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata,
MetadataMenuitem.attributes_format());
+ this.fetch_playlists();
}
public void transport_update(TransportMenuitem.action command)
{
debug("transport_event input = %i", (int)command);
if(command == TransportMenuitem.action.PLAY_PAUSE){
+ this.fetch_playlists();
this.player.PlayPause.begin();
}
else if(command == TransportMenuitem.action.PREVIOUS){
@@ -143,6 +149,26 @@ public class Mpris2Controller : GLib.Object
}
}
+ public void fetch_playlists()
+ {
+ if (this.playlists == null){
+ warning("Playlists object is null");
+ return;
+ }
+ PlaylistDetails[] current_playlists = this.playlists.GetPlaylists(0, 10, "Alphabetical", false);
+ if( current_playlists != null ){
+ 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( "Playlist Name = %s", detail.name);
+ debug( "Playlist path = %s", detail.path);
+ debug( "Playlist icon path = %s", detail.icon_path);
+ debug(" \n \n \n \n \n ");
+ }*/
+ }
+ }
+
public bool connected()
{
return (this.player != null && this.mpris2_root != null);
diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala
index ebea135..3f5519b 100644
--- a/src/mpris2-interfaces.vala
+++ b/src/mpris2-interfaces.vala
@@ -44,3 +44,27 @@ public interface MprisPlayer : Object {
// signals
public signal void Seeked(int64 new_position);
}
+
+
+// Playlist container
+public struct PlaylistDetails{
+ public ObjectPath path;
+ public string name;
+ public string icon_path;
+}
+
+[DBus (name = "org.mpris.MediaPlayer2.Playlists")]
+// TODO: API criticisms
+// get playlists should be able to be async => pass in struct to be populated or pass in callback
+public interface MprisPlaylists : Object {
+ //properties
+ public abstract string[] Orderings{owned get; set;}
+ public abstract uint32 PlaylistCount{owned get; set;}
+
+ //methods
+ public abstract async void ActivatePlaylist(ObjectPath playlist_id) throws IOError;
+ public abstract PlaylistDetails[] GetPlaylists ( uint32 index,
+ uint32 max_count,
+ string order,
+ bool reverse_order ) throws IOError;
+} \ No newline at end of file
diff --git a/src/player-controller.vala b/src/player-controller.vala
index 0b540f9..b9e275f 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -23,13 +23,14 @@ using Gee;
public class PlayerController : GLib.Object
{
- public const int WIDGET_QUANTITY = 4;
+ public const int WIDGET_QUANTITY = 5;
public static enum widget_order{
SEPARATOR,
TITLE,
METADATA,
TRANSPORT,
+ PLAYLISTS
}
public enum state{
@@ -158,7 +159,11 @@ public class PlayerController : GLib.Object
// Transport item
TransportMenuitem transport_item = new TransportMenuitem(this);
this.custom_items.add(transport_item);
-
+
+ // Playlist item
+ PlaylistsMenuitem playlist_menuitem = new PlaylistsMenuitem(this);
+ this.custom_items.add(playlist_menuitem);
+
foreach(PlayerItem item in this.custom_items){
root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item));
}
@@ -184,7 +189,7 @@ public class PlayerController : GLib.Object
this.update_state(state.CONNECTED);
TitleMenuitem title = this.custom_items[widget_order.TITLE] as TitleMenuitem;
title.toggle_active_triangle(true);
- this.mpris_bridge.initial_update();
+ this.mpris_bridge.initial_update();
}
else{
this.update_state(state.DISCONNECTED);
diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala
new file mode 100644
index 0000000..8106600
--- /dev/null
+++ b/src/playlists-menu-item.vala
@@ -0,0 +1,46 @@
+/*
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+using Dbusmenu;
+using DbusmenuPlaylists;
+using Gee;
+
+public class PlaylistsMenuitem : PlayerItem
+{
+ public PlaylistsMenuitem ( PlayerController parent )
+ {
+ Object ( item_type: MENUITEM_TYPE, owner: parent );
+ }
+
+ public void update (PlaylistDetails[] playlists)
+ {
+ foreach ( PlaylistDetail detail in playlists ){
+
+ }
+ }
+
+ public static HashSet<string> attributes_format()
+ {
+ HashSet<string> attrs = new HashSet<string>();
+ attrs.add(MENUITEM_TITLE);
+ attrs.add(MENUITEM_PLAYLISTS);
+ return attrs;
+ }
+
+}
diff --git a/src/sound-service.c b/src/sound-service.c
index 98f1881..defcb94 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;
}