Here is my python loader plugin which loads plain python scripts as full plugins. There is not much documentation, but I have included a few examples to get you going. triangle - Just a basic plugin which shows a triangle on a button press. This shows using ctypes to pass values from compiz to the python opengl bindings. basiczoom - Zooms in on the screen (basically) inactive - This is a port of my inactive plugin which I mentioned earlier. Its only a few lines of easy python code. The OBJECTS file contains a brief list of each property and method. I will try to get some proper documentation done soon. I think most things are complete, the TODO list contains a list of things I am aware of. You should be able to do most things that can be done with c plugins (without the hassle of pointers) http://www.anykeysoftware.co.uk/compiz/plugins/python.tar.gz Please report any bugs here or mail me offlist, there are probably a few :)
Thank you very much Mike, great work. I'm testing it, and it seems to run quite well here. For those who wants to try this plugin, remember to install python-opengl and python-ctypes, because you need them to load sample plugins. Regards, Pierpaolo On 4/10/07, Mike Dransfield <mike@blueroot.co.uk> wrote:> Here is my python loader plugin which loads plain python > scripts as full plugins. > > There is not much documentation, but I have included a few > examples to get you going. > > triangle - Just a basic plugin which shows a triangle on a button > press. This shows using ctypes to pass values from compiz to the > python opengl bindings. > > basiczoom - Zooms in on the screen (basically) > > inactive - This is a port of my inactive plugin which I mentioned > earlier. Its only a few lines of easy python code. > > The OBJECTS file contains a brief list of each property and method. > I will try to get some proper documentation done soon. > > I think most things are complete, the TODO list contains a list of > things I am aware of. You should be able to do most things that > can be done with c plugins (without the hassle of pointers) > > http://www.anykeysoftware.co.uk/compiz/plugins/python.tar.gz > > Please report any bugs here or mail me offlist, there are probably > a few :) > > _______________________________________________ > compiz mailing list > compiz@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/compiz >-- Pierpaolo Follia http://madchicken.altervista.org/tech
Travis Watkins wrote:> On 4/9/07, Mike Dransfield <mike@blueroot.co.uk> wrote: >> Here is my python loader plugin which loads plain python >> scripts as full plugins. > > Instead of zoomPreparePaintScreen you should just be able to have > preparePaintScreen and have the C side call WRAP/UNWRAP around running > this method. Python plugin writers should never have to know about > WRAP/UNWRAP, just defining a method with the right name should be > enough to get it called.I tried something similar to this, originally the plugin used functions rather than classes (thats why some are still named zoom*). When I changed it to use a class for each plugin the wrapped functions stopped working. I assumed it was because it was losing reference to the object instance. I might have been doing something else wrong though. The easy solution at the time was add a string with the method name. This allows plugin writers more flexibility although I could just use a default name if none is provided. Removing WRAP/UNWRAP totally seems virtually impossible without losing a lot of functionality. If I make them just provide a named method then I have to check each plugins attributes one by one and they would still have to call unwrap/call/wrap themselves during the wrapped function. Notice how inactive calls the core method at a specific point, that would be hard to do without the wrap function. If anyone has any ideas on making wrap/unwrap less complicated without removing the functionality then I would like to hear about it :)
On 4/9/07, Mike Dransfield <mike at blueroot.co.uk> wrote:> Here is my python loader plugin which loads plain python > scripts as full plugins.Instead of zoomPreparePaintScreen you should just be able to have preparePaintScreen and have the C side call WRAP/UNWRAP around running this method. Python plugin writers should never have to know about WRAP/UNWRAP, just defining a method with the right name should be enough to get it called. I'm sure I'll have more, similar feedback in the next few days as I try this out more. :) -- Travis Watkins http://www.realistanew.com
Just FYI I have updated this to support a few extra functions and have generated some (less than useful) documentation which I have here. http://www.anykeysoftware.co.uk/compiz/pydoc/compiz.html
I have just made another round of improvements and fixes. The main fixes have been to the memory usage and to add some forgotten functions. There are now 8 python plugins included in the package basiczoom - Same as before, just a basic zoom desktopmenu - Activates a menu when clicking on the desktop. It uses the menu program in the desktopmenu folder. doc - Just generates the compiz.html documentation. This is the smallest possible compiz plugin. inactive - Makes inactive windows desaturated. pyplane - A python version of the plane plugin, it is planned to add extra features not in plane now. pywallpaper - A copy of the wallpaper plugin which shows different wallpapers on the root window (ie. without a desktop window). This is improved over the C version because it is more stable and it supports vertical viewports. seethru - A copy of fakeargb to test the fragment function interface. It seems to work identically to the C version. It toggles between making everything black transparent and making everything white transparent. triangle - Same as before, basic GL example. http://www.anykeysoftware.co.uk/compiz/plugins/python.tar.gz http://www.anykeysoftware.co.uk/compiz/pydoc/compiz.html Thanks to RYX for desktopmenu, pyplane, pywallpaper and CompWindow utility functions.