GTK3 Example Code

Over the past year or so I've been doing a fair bit of GUI programming -- both in ${DAYJOB}s and otherwise. Until just recently most of my GUI experience has been with wxWidgets (and most of that via wxPython). Lately I've wandered to GTK.

The documentation for both toolkits is pretty good. I've found GTK's API reference documentation to be very thorough and mostly well detailed. The tutorials are especially good for an experienced programmer who knows his way around a GUI and just needs to learn how the toolkit works.

What I find lacking are a comprehensive set of tightly focused example programs. Take the clipboard example from gtkmm, for instance. It's supposed to be showing how to access the clipboard, but it's all cluttered up with irrelevant buttons and signals and stuff. Sure, it's not that hard to read through the code to pick out the relevant pieces, but why not produce a simple example app that's all relevant (or nearly all -- you can't avoid some of the boilerplate)?

And some topics are not covered at all -- like accelerator groups, where the API documentation says "you won't usually need these". But sometimes you do, and then it's hard to find an example of correct usage. (Yes, I figured it out, and it didn't take too long using the API reference, but a 25-line example program would have saved me some time.)

Don't misunderstand the point of this post: I'm not complaining about the state of the documentation, which is better than the docs for 98.3% of FOSS projects. Instead I'm proposing a collection of ultra-focused example programs for the breadth of the API. This will be a complement to the tutorials and reference docs.

It will ideally be against multiple language bindings (though I've found that an example in the C API is informative on how things should work in the Python or C++ binding, and vice versa). I've already got a few examples (C only so far) in the GitHub repository, and if life doesn't get in the way, I'll be adding more on a regular basis. In my dreams, I'll post some of the examples here with more explanation, but we'll see how that goes...

If you'd like to contribute a tightly focused example on some GTK feature, send a pull request on GitHub. If you'd like to request an example, open an issue ticket there.

Posted on 2012-05-07 by brian in user-interface .
Comments on this post are closed. If you have something to share, please send me email.