aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c5
-rw-r--r--src/service.vala7
-rw-r--r--tests/notifications-test.cc2
3 files changed, 8 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index d2a8be8..6cc3b13 100644
--- a/src/main.c
+++ b/src/main.c
@@ -22,19 +22,22 @@ main (int argc, char ** argv) {
notify_init ("indicator-sound");
MediaPlayerList * playerlist = NULL;
+ AccountsServiceUser * accounts = NULL;
if (g_strcmp0("lightdm", g_get_user_name()) == 0) {
playerlist = MEDIA_PLAYER_LIST(media_player_list_greeter_new());
} else {
playerlist = MEDIA_PLAYER_LIST(media_player_list_mpris_new());
+ accounts = accounts_service_user_new();
}
VolumeControlPulse * volume = volume_control_pulse_new();
- service = indicator_sound_service_new (playerlist, volume);
+ service = indicator_sound_service_new (playerlist, volume, accounts);
result = indicator_sound_service_run (service);
g_object_unref(playerlist);
+ g_clear_object(&accounts);
g_object_unref(service);
return result;
diff --git a/src/service.vala b/src/service.vala
index c63f5c0..c6f318b 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -18,7 +18,7 @@
*/
public class IndicatorSound.Service: Object {
- public Service (MediaPlayerList playerlist, VolumeControl volume) {
+ public Service (MediaPlayerList playerlist, VolumeControl volume, AccountsServiceUser? accounts) {
sync_notification = new Notify.Notification(_("Volume"), "", "audio-volume-muted");
this.notification_server_watch = GLib.Bus.watch_name(GLib.BusType.SESSION,
"org.freedesktop.Notifications",
@@ -34,10 +34,9 @@ public class IndicatorSound.Service: Object {
this.volume_control = volume;
+ this.accounts_service = accounts;
/* If we're on the greeter, don't export */
- if (GLib.Environment.get_user_name() != "lightdm") {
- this.accounts_service = new AccountsServiceUser();
-
+ if (this.accounts_service != null) {
this.accounts_service.notify["showDataOnGreeter"].connect(() => {
this.export_to_accounts_service = this.accounts_service.showDataOnGreeter;
eventually_update_player_actions();
diff --git a/tests/notifications-test.cc b/tests/notifications-test.cc
index 6e531fd..c738027 100644
--- a/tests/notifications-test.cc
+++ b/tests/notifications-test.cc
@@ -91,7 +91,7 @@ class NotificationsTest : public ::testing::Test
TEST_F(NotificationsTest, BasicObject) {
auto playerList = std::shared_ptr<MediaPlayerList>(MEDIA_PLAYER_LIST(media_player_list_mock_new()), [](MediaPlayerList * list){g_clear_object(&list);});
auto volumeControl = std::shared_ptr<VolumeControl>(VOLUME_CONTROL(volume_control_mock_new()), [](VolumeControl * control){g_clear_object(&control);});
- auto soundService = std::shared_ptr<IndicatorSoundService>(indicator_sound_service_new(playerList.get(), volumeControl.get()), [](IndicatorSoundService * service){g_clear_object(&service);});
+ auto soundService = std::shared_ptr<IndicatorSoundService>(indicator_sound_service_new(playerList.get(), volumeControl.get(), nullptr), [](IndicatorSoundService * service){g_clear_object(&service);});
/* Give some time settle */
loop(50);