Combining PySide and PyGObject introspection bindings

Some while back I added basic GObject Introspection support to GEGL and GEGL-GTK master a while back. This will* allow application developers to write their Gegl + Gtk based applications in any language supported by GObject Introspection, like Python, Vala and Javascript. For GeglQt, the Qt integration library for using Gegl in Qt based applications, it was natural to use PySide to provide Python bindings for it. The initial setup was quick and easy, thanks to the binding tutorial, but there was one challenge.

The current widgets provided by GeglQt are for displaying the output of a node in the GEGL graph. Therefore they have methods with the following signature to hook up it up:

From gegl-qt/nodeviewwidget.h
GeglNode *inputNode() const;
void setInputNode(GeglNode *node);

GeglNode is a GObject (from the C based glib) subclass, and without help the bindings generator (Shiboken) does not know what to do with it so the method cannot be bound. PySide could have been used to also generate bindings for Gegl itself, but what we actually want to do is to make use of the existing PyGObject based bindings.

Marcelo Lira on #pyside let me know that this should be possible by adding some annotations to the typesystem.xml file, and implementing a Shiboken::Converter<T>. It is indeed possible, and for the above type looks something like this:

From typesystem_gegl-qt.xml
<primitive-type name="GeglNodePtr">
      <conversion-rule file="geglnode_conversions.h"/>
      <include file-name="pygobject.h" location="global"/>
</primitive-type>

From geglnode_conversions.h
namespace Shiboken {
template<>
struct Converter<GeglNodePtr>
{
    static inline bool checkType(PyObject* pyObj)
    {
        return GEGL_IS_NODE(((PyGObject *)pyObj)->obj);
    }

    static inline bool isConvertible(PyObject* pyObj)
    {
        return GEGL_IS_NODE(((PyGObject *)pyObj)->obj);
    }

    static inline PyObject* toPython(void* cppObj)
    {
        return pygobject_new(G_OBJECT((cppObj)));
    }

    static inline PyObject* toPython(const GeglNodePtr geglNode)
    {
        return pygobject_new(G_OBJECT(geglNode));
    }

    static inline GeglNodePtr toCpp(PyObject* pyObj)
    {
        return GEGL_NODE(((PyGObject *)pyObj)->obj);
    }
};
}

The PyGObject C API and the GObject type system is here being used to implement what Shiboken needs. The attentive reader will note that GeglNodePtr is used and not GeglNode*. This is a simple “typedef GeglNode * GeglNodePtr“, which looks to be neccesary with current PySide (1.0.6) to avoid it being confused by the pointer. Hopefully that is fixable and won’t be necessary in the future.

With this solved, I committed the initial Python support to GeglQt master yesterday. It contains a trivial Python example showing the usage. Some build cleanups, binding generator tweaks and testing remains to be done, but expect Python support to be a prominent feature for GeglQt 0.1.0

 

* There are still a lot of GObject Introspection annotations missing in Gegl. See the tracking bug. Help wanted!

Making GEGL easier to use in graphical applications

So, in the last couple of months I’ve been working a bit on GEGL. Some of the work has already been covered by LWN, so I guess it is time that I blog about it…

GEGL is a generic image processing library which is used by applications like GIMP, (and in the future maybe MyPaint and DarkTable). It provides applications with a graph based image processing backend that can do non-destructive processing of high-bitdepth images, among other things.

One of the problems that I think has been limiting adaptation of GEGL has been the entry barrier to starting to use it in a graphical application. While GEGL provides the image processing backend, it did not provide good and easy ways of displaying the output on screen. Now it does!

GTK+, Clutter and Qt integration libraries

Some code for integrating GEGL in GTK+ based applications has existed in the GEGL tree for a long time, but it was not well maintained and there was no public API. After brushing up the code to use Cairo for rendering and to support both GTK+ 2 and 3, it was split out to a separate library and repository: gegl-gtk. This library now provides a GtkWidget for displaying the output of a node in the GEGL graph, with basic support for scaling and translations. Any change in the GEGL graph will be reflected in the view widget. This makes it trivial for applications using a GTK+ based user interface to get started using GEGL, see for instance the provided examples in C or in Python.

The same functionality is provided for Clutter based user interfaces by gegl-clutter in form of a ClutterActor. This code was previously available as clutter-gegl, but has now been renamed and moved to be a part of the GEGL project, and is maintained by Øyvind Kolsås. Example code in C.

Last but not least, gegl-qt was created to serve the needs of applications using Qt based user interfaces. The different widget systems (QWidget-, QGraphicsWidget- and QML-based) are all supported. In addition to the features currently available in the GTK+ and Clutter versions, the Qt view widgets also support auto-scaling and auto-centering. Python bindings via PySide is planned, but blocking on a PySide issue at the moment.

A pretty boring screenshot showing two QWidget based examples (code: 1, 2) for transformations:

Artwork: “Wanted“, speedpainting by David Revoy

The first stable release of gegl-qt and gegl-gtk will hopefully be available soon. The list of tasks can be found in the README files.

Display operations

In GEGL, image processing is described as a graph of operations. “gegl:display” and “gegl:gtk-display” operations existed in the gegl tree, and by attaching one of these to a node in the graph one could display the output of the graph at the given node in a window . Such display operations are useful for applications that just want to show the output of a graph without having to use a GUI library directly.

The problem was that both of these operations were optional, so applications could not rely on this functionality to be present. This is solved by letting the “gegl:display” operation be a meta-operation, which uses other operations as a handler to actually display the output. Such display handler operations are now provided by gegl (optional, using SDL), gegl-gtk (using GTK+) and gegl-qt (using Qt). In addition a fallback operation that will export a PNG file and launch an external application to display it will be provided in GEGL.

More to GEGL stuff to come soon, hopefully.

Lost in Thought – Opus Arise

If you’re a fan of traditional progressive metal, you might want to check out Lost in Thoughts debut album: Opus Arise.

Released April 29th this year, Opus Arise features some very solid songwriting much in the style of Dream Theater and similar bands. The musicianship is generally excellent, and the production is stellar. On the downside, this is not a very original album by any measure, you will not find too many fresh ideas or expressions in this album. So if you’re looking for something that takes progressive metal in a new direction; look elsewhere.

Here is the opening track, Beyond the Flames.

My favorite tracks include the slower Blood Red Diamond and the kicking closing track Assimulate, Destroy. You can find the album on Amazon.

Sadly the band had a car accident on their first European tour in late May, which left the drummer with a broken leg and having to undergo surgery. A news post comment from the drummer, and a recent interview seems to indicate that the recovery so far is going OK. Hopefully he will be fully recovered, back to playing drums, soon.

A friend told me that I should blog about music again. This was a shot at doing just that.

Workshop & BoF schedule at Desktop Summit 2011 published

We in the the organizing team have now published the schedule for pre-registered Workshop & BoF sessions at the Desktop Summit 2011 in Berlin.

There is still time to register for ad-hoc sessions, and we will have two dedicated “hacker rooms” where you can sit down with like-minded people and work on what you like!

See the webpage for more information.

 

Registration open for Workshops & BoFs at the DesktopSummit 2011

As a member of the local organizing team for the Desktop Summit 2011 in Berlin, I’m glad to say that you can now register your workshop or BoF session. These sessions take place during the last 3 days of the conference, and complement the presentations that take place during the 3 first days: The Workshops & BoFs sessions are hands-on sessions where people get together to discuss and work on issues face to face.

Short excerpt from the news entry on the webpage:

All forms of hands-on activities that aim to further the Free Desktop are welcomed. Examples of such sessions include BoF, project and cross-project meetings, workshops, hacking sessions and training/teaching sessions. Each session is self-organized and it is up to the hosts and participants to decide if the session is to be loosely oriented around a set of topics, or have a well-defined agenda.

The organisation committee would like to schedule as many of these sessions beforehand as possible. We expect over 1000 visitors and scheduling helps to ensure minimal overlap with other sessions and allows us to provide a clear timetable for the visitors.
The remainder of the rooms will be scheduled via the wiki but we urge you to pre-register and get a proposal in before the deadline, July 3rd!

I will be proposing a session or two of my own very soon, I suggest you do the same! Use this link

MyPaint and OpenRaster talks

One of my goals for this year was to give a presentation at a conference. And I can now say that I have achieved that goal.

I gave a talk about MyPaint at Libre Graphics Meeting 2011 in Montreal, Canada: MyPaint – the past, the present and the future.

[hdplay id=1]

Download in Ogg/Theora

I will also be giving a lighting talk at the DesktopSummit in Berlin about OpenRaster. It looks like this will be on August 7th at 14.00, but you should of course come for the whole week. Just look at the awesome program!

 

Example plugins for Maliit available

In Maliit input methods are implemented as plugins. This flexibility is important because it allows the same framework to provide very different text input methods, without us having to implement them all. Different virtual keyboards, hardware keyboard input, handwriting, speech-to-text, input methods for accessibility, et.c. are all possible with the Maliit framework. This makes the input method plugin API the most important extension point.

To make it simple to start developing an input method for Maliit, we have written a set of example plugins that can be used as a skeleton* for a new input method. There is one “Hello World” example showing the C++ interface, and one showing the newly added QML interface. The latest documentation for the framework in HTML format is also included, along with a simple test application. How to get started is documented on our wiki page: Go!

A very conventional example: An input method that allows you to input "Hello World"

A nice thing is that these examples are in our framework repository: built as part of the standard build, with simple tests run as part of our test-suite. This ensures that the examples stay up-to-date and working, something I find that step-by-step, code-and-talk tutorials in some documentation repository/directory typically do not.

If you want to look at real-life examples of plugins, check out the Meego Keyboard code (C++), the Meego Keyboard Quick code (QML), or foolegg from maemo.org’s cute-input-method code (QML with Pinjyin support!). Also make sure to check out Michael Hasselmanns talk at the Meego Spring 2011 Conference: Developing custom input methods for Meego.

If you hit any issues, contact us through one of our communication channels.

* Note that currently the license of the examples is LGPLv2 like the rest of the framework.

geglfilter: GStreamer element for manipulating video using Gegl

Gegl is an image processing framework used in projects like Gimp and DarkTable. It will eventually allow Gimp to allow non-destructive, high bit-depth image processing, among other things. And GStreamer is the multimedia framework for GNU/Linux, handling video/audio/other playback/recording/manipulation on your favorite desktop/server/mobile/embedded system.

After writing the Cairo overlay GStreamer element, I implement a basic GStreamer element which allows you to apply a filter to video in a GStreamer pipeline using Gegl. Using this element, video editing/manipulation applications like Pitivi could allow users to apply effects provided by Gegl to videos. Gegl is a very powerful image processing framework, and already has a significant number of image processing operations. More operations is expected, especially from the port the tools, filters and plugins used in Gimp to Gegl.

Here are some screenshots showing the standard GStreamer video test data being manipulated in different ways using Gegl. Note: the size of the images are only different because the output windows had different sizes when I took the screenshot.

Top left: original video. Top right: color temperature adjusted from 6500 to 9000 K Bottom left: inverted colors. Bottom right: inverted colors and black-white threshold

Top left: original video (no-op). Top right: color temperature adjusted from 6500 to 9000K. Bottom left: inverted colors. Bottom right: inverted colors and black-white threshold conversion

A bug has been filed for inclusion of this element into gst-plugins-good. The patch attached there also contains an example application, showing how to use the element.

In the patches you will find an example.

Introducing; Maliit on-screen keyboard in Gnome 3

Maliit (also known as Meego Input Methods) has the following overall goal: “to be the input method project for MeeGo and other GNU/Linux-based embedded/mobile platforms”.

This initial video shows Maliit running in Gnome 3, and demonstrates some of the very basic features provided by Maliit and the standard keyboard shipped with it. The demo is done on a WeTab tablet running a standard Fedora 15 Beta, with the latest Maliit software installed. Jan Arne Petersen is working a bit on  Fedora packages, so hopefully it will soon be easy to install for those who are interested.

Some more info about the features shown in above video:

0. Theming. Using the theming support in the standard Maliit keyboard, it is easy to go from a mockup to ready implemented theming. This theme was based on the mockup from live.gnome.org (by Jakub Steiner I believe?) and done by Michael Hasselmann in a couple of hours. He also has a blogpost on how the theming system works.

1. Typing text.This is of course the number one feature of an on-screen keyboard. There are some essential best-practice and some tricks used in Maliit to be able to get really good reponse time and typing speeds. I hope we will have some blogposts about that soon.

Typing speed can be further enchanced by enabling multitouch support (not working out-of-the-box in Fedora due to missing support further down the stack), or by installing a prediction/correction engine. User feedback can be enchanced with audatory and tactile feedback (requires hardware and driver support obviously).

2. Different languages/layouts, and switching between them. Maliit comes with layouts for over 20 languages, tested and tweaked by usability experts. Latin, Cyrillic, Arabic and Chinese based scripts are covered. The layouts are defined by XML files, so one can easily change them if wanted.

Chinese ZhuyinRussian

Arabic

For more of the features offered by Maliit framework and standard keyboard, see the wiki page. If you are interested in improving Maliit, or its integration in Gnome 3 or other GNU/Linux environment, join the irc channel or mailing list.

Next up; the importance and difficulties of input method integration on touch enabled devices.

Going to Libre Graphics Meeting 2011 in Montreal!

So, it is confirmed, I’m going to LGM 2011! I was at LGM last year, and I expect this year to be just as good. Hopefully I’ll also be giving a talk this time, about MyPaint and/or OpenRaster.

If you are interested in free and open source graphics software, or the production of freely licensed graphical works, you should go too! See the press release for more information, or go straight to submit a talk proposal. If you cannot be there but still want to show your support, please consider donating.

I guess this means I should order the tickets soon…