Example of KTutorial for the real world: Gwenview

In this third and last example I will show the KTutorial implementation of a tutorial for Gwenview.

Like the previous tutorial for Kdenlive, this tutorial was made after the release of KTutorial 0.5, so nothing had to be changed in KTutorial to implement it. Unlike the Kdenlive tutorial, for this one I had to modify Gwenview code for something else than just to use KTutorial. But it was not to add object names like for the showFoto tutorial. In this case, I added a little hack to reparent KActions from the main KActionCollection to the main application window.

The KActionCollection created by KXmlGuiWindow (the base class of the main application window) is not parented to the main application window. However, the KActions are parented to the KActionCollection. KTutorial scripted tutorials (like those exported from the editor) can only find objects that are descendants of the main application window, so the KActions have to be reparented to the main Gwenview window to be found by KTutorial.

Note that reparenting the KActions is not mandatory for KTutorial to work with Gwenview (or any other application). However, it provides a more interactive experience, at least with the tutorial I implemented in this example. If the KActions could not have been used the tutorial could have been written anyway, but it would have contained more “Continue” buttons to change to the new step, instead of changing when the user does what he is asked to do.

Well, here it is the video showing the tutorial being followed in Gwenview (Theora, 1280×800, 12MB). The source for this tutorial, which can be viewed and edited using KTutorial editor, can be downloaded here: “Full screen interface” tutorial for Gwenview.

As I have already said, the changes made to Gwenview are the same that for Kdenlive, but also reparenting the KActions: Gwenview is linked against KTutorial (if found), the tutorial itself is added as a Javascript file, the tutorial script is included in the message extraction for i10n and the KActions are reparented to the main application window. If you want to try this patch yourself, here it is: Gwenview patch (against current master at the time of this writing, which is ef544ad9).

I hope you have liked this three example series and, who knows, maybe become interested about KTutorial 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: