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

Get prefers color scheme from accountsservice #319

Merged
merged 20 commits into from
Apr 23, 2020

Conversation

danirabbit
Copy link
Member

@danirabbit danirabbit commented Sep 13, 2019

Create a Granite.Settings class like Gtk.Settings. Fixes #276

Read-only is intentional as we don't want apps setting this for the user

@cassidyjames
Copy link
Contributor

cassidyjames commented Apr 21, 2020

I think we'll want to switch this to an enum since elementary/default-settings#166 was merged.

@danirabbit
Copy link
Member Author

danirabbit commented Apr 21, 2020

@cassidyjames Updated. This should work with the new accountsservice stuff.

Since there's no system UI for this yet, you can send this in dfeet "io.elementary.pantheon.AccountsService", "PrefersColorScheme", GLib.Variant("i", 1)

I guess there's a question of how should we demo this? I think we want the override here for the demo maybe? Or should we remove that toggle?

Also, we currently only include this for accountsservice in Odin. Should we add this in Hera too? Maybe not necessarily exposing the setting yet, but if it exists in Granite and AccountsService we could start testing it

Is it okay to make this a boolean property or should we make this enum out of the box? The boolean is nice because you can super easily bind this to app-prefers-dark right now. But this doesn't account for any prefers-light. I guess if we decide to support that we can come back and deprecate the boolean property?

@cassidyjames
Copy link
Contributor

I guess there's a question of how should we demo this? I think we want the override here for the demo maybe? Or should we remove that toggle?

I think we default to the user preference but still allow a local override (so devs can still test how widgets look without changing their whole system preference)? But we can think about it. Another option would be to implement what we expect to see in apps like Code or Terminal where we might want to allow for a tri-state of light/dark/follow system.

Also, we currently only include this for accountsservice in Odin. Should we add this in Hera too? Maybe not necessarily exposing the setting yet, but if it exists in Granite and AccountsService we could start testing it

Yeah I think we include it in Hera. I think I'd like to ship the system UI stuff for 5.2 if possible, because it has been a long time coming and would be a nice preview of the bigger dark style stuff for 6.0.

Is it okay to make this a boolean property or should we make this enum out of the box? The boolean is nice because you can super easily bind this to app-prefers-dark right now. But this doesn't account for any prefers-light. I guess if we decide to support that we can come back and deprecate the boolean property?

Yeah I think boolean is fine and we can deprecate later if/when we expose a light preference.

@danirabbit danirabbit marked this pull request as ready for review April 21, 2020 23:48
@cassidyjames
Copy link
Contributor

cassidyjames commented Apr 22, 2020

Hmm, I guess this raises the question of how apps should bind to it. If it changes live, I imagine we'd want the app to change instantly, too. But if they offer an override, how does that interact? I think that's where it has to become a tri-state of:

  • Follow system preference
  • Always light
  • Always dark

Which is similar to what I see in Android apps fwiw. I think most apps that support a dark style should just automatically follow along with the setting and not offer up any sort of UI for it, though.

@cassidyjames
Copy link
Contributor

I guess I'm fine in general with this as a starting point, we can always iterate. I would like to get a review of the code side from someone more familiar and opinionated about Granite and namespacing and everything, though.

@cassidyjames cassidyjames requested review from tintou and donadigo April 22, 2020 03:18
lib/Widgets/Settings.vala Outdated Show resolved Hide resolved
@tintou
Copy link
Member

tintou commented Apr 23, 2020

It would probably make it clearer indeed to return an enum instead of having a boolean, that way we can extend it without fearing API breaks

danirabbit and others added 2 commits April 23, 2020 16:52
Co-Authored-By: Corentin Noël <corentin@elementary.io>
@cassidyjames
Copy link
Contributor

cassidyjames commented Apr 23, 2020

@tintou see: elementary/default-settings#167 (comment)

We should decide on unsigned or signed and then make sure it matches in the master and hera branches of default-settings as well as here.

Edit:

enums are int when flags are uint in Vala
that's their standard GVariant type

Otherwise we end-up with annotations like this https://github.com/elementary/switchboard-plug-display/blob/master/src/Interfaces/MutterDisplayConfig.vala#L36
@tintou

cassidyjames added a commit to elementary/default-settings that referenced this pull request Apr 23, 2020
danirabbit pushed a commit to elementary/default-settings that referenced this pull request Apr 23, 2020
cassidyjames
cassidyjames previously approved these changes Apr 23, 2020
Copy link
Contributor

@cassidyjames cassidyjames 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 advertised. Thanks for hooking up the changes as well to demo how apps can do that!

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.

Add way to check if the OS prefers a dark style
3 participants