4
If you want your own plugin within this source tree
5
don't forget to add the new subdirectory to the plugins' Makefile.am
6
SUBDIRS list and add your Makefile to the list of Makefiles found at
7
about the end of the configure.ac file AC_CONFIG_FILES.
8
The API is currently internal until the API is finalized, so you have
9
to build it in this source tree.
11
Some more useful notes on developing plugins:
15
If you want to display large elements that can be toggled instead of small overlays,
16
you can use wm.begin_modal() to make Gala enter modal mode. In this mode, you'll be
17
able to receive key events and all mouse events will be delivered regardless of the
18
region you have set. Don't forget to call wm.end_modal() and provide an obvious way
19
to exit modal mode for the user, otherwise he will be stuck and can only restart
24
To add keybindings, you'll need a gsettings schema. You can take a look at Gala's
25
schema in data/org.pantheon.desktop.gschema.xml for an example. You'll also find
26
how to correctly declare shortcut keys in that file. Once you got this file ready
27
it's pretty easy. Just enable its installation in cmake, the relevant is commented
28
out in this template, and call wm.get_screen().get_display().add_keybinding().
29
The keybinding function takes the name of the shortcut key in your
30
schema, then a GSettings instance for that schema, which can be obtained with
31
'new GLib.Settings("org.pantheon.gala.plugins.my-plugin")', then some flags, for
32
which you can almost always use 0, refer to the vapi for more details, and finally
33
your function as arguments. Its delegate is:
35
public delegate void KeyHandlerFunc (Meta.Display display, Meta.Screen screen,
36
Meta.Window? window, X.Event event, Meta.KeyBinding binding);
38
So it'd be something like
40
void initialize (Gala.WindowManager wm)
43
var display = wm.get_screen ().get_display ();
44
var schema = new GLib.Settings ("org.pantheon.desktop.gala.plugins");
45
display.add_keybinding ("my-shortcut", schema, 0, my_handler);
48
void my_handler (Meta.Display display, Meta.Screen screen, Meta.Window? window,
49
X.Event event, Meta.KeyBinding binding)
51
print ("Shortcut hit! D:");
55
wm.get_screen ().get_display ().remove_keybinding ("my-shortcut");
58
Overriding default keybindings
59
------------------------------
60
Libmutter allows you to override exisiting shortcuts, which is a lot easier than
61
adding new ones. All you have to do is:
63
Keybinding.set_custom_handler ("shortcut-name", my_handler);
65
The signature for my_handler is the same as above.
69
A great source for exploring the possibilities of mutter's API is scrolling through
70
the mentioned mutter vapi. In some cases you can find documentation on particular
71
functions in the mutter source code. Just grep for their C names.