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 it's GTK dependency.
GTK-2 and GTK-3
GTK-2 and GTK-3, are provided by the x11-libs/gtk+ package.
Some applications may optionally be built with support for a GTK interface when enabling the gtk USE flag.
There are also gtk2 and gtk3 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 |
GTK-4
GTK-4 is provided by gui-libs/gtk, a separate package.
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) |
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 |
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
Configuration
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 settings
- lxde-base/lxappearance - part of the LXDE desktop environment, works for GTK 2 apps also (dark theme). Or manually edit ~/.gtkrc-2.0
GTK 3
Specify that a dark theme should be used for a particular user:
~/.config/gtk-3.0/settings.ini
[Settings]
gtk-application-prefer-dark-theme = true
Specify that a dark theme should be used for all users:
/etc/gtk-3.0/settings.ini
[Settings]
gtk-application-prefer-dark-theme = true
GTK 4
A user's GTK 4 theme should normally be set via the gtk-theme-name
setting, which can be specified in a gtk-4.0/settings.ini file:
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.[1]
For example:
~/.config/gtk-4.0/settings.ini
[Settings]
gtk-theme-name='Adwaita'
gtk-application-prefer-dark-theme = 1
The GTK_THEME environment variable can be used when debugging[2]. 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:dark
More generally, for a list of GTK 4 properties that can be set via a gtk-4.0/settings.ini file, refer to this page.
Troubleshooting
Mouse 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:
~/.bashrc
export GDK_CORE_DEVICE_EVENTS=1
For more information, see GTK applications (sometimes?) do not scroll correctly, lacks focus?.
See also
- GNOME — a feature-rich desktop environment provided by the GNOME project.
External resources
- GTK 4.0 documentation
- x11-libs/wxGTK - GTK version of wxWidgets, a cross-platform C++ GUI toolkit
References
- ↑ "Gtk > Settings". Retrieved on 2025-01-26.
- ↑ "Running and debugging GTK Applications". Retrieved on 2025-01-26.