GTK+ is the graphical application framework used to develop all GNOME applications. This section presents tips and tricks with GTK+ to help you develop great adaptive applications for GNOME, for general GTK+ and GNOME development resources please check the Development Resources page.
From now on, this section assumes you are familiar with the basics of GTK+ application development.
The GTK+ Inspector¶
The GTK+ Inspector is a tool giving you direct and dynamic access to the internal state of the user interface of your GTK+ application at runtime. It is similar in concept to a web inspector.
The GTK+ Inspector is extremely convenient to debug your GTK+ application. To use it you first need to enable it via GSettings:
$ gsettings set org.gtk.Settings.Debug enable-inspector-keybinding true
To trigger the inspector simply press Control-Shift-I or Control-Shift-D when running the application.
Alternatively you can set the
GTK_DEBUG environment variable to
$ GTK_DEBUG=interactive your-application
For the GTK+ Inspector to work in your flatpaked application, you need to add
--env=DCONF_USER_CONFIG_DIR=.config/dconf to the
A GtkLabel can prevent your application’s UI from reaching really small sizes, but there are simple tricks to make them do so. Consider using one of the following tricks on each of your labels!
Allowing your label to ellipsize will cut a part of your string when there isn’t enough space for it, you can enable it and choose which part will be cut with the GtkLabel ellipize property. Use it if you really need your label to be on a single line.
Letting your label wrap will preserve the integrity of the text at the expense of more height, you can enable it with the GtkLabel wrap property and choose how to wrap with the GtkLabel wrap-mode property.
By allowing the label to wrap, it will always request enough height when fully wrapped. Consider putting your label or a widget containing it into a scrollable window to avoid height becoming a problem.