[GTK3] Add module to reload colorscheme in GTK3 apps without restarting them
AbandonedPublic

Authored by cblack on Sep 27 2019, 9:33 PM.

Details

Reviewers
apol
The-Feren-OS-Dev
Group Reviewers
Plasma
Summary

The title is somewhat self explanatory. GTK apps will reload ~/.config/gtk-3.0/colors.css without restarting.

Test Plan

gtk-app-here --gtk-module colorreload-gtk-module

Diff Detail

Repository
R98 Breeze for Gtk
Branch
arcpatch-D24275_1
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 22595
Build 22613: arc lint + arc unit
cblack created this revision.Sep 27 2019, 9:33 PM
Restricted Application added a project: Plasma. · View Herald TranscriptSep 27 2019, 9:33 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
cblack requested review of this revision.Sep 27 2019, 9:33 PM
cblack added a reviewer: apol.Sep 27 2019, 9:33 PM
cblack edited the summary of this revision. (Show Details)
$ gedit --gtk-module colorreload-gtk-module
Gtk-Message: 17:44:24.968: Failed to load module "colorreload-gtk-module"

What am I doing wrong?

Does it work if you use an absolute path to the library? Go to $BUILDROOT/color-reload-module/libcolorreload-gtk-module.so and run gedit --gtk-module $PWD/libcolorreload-gtk-module.so

GB_2 added a subscriber: GB_2.Oct 12 2019, 5:44 PM

Does it work if you use an absolute path to the library? Go to $BUILDROOT/color-reload-module/libcolorreload-gtk-module.so and run gedit --gtk-module $PWD/libcolorreload-gtk-module.so

Nope, still shows the error.

cblack added a comment.Dec 3 2019, 3:50 PM
In D24275#546111, @GB_2 wrote:

Does it work if you use an absolute path to the library? Go to $BUILDROOT/color-reload-module/libcolorreload-gtk-module.so and run gedit --gtk-module $PWD/libcolorreload-gtk-module.so

Nope, still shows the error.

Does the module work if you use the meson.build I accidentally checked in? meson _build, ninja -C _build install (no sudo)

GB_2 added a comment.Dec 3 2019, 4:11 PM

Works now :-)

cblack added a comment.Dec 3 2019, 4:12 PM
In D24275#571531, @GB_2 wrote:

Works now :-)

With the cmake or the meson?

GB_2 added a comment.EditedDec 3 2019, 4:16 PM
In D24275#571531, @GB_2 wrote:

Works now :-)

With the cmake or the meson?

Meson.

Needs a rebase on current master.

cblack updated this revision to Diff 70834.Dec 3 2019, 5:10 PM

Pull from master

nicolasfella added a subscriber: nicolasfella.EditedDec 3 2019, 5:47 PM

Unrelated to the issue: For GLIB2 we have a ECM find module that makes things a bit nicer. See https://invent.kde.org/snippets/601
For GTK we don't have one, but if we use it on at least one other place it might be worth making one

Edit: Of course we find GTK already in the very same project, so we can just use those variables. No need for pkgconfig here

cblack updated this revision to Diff 75203.Feb 7 2020, 10:15 PM

Drop meson.build, clean CMakeLists.txt, rebase on master

cblack updated this revision to Diff 75205.Feb 7 2020, 10:26 PM

Fix memory leak

davidedmundson added a subscriber: davidedmundson.EditedFeb 8 2020, 3:44 AM

This would also be loaded and operational when running in a gnome session. It's important we don't cause issues there.

Or are modules not autoloaded? If not what's our plan for having our users use this?

Does this work if colours.css doesn't exist and is then created at runtime?

color-reload-module/reloader.c
27

What is this 801?

cblack marked an inline comment as done.Feb 8 2020, 3:48 AM

Looking at documentation, the colour module should gracefully fail when it's unable to locate the colors.css, however I have not tested this.

color-reload-module/reloader.c
27

GTK loads in the original colors.css at priority 800, so priority 801 will override it.

The-Feren-OS-Dev accepted this revision.Feb 17 2020, 6:39 PM
The-Feren-OS-Dev added a subscriber: The-Feren-OS-Dev.

Had to lower the cmake version requirement to be able to compile this, but this works just fine, and it's definitely something that'd be nice to have. I can't see any regressions nor leaks, either on this current patch version.

This revision is now accepted and ready to land.Feb 17 2020, 6:39 PM
ngraham added inline comments.Feb 17 2020, 6:53 PM
color-reload-module/CMakeLists.txt
2

As noticed by @The-Feren-OS-Dev, this is too high.

cblack updated this revision to Diff 75856.Feb 17 2020, 7:01 PM

Lower min version of CMake

gikari added a subscriber: gikari.Feb 17 2020, 7:32 PM

Since we plan to move more GTK related code to kde-gtk-config repo (specifically coloration of GTK apps from krdb), isn't it more reasonable to put this module in kde-gtk-config repo?

cblack abandoned this revision.Mar 16 2020, 2:00 PM