The Wayback Machine - https://web.archive.org/web/20130517220958/http://mikhas.posterous.com/tag/gtk

Thoughts 'n Stuff

Better GTK+ support in Maliit

So far, using Maliit's virtual keyboard in GTK+ applications required fetching and compiling a GTK+ input method brigde yourself. Not any more. With the latest release, GTK+ applications should just work out of the box, thanks to Jon's integration efforts. Right at the same time, Łukasz was looking into using Maliit together with GTK+ applications on his Ubuntu desktop. He did a great job testing Jon's improvement and also contributed patches to properly update GTK+'s input method module cache. When compared to the Qt support, the gap in terms of supported features is quite large. We would like to further improve the GTK+ support and contributions are certainly welcome.

Filed under  //   GTK+   Input methods   Maliit   Openismus   Qt   Ubuntu  

Undocumented Widgets?

I accidently the GTK+ tutorial!!! So that is why people struggle with tree views!

Filed under  //   GTK+   Openismus  

Debugging signals in GTK+

So I ran over an odd signal flow in the GTK+, and I needed to get helpful debug information. Daniel quickly pointed me to the GTypeDebugFlags, which contains the pro-tip to use the environment variable GOBJECT_DEBUG instead (the glib docs that come with the source has the same advice)[1]. Great!

$ GOBJECT_DEBUG=signals my_gtk_app

and I was able to kill the bug.

[1] May need recompilation of glib with debugging enabled.

Filed under  //   GTK+   Openismus  

Learning GTK+

During the last weeks I started to learn about the GTK+. I mostly followed the official tutorial but soon tried to walk on my own legs. Perhaps that was not always the best choice, as I ran into dead ends later (I skipped some chapters which probably were important, but their title did not give it away). Requiring sequential reading is so 1999 ...

Now why is the GTK+ awesome? Simple, when using the GTK+ you almost forget you write in portable macro assembler. Pointers are annotated with a nice semantic (reference to an object, comparable to what languages with OO support see in variables), and memory management is usually none of your concern.

The next feature I was impressed with is type-checking since it gives you valuable hints whether you got the semantics of your pointers right. Granted, most of it happens at runtime, and it does not come without costs. But how else would you do it in C?

Also, I do like the approach of the GTK+ to not enforce a pixel-based layout. The GTK+ will negotiate the appropiate window size for your widgets, and it will re-negotiate it once you remove/hide widgets from your layout. This all comes for free together with the object hierarchy you create when you define the ownership relation of your widgets.

However, as soon as you start writing custom widgets it all gets a bit hairy. The good news are that for one, this part is well-documented on the web, and also that once you created a custom widget it can be used just as easily as the built-in widget types. Should that not be enough to encourage you to go the extra steps necessary then simply take it as a valuable lesson about "Implementing Object Orientation from Scratch".

And then I came across GObject properties. It all looked cumbersome, for little gain. At first I feared I would even have to pack everything into GValues before I can access properties, but luckily there is g_object_set() (and not g_object_set_property(), as you might have guessed). Now if properties could be made to react to signals directly ...

Overall, I like the GTK+ so far. Some things could be more obvious, some other things you just have to accept as god-given, and the rest seems dead-simple. If you are undecided which GUI toolkit to learn then perhaps the long list of available language bindings (quality may vary) is convincing to you. Learn once, use everywhere :-)

Filed under  //   GTK+   Gnome   Openismus