summaryrefslogtreecommitdiff
path: root/gtk/gtkcalendar.c
diff options
context:
space:
mode:
authorMatthias Clasen <maclas@gmx.de>2004-01-02 01:52:04 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2004-01-02 01:52:04 +0000
commit194c2550f669215a16abd63a5b3e2472194a23c6 (patch)
treef15da08a3c589447292cd984c46c6b3158645dfc /gtk/gtkcalendar.c
parentdfcf1818c71e340aee59787f25b1fe3b86dc7a55 (diff)
downloadgdk-pixbuf-194c2550f669215a16abd63a5b3e2472194a23c6.tar.gz
Changes to support week_start values other than 0 and 1, e.g. 6 will let
Fri Jan 2 02:50:11 2004 Matthias Clasen <maclas@gmx.de> * gtk/gtkcalendar.c (gtk_calendar_compute_days): * gtk/gtkcalendar.c (gtk_calendar_paint_day_names): * gtk/gtkcalendar.c (gtk_calendar_init): Changes to support week_start values other than 0 and 1, e.g. 6 will let weeks start on Saturday. (#130353, Roozbeh Pournader)
Diffstat (limited to 'gtk/gtkcalendar.c')
-rw-r--r--gtk/gtkcalendar.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c
index 2a117759b..dd889efc6 100644
--- a/gtk/gtkcalendar.c
+++ b/gtk/gtkcalendar.c
@@ -712,18 +712,22 @@ gtk_calendar_init (GtkCalendar *calendar)
else if (strcmp (year_before, "calendar:MY") != 0)
g_warning ("Whoever translated calendar:MY did so wrongly.\n");
- /* Translate to calendar:week_start:1 if you want Monday to be the
- * first day of the week; otherwise translate to calendar:week_start:0.
- * Do *not* translate it to anything else, if it isn't calendar:week_start:1
- * or calendar:week_start:0 it will not work.
- */
- week_start = _("calendar:week_start:0");
- if (strcmp (week_start, "calendar:week_start:1") == 0)
- private_data->week_start = 1;
- else if (strcmp (week_start, "calendar:week_start:0") == 0)
- private_data->week_start = 0;
- else
- g_warning ("Whoever translated calendar:week_start:0 did so wrongly.\n");
+ /* 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
+ * to be the first day of the week, and so on.
+ */
+ week_start = _("calendar:week_start:0");
+
+ if (strncmp (week_start, "calendar:week_start:", 20) == 0)
+ private_data->week_start = *(week_start + 20) - '0';
+ else
+ private_data->week_start = -1;
+
+ if (private_data->week_start < 0 || private_data->week_start > 6)
+ {
+ g_warning ("Whoever translated calendar:week_start:0 did so wrongly.\n");
+ private_data->week_start = 0;
+ }
}
GtkWidget*
@@ -1915,8 +1919,7 @@ gtk_calendar_paint_day_names (GtkWidget *widget)
day = 6 - i;
else
day = i;
- if (private_data->week_start == 1)
- day= (day+1)%7;
+ day = (day + private_data->week_start) % 7;
g_snprintf (buffer, sizeof (buffer), "%s", default_abbreviated_dayname[day]);
pango_layout_set_text (layout, buffer, -1);
@@ -2229,7 +2232,7 @@ gtk_calendar_compute_days (GtkCalendar *calendar)
gint row;
gint col;
gint day;
-
+
g_return_if_fail (GTK_IS_CALENDAR (calendar));
private_data = GTK_CALENDAR_PRIVATE_DATA (GTK_WIDGET (calendar));
@@ -2240,12 +2243,7 @@ gtk_calendar_compute_days (GtkCalendar *calendar)
ndays_in_month = month_length[leap (year)][month];
first_day = day_of_week (year, month, 1);
-
- if (private_data->week_start == 1)
- first_day--;
- else
- first_day %= 7;
-
+ first_day = (first_day + 7 - private_data->week_start) % 7;
/* Compute days of previous month */
if (month > 1)