Bug 413678 - Setting gtk2 theme through system settings doesnt work if a .gtkrc-2.0 file already exists
Summary: Setting gtk2 theme through system settings doesnt work if a .gtkrc-2.0 file a...
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_gtk (show other bugs)
Version: 5.17.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Mikhail Zolotukhin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-31 16:23 UTC by zee.mzha
Modified: 2019-11-07 17:57 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.17.3
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zee.mzha 2019-10-31 16:23:18 UTC
If a .gtkrc-2.0 file already exists (regardless of who created it, plasma or the user), changing the gtk2 theme through plasma settings doesn't work. If you look at plasma settings it will report the correct theme, however if you actually open the .gtkrc-2.0 file you'll see that it hasn't been changed

Steps to reproduce:

1. Create .gtkrc-2.0 file either manually or by setting a gtk2 theme through plasma settings

2. Change the gtk2 theme from plasma settings

Once done you can see that the "include "/path/to/theme/rc" hasn't actually been changed to the newly selected theme.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
KDE Plasma Version: 5.17.2
KDE Frameworks Version: 5.63.0
Qt Version: 5.13.1
Comment 1 Mikhail Zolotukhin 2019-11-04 17:17:31 UTC
What is the contents of your gtkrc file?

Also, try deleting the gtkrc and then apply settings from the KCM. Will the gtk2 theme be correctly applied after that?
Comment 2 zee.mzha 2019-11-04 17:24:24 UTC
Yes if you delete the file and apply the theme again from the system settings then it will create the file correctly

Here's a pastebin of my current gtkrc-2.0. The bit that's supposed to change is on the 3rd line, the include path. https://pastebin.com/RCTaiB1m
Comment 3 Nate Graham 2019-11-07 17:56:28 UTC
Git commit 308342b16f0a1af0437e1a7d7049b59d30a81952 by Nate Graham, on behalf of Mikhail Zolotukhin.
Committed on 07/11/2019 at 17:55.
Pushed by ngraham into branch 'Plasma/5.17'.

Remove gtkrc-2.0 legacy settings

Summary:
Previously GTK KCM wrote to gtkrc redundant settings lines:
# `include "path to chosen gtk2 theme"`
#
```
style "user-font"
{
font-name="whatever font was chosen"
}
widget_style "*" style "user-font"
```

Now GTK KCM does not write those lines to configuration file,
but ones that was kept from previous versions of KCM
are causing various glitches, when applying gtk2
configuration, for theme and font configs respectively.

This patch fixes these issues removing these lines from gtkrc
by force, after applying any configuration from GTK KCM.
Related: bug 413107

Test Plan:
 # Open ~/gtkrc-2.0 and add those lines (theme and font name are arbitrary):
```
include "/usr/share/themes/Adwaita-dark/gtk-2.0/gtkrc"
style "user-font"
{
    font_name="Noto Sans Regular"
}
widget_class "*" style "user-font"
```
# Open GTK KCM and apply any configuration
# Reopen ~/gtkrc-2.0 file and check, that those lines were removed

Reviewers: cblack, #plasma, apol, ngraham

Reviewed By: cblack, ngraham

Subscribers: ervin, ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D25147

M  +22   -0    src/appearancegtk2.cpp
M  +1    -0    src/appearancegtk2.h

https://commits.kde.org/kde-gtk-config/308342b16f0a1af0437e1a7d7049b59d30a81952