2
// Copyright (C) 2014 Tom Beckmann
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
14
// You should have received a copy of the GNU General Public License
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
19
This is a template class showing some of the things that can be done
20
with a gala plugin and how to do them.
23
namespace Gala.Plugins.Template
25
public class Main : Gala.Plugin
27
const int PADDING = 50;
29
Gala.WindowManager? wm = null;
30
Clutter.Actor red_box;
32
// This function is called as soon as Gala has started and gives you
33
// an instance of the GalaWindowManager class.
34
public override void initialize (Gala.WindowManager wm)
36
// we will save the instance to our wm property so we can use it later again
37
// especially helpful when you have larger plugins with more functions,
38
// we won't need it here
41
// for demonstration purposes we'll add a red quad to the stage which will
42
// turn green when clicked
43
red_box = new Clutter.Actor ();
44
red_box.set_size (100, 100);
45
red_box.background_color = { 255, 0, 0, 255 };
46
red_box.reactive = true;
47
red_box.button_press_event.connect (turn_green);
49
// we want to place it in the lower right of the primary monitor with a bit
50
// of padding. refer to vapi/libmutter.vapi in gala's source for something
51
// remotely similar to a documentation
52
var screen = wm.get_screen ();
53
var rect = screen.get_monitor_geometry (screen.get_primary_monitor ());
55
red_box.x = rect.x + rect.width - red_box.width - PADDING;
56
red_box.y = rect.y + rect.height - red_box.height - PADDING;
58
// to order Gala to deliver mouse events to our box instead of the underlying
59
// windows, we need to mark the region where the quad is located.
60
// The plugin class offers an utility function for this purpose, the track_actor
61
// function. It will update the region with the allocation of the actor
62
// whenever its allocation changes. Make sure to set freeze_track to
63
// true while animating the actor to not make gala update the region
64
// every single frame.
65
// You can also handle the region manually by setting the custom_region
66
// property. The tracked actors and custom regions will be merged by
68
track_actor (red_box);
70
// now we'll add our box into the ui_group. This is where all the shell
71
// elements and also the windows and backgrouds are located.
72
wm.ui_group.add_child (red_box);
75
bool turn_green (Clutter.ButtonEvent event)
77
red_box.background_color = { 0, 255, 0, 255 };
81
// This function is actually not even called by Gala at the moment,
82
// still it might be a good idea to implement it anyway to make sure
83
// your plugin is compatible in case we'd add disabling specific plugins
85
public override void destroy ()
87
// here you would destroy actors you added to the stage or remove
95
// this little function just tells Gala which class of those you may have in
96
// your plugin is the one you want to start with and delivers some additional
97
// details about your plugin. It also gives you the option to choose a specific
98
// function which your plugin fulfils. Gala will then make sure that there is
99
// no duplicate functionality.
100
public Gala.PluginInfo register_plugin ()
103
"template-plugin", // the plugin's name
104
"Tom Beckmann <tomjonabc@gmail.com>", // you, the author
105
typeof (Gala.Plugins.Template.Main), // the type of your plugin class
107
Gala.PluginFunction.ADDITION, // the function which your plugin
108
// fulfils, ADDITION means nothing
111
Gala.LoadPriority.IMMEDIATE // indicates whether your plugin's
112
// start can be delayed until gala
113
// has loaded the important stuff or
114
// if you want your plugin to start
115
// right away. False means wait.