various little fixes

This commit is contained in:
Tom Beckmann 2014-03-12 21:04:08 +01:00
parent e26d4274a0
commit 8bd6411dd8
7 changed files with 99 additions and 82 deletions

View File

@ -26,6 +26,19 @@ namespace Gala
WINDOW_OVERVIEW
}
public enum LoadPriority
{
/**
* Have your plugin loaded immediately once gala has started
*/
IMMEDIATE,
/**
* Allow gala to defer loading your plugin once it got the
* major part of the initialization done
*/
DEFERRED
}
public struct PluginInfo
{
string name;
@ -44,11 +57,11 @@ namespace Gala
PluginFunction provides;
/**
* Indicate that your plugin does not need to be started immediately on
* gala's launch but can wait until there's a bit less stuff going on.
* Especially use this if you're adding a completely new ui component.
* Give gala a hint for when to load your plugin. Especially use DEFERRED
* if you're adding a completely new ui component that's not directly
* related to the wm.
*/
bool load_can_wait;
LoadPriority load_priority;
/**
* You don't have to fill this field, it will be filled by gala with
@ -139,6 +152,8 @@ namespace Gala
/**
* Stop listening to allocation changes and remove the actor's
* allocation from the region array.
*
* @param actor The actor to stop listening the changes on
*/
public void untrack_actor (Clutter.Actor actor)
{

View File

@ -15,13 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// note on compilation: If you want your own plugin within this source tree
// don't forget to add the new subdirectory to the plugins' Makefile.am
// SUBDIRS list and add your Makefile to the list of Makefiles found at
// about the end of the configure.ac file AC_CONFIG_FILES.
// The API is currently internal until the API is finalized, so you have
// to build it in this source tree.
/*
This is a template class showing some of the things that can be done
with a gala plugin and how to do them.
@ -115,7 +108,7 @@ public Gala.PluginInfo register_plugin ()
// fulfils, ADDITION means nothing
// specific
false // indicates whether your plugin's
Gala.LoadPriority.IMMEDIATE // indicates whether your plugin's
// start can be delayed until gala
// has loaded the important stuff or
// if you want your plugin to start
@ -123,68 +116,3 @@ public Gala.PluginInfo register_plugin ()
};
}
/*
Some more useful stuff:
Modal Mode
----------
If you want to display large elements that can be toggled instead of small overlays,
you can use wm.begin_modal() to make Gala enter modal mode. In this mode, you'll be
able to receive key events and all mouse events will be delivered regardless of the
region you have set. Don't forget to call wm.end_modal() and provide an obvious way
to exit modal mode for the user, otherwise he will be stuck and can only restart
Gala.
Keybindings
-----------
To add keybindings, you'll need a gsettings schema. You can take a look at Gala's
schema in data/org.pantheon.desktop.gschema.xml for an example. You'll also find
how to correctly declare shortcut keys in that file. Once you got this file ready
it's pretty easy. Just enable its installation in cmake, the relevant is commented
out in this template, and call wm.get_screen().get_display().add_keybinding().
The keybinding function takes the name of the shortcut key in your
schema, then a GSettings instance for that schema, which can be obtained with
'new GLib.Settings("org.pantheon.gala.plugins.my-plugin")', then some flags, for
which you can almost always use 0, refer to the vapi for more details, and finally
your function as arguments. Its delegate is:
public delegate void KeyHandlerFunc (Meta.Display display, Meta.Screen screen,
Meta.Window? window, X.Event event, Meta.KeyBinding binding);
So it'd be something like
void initialize (Gala.WindowManager wm)
{
[...]
var display = wm.get_screen ().get_display ();
var schema = new GLib.Settings ("org.pantheon.desktop.gala.plugins");
display.add_keybinding ("my-shortcut", schema, 0, my_handler);
[...]
}
void my_handler (Meta.Display display, Meta.Screen screen, Meta.Window? window,
X.Event event, Meta.KeyBinding binding)
{
print ("Shortcut hit! D:");
}
void destroy ()
{
wm.get_screen ().get_display ().remove_keybinding ("my-shortcut");
}
Overriding default keybindings
------------------------------
Libmutter allows you to override exisiting shortcuts, which is a lot easier than
adding new ones. All you have to do is:
Keybinding.set_custom_handler ("shortcut-name", my_handler);
The signature for my_handler is the same as above.
More info
---------
A great source for exploring the possibilities of mutter's API is scrolling through
the mentioned mutter vapi. In some cases you can find documentation on particular
functions in the mutter source code. Just grep for their C names.
*/

73
plugins/template/README Normal file
View File

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

View File

@ -121,7 +121,7 @@ public Gala.PluginInfo register_plugin ()
author = "Gala Developers",
plugin_type = typeof (Gala.Plugins.Zoom.Main),
provides = Gala.PluginFunction.ADDITION,
load_can_wait = false
load_priority = Gala.LoadPriority.IMMEDIATE
};
}

View File

@ -99,7 +99,6 @@ namespace Gala
// add plugin's requested areas
if (area == InputArea.FULLSCREEN || area == InputArea.HOT_CORNER) {
foreach (var rect in PluginManager.get_default ().get_all_regions ()) {
print ("%i %i %i %i\n", rect.x, rect.y, rect.width, rect.height);
rects += rect;
}
}

View File

@ -106,7 +106,7 @@ namespace Gala
info.module_name = plugin_name;
module.make_resident ();
if (info.load_can_wait) {
if (info.load_priority == LoadPriority.DEFERRED) {
load_later_plugins.add (info);
} else {
load_plugin_class (info);

View File

@ -301,8 +301,10 @@ namespace Gala
// if we didnt switch, show a nudge-over animation. need to take the indices
// here since the changing only applies after the animation ends
if (old_index == 0 && direction == MotionDirection.LEFT ||
old_index == screen.n_workspaces - 1 && direction == MotionDirection.RIGHT) {
if ((old_index == 0
&& direction == MotionDirection.LEFT)
|| (old_index == screen.n_workspaces - 1
&& direction == MotionDirection.RIGHT)) {
var dest = (direction == MotionDirection.LEFT ? 32.0f : -32.0f);
ui_group.animate (Clutter.AnimationMode.LINEAR, 100, x:dest);