Simple GTK+ 3.0 container subclass example

This is a relatively simple example of how to subclass the Container widget in GTK+ 3.0.

Once upon a time, I needed a container with the following capabilities:

1. It holds one child widget.
2. It places a label on the left or right side of the child widget.
3. The label can be text or a Pixbuf, and the label can be aligned to the right, center, or left. 4. All of the labels in a group of these containers needed to have the same width.

I was surprised how long it took me to get this working in GTK+ 2.*. I had to dig through the sources of a lot of different programs before I finally narrowed the code down to the minimum necessary for a simple container subclass.

Maybe this will be useful to someone out there developing custom widgets.

Yes, there are other ways to do this, but that's not the point.
Mark Leisher

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]