From 636de261d04d47de8305597c27c9eed921c20b71 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Feb 2014 15:11:29 -0600 Subject: Adding support to the greeter signals on the other side --- src/accounts-service-user.vala | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src') diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala index f021764..debf8bb 100644 --- a/src/accounts-service-user.vala +++ b/src/accounts-service-user.vala @@ -23,6 +23,7 @@ public class AccountsServiceUser : Object { AccountsServiceSoundSettings? proxy = null; uint timer = 0; MediaPlayer? _player = null; + GreeterBroadcast? greeter = null; public MediaPlayer? player { set { @@ -97,6 +98,14 @@ public class AccountsServiceUser : Object { null, new_proxy); }); + + Bus.get_proxy.begin ( + BusType.SYSTEM, + "com.canonical.Unity.Greeter.Broadcast", + "/com/canonical/Unity/Greeter/Broadcast", + DBusProxyFlags.NONE, + null, + greeter_proxy_new); } ~AccountsServiceUser () { @@ -112,4 +121,37 @@ public class AccountsServiceUser : Object { warning("Unable to get proxy to user sound settings: %s", e.message); } } + + void greeter_proxy_new (GLib.Object? obj, AsyncResult res) { + try { + this.greeter = Bus.get_proxy.end (res); + + this.greeter.SoundPlayPause.connect((username) => { + if (username != GLib.Environment.get_user_name()) + return; + if (this._player == null) + return; + this._player.play_pause(); + }); + + this.greeter.SoundNext.connect((username) => { + if (username != GLib.Environment.get_user_name()) + return; + if (this._player == null) + return; + this._player.next(); + }); + + this.greeter.SoundPrev.connect((username) => { + if (username != GLib.Environment.get_user_name()) + return; + if (this._player == null) + return; + this._player.previous(); + }); + } catch (Error e) { + this.greeter = null; + warning("Unable to get greeter proxy: %s", e.message); + } + } } -- cgit v1.2.3