GTK3, themes, and the GIMP-2.99 (current GIMP git master) user interface

GIMP-2.99 (current GIMP git master since the release of GIMP-2.10) uses GTK3 for the user interface. As most of you already know, GTK3 uses a sort of augmented css to “style” GTK3 interfaces.

I’ve encountered and found solutions to some GIMP-2.99 interface issues, and still have a couple of other issues to solve. Hence this post - maybe information below might help others, maybe others have information that might solve the remaining issues I’ve encountered.

Under some circumstances the current default GIMP-2.99 theme will work just fine, and especially if you use Single Window Mode.

However, when using Multi Window Mode under easy-to-replicate circumstances (for which I’ll try to post a screencast once I figure out how), there can be a lot of unwanted movement of the image inside the image window, along with text and background color changes when the mouse or stylus is moved between windows.

At first I assumed the interface problems were stemming from the fact that I use a very tweaked version of Gentoo plus the IceWM “desktop”. However, after experimenting with GIMP-2.99 on another machine running OpenSUSE, the same issues (or variations thereof) turned out to also happen on OpenSUSE using a variety of other Desktops.

So I spent the last couple of days tracking down information on how this GTK3 theming stuff hangs together. Here’s a quick summary in case anyone else might find the information useful:

GTK3 user interfaces are controlled by environmental variables, “settings.ini” files, and css files.

For GIMP git master/GIMP-2.99, which uses GTK+3 version 3.22, the files listed below (and maybe others, I’m not an expert) affect GIMP’s user interface:

  1. The default/system GTK3 theme installed in “/usr/share”, plus environmental variables in “/etc”. The exact locations of the relevant files does vary from one Linux distribution to the next. Some/most distributions/desktops by default install a particular theme. For my Gentoo install the default (and I think only) GTK3 theme is Adwaita.

  2. Additional GTK3 themes a user might have installed and selected as the default theme in place of whatever was installed as per 1. Sometimes these themes go into “$HOME/.themes” and sometimes in “/usr/share”.
    Most desktops allow the user some way to select a theme different from the default theme for the desktop. Often there is a utility for tweaking various aspects of the theme. I didn’t install any such utility on my Gentoo/IceWM setup, so I don’t know where such changes are saved to whatever configuration file.

  3. Parameters passed while starting X (and presumably Wayland) via various configuration files sourced while starting X. On my Gentoo system these files are used to set “environmental” variables:

    • $HOME/.bash_profile
    • $HOME/.bashrc
    • $HOME/.xinitrc

    The relevant files are more or less distribution- and desktop-specific. For example some distributions use .xsession and some desktops provide desktop-specific files. To cover all the bases, for my Gentoo/IceWM setup i put the exact same GTK3-relevant lines in all three of the above files:

    export GTK_OVERLAY_SCROLLING=0
    export GTK_CSD=0
    export LD_PRELOAD="/home/elle/code-install/gtk3-nocsd/libgtk3-nocsd.so.0"
    

    The last line is explained here and requires downloading and compiling a small bit of code: GitHub - PCMan/gtk3-nocsd: A hack to disable gtk+ 3 client side decoration - I don’t know how useful this code might be in practice and especially wrt to GIMP - requires more experimenting.

  4. User files where users can add modifications to what’s already been established by 1. and 2. and 3. above. On my Gentoo installation these two files are relevant:

    • $HOME/.config/gtk3-3.0/gtk.css - Currently on my system this is an empty file as my goal was to simplify what influences GIMP themes. Stuff that goes here can have fairly drastic influence on applications, or no influence at all if following outdated advice on the internet using older GTK3 “stuff” that’s been deprecated by newer versions of GTK3 . . .

    • $HOME/.config/gtk3-3.0/settings.ini - Here’s the lines I put in the “settings.ini” file:

        [Settings]
        gtk-icon-theme-name = Adwaita
        gtk-theme-name = Adwaita
        gtk-font-name = DejaVu Sans 12
        gtk-enable-animations = 0
        gtk-menu-popup-delay = 0
        gtk-primary-button-warps-slider = false
      
  5. GTK3 css files that are specific to default GIMP themes and/or to user-added themes. I’ve been using Benoit Touchette’s themes:

    GitHub - draekko-rand/GIMP-3-Themes: My collection of GIMP 3 themes [WIP]
    https://gitlab.gnome.org/GNOME/gimp/issues/1628

    File locations given below assume GIMP-2.99 is installed in a prefix at location “$PREFIX” (for example “$HOME/code/gimpgtk3/install”), along with a “config” folder in the prefix where user settings are stored.

    • $PREFIX/share/gimp/2.99/themes/System/gimp.css - This is currently the only default GIMP-2.99 theme, afaik. I opened “$PREFIX/share/gimp/2.99/themes/System/gimp.css” and commented it completely out as a way to simplify the task of figuring out what might be affecting the GIMP-2.99 user interface. Then I just left it commented out as it seemed to be contributing to some interface issues.

    • $PREFIX/config/gimp.css - This is where users can additional css for styling GIMP’s default theme. Again I left this blank - it might work with the default theme, but I think user-added themes might just ignore this file.

    • $PREFIX/config/themes/Light/gimp.css - There are also css files for the Gray and Dark themes, but I mostly have been experimenting with the Light theme css file.

    • $PREFIX/config/theme.css - The only thing this file does is import the default and user-added theme css files. It doesn’t contain any additional css. This file is automatically updated by GIMP to reflect the user’s choice of themes, and so there’s no point in trying to modify it.

So there are a lot of files that can affect GIMP-2.99’s GTK3 interface, and the precise contents of the system and user $HOME files will depend on the operating system and the desktop, plus whatever modifications a user might have made. So figuring out what might be affecting GIMP-2.99 interface takes a bit of experimenting and detective work.

I did manage to tweak Benoit Touchette’s “Light” theme to resolve most of the GIMP-2.99 interface issues I was having. The remaining major issue - the image suddenly moving sideways in the image window, accompanied by disappearing/reappearing scrollbars - can be avoided by keeping the image window size wider than approximately 670px as measured using a screen ruler. Right now I’m not even sure if this is a GTK3 theming issue or maybe instead a bug in GIMP.

Just as a sidenote a coworker started building gimp snapshots

Maybe Elle is actually using them? :smiley:

Elle should we have that extension you mention in the repository as well?

Right now I’m not even sure if this is a GTK3 theming issue or maybe instead a bug in GIMP.

@Elle As you know Gimp 2.99 is under heavy development, so bug are something I would expect. I would here simply ask mitch on IRC if this is a known bug.

Hi @darix

That’s really nice! to know that someone has put gimp git master in the OpenSUSE graphics repository - more people using GIMP-2.99 means more people testing. But I built babl/GEGL/GIMP from source in a prefix so I could update from git.

If by “extension” you mean Benoit’s themes for GIMP-2.99, yes, those are really nice to have available to use with GIMP-2.99.

I’m currently dual-booting Gentoo and OpenSUSE on the same machine. I know, dual-booting is so old-fashioned but it still has some advantages over using a VM, and there was plenty much room on my ssd card.

I still use Gentoo+IceWM as my main operating system and desktop, including when using GIMP for actual editing. But OpenSUSE is considerably easier to use for checking to see how GIMP-2.99 user interface looks on different desktops. And it’s nice to be able to verify bugs that I encounter on Gentoo by checking what happens with OpenSUSE.

Hi @Tobias - I just did file a bug report:

The say a picture is worth a thousand words. But I don’t think I could actually explain what I’ve summarized as “image shifting in the image window”, even using simple screenshots. So instead I made screen recordings and attached them to the bug report.