summaryrefslogtreecommitdiff
path: root/gtk/gtkcalendar.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2014-12-23 21:49:21 -0500
committerMatthias Clasen <mclasen@redhat.com>2014-12-23 21:49:21 -0500
commitd216d89d6f1328d06396b8a4fe1fb42baf3e666c (patch)
treed1a3fe3f7e40ccd56b04dac43c473216d280b034 /gtk/gtkcalendar.c
parent7b9065c2eea5332ec69285ccdc52106a27e25111 (diff)
downloadgtk+-d216d89d6f1328d06396b8a4fe1fb42baf3e666c.tar.gz
GtkCalendar: Slightly change overflow behaviour
If the first of the month was falling on a Sunday, we would not render any days of the previous month, and instead show two weeks of the next month at the bottom. Improve this by showing one week of each. https://bugzilla.gnome.org/show_bug.cgi?id=301835
Diffstat (limited to 'gtk/gtkcalendar.c')
-rw-r--r--gtk/gtkcalendar.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c
index a3a4d8554f..3985a7d42e 100644
--- a/gtk/gtkcalendar.c
+++ b/gtk/gtkcalendar.c
@@ -983,27 +983,26 @@ calendar_compute_days (GtkCalendar *calendar)
first_day = day_of_week (year, month, 1);
first_day = (first_day + 7 - priv->week_start) % 7;
+ if (first_day == 0)
+ first_day = 7;
/* Compute days of previous month */
if (month > 1)
ndays_in_prev_month = month_length[leap (year)][month - 1];
else
ndays_in_prev_month = month_length[leap (year - 1)][12];
- day = ndays_in_prev_month - first_day + 1;
+ day = ndays_in_prev_month - first_day+ 1;
- row = 0;
- if (first_day > 0)
+ for (col = 0; col < first_day; col++)
{
- for (col = 0; col < first_day; col++)
- {
- priv->day[row][col] = day;
- priv->day_month[row][col] = MONTH_PREV;
- day++;
- }
+ priv->day[0][col] = day;
+ priv->day_month[0][col] = MONTH_PREV;
+ day++;
}
/* Compute days of current month */
- col = first_day;
+ row = first_day / 7;
+ col = first_day % 7;
for (day = 1; day <= ndays_in_month; day++)
{
priv->day[row][col] = day;