simple is better

GTK+ / Glade

Author: Roland Koebler (rk at simple-is-better dot org)
Website:http://www.simple-is-better.org/gtk/
Date: 2014-06-10

1   GTK+

GTK+ is a library (or "toolkit") for graphical user-interfaces.

It's licensed under GNU LGPL, so it can be used without any license fees for both open-source and closed-source software, and for both free and commercial software [1]. There are bindings for many languages, and it works on Linux, Mac OS X and Windows.

There is also a good graphical interface designer / GUI-builder, called Glade.

Links:

[1]

But you have to fulfill the LGPL-conditions, which means that you have to (a) tell the users which GTK+-library-versions were used and where the sourcecode of the GTK+-libraries can be obtained and (b) make it possible that users can link the software with the GTK+-libraries themselves (which is usually done by using dynamic linking).

For more or more detailed information, please read the LGPL.

1.1   Building GTK+

Usually, the GTK+-versions included in your Linux-distributions should be used. If you need a newer GTK+-version, you probably have to compile it yourself.

To simplify this, I wrote a small interactive shell-script, which downloads the sourcecode of the newest GTK+-libraries (incl. most dependencies), and compiles and installs them (locally) in the right order; it optionally also downloads/compiles/installs Glade. See Building Glade below for details.

1.2   GTK+ 2 vs. GTK+ 3

GTK+ 2 is the old version, GTK+ 3 is the current version. For new projects, GTK+ 3 should be used.

GTK+3 is not completely compatible to GTK+2, but it's usually not too difficult to migrate an application from GTK+2 to GTK+3. More information about the migration can be found at https://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html

GTK+3 is also more powerful, has more widgets and allows to modify the appearance of all widgets with CSS (cascading style sheets).

1.3   GTK+ vs. Qt

The two most common GUI-toolkits on Linux are GTK+ and Qt.

I personally prefer GTK+, since:

  • Its widget-concepts (especially its "container-concept") is superior to Qt in my opinion.
  • Its GUI builder (Glade) is much better than the Qt Designer in my opinion.
  • It can be used in C-programs, and doesn't require C++.
  • Its versions are more stable, so I rarely need to migrate my applications to new library-versions.
  • It was always licensed under LGPL and so always allowed to use it in commercial closed-source software without license fees.
  • There's no financial risk for unintentional violations of the license of GTK+ for commercial applications; but for Qt, I probably would have to pay a compensation of several thousand euro per year, if I unintentionally overlooked or misinterpreted some license-requirement in a commercial, non-open-source application.

A more detailed comparison will follow later. (TODO)

1.4   Python

GTK+ can be used in many programming-languages, but I personally recommend Python, since Python has an exceptionally clear syntax and is much easier to use than many other programming languages.

If you use GTK+ with Glade and Python, you get a quite nice and simple-to-use RAD, and can easily, quickly and efficiently develop user-interfaces.

Some examples etc. will follow later. (TODO)

2   Glade

Glade is the graphical interface-builder for GTK+: It allows to arrange and configure the widgets graphically by mouse, and saves the designed user-interface in an GtkBuilder-XML-file. The user-interface can then be loaded dynamically from this XML-file by all programming-languages with GTK+-support.

This can be used to separate the appearance of the user-interface from the application logic more clearly, and that this allows to modify the user-interface without any sourcecode-modifications and without recompiling.

It works well, and I recommend to use it.

Unfortunately, Glade also has some bugs. Since bugs in Glade are only fixed in the newest version, you usually should use the newest version instead of the version included in the repository of your Linux-distribution. See Building Glade below.

Links:

2.1   libglade vs. GtkBuilder

Older versions of Glade used a Glade-specific fileformat and a library called "libglade" for storing and retrieving user-interfaces in/from XML-files. It's deprecated now, and should not be used in new projects.

Newer versions of Glade use the GtkBuilder-XML-fileformat, and the GtkBuilder-functionality, which is completely integrated into GTK+, and which is not restricted to Glade. GtkBuilder is also more powerful, since it e.g. can include actions, data-models (e.g. treestores) etc.

New projects should always use the GtkBuilder-fileformat/-functionality; old projects should migrate to GtkBuilder.

2.2   Building Glade

Since bugs in Glade are only fixed in the newest version, you usually should use the newest version of Glade.

But since the newest Glade-version usually also requires the newest GTK+-version, it's sometimes hard to compile the newest Glade. To simplify this, I wrote a small interactive shell-script, which downloads the newest Glade- and newest GTK+-sourcecode (incl. most of its dependencies), and compiles and installs them (locally) in the right order.

The script can also be used to compile different versions of Glade/GTK+ and install them into different directories.

Usage:

bash ./glade_build.sh

Download:

glade_build.sh