[GTK Config] Apply color scheme to GTK3 applications
ClosedPublic

Authored by gikari on Mar 16 2020, 1:00 PM.

Details

Summary

Move from krdb (see D28070) with some refactorings.
Depends on D28070

Test Plan

This is how I got it to work, improvements to the process are appreciated

  1. Apply D28070
  2. Compile breeze-gtk and then copy $PREFIX/kde/usr/share/themes/Breeze to /usr/share/themes (replacing the existing Breeze (make a backup)). This is needed because Breeze-Gtk recently changed its color definitions names, which are used in this diff. Old Breeze-Gtk uses different ones and therefore the coloration won't work.
  3. Run systemsettings and reapply Breeze theme from Application Style KCM
  4. Restart kded5
  5. Go to colors KCM, open it side by side with GTK3 applications (preferably Gedit NOT Nautilus or Lutris (those ones are kept open if you press cross in headerbar))
  6. Change the color scheme.
  7. The application must change the colorscheme

Diff Detail

Repository
R99 KDE Gtk Configuration Tool
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
gikari created this revision.Mar 16 2020, 1:00 PM
Restricted Application added a project: Plasma. · View Herald TranscriptMar 16 2020, 1:00 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
gikari requested review of this revision.Mar 16 2020, 1:00 PM
gikari edited the test plan for this revision. (Show Details)Mar 16 2020, 1:06 PM
gikari retitled this revision from [WIP][GTK Config] Apply color scheme to GTK3 application to [WIP][GTK Config] Apply color scheme to GTK3 applications.
gikari edited the test plan for this revision. (Show Details)
gikari edited the test plan for this revision. (Show Details)
gikari added inline comments.Mar 16 2020, 1:12 PM
kded/configeditor.cpp
114

Also, I would like to move D24275 to kde-gtk-config repo too with autoloading the module to all GTK applications.

gikari edited the test plan for this revision. (Show Details)Mar 16 2020, 10:05 PM
gikari planned changes to this revision.Mar 17 2020, 6:08 PM
gikari updated this revision to Diff 77855.Mar 17 2020, 6:23 PM
  • Rebase on master
  • Add recoloration module
gikari edited the summary of this revision. (Show Details)Mar 17 2020, 6:25 PM
gikari edited the test plan for this revision. (Show Details)
cblack requested changes to this revision.Mar 17 2020, 6:26 PM

The GTK+ module shouldn't be in this patch, as it and the functions to write CSS are separate changes.

This revision now requires changes to proceed.Mar 17 2020, 6:26 PM
gikari planned changes to this revision.Mar 17 2020, 6:30 PM
  • I should add the recoloration module to autoload with GTK applications

The GTK+ module shouldn't be in this patch, as it and the functions to write CSS are separate changes.

Then how do I test the recoloration? It seems like it applies randomly whenever the GTK app would like to update the colors, but with that module it's predictable. Or do you mean to make it as a separate patch, but make this one depend on it?

  • I should add the recoloration module to autoload with GTK applications

The GTK+ module shouldn't be in this patch, as it and the functions to write CSS are separate changes.

Then how do I test the recoloration? It seems like it applies randomly whenever the GTK app would like to update the colors, but with that module it's predictable. Or do you mean to make it as a separate patch, but make this one depend on it?

The two items don't have a dependency relation codewise. You simply test the recolouration like how it's been up until now—restart the applications.

You simply test the recolouration like how it's been up until now—restart the applications.

It doesn't work. This is what I was talking about:

It seems like it applies randomly whenever the GTK app would like to update the colors, but with that module it's predictable.

You simply test the recolouration like how it's been up until now—restart the applications.

It doesn't work. This is what I was talking about:

It seems like it applies randomly whenever the GTK app would like to update the colors, but with that module it's predictable.

You seem to be testing with Nautilus, which doesn't actually close when you press the close button.

You simply test the recolouration like how it's been up until now—restart the applications.

It doesn't work. This is what I was talking about:

It seems like it applies randomly whenever the GTK app would like to update the colors, but with that module it's predictable.

You seem to be testing with Nautilus, which doesn't actually close when you press the close button.

Yes, you're right, but I also tested it with Lutris. It also does not work. But with gedit it works fine.

You simply test the recolouration like how it's been up until now—restart the applications.

It doesn't work. This is what I was talking about:

It seems like it applies randomly whenever the GTK app would like to update the colors, but with that module it's predictable.

You seem to be testing with Nautilus, which doesn't actually close when you press the close button.

Yes, you're right, but I also tested it with Lutris. It also does not work. But with gedit it works fine.

Lutris is also another application that doesn't close fully when you press close (however, that part is configurable in Lutris.)

gikari updated this revision to Diff 77860.Mar 17 2020, 7:01 PM
gikari edited the summary of this revision. (Show Details)
  • Remove the recolor module. It is D28076 now
gikari edited the test plan for this revision. (Show Details)Mar 17 2020, 7:14 PM
gikari retitled this revision from [WIP][GTK Config] Apply color scheme to GTK3 applications to [GTK Config] Apply color scheme to GTK3 applications.
davidre added a subscriber: davidre.EditedMar 18 2020, 6:24 PM

It seems it is possible to do this (removing stuff from the data engine) after all. I will try to work on this in the next time

Seems I replied to the wrong diff, oops...

gikari edited the summary of this revision. (Show Details)Mar 29 2020, 10:26 PM
gikari edited the test plan for this revision. (Show Details)
gikari updated this revision to Diff 78823.Mar 29 2020, 10:54 PM
gikari marked an inline comment as done.
  • Rebase on master
  • Add recoloration module check
cblack accepted this revision.Mar 29 2020, 11:04 PM
This revision is now accepted and ready to land.Mar 29 2020, 11:04 PM

Hmm, when following those instructions, I get the following console error:

Gtk-Message: 08:50:13.086: Failed to load module "colorreload-gtk-module"

And the color scheme doesn't change. The colorreload-gtk3-module target did get built, and it installed a shared library to /home/nate/kde/usr/lib64/gtk-3.0/modules/libcolorreload-gtk-module.so

Hmm, when following those instructions, I get the following console error:

Gtk-Message: 08:50:13.086: Failed to load module "colorreload-gtk-module"

And the color scheme doesn't change. The colorreload-gtk3-module target did get built, and it installed a shared library to /home/nate/kde/usr/lib64/gtk-3.0/modules/libcolorreload-gtk-module.so

GTK™ isn't too fond of trying to load stuff from outside the standard directories.

Well this is kind of a problem then since we need to support development builds to a nonstandard install prefix.

GTK™ isn't too fond of trying to load stuff from outside the standard directories.

How can this be fixed?

gikari added a comment.EditedMar 30 2020, 7:43 PM

Hmm, when following those instructions, I get the following console error:

Gtk-Message: 08:50:13.086: Failed to load module "colorreload-gtk-module"

And the color scheme doesn't change. The colorreload-gtk3-module target did get built, and it installed a shared library to /home/nate/kde/usr/lib64/gtk-3.0/modules/libcolorreload-gtk-module.so

Try export GTK_PATH='/home/nate/kde/usr/lib/gtk-3.0/' before launching a GTK app. This should make module to load.

The path would be /home/nate/kde/usr/lib64/gtk-3.0/ on my system, but nonetheless there is no effect. :(

The path would be /home/nate/kde/usr/lib64/gtk-3.0/ on my system, but nonetheless there is no effect. :(

Is the GTK application throwing the same error, that the module is not found, or recoloration does not work?

Same error about not being able to find the module. Sorry for not being clear.

Same error about not being able to find the module. Sorry for not being clear.

You can provide a full path to the library instead of letting GTK do name to library resolution.

Same error about not being able to find the module. Sorry for not being clear.

Does the specified path contain (/home/nate/kde/usr/lib64/gtk-3.0/) modules directory with the libcolorreload-gtk-module.so file?
If there it is, try launching GTK app with:

gtk-app --gtk-module /home/nate/kde/usr/lib64/gtk-3.0/modules/libcolorreload-gtk-module.so

The parameter must be absolute path.

You can provide a full path to the library instead of letting GTK do name to library resolution.

Yes, you can, but that's inconvenient. According to this you can specify GTK_PATH environment variable, so that GTK knows where to search for modules. It works for me at least.

I also noticed a dynamic recoloration bug: it doesn't work if the app is launched with the color scheme, that it was using in the previous launch. To make it work I have to change color scheme and relaunch the app. The app therefore changes its color scheme to a new one and it is now reacting to color scheme change properly (i.e. changes it without restart).

gikari added a comment.Apr 3 2020, 5:36 PM

@ngraham Did you manage to load the recoloration module into the GTK app by one or another way?

Haven't tried yet, sorry. I'll give it another shot today.

gikari updated this revision to Diff 79263.Apr 4 2020, 8:32 AM
  • Rebase on master

Still doesn't work for me:

gnome-chess --gtk-module /home/nate/kde/usr/lib64/gtk-3.0/modules/libcolorreload-gtk-module.so
Gtk-Message: 08:49:51.962: Failed to load module "colorreload-gtk-module"
gikari added a comment.Apr 7 2020, 2:59 PM

Still doesn't work for me:

gnome-chess --gtk-module /home/nate/kde/usr/lib64/gtk-3.0/modules/libcolorreload-gtk-module.so
Gtk-Message: 08:49:51.962: Failed to load module "colorreload-gtk-module"

Actually the specified module is loaded. The error message comes from the module specified in the settings.ini.

If it weren't the message would be something like this (i.e. mentioning absolute module path):

Gtk-Message: 17:56:18.012: Failed to load module "/home/gikari/kde/usr/lib/gtk-3.0/modules/libcolorreload-gtkd-module.so"

Check the recoloration - does it work?

Still doesn't work:

gnome-chess --gtk-module /home/nate/kde/usr/lib64/gtk-3.0/modules/libcolorreload-gtk-module.so
Gtk-Message: 08:49:51.962: Failed to load module "colorreload-gtk-module"

Still doesn't work for me:

gnome-chess --gtk-module /home/nate/kde/usr/lib64/gtk-3.0/modules/libcolorreload-gtk-module.so
Gtk-Message: 08:49:51.962: Failed to load module "colorreload-gtk-module"

Actually the specified module is loaded. The error message comes from the module specified in the settings.ini.

If it weren't the message would be something like this (i.e. mentioning absolute module path):

Gtk-Message: 17:56:18.012: Failed to load module "/home/gikari/kde/usr/lib/gtk-3.0/modules/libcolorreload-gtkd-module.so"

Check the recoloration - does it work?

No. :(

gikari added a comment.Apr 7 2020, 3:04 PM

I also noticed a dynamic recoloration bug: it doesn't work if the app is launched with the color scheme, that it was using in the previous launch. To make it work I have to change color scheme and relaunch the app. The app therefore changes its color scheme to a new one and it is now reacting to color scheme change properly (i.e. changes it without restart).

Can you reproduce this behavior?

No. :(

I feel like I'm doing something really stupid here to make nothing work...

gikari added a comment.Apr 7 2020, 3:25 PM

Hm, this is bizarre. I've tested once again and now the bug I mentioned before is gone.

@ngraham Did you launch system settings (colors section) after applying D28070 to plasma-desktop? Without that patch it won't work possibly due to conflicts.

I did. I followed your test plan exactly. :/

ndavis added a subscriber: ndavis.Apr 10 2020, 8:06 PM

Works for me. @ngraham, perhaps you forgot to restart kded5? I forgot that at first.

If the code looks good to you, let's ship it.

So, is it ok to land? If so, approve please.

ngraham accepted this revision.Apr 14 2020, 7:07 PM
This revision was automatically updated to reflect the committed changes.