diff options
author | Ted Gould <ted@gould.cx> | 2014-02-27 15:11:29 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2014-02-27 15:11:29 -0600 |
commit | 636de261d04d47de8305597c27c9eed921c20b71 (patch) | |
tree | 967fb54251afbd917168df95c4a90879715a1c4d /src/accounts-service-user.vala | |
parent | 70d2d969bc4ba562792580f10e8c382691fa5881 (diff) | |
download | ayatana-indicator-sound-636de261d04d47de8305597c27c9eed921c20b71.tar.gz ayatana-indicator-sound-636de261d04d47de8305597c27c9eed921c20b71.tar.bz2 ayatana-indicator-sound-636de261d04d47de8305597c27c9eed921c20b71.zip |
Adding support to the greeter signals on the other side
Diffstat (limited to 'src/accounts-service-user.vala')
-rw-r--r-- | src/accounts-service-user.vala | 42 |
1 files changed, 42 insertions, 0 deletions
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<GreeterBroadcast> ( + 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); + } + } } |