GTK
GTK is a toolkit for creating graphical user interfaces. It is part of the GNU Project and maintained by GNOME.
Installation
Though GTK can be installed with the emerge command, it will usually be pulled in as a dependency by an ebuild.
If installing external software on Gentoo that requires GTK, write an ebuild to manage the installation of that software with its GTK dependency.
GTK 4
GTK 4 is provided by gui-libs/gtk .
The gtk4 USE flag is provided by packages that have optional GTK 4 support.
USE flags
USE flags for gui-libs/gtk GTK is a multi-platform toolkit for creating graphical user interfaces
+X
Add support for X11
+introspection
Add support for GObject based introspection
aqua
Include support for the Mac OS X Aqua (Carbon/Cocoa) GUI
broadway
Enable the GDK Broadway backend.
cloudproviders
Enable GtkPlacesSidebar to access cloud services
colord
Use x11-misc/colord for color management in printing
cups
Add support for CUPS (Common Unix Printing System)
examples
Install examples, usually source code
gstreamer
Add support for media-libs/gstreamer (Streaming media)
gtk-doc
Build and install gtk-doc based developer documentation for dev-util/devhelp, IDE and offline use
sysprof
Enable profiling data capture support using dev-util/sysprof-capture
test
Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
vulkan
Add support for 3D graphics and computing via the Vulkan cross-platform API
wayland
Enable dev-libs/wayland backend
GTK 3 and GTK 2
GTK 3 and GTK 2 are provided by the x11-libs/gtk+ package.
Some applications may optionally be built with support for GTK by enabling their gtk USE flag.
There are also gtk3 and gtk2 USE flags.
USE flags
USE flags for x11-libs/gtk+ Gimp ToolKit +
+X
Add support for X11
+introspection
Add support for GObject based introspection
aqua
Include support for the Mac OS X Aqua (Carbon/Cocoa) GUI
broadway
Enable the GDK Broadway backend
cloudproviders
Enable GtkPlacesSidebar to access cloud services
colord
Use x11-misc/colord for color management in printing
cups
Add support for CUPS (Common Unix Printing System)
examples
Install examples, usually source code
gtk-doc
Build and install gtk-doc based developer documentation for dev-util/devhelp, IDE and offline use
sysprof
Enable profiling data capture support using dev-util/sysprof-capture
test
Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
vim-syntax
Pulls in related vim syntax scripts
wayland
Enable dev-libs/wayland backend
xinerama
Add support for querying multi-monitor screen geometry through the Xinerama API
Configuration
One way of determining which version of GTK is used by a program is to check the output of ldd(1) :
user $ldd $(command -v amsynth) | grep gtklibgtk-x11-2.0.so.0 => /usr/lib64/libgtk-x11-2.0.so.0 (0x00007ff535d8e000)
This shows that amsynth uses GTK 2.
Some environments have their own settings influencing the appearance of GTK applications. For example, GNOME has settings in the org.gnome.desktop.interface dconf schema (amongst others). Tools available for directly working with such settings include:
- GSettings - Command-line tool for editing dconf(1) settings. Some software might instead use the older GConf [1] .
- lxde-base/lxappearance - Part of the LXDE desktop environment; works for GTK 2 apps also (dark theme).
GTK 4
gtk4-query-settings(1) can be used to list current settings.
GTK 4 uses the file ~/.config/gtk-4.0/settings.ini by default for user settings. For example:
~/.config/gtk-4.0/settings.ini[Settings] gtk-theme-name = "Adwaita" gtk-application-prefer-dark-theme = 1
Note that:
GTK reads default values for settings from settings.ini files in /etc/gtk-4.0, $XDG_CONFIG_DIRS/gtk-4.0 and $XDG_CONFIG_HOME/gtk-4.0. These files must be valid key files, and have a section called
[Settings]. Themes can also provide default values for settings by installing a settings.ini file next to their gtk.css file.[2]
The GTK_THEME environment variable can be used when debugging[3] . For example, to specify that the dark Adwaita theme should be used by programs subsequently opened in a shell session:
user $export GTK_THEME=Adwaita:darkFor a list of GTK 4 properties that can be set via a gtk-4.0/settings.ini file, refer to this page.
GTK 3
GTK 3 uses the file ~/.config/gtk-3.0/settings.ini by default for user settings. For example:
~/.config/gtk-3.0/settings.ini[Settings] gtk-application-prefer-dark-theme = true
To specify default settings for all users, modify /etc/gtk-3.0/settings.ini. For example:
/etc/gtk-3.0/settings.ini[Settings] gtk-application-prefer-dark-theme = true
The x11-libs/gtk+ version 3 package provides the gtk-query-settings(1) utility for printing the name and value of all GtkSettings properties.
GTK 2
GTK 2 uses the file ~/.gtkrc-2.0 for user settings. Example file:
~/.gtkrc-2.0gtk-font-name = "Liberation Sans 16" gtk-cursor-theme-name = "Adwaita" gtk-fallback-icon-theme = "gnome" gtk-icon-theme-name = "Adwaita" gtk-theme-name = "Adwaita"
The GTK2_RC_FILES environment variable can be set to point to a gtkrc-2.0 file containing settings for a particular GTK 2 application.
Troubleshooting
GTK Inspector
Both GTK 4 and GTK 3 support an interactive debugger known as the GTK Inspector. It can be enabled by setting the GTK_DEBUG environment variable to interactive when running a GTK-based program, e.g.:
user $GTK_DEBUG=interactive d-spyMouse scrolling doesn't work
With the gtk-3 applications under fvwm or other window manager / desktop environments, mouse scrolling sometime doesn't work as it should or at all. At the same time, it work with the applications using other toolkit environments like Qt, which imply this is not a system or Xorg configuration issue. To fix that issue, to add the following environmental variable should work, as example:
~/.bashrcexportGDK_CORE_DEVICE_EVENTS=1
For more information, see GTK applications (sometimes?) do not scroll correctly, lacks focus?.
Additional software
Search packages.gentoo.org for packages to use with GTK, such as themes or language bindings.
Themes
- x11-themes/arc-theme - flat theme with transparent elements for GTK 2/3/4
Development tools
- Cambalache - RAD tool for GTK4 and GTK3
- dev-util/gnome-builder - Integrated Development Environment for GNOME
- dev-util/glade - RAD tool for GTK3, unmaintained
Language bindings
- dev-libs/gjs - Javascript bindings for GNOME
- dev-cpp/gtkmm - C++ interface for GTK
- dev-python/pygobject - Python bindings for GObject based libraries such as GTK
See also
- GNOME — a feature-rich desktop environment provided by the GNOME project.
External resources
- GTK 4.0 documentation
- GTK 3.0 documentation
- x11-libs/wxGTK - GTK version of wxWidgets, a cross-platform C++ GUI toolkit
References
- ↑ "Gnome, GSettings, gconf, and which one you want". Retrieved on 2026年02月25日.
- ↑ "Gtk > Settings". Retrieved on 2025年01月26日.
- ↑ "Running and debugging GTK Applications". Retrieved on 2025年01月26日.