Another attempt to correct the calculations for the first week day. We may

2005-09-30  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkcalendar.c (gtk_calendar_init): Another attempt
	to correct the calculations for the first week day. We may
	just have to remove this code if too many locales turn out
	to have broken data.
This commit is contained in:
Matthias Clasen 2005-09-30 17:53:19 +00:00 committed by Matthias Clasen
parent 0d047a359d
commit c693b5d641
3 changed files with 22 additions and 8 deletions

View File

@ -1,5 +1,10 @@
2005-09-30 Matthias Clasen <mclasen@redhat.com> 2005-09-30 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcalendar.c (gtk_calendar_init): Another attempt
to correct the calculations for the first week day. We may
just have to remove this code if too many locales turn out
to have broken data.
* gtk/gtkimage.c (gtk_image_expose): Don't leak pixbuf in * gtk/gtkimage.c (gtk_image_expose): Don't leak pixbuf in
some cases. (#317611, Tommi Komulainen) some cases. (#317611, Tommi Komulainen)

View File

@ -1,5 +1,10 @@
2005-09-30 Matthias Clasen <mclasen@redhat.com> 2005-09-30 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcalendar.c (gtk_calendar_init): Another attempt
to correct the calculations for the first week day. We may
just have to remove this code if too many locales turn out
to have broken data.
* gtk/gtkimage.c (gtk_image_expose): Don't leak pixbuf in * gtk/gtkimage.c (gtk_image_expose): Don't leak pixbuf in
some cases. (#317611, Tommi Komulainen) some cases. (#317611, Tommi Komulainen)

View File

@ -565,7 +565,9 @@ gtk_calendar_init (GtkCalendar *calendar)
time_t tmp_time; time_t tmp_time;
GtkCalendarPrivate *priv; GtkCalendarPrivate *priv;
gchar *year_before; gchar *year_before;
gchar *week_start, week_startsub = 1; gchar *langinfo;
gint week_1stday = 0;
gint first_weekday = 1;
guint week_origin; guint week_origin;
priv = calendar->priv = G_TYPE_INSTANCE_GET_PRIVATE (calendar, priv = calendar->priv = G_TYPE_INSTANCE_GET_PRIVATE (calendar,
@ -652,16 +654,18 @@ gtk_calendar_init (GtkCalendar *calendar)
g_warning ("Whoever translated calendar:MY did so wrongly.\n"); g_warning ("Whoever translated calendar:MY did so wrongly.\n");
#ifdef HAVE__NL_TIME_FIRST_WEEKDAY #ifdef HAVE__NL_TIME_FIRST_WEEKDAY
week_start = nl_langinfo (_NL_TIME_FIRST_WEEKDAY); langinfo = nl_langinfo (_NL_TIME_FIRST_WEEKDAY);
week_origin = GPOINTER_TO_INT (nl_langinfo (_NL_TIME_WEEK_1STDAY)); first_weekday = langinfo[0];
if (week_origin == 19971130) langinfo = nl_langinfo (_NL_TIME_WEEK_1STDAY);
week_startsub = 0; week_origin = GPOINTER_TO_INT (langinfo);
else if (week_origin == 19971201) if (week_origin == 19971130) /* Sunday */
week_startsub = 1; week_1stday = 0;
else if (week_origin == 19971201) /* Monday */
week_1stday = 1;
else else
g_warning ("Unknown value of _NL_TIME_WEEK_1STDAY.\n"); g_warning ("Unknown value of _NL_TIME_WEEK_1STDAY.\n");
priv->week_start = (*((unsigned char *) week_start) - week_startsub) % 7; priv->week_start = (week_1stday + first_weekday - 1) % 7;
#else #else
/* Translate to calendar:week_start:0 if you want Sunday to be the /* Translate to calendar:week_start:0 if you want Sunday to be the
* first day of the week to calendar:week_start:1 if you want Monday * first day of the week to calendar:week_start:1 if you want Monday