5 [DBus (name
= "org.gnome.SettingsDaemon.MediaKeys")]
6 interface MediaKeys
: GLib
.Object
{
7 public abstract void GrabMediaPlayerKeys (string application
, uint32 time
);
8 public abstract void ReleaseMediaPlayerKeys (string application
);
9 public signal void MediaPlayerKeyPressed (string application
, string keys
);
12 public class MMKeys
: Gmpc
.Plugin
.Base
{
13 public const int[] pversion
= {0,0,0};
14 private DBus
.Connection conn
;
15 private MediaKeys keys
;
17 public override weak string get_name() {
21 public override weak int[] get_version() {
24 private void callback (MediaKeys mkeys
, string application
, string keys
) {
25 if(this
.get_enabled() == false) return;
26 if(application
!= "gmpc") return;
27 if(keys
== "Play") MPD
.Player
.play(server
);
28 else if(keys
== "Pause") MPD
.Player
.pause(server
);
29 else if(keys
== "Next") MPD
.Player
.next(server
);
30 else if(keys
== "Previous") MPD
.Player
.prev(server
);
31 else if(keys
== "Stop") MPD
.Player
.stop(server
);
34 /* Set the plugin as an internal one and of type pl_browser */
36 conn
= DBus
.Bus
.get (DBus
.BusType
.SESSION
);
37 keys
= (MediaKeys
) conn
.get_object ( "org.gnome.SettingsDaemon",
38 "/org/gnome/SettingsDaemon/MediaKeys");
40 keys
.GrabMediaPlayerKeys("gmpc", (uint)0);
41 keys
.MediaPlayerKeyPressed
+= callback;
44 keys
.ReleaseMediaPlayerKeys("gmpc");
48 public Type
plugin_get_type () {
49 return typeof (MMKeys
);