mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
Use the Win32 thread locale's first day of week setting on Win32.
2006-10-07 Tor Lillqvist <tml@novell.com> * gtk/gtkcalendar.c (gtk_calendar_init): Use the Win32 thread locale's first day of week setting on Win32. (#339752, Bogdan Nicula) Don't do this if one of the environment variables that affect gettext is set, though. In that case use the week start day from the corresponding message catalog. Unfortunately the same logic isn't possible in the weekday and month name lookup; there even if you have set one of the aforementioned environment variables, you still get the weekday and month names from the Win32 thread locale. Yes, this is inconsistent. Use only wide-character API in the Win32 code in this file, too.
This commit is contained in:
parent
c52d217e07
commit
e4581869b4
16
ChangeLog
16
ChangeLog
@ -1,3 +1,19 @@
|
||||
2006-10-07 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
* gtk/gtkcalendar.c (gtk_calendar_init): Use the Win32 thread
|
||||
locale's first day of week setting on Win32. (#339752, Bogdan
|
||||
Nicula) Don't do this if one of the environment variables that
|
||||
affect gettext is set, though. In that case use the week start day
|
||||
from the corresponding message catalog.
|
||||
|
||||
Unfortunately the same logic isn't possible in the weekday and
|
||||
month name lookup; there even if you have set one of the
|
||||
aforementioned environment variables, you still get the weekday
|
||||
and month names from the Win32 thread locale. Yes, this is
|
||||
inconsistent.
|
||||
|
||||
Use only wide-character API in the Win32 code in this file, too.
|
||||
|
||||
2006-10-06 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkfilechooser.c (gtk_file_chooser_set_select_multiple):
|
||||
|
@ -560,10 +560,10 @@ gtk_calendar_init (GtkCalendar *calendar)
|
||||
time_t secs;
|
||||
struct tm *tm;
|
||||
gint i;
|
||||
char buffer[255];
|
||||
#ifdef G_OS_WIN32
|
||||
wchar_t wbuffer[100];
|
||||
#else
|
||||
char buffer[255];
|
||||
time_t tmp_time;
|
||||
#endif
|
||||
GtkCalendarPrivate *priv;
|
||||
@ -591,23 +591,11 @@ gtk_calendar_init (GtkCalendar *calendar)
|
||||
strftime ( buffer, sizeof (buffer), "%a", gmtime (&tmp_time));
|
||||
default_abbreviated_dayname[i] = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
|
||||
#else
|
||||
if (G_WIN32_HAVE_WIDECHAR_API ())
|
||||
{
|
||||
if (!GetLocaleInfoW (GetThreadLocale (), LOCALE_SABBREVDAYNAME1 + (i+6)%7,
|
||||
wbuffer, G_N_ELEMENTS (wbuffer)))
|
||||
default_abbreviated_dayname[i] = g_strdup_printf ("(%d)", i);
|
||||
else
|
||||
default_abbreviated_dayname[i] = g_utf16_to_utf8 (wbuffer, -1, NULL, NULL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!GetLocaleInfoA (GetThreadLocale (),
|
||||
(LOCALE_SABBREVDAYNAME1 + (i+6)%7) | LOCALE_USE_CP_ACP,
|
||||
buffer, G_N_ELEMENTS (buffer)))
|
||||
default_abbreviated_dayname[i] = g_strdup_printf ("(%d)", i);
|
||||
else
|
||||
default_abbreviated_dayname[i] = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -619,23 +607,11 @@ gtk_calendar_init (GtkCalendar *calendar)
|
||||
strftime ( buffer, sizeof (buffer), "%B", gmtime (&tmp_time));
|
||||
default_monthname[i] = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
|
||||
#else
|
||||
if (G_WIN32_HAVE_WIDECHAR_API ())
|
||||
{
|
||||
if (!GetLocaleInfoW (GetThreadLocale (), LOCALE_SMONTHNAME1 + i,
|
||||
wbuffer, G_N_ELEMENTS (wbuffer)))
|
||||
default_monthname[i] = g_strdup_printf ("(%d)", i);
|
||||
else
|
||||
default_monthname[i] = g_utf16_to_utf8 (wbuffer, -1, NULL, NULL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!GetLocaleInfoA (GetThreadLocale (),
|
||||
(LOCALE_SMONTHNAME1 + i) | LOCALE_USE_CP_ACP,
|
||||
buffer, G_N_ELEMENTS (buffer)))
|
||||
default_monthname[i] = g_strdup_printf ("(%d)", i);
|
||||
else
|
||||
default_monthname[i] = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -698,6 +674,32 @@ gtk_calendar_init (GtkCalendar *calendar)
|
||||
else if (strcmp (year_before, "calendar:MY") != 0)
|
||||
g_warning ("Whoever translated calendar:MY did so wrongly.\n");
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* Check if any of those environment variables that affect the
|
||||
* behaviour of gettext are set. If not, we use the thread's
|
||||
* locale's week start day.
|
||||
*/
|
||||
if (getenv ("LANGUAGE") == NULL &&
|
||||
getenv ("LC_ALL") == NULL &&
|
||||
getenv ("LC_MESSAGES") == NULL &&
|
||||
getenv ("LANG") == NULL)
|
||||
{
|
||||
priv->week_start = 0;
|
||||
week_start = NULL;
|
||||
|
||||
if (GetLocaleInfoW (GetThreadLocale (), LOCALE_IFIRSTDAYOFWEEK,
|
||||
wbuffer, G_N_ELEMENTS (wbuffer)))
|
||||
week_start = g_utf16_to_utf8 (wbuffer, -1, NULL, NULL, NULL);
|
||||
|
||||
if (week_start != NULL)
|
||||
{
|
||||
priv->week_start = (week_start[0] - '0' + 1) % 7;
|
||||
g_free(week_start);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
#ifdef HAVE__NL_TIME_FIRST_WEEKDAY
|
||||
langinfo = nl_langinfo (_NL_TIME_FIRST_WEEKDAY);
|
||||
first_weekday = langinfo[0];
|
||||
@ -729,6 +731,9 @@ gtk_calendar_init (GtkCalendar *calendar)
|
||||
priv->week_start = 0;
|
||||
}
|
||||
#endif
|
||||
#ifdef G_OS_WIN32
|
||||
}
|
||||
#endif
|
||||
|
||||
calendar_compute_days (calendar);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user