Feb 272016

Remember my GSoC project that was supposed to happen for GTK+ 3.18?

It didn’t happen back then, we decided that at GUADEC in Sweden already. It was just too late for the release in September. So, 3.20 it is!

Unfortunately, both the implementation and the port of eog were more difficult than I anticipated. Getting the interaction between the adjustment values and the gestures right took way too long. Porting eog is hard because it’s not just an image viewer, but also allows users to save rotated images, etc. Porting it will require some serious work.

So… 3.22 it is!

Why didn’t we Merge it?

Ultimately, we didn’t merge GtkImageView this cycle because there was no user of at the time of merge (there’s an eog branch though), and there are some unsolved problems.

The current API does not give you the amount of control your probably want when you write an image viewer, e.g. eog sets the filter depending on zoom state and user settings. Exposing an API for this would be a possibility, but not a very elegant one. Other problems include scalable vector graphics you want to re-render once the zoom changes.

I’ currently working on fixing these problems by using a more generic API for “images” than cairo surfaces or GdkPixbufs in the wip/baedert/gtkimageview branch. I’m also hoping to simultaneously work on gnome-photos, which is another interesting candidate because it uses gegl to draw the image.

The Good News

Over the course of GTK+ 3.19, quite a few people asked about GtkImageView and whether it’s going to be merged or not. I think I always said yes because there was no real reason to say no, and now I’m a big fat phony.

However, the “current” implementation works just fine if you want to display simple images, so here’s a repository with a GtkImageView version you can use in your project (I hope). Contains GtkImageView, a simple demo and a vapi file (because I might need that in the not-so-distant future).

If you use the version from this repo and find any bugs, please file them there since they might also exist in the version I’m working on in the GTK+ repository.

And before I forget it, here’s a useless video so this isn’t all just text:

Notice that the rotation doesn’t happen around the image center, but around the center of the current visible part of the image. In case the rotation happens using a two-finger touchscreen gesture (or touchpad gesture I assume, I don’t think I’ve ever tested this), the image will be rotated around the bounding box center of the gesture.

All scale and angle changed are nicely animated unless you set transitions-enabled to FALSE (The “Reset” button in that video just sets scale to 1 and angle to 0). Also contains async image loading and a few other nice things that video doesn’t show like the fit-allocation property (image will be scaled to the widget allocation)  and the snap-angle property, in case you want to allow the user to use gestures to rotate the image, but only accept 90deg steps.

Timm Bäder: (No) GtkImageView in GTK+ 3.20
Source: Planet Gnome