aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt12
-rw-r--r--src/main.c11
-rw-r--r--src/media-player-list-greeter.vala23
-rw-r--r--src/media-player-list-mpris.vala (renamed from src/media-player-list.vala)19
-rw-r--r--src/service.vala4
5 files changed, 55 insertions, 14 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7d58afb..15133f0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -63,10 +63,22 @@ vala_add(indicator-sound-service
media-player-list.vala
DEPENDS
media-player
+)
+vala_add(indicator-sound-service
+ media-player-list-mpris.vala
+ DEPENDS
+ media-player-list
+ media-player
media-player-mpris
mpris2-interfaces
)
vala_add(indicator-sound-service
+ media-player-list-greeter.vala
+ DEPENDS
+ media-player-list
+ media-player
+)
+vala_add(indicator-sound-service
mpris2-interfaces.vala
)
vala_add(indicator-sound-service
diff --git a/src/main.c b/src/main.c
index f8635c8..a14bdea 100644
--- a/src/main.c
+++ b/src/main.c
@@ -21,9 +21,18 @@ main (int argc, char ** argv) {
/* Initialize libnotify */
notify_init ("indicator-sound");
+ MediaPlayerList * playerlist = NULL;
- service = indicator_sound_service_new ();
+ if (g_strcmp0("lightdm", g_get_user_name())) {
+ playerlist = MEDIA_PLAYER_LIST(media_player_list_greeter_new());
+ } else {
+ playerlist = MEDIA_PLAYER_LIST(media_player_list_mpris_new());
+ }
+
+ service = indicator_sound_service_new (playerlist);
result = indicator_sound_service_run (service);
+
+ g_object_unref(playerlist);
g_object_unref(service);
return result;
diff --git a/src/media-player-list-greeter.vala b/src/media-player-list-greeter.vala
new file mode 100644
index 0000000..6bcf270
--- /dev/null
+++ b/src/media-player-list-greeter.vala
@@ -0,0 +1,23 @@
+/*
+ * Copyright © 2014 Canonical Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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/>.
+ *
+ * Authors:
+ * Ted Gould <ted@canonical.com>
+ */
+
+public class MediaPlayerListGreeter : MediaPlayerList {
+
+
+}
diff --git a/src/media-player-list.vala b/src/media-player-list-mpris.vala
index 87ca1f0..0ed3c72 100644
--- a/src/media-player-list.vala
+++ b/src/media-player-list-mpris.vala
@@ -21,23 +21,23 @@
* MediaPlayerList is a list of media players that should appear in the sound menu. Its main responsibility is
* to listen for MPRIS players on the bus and attach them to the corresponding %Player objects.
*/
-public class MediaPlayerList {
+public class MediaPlayerListMpris : MediaPlayerList {
- public MediaPlayerList () {
+ public MediaPlayerListMpris () {
this._players = new HashTable<string, MediaPlayerMpris> (str_hash, str_equal);
BusWatcher.watch_namespace (BusType.SESSION, "org.mpris.MediaPlayer2", this.player_appeared, this.player_disappeared);
}
/* only valid while the list is not changed */
- public class Iterator {
+ public class Iterator : MediaPlayerList.Iterator {
HashTableIter<string, MediaPlayerMpris> iter;
- public Iterator (MediaPlayerList list) {
+ public Iterator (MediaPlayerListMpris list) {
this.iter = HashTableIter<string, MediaPlayerMpris> (list._players);
}
- public MediaPlayer? next_value () {
+ public override MediaPlayer? next_value () {
MediaPlayerMpris? player;
if (this.iter.next (null, out player))
@@ -47,8 +47,8 @@ public class MediaPlayerList {
}
}
- public Iterator iterator () {
- return new Iterator (this);
+ public override MediaPlayerList.Iterator iterator () {
+ return new Iterator (this) as MediaPlayerList.Iterator;
}
/**
@@ -89,7 +89,7 @@ public class MediaPlayerList {
* Synchronizes the player list with @desktop_ids. After this call, this list will only contain the players
* in @desktop_ids. Players that were running but are not in @desktop_ids will remain in the list.
*/
- public void sync (string[] desktop_ids) {
+ public override void sync (string[] desktop_ids) {
/* hash desktop_ids for faster lookup */
var hash = new HashTable<string, unowned string> (str_hash, str_equal);
@@ -107,9 +107,6 @@ public class MediaPlayerList {
this.insert (id);
}
- public signal void player_added (MediaPlayer player);
- public signal void player_removed (MediaPlayer player);
-
HashTable<string, MediaPlayerMpris> _players;
void player_appeared (DBusConnection connection, string name, string owner) {
diff --git a/src/service.vala b/src/service.vala
index 25f3011..7b88e1b 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -18,12 +18,12 @@
*/
public class IndicatorSound.Service {
- public Service () {
+ public Service (MediaPlayerList playerlist) {
this.settings = new Settings ("com.canonical.indicator.sound");
this.volume_control = new VolumeControl ();
- this.players = new MediaPlayerList ();
+ this.players = playerlist;
this.players.player_added.connect (this.player_added);
this.players.player_removed.connect (this.player_removed);