Delegation

One of the core tenets of the Clutter API design since the 1.0 days, six years ago, is to use delegation whenever possible. We have ClutterLayoutManager for layout management; ClutterContent for content display; ClutterAction for event handling; and ClutterEffect for content post-processing.

Up until now, the Clutter API, lacked a way to delegate mapping an actor state to a separate state object — something like a “model/view” split. Sure, we had ClutterModel to store some state in a tabular form rows of data organized in columns of attributes, but there was no way to represent that data, and, more importantly, the data itself was decomposed into separate values, with little to no effective or efficient way of grouping it into proper objects, unless you shoved object instances into the model.

The history of ClutterModel is also one fraught with expedient. The reason it was introduced in Clutter 0.6 was because of the lack of a corresponding data structure in GLib itself; the only similar data structure could only be found in GTK+ — i.e. GtkTreeModel. Given how tied GtkTreeModel is tied to GtkTreeView, we simply could not provide a view actor or interface inside Clutter, at the time. We did add simple view actors in layers above Clutter, like Tidy or Mx, but they were tailored to specific use cases and thus unsuitable to be reintegrated back into the low level API.

Since the 0.x days, there have been many changes in the GNOME core platform. One of those changes is GListModel, available starting from GLib 2.44. The list model API is fairly simple, and geared towards collections of GObject instances, which can then signal changes through property notification. You can see this in effect in the GtkListBox API.

For all these reason, I’ve added two new methods to the actor class, available starting with the 1.24 stable cycle, that allow you to bind a GListModel to a ClutterActor, and create children that represent objects inside the model:

  • clutter_actor_bind_model() — this function lets you control the whole child creation phase through a simple delegate function; it’s the obvious port of the GtkListBox method linked above
  • clutter_actor_bind_model_with_properties() — this is a convenience function that takes over the child actor creation, and lets you specify the type of the children to create, as well as the properties to bind, in a simple way

Clutter ships an example of this new functionality; while it may seem overly verbose, it shows how to neatly encapsulate model, view, and controller into three separate classes, and let the Clutter and GObject API take control of the relationship between the types. This should help you when modelling your UI and your logic code, and improve the maintainability of your application.

PyClutter Reborn

Back when I started hacking on Clutter, the Python bindings were the first thing I wrote. In order to make them happen, I had to understand the intent of the library, in order to fix the API to be binding-friendly. It was another time — a time before introspection made run-time bindings that automatically acquired support for new API once the underlying shared library changed. I had to learn the CPython API; the code generation utilities that turned C header files into defs files and defs files into C code; and, finally, the build system used by PyGTK that blended all this stuff on one end, and spat out a Python C module on the other.

For a long while, the Python bindings for Clutter have been based on that particular brand on insanity; people were able to switch to the introspection-based ones and drop PyClutter entirely, but the API was not as nice to use, and you’d be missing out on some niceties provided by both Python and Clutter.

In 2011, Bastian Winkler started porting the whole infrastructure to the overrides mechanism provided by PyGObject; instead of just loading the Clutter introspection data, you’d load a pure Python module that wrapped specific bits of the exposed API, and made it nicer to use.

For various reasons — mostly lack of time on my side — that work was bit-rotting in a branch of the Git repository. Well, no more. The master branch of the PyClutter repository is now providing introspection overrides similar to the ones for GTK+. I also added a bunch of examples, ported from their C equivalent, to show the idiomatic use of Clutter in a Python context.

I’ll probably do a release, but I’d be happy if somebody wanted to pick up the bindings and run with them — I’m not much of a Python programmer myself.

What’s new in Clutter 1.22

Hello, everyone!

It’s been a while since I’ve used this blog to do something more than repeat the announcements for new releases, or for changes in the Git repository. Let’s break the streak, and outline some of the changes that have happened in the last few months in the Clutter repository in preparation for the 1.22 release.

As you may have noticed, the development pace has slowed down considerably from the heyday of the 1.10 and 1.12 development cycles — no more apocalypses are scheduled for you. Most of the resources I have are currently being spent on the Clutter-inside-GTK project, which is called GSK and has been outlined on my blog. This does not mean that the development of Clutter has ceased; since Clutter is still in use, bug fixes and new features are planned and landing in the Git repository.

Let’s start with the biggest change, if not in terms of size of the commit at least in terms of impact for users and application developers: the GDK backend is now the default backend on Linux, instead of the X11 one. What does this mean for users? It likely means that Clutter-based applications will behave much better when it comes to system integration. GDK is the GTK+ windowing system abstraction API, and it has a lot more features than Clutter’s own. You’ll start noticing that things like making the ClutterStage full screen works a lot better with Clutter 1.22, for instance, as it will respect details like the current primary monitor, as well as the monitor geometry. For application developers this change means that you now have access to the GDK API from Clutter, and you can modify things like window decorations, or input shape, without having to resort to writing X11-specific code using Xlib. If your application requires the X11 backend, though, you can (and should) enforce this dependency using the clutter_set_windowing_backend() function, which was added in Clutter 1.16, about two years ago. The change to using the GDK backend by default has been the result of a lot of work from Lionel Landwerlin.

Still from the backend news department, we have a new windowing system backend for the Mir display server, courtesy of Marco Treviño Trevisan. This means that Clutter-based applications will be able to run natively under Mir. We also have improvements in the input backends based on X11 and libinput; changes in the latter have been driven by GNOME Shell running as a Wayland compositor, and are the result of many hours of work from Rui Matos, Jonas Ådahl, and Carlos Garnacho. One final addition, written by Owen Taylor, for the X11 backend is the ability to tell Clutter to set up visuals using the GLX stereo buffers bit; this means that you can set up rendering of Clutter actors differently for the right and left “eye” buffers.

In terms of new API, we have two changes related to how actors compute their preferred size. The first one is a new ClutterRequestMode enumeration value, CLUTTER_REQUEST_CONTENT_SIZE. This new mode tells a ClutterActor to use the preferred size of its ClutterContent (if one is assigned) to determine its own natural size. Since it’s the natural size, if the actor gets allocated a smaller size by its parent, the content’s gravity will do the rest, and control how the content is sized with regards to the actor’s allocation. The other new API is inside ClutterConstraint, and allows a constraint to control the preferred size of the actor using it, just like it controls the allocation. ClutterActor will query all constraints associated to an instance and compute the preferred size depending on them. This allows you to query an actor’s preferred size and get sensible values, even in the case it’s using constraints.

After getting helpful feedback on the Clutter mailing list, the documentation with regards to the deprecation notices has been improved; the deprecated classes and functions now should all point to their replacements (where applicable).

The Clutter 1.22 release is planned alongside the GNOME 3.16 release, so you can expect it by the end of March.

Have fun!

Changes in the layout of the Git repository

I sent this announcement to the mailing list as well.

for the past couple of years, Clutter has been developed off of a topic branch, while the master branch has been reserved to the development of the API-incompatible 2.0 series.

since the 2.0 series will likely not happen, and given the confusion that the layout of the repository induced in new contributors, I decided to do some surgery on the Git repository.

starting now, Clutter will follow the classic model of “development happens in master, stable releases happen from topic branches”.

the clutter-1.22 branch, which was being used for the development of Clutter 1.22 and meant to be used for GNOME 3.16, has been merged into the master branch.

the clutter-1.22 branch will be left alone, until Clutter 1.22 is released, at which point it all changes between now and the 1.22 branch point will be merged back into the clutter-1.22 branch, like it used to happen.

given that all the changes on the master branch were either commits in preparation for 2.0, or cherry picks from clutter-1.* branches, I opted to just revert them all; they are still recorded in the history, so it’s trivial to cherry pick them out. the merge itself retains all the history of the existing topic branches.

since I only used reverts and merges, there aren’t any forced pulls. the integrity of the Git repository is left intact.

I’m going to change jhbuild and gnome-continuous to pull from master for the current development cycle, as soon as I’ve thoroughly tested the change. if you are using jhbuild to build Clutter, you won’t notice any change, but you should double check that the branch you are using is the correct one, if you have a habit of building Clutter manually.

have fun!

New Clutter-GTK releases

good news, everyone!

I just released two tarballs of the Clutter-GTK integration library:

Clutter-GTK 1.2.2
The last release in the old stable 1.2 series, with a set of fixes backported from the master branch.
Clutter-GTK 1.4.0
The first release in the new stable 1.4 series, the result of the current development cycle.

you can find both at the usual URL: download.gnome.org/sources/clutter-gtk.

have fun!

Weekly Updates for 2012-10-14

  • moving day! the new mailing list for the Clutter project is now hosted on http://t.co/QnGTRxeL: https://t.co/m4nRpy8V #
  • if you were subscribed on http://t.co/4cFfFv91 you should already be subscribed to the new list #
  • stay tuned for more moving news! #
  • in other news: work for Clutter 2.0 has started in earnest; the wip/clutter-1.99 branch landed on http://t.co/IiKOkFD6 last night #
  • diffstat against master: 295 files changed, 5669 insertions(+), 45500 deletions(-) #

Powered by Twitter Tools

Moving day!

hi everyone;

a couple of years ago we started moving infrastructure away from a server hosted at the Intel OTC. Git and Bugzilla were the first two services moved under the GNOME infrastructure1; the Wiki followed a month ago.

today, we move the mailing list from lists.clutter-project.org to mail.gnome.org and the blog to blogs.gnome.org.

I would like to thank the Intel IT team for taking care of the Intel/OTC side of things, and the GNOME System administration team for their help in the migration — kudos.

there are still some bits missing — the cookbook, for instance, still needs a new home on developer.gnome.org; and the clutter-project.org domain needs to be transferred — but I’m sure we’ll be able to sort these issues out soon.

in the mean time, have fun with Clutter!

  1. or to GitHub for non-GNOME specific components []

Clutter 1.12.0

Good news, everyone!

A new Clutter release is now available at download.gnome.org/sources/clutter/1.12/.

Release Notes

  • This version is API and ABI compatible with the current stable release of Clutter.
  • Installing the contents of this release will overwrite the files from the installation of the current release of Clutter.
  • Bugs should be reported on the Clutter Bugzilla product.

List of changes since Clutter 1.10

For detailed announcements see:

Add ClutterScrollActor
ClutterScrollActor is an actor that provides a scrollable viewport to show a portion of its children.
Add ClutterTransitionGroup and ClutterKeyframeTransition
Two ClutterTransition subclasses that provide grouping and keyframe-based transitions to the explicit animation API of ClutterActor.
Add new transformation API to ClutterActor
ClutterActor now provides a ‘pivot point’ that is used for all transformations: scaling, rotation, translation; also, any actor can be transformed by providing a 3D matrix, bypassing the decomposed transformations; finally, any actor can apply an initial transformation to its children. All matrix-based properties are also animatable.
Add multi-touch gesture recognizers
ClutterPanAction, ClutterZoomAction, and ClutterRotateAction are gesture recognizers that can be used to detect common multi-touch gestures. The ClutterGestureAction class has been modified to make it easy to create new gesture recognizers.
Layout manager improvements
ClutterGridLayout is a new layout managed implementing a flexible grid; setting the allocation of an actor will respect the actor’s easing state, making animatable layout managers easy to write; any actor can automatically expand in both the horizontal and vertical directions, and the expansion will bubble up to its parent.
Deprecations
ClutterCairoTexture (replaced by ClutterCanvas); ClutterTexture (replaced by ClutterImage); ClutterMedia (replaced by clutter-gst API); ClutterAnimation, ClutterAnimator, ClutterState (replaced by the implicit and explicit actor animation API); ClutterLayoutManager’s animation API (replaced by the implicitly animatable ClutterActor:allocation property); ClutterActor’s paint and pick signals have been deprecated.
List of changes since Clutter 1.11.16
Fix the device tracking for core X11 pointers
If a master input device can emit both touch and pointer events we end up in an inconsistent state; we should account for this case when tracking the stage that contains the events of each input device.
Respect text direction in BinLayout
The text direction of the children of an actor using the BinLayout layout manager should be taken into account, both when using the Actor’s align flags and when using the legacy BinAlignment flags.
Translations updates
Hindi, Telugu, Catalan, Malayalam, Japanese, Bulgarian, Kannada.
List of bugs fixed since Clutter 1.11.16
  • #684214 – messageTray: Fix summary position in RTL locales
  • #684552 – Track coordinates and device ids in test-events
  • #684530 – Print device number in debug messages from input-device
  • #684509 – Mouse events lost after touch event from virtual core pointer

Many thanks to all the contributors to the Clutter 1.11 development cycle

Bastian Winkler, Emanuele Aina, Jasper St. Pierre, Lionel Landwerlin, Chun-wei Fan, Daniel Mustieles, Fran Diéguez, Piotr Drąg, Neil Roberts, Tomeu Vizoso, Alejandro Piñeiro, Chao-Hsiung Liao, Nilamdyuti Goswami, Alexander Larsson, Ihar Hrachyshka, Tom Tryfonidis, Tristan Van Berkom, Мирослав Николић, Bastien Nocera, Christian Kirbach, Cosimo Cecchi, Yuri Myasoedov, Alexander Shopov, Alexandre Franke, Andika Triwidada, Aurimas Černius, Carles Ferrando, Daniel Korostil, Debarshi Ray, Dirgita, Duarte Loreto, Evan Nemerson, Jonh Wendell, Matej Urbančič, Rob Bradford, Robert Bragg, Sasi Bhushan Boddepalli, Andre Kuehne, Andy Wingo, Ani Peter, Ask H. Larsen, Bruce Cowan, Bruno Brouard, Chandan Kumar, Daniel Nylander, Danielle Madeley, Dimitris Spingos, Dominique Bureau, Enrico Nicoletto, Frédéric Péters, Gil Forcada, Giovanni Campagna, Jordi Serratosa, Kenneth Nielsen, Kjartan Maraas, Krishnababu Krothapalli, Martin Srebotnjak, Matthias Clasen, Mike Ruprecht, Nishio Futoshi, Owen W. Taylor, Peter Hutterer, Rajesh Ranjan, Rico Tzschichholz, Rudolfs Mazurs, Rui Matos, Shankar Prasad, Sjoerd Simons, Stefano Facchini, Viktor Nyberg.

Have fun with Clutter!