-
Notifications
You must be signed in to change notification settings - Fork 811
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
First day of the week changes #1935
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the two bug fix commits please make the summary lines match the bug title. You can change the bug title if you want.
I haven't yet tested, generally looks pretty good. I'm not keen on more use of GDate but it looks like the alternative is to use ICU directly. That's too much work for this PR.
I have missed this before, will do when I push again. |
I have made the changes to bug titles and removed my function in the last commit. |
Thanks. I hope to get time to test it later today. |
@Bob-IT OK, it looks like it should when one changes the starting weekday. I used an old test file with an SX that hasn't been allowed to run for a while. I was surprised that the calendar begins on the next month in which the selected SX is supposed to run rather than the current year. That makes me think that a start-month & year selector might be a useful addition. I don't think we want the start-of-week selector to be displayed most of the time. The other thing that I noticed is that that it doesn't respond to changing the LANG value, either in etc/environment or with an environment variable in the shell, at least on my Mac. I had to change the region in System Preferences to get it to start the week on Monday instead of Sunday. Of course as soon as someone notices this they'll wonder why the date selector calendar always starts on Sunday no matter the locale. |
There is code in gnc-dense-cal.c here that changes the default start month/year from now to the first date to be shown. What may be confusing and I think may of come up before is there is no year indicated. I have a schedule that last ran on 11/09/2018 with never as the next occurrence, if change that to 11/09/2019 the calendar starts from OCT. I suppose that could be fixed by combining your suggestion with month and year combo's so on the left we get... Then the next question would be how permanent are they, should they be saved while scheduled transactions page is open between sessions and reset to now when page is closed/opened?
Did a normal |
That works for me, and I wouldn't persist it, even when switching SXes in the list that might have different next dates.
#1907 nukes the whole function. I think that's the right thing to do. I don't see what that's got to do with anything though. The issue is that macOS uses ICU for its localization and ICU doesn't use ISO locale codes, so |
Is that the true reason ? If I look at the code that sets the locales - which has separate code paths on linux, windows and macos - I see the macOS path prioritizes the locale found in the macOS configuration system, while the linux path prioritizes what's set as environment variable. So if a valid locale is found in the macOS configuration system, the environment is never checked. Which would explain why you can't play with environment variables to test locale related stuff on macOS. Our Windows locale code will first try the C library's |
@gjanssens, It's supposed to work like Windows where it checks the environment first. I'll take a look. |
Yes. If I add --- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -46,6 +46,7 @@
#include <cinttypes>
#include <unicode/calendar.h>
+#include <unicode/locid.h>
#include "gnc-date.h"
#include "gnc-date-p.h"
@@ -199,7 +200,8 @@ gnc_start_of_week (void)
if (!cached_result)
{
UErrorCode err = U_ZERO_ERROR;
- auto cal = icu::Calendar::createInstance (err);
+ icu::Locale icu_locale = icu::Locale::createFromName(setlocale(LC_TIME, nullptr));
+ auto cal = icu::Calendar::createInstance (icu_locale, err);
if (!cal)
{
PERR("ICU error: %s\n", u_errorName (err)); to set the ICU locale from the POSIX locale then it behaves as expected when
Half true. Attempting to set --- a/gnucash/gnucash-locale-macos.mm
+++ b/gnucash/gnucash-locale-macos.mm
@@ -197,10 +197,15 @@
if (!setlocale(LC_ALL, [locale_str UTF8String]))
locale_str = mac_find_close_country(locale_str, country_str, lang_str);
/* Cache the final locale string to be returned to the calling program */
- gnc_locale = g_strdup ([locale_str UTF8String]);
-
- if (g_getenv("LANG") == NULL)
+ if (!(gnc_locale = g_strdup(g_getenv("LANG"))))
+ {
+ gnc_locale = g_strdup ([locale_str UTF8String]);
g_setenv("LANG", [locale_str UTF8String], TRUE);
+ }
+ else
+ {
+ locale_str = [NSString stringWithCString : gnc_locale encoding: NSUTF8StringEncoding];
+ }
mac_set_currency_locale(locale, locale_str);
/* Now call gnc_localeconv() to force creation of the app locale Gets setting |
@Bob-IT Can you wrap this up in the next week-10 days? I'd like to get it into GC5.7. |
@jralls I did have a look at making the changes for this but did not like it, I think it gave the impression it could do more than in reality it could. I think it may be easier to remove them as originally intended and commit the rest of the changes. I will have another think about adding them and create a separate PR for it. |
@Bob-IT That's reasonable, it's not related to calendar layout. Are all of the testing widgets confined to that last commit? |
@Bob-IT Go for it. |
Create two new variables for the height of the day top bar and width of the month side bar along with the existing label_height. These two new variables have the same value but made it easier to identify the alignment error.
Add a 2 px of padding as default to the day top and month side bars and also allow it to be changed by CSS.
In the dense calendar, add a default number of months per column entry to the view model to get a better layout when the function gnc_dense_cal_set_num_months is solely used. This default number of months per column can still be over ridden by using the function gnc_dense_cal_set_months_per_col.
The position of the divider is saved when the Scheduled Transaction page is left open and reverts to the default when closed. This commit adds a menu option 'Save layout as default' which will save the position as a preference setting so it will be remembered.
The number of months to display is saved when the Scheduled Transaction page is left open and reverts to the default of 12 when closed. This commit add to the existing save layout menu so that it will save the number of months to display to a preference setting so it will be remembered
As promised this was what I was working on last November when I got distracted.
There are couple of bug fixes for saving the scheduled transaction page layout, i.e, the paned position and the number of months along with some tidy up.
The last three commits are the real changes.
gnc_get_first_day_of_week
function which is OS specific.That function is in
gnc-gnome-utils
which maybe in the wrong place but it had other Mac specific code and so was convenient. I am not sure the Mac code is correct but on Windows changing thestart day
under settings is reflected. The Mac and Windows functions do have error detection so that could default tognc_start_of_week.
I have used a website that creates a calendar that allowed you to specify start day and from what I could see the calendars do match but would like other people to test it.