GTK

From Gentoo Wiki
Jump to:navigation Jump to:search
This article is a stub. Please help out by expanding it - how to get started.

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
Data provided by the Gentoo Package Database · Last update: 2026年07月10日 20:42 More information about USE flags

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
Data provided by the Gentoo Package Database · Last update: 2026年07月25日 17:57 More information about USE flags

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 gtk
libgtk-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:

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:

FILE ~/.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:dark

For 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:

FILE ~/.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:

FILE /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:

FILE ~/.gtkrc-2.0
gtk-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-spy

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:

FILE ~/.bashrc
exportGDK_CORE_DEVICE_EVENTS=1

For more information, see GTK applications (sometimes?) do not scroll correctly, lacks focus?.

Additional software

  Important note to editors
This section currently is just a stub with a few examples of packages, please complete it with more useful content.

Search packages.gentoo.org for packages to use with GTK, such as themes or language bindings.

Themes

Development tools

Language bindings

See also

External resources

References

  1. "Gnome, GSettings, gconf, and which one you want". Retrieved on 2026年02月25日.
  2. "Gtk > Settings". Retrieved on 2025年01月26日.
  3. "Running and debugging GTK Applications". Retrieved on 2025年01月26日.