Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a style manager #731

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Introduce a style manager #731

wants to merge 16 commits into from

Conversation

leolost2605
Copy link
Member

@leolost2605 leolost2605 commented Sep 18, 2024

This moves the provider management etc. from the init function to a separate class StyleManager.

This class now also automatically handles adjusting the theme to system preference and allowing the application to override this (which was my motivation since that's a bunch of boiler plate code that then could be removed from the applications startup functions).

Since more stuff is going to have to be done here (see e.g. https://gitlab.gnome.org/GNOME/gtk/-/issues/6821) this might be a good way to go now.

This currently is a global style manager for all displays but maybe we should follow Adw.StyleManager and make it per display? This is now per display since that makes more sense in general

@leolost2605
Copy link
Member Author

Regarding the demo: I opted to leave the switch that directly interfaces with gtk settings in the headerbar which can cause a mismatch between e.g. force dark in the stylemanager page and a light mode of the app. This is intended behavior because we shouldn't actually do anything with gtk settings manually but it might confuse people who use the demo.

@leolost2605 leolost2605 requested a review from a team September 18, 2024 23:43
lib/StyleManager.vala Outdated Show resolved Hide resolved
lib/StyleManager.vala Outdated Show resolved Hide resolved
lib/StyleManager.vala Outdated Show resolved Hide resolved
@leolost2605
Copy link
Member Author

Fyi I switched it to per display style managers because that just makes more sense and is a lot nicer in code (no more need for lots of foreachs)

Copy link
Member

@danirabbit danirabbit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm so testing this, it doesn't seem to work in the demo and I get:
** (granite-7-demo:140614): CRITICAL **: 11:57:41.997: granite_style_manager_set_color_scheme_override: assertion 'self != NULL' failed

@danirabbit
Copy link
Member

we shouldn't actually do anything with gtk settings manually but it might confuse people who use the demo.

I think we should probably remove the switch to make sure the demo is working properly and contains only good example code and not stuff we don't want other people to copy

@leolost2605
Copy link
Member Author

leolost2605 commented Sep 19, 2024

Hm so testing this, it doesn't seem to work in the demo and I get: ** (granite-7-demo:140614): CRITICAL **: 11:57:41.997: granite_style_manager_set_color_scheme_override: assertion 'self != NULL' failed

This should be fixed now, for some reason static construction didn't seem to work?

Copy link
Member

@danirabbit danirabbit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected, looks good, just a few comments!

lib/StyleManager.vala Show resolved Hide resolved
lib/StyleManager.vala Outdated Show resolved Hide resolved
lib/StyleManager.vala Outdated Show resolved Hide resolved
lib/StyleManager.vala Outdated Show resolved Hide resolved
demo/Views/StyleManagerView.vala Outdated Show resolved Hide resolved
@danirabbit
Copy link
Member

@alice-mkh Any thoughts on how this will/won't interact with Adw in for example Epiphany?

@danirabbit
Copy link
Member

I wanna get this Granite 7.6.0 release out and then we can go ahead and merge this for an 8.0.0 that we don't have to worry about breakage etc and have plenty of time to test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants