aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am1
-rw-r--r--src/common-defs.h2
-rw-r--r--src/music-player-bridge.vala17
-rw-r--r--src/player-controller.vala21
-rw-r--r--src/playlists-menu-item.vala1
-rw-r--r--src/sound-service-dbus.c48
-rw-r--r--src/sound-service.c41
-rw-r--r--src/sound-service.xml11
-rw-r--r--src/track-specific-menu-item.vala40
-rw-r--r--vapi/common-defs.vapi1
10 files changed, 165 insertions, 18 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index c546f0f..fde333a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -46,6 +46,7 @@ checkxml: $(srcdir)/sound-service.xml
music_bridge_VALASOURCES = \
music-player-bridge.vala \
transport-menu-item.vala \
+ track-specific-menu-item.vala \
metadata-menu-item.vala \
player-controller.vala \
mpris2-interfaces.vala \
diff --git a/src/common-defs.h b/src/common-defs.h
index b1b001e..a20fb03 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -67,6 +67,8 @@ typedef enum {
#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-sound-menu-player-transport-type"
#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-transport-state"
+#define DBUSMENU_TRACK_SPECIFIC_MENUITEM_TYPE "x-canonical-sound-menu-player-track-specific-type"
+
#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-type"
#define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-xesam:artist"
#define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-xesam:title"
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index b5932fa..3cda638 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -27,7 +27,7 @@ public class MusicPlayerBridge : GLib.Object
private SettingsManager settings_manager;
private Dbusmenu.Menuitem root_menu;
- private HashMap<string, PlayerController> registered_clients;
+ private HashMap<string, PlayerController> registered_clients;
private Mpris2Watcher watcher;
public MusicPlayerBridge()
@@ -158,6 +158,21 @@ public class MusicPlayerBridge : GLib.Object
this.watcher.client_disappeared.connect (this.client_has_vanished);
}
+ public void enable_player_specific_items_for_client (string desktop_id)
+ {
+ // TODO
+ }
+
+ public void enable_track_specific_items_for_client (string desktop_id)
+ {
+ var mpris_key = determine_key ( desktop_id );
+ if (this.registered_clients.has_key (mpris_key) == false){
+ warning ("we don't have a client with desktop id %s registered", desktop_id);
+ return;
+ }
+ this.registered_clients[mpris_key].enable_track_specific_items();
+ }
+
private static AppInfo? create_app_info ( string desktop )
{
DesktopAppInfo info = new DesktopAppInfo ( desktop ) ;
diff --git a/src/player-controller.vala b/src/player-controller.vala
index a08f692..52adb23 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -23,12 +23,13 @@ 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,
METADATA,
TRANSPORT,
+ TRACK_SPECIFIC,
PLAYLISTS
}
@@ -105,6 +106,14 @@ public class PlayerController : GLib.Object
error.message );
}
}
+
+ public void enable_track_specific_items()
+ {
+ debug ("enable_track_specific_items");
+ TrackSpecificMenuitem menuitem = this.custom_items[widget_order.TRACK_SPECIFIC] as TrackSpecificMenuitem;
+ menuitem.root_item.property_set_bool (MENUITEM_PROP_VISIBLE, true);
+ menuitem.root_item.property_set_bool (MENUITEM_PROP_ENABLED, true);
+ }
private void establish_mpris_connection()
{
@@ -180,16 +189,24 @@ public class PlayerController : GLib.Object
// Transport item
TransportMenuitem transport_item = new TransportMenuitem(this);
this.custom_items.add(transport_item);
+
+ // Track Specific item
+ TrackSpecificMenuitem track_specific_item = new TrackSpecificMenuitem(this);
+ this.custom_items.add(track_specific_item);
// Playlist item
PlaylistsMenuitem playlist_menuitem = new PlaylistsMenuitem(this);
this.custom_items.add(playlist_menuitem);
foreach(PlayerItem item in this.custom_items){
- if (this.custom_items.index_of(item) == 3) {
+ if (this.custom_items.index_of(item) == 4) {
PlaylistsMenuitem playlists_menuitem = item as PlaylistsMenuitem;
root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item));
}
+ else if (this.custom_items.index_of(item) == 3) {
+ TrackSpecificMenuitem trackspecific_menuitem = item as TrackSpecificMenuitem;
+ root_menu.child_add_position(trackspecific_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item));
+ }
else{
root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item));
}
diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala
index 7faa214..452a586 100644
--- a/src/playlists-menu-item.vala
+++ b/src/playlists-menu-item.vala
@@ -39,7 +39,6 @@ public class PlaylistsMenuitem : PlayerItem
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)
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index 6fb0a64..5d7c4cd 100644
--- a/src/sound-service-dbus.c
+++ b/src/sound-service-dbus.c
@@ -58,6 +58,14 @@ struct _SoundServiceDbusPrivate {
Device* device;
};
+enum {
+ TRACK_SPECIFIC_ITEM,
+ PLAYER_SPECIFIC_ITEM,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
static GDBusNodeInfo * node_info = NULL;
static GDBusInterfaceInfo * interface_info = NULL;
@@ -110,6 +118,22 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass)
g_error("Unable to find interface '" INDICATOR_SOUND_DBUS_INTERFACE "'");
}
}
+ signals[TRACK_SPECIFIC_ITEM] = g_signal_new("track-specific-item-requested",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 2, G_TYPE_STRING,
+ G_TYPE_STRING);
+ signals[PLAYER_SPECIFIC_ITEM] = g_signal_new("player-specific-item-requested",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 2, G_TYPE_STRING,
+ G_TYPE_STRING);
}
static void
@@ -148,7 +172,6 @@ sound_service_dbus_create_root_item (SoundServiceDbus* self)
{
SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
priv->root_menuitem = dbusmenu_menuitem_new();
- //g_debug("Root ID: %d", dbusmenu_menuitem_get_id(priv->root_menuitem));
DbusmenuServer *server = dbusmenu_server_new (INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH);
dbusmenu_server_set_root (server, priv->root_menuitem);
g_object_unref (priv->root_menuitem);
@@ -183,9 +206,9 @@ sound_service_dbus_build_sound_menu ( SoundServiceDbus* self,
dbusmenu_menuitem_property_set( settings_mi,
DBUSMENU_MENUITEM_PROP_LABEL,
- _("Sound Settings..."));
+ _("Sound Preferences..."));
dbusmenu_menuitem_child_append(priv->root_menuitem, settings_mi);
- g_object_unref (settings_mi);
+ g_object_unref (settings_mi);
g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
G_CALLBACK(show_sound_settings_dialog), NULL);
}
@@ -297,6 +320,25 @@ bus_method_call (GDBusConnection * connection,
player_name);
retval = g_variant_new ("(b)", result);
}
+ else if (g_strcmp0(method, "EnableTrackSpecificItems") == 0) {
+ gchar** player_object_path_and_id;
+ g_variant_get (params, "(ss)", &player_object_path_and_id);
+ /*g_debug ("EnableTrackSpecificItems - name %s", player_object_path);
+ g_signal_emit (service,
+ signals[TRACK_SPECIFIC_ITEM],
+ 0,
+ player_object_path);*/
+
+ }
+ else if (g_strcmp0(method, "EnablePlayerSpecificItems") == 0) {
+ /*gchar* player_object_path;
+ g_variant_get (params, "(s)", &player_object_path);
+ g_debug ("EnableTrackSpecificItems - name %s", player_object_path);
+ g_signal_emit (service,
+ signals[TRACK_SPECIFIC_ITEM],
+ 0,
+ player_object_path);*/
+ }
else {
g_warning("Calling method '%s' on the sound service but it's unknown", method);
}
diff --git a/src/sound-service.c b/src/sound-service.c
index 1324537..dd957a0 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -21,15 +21,13 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "pulseaudio-mgr.h"
#include "sound-service-dbus.h"
#include "music-player-bridge.h"
-
#include <locale.h>
static GMainLoop *mainloop = NULL;
-
+static MusicPlayerBridge* player_bridge;
/**********************************************************************************************************************/
// Init and exit functions
/**********************************************************************************************************************/
-
/**
service_shutdown:
When the service interface starts to shutdown, we
@@ -47,29 +45,54 @@ service_shutdown (IndicatorService *service, gpointer user_data)
return;
}
+void
+on_player_specific_item_requested (SoundServiceDbus* sound_service,
+ const gchar* desktop_id,
+ const gchar* player_object_path,
+ gpointer userdata)
+{
+ music_player_bridge_enable_player_specific_items_for_client (player_bridge, desktop_id);
+ g_debug ("ON PLAYER SPECIFIC ITEM REQUESTED %s", desktop_id);
+}
+
+void
+on_track_specific_item_requested (SoundServiceDbus* sound_service,
+ const gchar* desktop_id,
+ const gchar* player_object_path,
+ gpointer userdata)
+{
+ music_player_bridge_enable_track_specific_items_for_client (player_bridge, desktop_id);
+ g_debug ("ON TRACK SPECIFIC ITEM REQUESTED %s", desktop_id);
+}
+
/**
main:
**/
int
main (int argc, char ** argv)
{
-
g_type_init();
textdomain (GETTEXT_PACKAGE);
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
setlocale (LC_ALL, "");
- IndicatorService *service = indicator_service_new_version(INDICATOR_SOUND_DBUS_NAME,
- INDICATOR_SOUND_DBUS_VERSION);
+ IndicatorService *service = indicator_service_new_version (INDICATOR_SOUND_DBUS_NAME,
+ INDICATOR_SOUND_DBUS_VERSION);
g_signal_connect(G_OBJECT(service),
INDICATOR_SERVICE_SIGNAL_SHUTDOWN,
G_CALLBACK(service_shutdown), NULL);
SoundServiceDbus* sound_service = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL);
+ g_signal_connect(G_OBJECT(sound_service),
+ "track-specific-item-requested",
+ G_CALLBACK(on_track_specific_item_requested), NULL);
+ g_signal_connect(G_OBJECT(sound_service),
+ "player-specific-item-requested",
+ G_CALLBACK(on_player_specific_item_requested), NULL);
- DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item(sound_service);
- MusicPlayerBridge* server = music_player_bridge_new();
- music_player_bridge_set_root_menu_item(server, root_menuitem);
+ DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item (sound_service);
+ player_bridge = music_player_bridge_new ();
+ music_player_bridge_set_root_menu_item (player_bridge, root_menuitem);
// Run the loop
mainloop = g_main_loop_new(NULL, FALSE);
diff --git a/src/sound-service.xml b/src/sound-service.xml
index 517088e..af0f136 100644
--- a/src/sound-service.xml
+++ b/src/sound-service.xml
@@ -12,11 +12,20 @@
<arg type='s' name='player_desktop_name' direction="in"/>
<arg type='b' name='result' direction="out"/>
</method>
-
<method name = "GetSoundState">
<annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type='i' name='current_state' direction="out"/>
</method>
+ <method name = "EnableTrackSpecificItems">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type='s' name='player_object_path' direction="in"/>
+ <arg type='s' name='player_desktop_id' direction="in"/>
+ </method>
+ <method name = "EnablePlayerSpecificItems">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type='s' name='player_desktop_id' direction="in"/>
+ <arg type='s' name='player_object_path' direction="in"/>
+ </method>
<signal name="SoundStateUpdate">
<arg name="new_state" type="i" direction="out"/>
</signal>
diff --git a/src/track-specific-menu-item.vala b/src/track-specific-menu-item.vala
new file mode 100644
index 0000000..718a564
--- /dev/null
+++ b/src/track-specific-menu-item.vala
@@ -0,0 +1,40 @@
+/*
+Copyright 2011 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 Gee;
+using DbusmenuTrackSpecific;
+using Dbusmenu;
+
+public class TrackSpecificMenuitem : PlayerItem
+{
+ public Menuitem root_item{get; construct;}
+
+ public TrackSpecificMenuitem (PlayerController parent)
+ {
+ Object(item_type: MENUITEM_TYPE, owner: parent);
+ }
+ construct
+ {
+ this.root_item = new Menuitem();
+ this.root_item.property_set ( MENUITEM_PROP_LABEL, _("Like This") );
+ this.root_item.property_set_bool (MENUITEM_PROP_VISIBLE, false);
+ this.root_item.property_set_bool (MENUITEM_PROP_ENABLED, false);
+ }
+}
diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi
index 6262e2f..33b4aad 100644
--- a/vapi/common-defs.vapi
+++ b/vapi/common-defs.vapi
@@ -52,7 +52,6 @@ namespace DbusmenuPlaylist{
public const string MENUITEM_PATH;
}
-
[CCode (cprefix ="Transport", cheader_filename = "common-defs.h")]
namespace Transport{
public enum Action{