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

Enhancement: Select First Day of Week for Locale #127

Closed
wants to merge 30 commits into from

Conversation

lainsce
Copy link

@lainsce lainsce commented Nov 12, 2020

This eventually will change the order of days on Calendar and Date Time indicator popover by issuing a setting that gets read by both. Fixes #86 .

Looks like:
Screenshot from 2020-11-12 17 53 56

@lainsce lainsce marked this pull request as draft November 13, 2020 03:41
@lainsce
Copy link
Author

lainsce commented Nov 13, 2020

The way this works is:

  1. io.elementary.switchboard.locale/first-day changes, and sets a (translatable) string of the day that it is ("Sunday" is default)
  2. This will propagate to whatever place reads this such as a calendar widget or some such, and reorders the columns to reflect the setting.
  3. ???
  4. Profit!

Now all you need, is to use this on apps or indicators that have a calendar grid, to reorder the grid based on this setting.

@lainsce lainsce marked this pull request as ready for review November 13, 2020 15:02
@lainsce
Copy link
Author

lainsce commented Nov 13, 2020

Actually, going to need some help with save-stating this on the checkbox, as currently it jumps to Sunday.

@lainsce lainsce marked this pull request as ready for review November 14, 2020 01:29
@lainsce
Copy link
Author

lainsce commented Nov 14, 2020

Ready to review.

Copy link
Collaborator

@jeremypw jeremypw left a comment

Choose a reason for hiding this comment

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

It is possible for first_day to take an invalid value and the combobox is then blank.
When you select a different locale (but do not set it as default) and then close, first_day is set to -1.
I think you should put a range attribute in the schema limiting acceptable entries 0 - 6. Should range check in the code when setting the combobox and when saving the setting as well.

I note that only one first_day can be saved so if someone needs to switch between two or more locales with different first days they would have to reset it each time. I guess if that is a significant issue it could be addressed in a later PR though.

@lainsce
Copy link
Author

lainsce commented Nov 17, 2020

Could you guide me on how to make a ranged gschema? I've never done that type of thing before.

As for the rest about checking on code if it's on the range, I'd wager it should be fixed if the gschema is ranged, wouldn't it?

@jeremypw
Copy link
Collaborator

I am not quite sure what happens if code tries to write an out of range value to a setting so it is better to be sure this cannot happen one way or another.

@lainsce
Copy link
Author

lainsce commented Nov 17, 2020

There we go.

@lainsce lainsce requested a review from jeremypw November 17, 2020 18:21
src/LocaleManager.vala Outdated Show resolved Hide resolved
@lainsce
Copy link
Author

lainsce commented Nov 17, 2020

After addressing things, there's a small lag on first open, but shouldn't be anything bad.

@lainsce
Copy link
Author

lainsce commented Nov 24, 2020

Review points addressed. 👍

@jeremypw
Copy link
Collaborator

If we can read the first day of the week from Posix then we do not really need a combobox ...

There a Posix enum NLTime.FIRST_WEEKDAY in posix.vapi - maybe this is useful?

@lainsce
Copy link
Author

lainsce commented Nov 25, 2020

The thing is that it's not the problem this PR is solving really reading from Posix and automatically setting things; it's solving the "I'm Spanish, but my system is purposefully in English because I'm studying it or my company set it so, or whatever the reason, so calendars starts on Sunday instead of my country's week start. I can customize via the combobox to make it familiar to me, and keep using my system in English.".

Also, we already do that, but now we can show to the user the setting via this, in a future PR as well.

@lainsce
Copy link
Author

lainsce commented Nov 26, 2020

Please understand that further efforts on Locale and Account Services or ideas like that would bloat this PR and make it not follow the (unwritten?) guideline of a PR doing one thing per PR as I was told many times to do.

@mcclurgm
Copy link

mcclurgm commented Dec 1, 2020

I know this is out of scope, but since there's a discussion already here I don't know where better to put it. I put a bit of info about the posix locale in the original issue. There's also some stuff about this over in the calendar code.

Also, there's a potential issue with the WEEK_1STDAY variable here. According to posix, the numbering of each day of the week depends on the value of that variable. So either we could take that into account here, or assert that every day of the week has the same number no matter what posix says. I put a comment to this effect in the Calendar PR.

@jeremypw jeremypw requested a review from danirabbit December 2, 2020 16:53
@jeremypw
Copy link
Collaborator

jeremypw commented Dec 2, 2020

I am happy for this to be merged on the assumption that further work will be done to ensure that the default setting for this is correct.

@mcclurgm
Copy link

mcclurgm commented Dec 6, 2020

I'm happy to do that since I did the week start stuff in calendar, but it will be a while before I can guarantee. But in theory a "correct" solution that accounts for the posix stuff should be pretty similar to what's in that codebase, assuming I did it right.

@jeremypw
Copy link
Collaborator

jeremypw commented Dec 6, 2020

Good - just needs to @danrabbit to sign off on it now.

@danirabbit
Copy link
Member

danirabbit commented Dec 9, 2020

I feel like this should start at 1, not 0 because as @mcclurgm points out in that calendar code block GLib uses 1-7 and we could reserve 0 for a future "automatic/from locale" setting

@lainsce
Copy link
Author

lainsce commented Dec 9, 2020

I feel like this should start at 1, not 0 because as @mcclurgm points out in that calendar code block GLib uses 1-7 and we could reserve 0 for a future "automatic/from locale" setting

But AFAIK, the Evolution key starts at 1 for Monday. So which futureproofing are we going to push towards? Besides, I think work towards an Automatic Locale thing for the combobox can be done in a new PR.

@mcclurgm
Copy link

mcclurgm commented Dec 9, 2020

But AFAIK, the Evolution key starts at 1 for Monday. So which futureproofing are we going to push towards?

Not sure what other future proofing you're referring to? It seems to me like matching Evolution would be a good thing.

I'd personally support changing to 1 = Monday, since then we could use it directly as a GLib.Weekday in any clients that access the setting. But if we change it, that will break what's in the active Calendar PR. (The current setting is equivalent to what's in all the Ubuntu locales I've seen, which is 1 = Sunday.) But it would simplify the code needed in Calendar, since it could just see the setting and immediately short-circuit with that result. (Basically, this.week_start = (GLib.Weekday) setting; return;)

@danirabbit
Copy link
Member

Yeah I think 1-7 starting with Monday seems like the best option since it matches Evolution and GLib.Weekday

data/io.elementary.switchboard.locale.gschema.xml Outdated Show resolved Hide resolved
src/LocaleManager.vala Outdated Show resolved Hide resolved
src/Widgets/LocaleSetting.vala Outdated Show resolved Hide resolved
@lainsce
Copy link
Author

lainsce commented Dec 9, 2020

Alright, changes added in. :)

@lainsce lainsce closed this Apr 23, 2022
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.

Support for changing the First day of Week
6 participants