Bug 423141

Summary: GTK2 theming broken after update to Plasma 5.19
Product: [Applications] systemsettings Reporter: Jerzy Witwinowski <locutus>
Component: kcm_styleAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: edisonalvaringo, linux, mail, nate, pizzadude, plasma-bugs, uhhadd, zawertun
Priority: NOR Keywords: regression
Version: 5.18.5   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=430046
Latest Commit: Version Fixed In: 5.20
Sentry Crash Report:
Attachments: GTK2 apps before opening the preview window
GTK2 apps when the preview window is opened
GTK2 apps after the preview window was closed

Description Jerzy Witwinowski 2020-06-18 08:20:35 UTC
SUMMARY
After update to Plasma 5.19 the themes for GTK2 ceased to work. GTK3 themes still work as expected.

STEPS TO REPRODUCE
1. Update Plasma from 5.18 to 5.19
2. Optional: set any theme for GTK2 applications in the Plasma Control panel (optional, because if it is an operating system that is actually used on everyday basis, this would have already been set long before the update)
3. Launch any GTK2 application (GIMP, Inkscape, Ripperx...)

OBSERVED RESULT
The chosen theme is not applied, GTK2 apps launch with Raileigh theme by default. However, if you try to launch a GTK2 app when previewing a GTK2 theme (in the Plasma control panel), it will launch correctly with this theme applied. But as soon as you close the preview window, the app reverts back to the default theme.

EXPECTED RESULT
The chosen GTK2 theme should be applied correctly all the time in GTK2 apps.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE Neon 5.19
(available in About System)
KDE Plasma Version: 5.19.0
KDE Frameworks Version: 5.70.0
Qt Version: 5.14.2

ADDITIONAL INFORMATION
Issue reproduced both on a PC (Acer Aspire X1930) and in an install inside VirtualBox on Mac
Comment 1 p d 2020-06-19 17:05:11 UTC
I have this issue on one of my machines, Fedora 32 KDE with zawertun's copr for latest KDE. On my other machine, I don't have this issue.
Comment 2 p d 2020-06-19 17:05:41 UTC
It should be worth noting that both machines (affected and unaffected) are the same distro and copr repo.
Comment 3 p d 2020-06-19 18:13:41 UTC
The problem now exists on both computers after trying to change the theme as a test, but good news! I found a workaround.

Add this to ~/.profile, ~/.bashrc, and if you use fish shell, ~/.config/fish/config.fish

export GTK2_RC_FILES=/usr/share/themes/Breeze-Dark/gtk-2.0/gtkrc 
export GTK_DATA_PREFIX=""

You can change Breeze-Dark to the theme you like.
Comment 4 boospy 2020-06-21 08:45:21 UTC
Here and in the whole office computeres the same.
Comment 5 edisonalvaringo 2020-06-30 04:57:05 UTC
hi I'm seeing this behaviour on plasma 5.18 kubuntu 20.04 default, I updated something and got broke, not sure what broke the system, maybe it is not a bug with plasma rather a bug of some component of the system not sure.
Comment 6 edisonalvaringo 2020-06-30 05:02:53 UTC
the bug looks the same as you, if I use the preview window the gtk2 theme applies but I think that I don't know why, but the gtk2 apps are trying to use the gtk3 theme instead, maybe they are defaulting to the gtk3 theme for some reason I don't  know. If I change the file in .config/gtk-3.0/settings , it doesn't work, I don't know where the gtk2 apps are reading the theme settings.
Comment 7 edisonalvaringo 2020-06-30 05:18:00 UTC
the workaround that "p d" mentions doesn't work for me lxappareance doesn't work also, but gtk-chtheme DOES WORK!
Comment 8 edisonalvaringo 2020-06-30 05:23:21 UTC
so another thing I noticed, gtk-chtheme works but as long as you launch the apps from the menu, if you launch them using a command from terminal of from the drop down launcher it doesn't work. This is clearly a variable that's messing up the system. But I don't know where to look it's not .bashrc, nor .profile nor, gtk-2.0 nor gtk-2.0-kde4
Comment 9 Nate Graham 2020-06-30 19:11:38 UTC
Cannot reproduce on openSUSE Tumbleweed. Where is the Raileigh theme coming from? I don't think it's installed by default on Neon. Could someone attach a screenshot, or even better, a screen recording of this happening?
Comment 10 edisonalvaringo 2020-06-30 21:05:36 UTC
this is on ubuntu focal using kde from archive.kde.neon.org, as you can see the gtk2 theme is defaulting to the gtk3 version instead of using the gtk2 one.
If it helps also on konsole I get this error when launching gtk2 apps,


 Gtk-CRITICAL **: 17:58:56.783: IA__gtk_widget_set_colormap: assertion '!gtk_widget_get_realized (widget)' failed



https://drive.google.com/file/d/1aMfSg57QvzOE4S_DwTbCkExmy0oPsER_/view?usp=sharing
Comment 11 Nate Graham 2020-06-30 21:34:03 UTC
(In reply to edisonalvaringo from comment #10)
> this is on ubuntu focal using kde from archive.kde.neon.org
FWIW that's not a supported configuration and as such it confuses the issue because now I don't know if it's a real problem in the code or a local misconfiguration.
See https://neon.kde.org/faq.
Comment 12 edisonalvaringo 2020-06-30 21:39:20 UTC
(In reply to Nate Graham from comment #11)
> (In reply to edisonalvaringo from comment #10)
> > this is on ubuntu focal using kde from archive.kde.neon.org
> FWIW that's not a supported configuration and as such it confuses the issue
> because now I don't know if it's a real problem in the code or a local
> misconfiguration.
> See https://neon.kde.org/faq.

yes but it also happens on kubuntu 20.04 lts default, I had to try a different configuration just in case.
Comment 13 Jerzy Witwinowski 2020-07-01 19:48:20 UTC
Created attachment 129829 [details]
GTK2 apps before opening the preview window

As asked by Nate Graham - I provide a series of three screenshots documenting the bug.
Comment 14 Jerzy Witwinowski 2020-07-01 19:49:02 UTC
Created attachment 129830 [details]
GTK2 apps when the preview window is opened

As asked by Nate Graham - I provide a series of three screenshots documenting the bug.
Comment 15 Jerzy Witwinowski 2020-07-01 19:49:44 UTC
Created attachment 129831 [details]
GTK2 apps after the preview window was closed

As asked by Nate Graham - I provide a series of three screenshots documenting the bug.
Comment 16 Jerzy Witwinowski 2020-07-01 19:53:38 UTC
I added the screenshots, as Nate Graham asked. I also wanted to confirm that for me the workaround proposed by p d (setting the system variable GTK2_RC_FILES) works.
Comment 17 Nate Graham 2020-07-01 19:58:33 UTC
Thanks, that's helpful. It's also really weird.

Carson or Mikhail, any ideas here??
Comment 18 Mikhail Zolotukhin 2020-07-01 21:06:48 UTC
This "bug" is happening, because GTK2 applications are using the theme provided by GTK3 setting, because the latter sets itself in xsettingsd.conf file. And xsettings does not have a separate settings for GTK2 and GTK3 applications (therefore it applies the theme from the config to both). Therefore, unfortunately, this is unfixable. It's also one of the reasons why I wanted to merge GTK2 and GTK3 theme setting into one in the UI.

If the OP really want to use separate themes for GTK2 and GTK3 applications (which are rare these days if the themes are new), they can uninstall the xsettingsd daemon. But please note, that this action makes it impossible to change the theme and other settings (such as fonts, icons etc.) for GTK applications on the fly, i.e. without restarting them,

Or the OP can just use one theme for GTK2 and GTK3 applications.
Comment 19 edisonalvaringo 2020-07-01 22:03:21 UTC
I can confirm removing xsettingsd fixes the issue for me.
Comment 20 Nate Graham 2020-07-01 23:03:14 UTC
> It's also one of the reasons why I wanted to merge GTK2 and GTK3 theme setting into one in the UI.
Was there some blocker preventing that? Sounds like it could be a good solution if otherwise users will hit this unfixable bug.
Comment 21 Mikhail Zolotukhin 2020-07-01 23:20:12 UTC
The old diffs were here https://phabricator.kde.org/D29749 and there https://phabricator.kde.org/D29748

If I understood correctly, the main reasons the diff was abordoned were the UI and the fact, that there are still some major apps, that use GTK2 (GIMP and Audacity).

I started a work on a list-based GTK theme selection some time ago, but it is unfinished and somewhat hacky on the Kirigami/QML side, since we do not have the exact needed component. Currently I don't have enough time to fully implement the idea, but I can create merge requests on Invent from the old diffs,
Comment 22 Jerzy Witwinowski 2020-07-04 06:12:16 UTC
I have one question as a person whose informatics skills are limited to writing simple scripts in Perl or Python: why this bug is impossible to correct? Can't you just roll back to the solution that was used until Plasma 5.18? It's better to have to restart GTK2 apps to see the theme applied than to never see the theme applied at all, isn't it? Or maybe you could just implement the p d workaround - modifying the kde-gtk-config package so that it sets correctly the GTK2_RC_FILES system variable should be like two lines of code. An ugly solution is still better than no solution at all... And finally if clicking the preview button correctly sets the theme, can't the code be modified so that whatever hitting the preview button does to the system stays that way after the preview window is closed?
Comment 23 Mikhail Zolotukhin 2020-07-04 09:48:40 UTC
It's impossible to fix keeping the existing functionality, i.e. changing the settings of the GTK apps without restarting them, using xsettingsd. More over GTK2 is deprecated, I do not want to sacrifice the UX and features to support the rare use case, where the themes for GTK applications depend on the framework version, and what's even more, where one version is too old and still used by 1-2 applications (Audacity (via wxWidgets) and GIMP), that still for some reason cannot port themselves to the newer version of the framework they are using during all these years (9 years since GTK3 release, I think).

Regarding the previews: GTK2 one uses a hack: it stops xsettingsd before launching and starts it after closing the preview. This cannot be used for applications, that stay open during a long period of time, because this behavior breaks "on the fly settings changing" feature.
Comment 24 Nate Graham 2020-07-06 16:11:30 UTC
(In reply to Mikhail Zolotukhin from comment #21)
> The old diffs were here https://phabricator.kde.org/D29749 and there
> https://phabricator.kde.org/D29748
Given the information you've provided here, I think we should do that. Maybe you can re-open those or put them in GitLab?

Inkscape just had its 1.0 release and now uses GTK3 so that pretty much just leaves GIMP.
Comment 25 edisonalvaringo 2020-07-07 09:54:10 UTC
There are other apps, old apps that use GTK2, I'm not a dev just a user,  just my two cents, but what about something in the middle solution? removing the gtk2 theming options seems reasonable, but maybe more advance users with not so common apps will still want to theme GTK2 their way, I have two apps here in my desktop WinFF and Palemoon that use GTK2. What about disabling theming by default, but adding a config hidden setting that will allow individual gtk2 theming? maybe that can be changed with a setting in "rc" text file and add a warning about xsettings incompatibility in the comments sections of that file. just my two cents.
Comment 26 edisonalvaringo 2020-07-07 10:05:42 UTC
anyway people using old gtk2 apps could still use gtk-chtheme, and remove xsettings,  what I said it's like a cornercase .
Comment 27 Mikhail Zolotukhin 2020-07-07 11:19:08 UTC
(In reply to Nate Graham from comment #24)
> Given the information you've provided here, I think we should do that. Maybe
> you can re-open those or put them in GitLab?
> 
> Inkscape just had its 1.0 release and now uses GTK3 so that pretty much just
> leaves GIMP.

Done.

https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/54

https://invent.kde.org/plasma/kde-gtk-config/-/merge_requests/7
Comment 28 Mikhail Zolotukhin 2020-07-21 15:19:57 UTC
Git commit 9323a96a9e7ec93f735e10ee671c3824b35429df by Mikhail Zolotukhin.
Committed on 21/07/2020 at 15:18.
Pushed by gikari into branch 'master'.

Provide an unified interface for setting GTK theme

GTK configuration in Plasma depends on xsettings daemon, that has no
separation between GTK2 and GTK3 theme, therefore separate themes for
GTK2 and GTK3 are impossible, while this daemon is working. The daemon
itself provides the functionality to apply settings to GTK applications
without restarting them.

The functionality to apply different themes to applications, depending on
the framework version isn't necessary, when 99% of the themes are
compatible with both versions and when most of the applications are
using the last GTK version anyway.

Given all that, I think, that a theme selection must be narrowed to one
and only one theme for both versions of the GTK framework.

M  +0    -1    CMakeLists.txt
D  +0    -12   gtkproxies/CMakeLists.txt
D  +0    -130  gtkproxies/preview.c
D  +0    -576  gtkproxies/preview.ui
D  +0    -71   gtkproxies/reload.c
M  +21   -1    kconf_update/gtktheme.cpp
M  +3    -28   kded/configeditor.cpp
M  +0    -2    kded/configeditor.h
M  +3    -17   kded/gtkconfig.cpp
M  +3    -8    kded/gtkconfig.h
M  +0    -60   kded/themepreviewer.cpp
M  +0    -10   kded/themepreviewer.h

https://invent.kde.org/plasma/kde-gtk-config/commit/9323a96a9e7ec93f735e10ee671c3824b35429df
Comment 29 Mikhail Zolotukhin 2020-07-21 15:20:02 UTC
Git commit d9d49d5c8f831a289401c50470a46a2cd5778faa by Mikhail Zolotukhin.
Committed on 21/07/2020 at 15:19.
Pushed by gikari into branch 'master'.

[GTK Integration] Apply the same theme for GTK2 and GTK3 applications

GTK configuration in Plasma depends on xsettings daemon, that has no
separation between GTK2 and GTK3 theme, therefore separate themes for
GTK2 and GTK3 are impossible, while this daemon is working. The daemon
itself provides the functionality to apply settings to GTK applications
without restarting them.

The functionality to apply different themes to applications, depending on
the framework version isn't necessary, when 99% of the themes are
compatible with both versions and when most of the applications are
using the last GTK version anyway.

Given all that, I think, that a theme selection must be narrowed to one
and only one theme for both versions of the GTK framework.

M  +1    -1    kcms/style/CMakeLists.txt
D  +0    -34   kcms/style/gtk2_themes.knsrc
R  +1    -1    kcms/style/gtk_themes.knsrc [from: kcms/style/gtk3_themes.knsrc - 095% similarity]
M  +13   -39   kcms/style/gtkpage.cpp
M  +7    -14   kcms/style/gtkpage.h
M  +1    -17   kcms/style/gtkthemesmodel.cpp
M  +1    -2    kcms/style/gtkthemesmodel.h
M  +17   -95   kcms/style/package/contents/ui/GtkStylePage.qml

https://invent.kde.org/plasma/plasma-desktop/commit/d9d49d5c8f831a289401c50470a46a2cd5778faa