Get the information about the first day of the week from the locale using

* gtk/gtkcalendar.c: Get the information about the first day of the week from
	the locale using another instance of the "magic translated string" technique.
	Ignore the display option GTK_CALENDAR_WEEK_START_MONDAY with a warning.  (#87977)
This commit is contained in:
Matthias Clasen
2003-08-08 22:44:14 +00:00
parent 40f0f447f7
commit 6e1e7d30fc
8 changed files with 60 additions and 84 deletions

View File

@ -6,7 +6,11 @@
* gtk/gtkcalendar.c: Complete the RTL flipping support for GtkCalendar, make it * gtk/gtkcalendar.c: Complete the RTL flipping support for GtkCalendar, make it
possible to flip the headings using the "magic translated string" technique. possible to flip the headings using the "magic translated string" technique.
Translators, note the comment in gtk_calendar_init() explaining this. Translators, note the comment in gtk_calendar_init() explaining this. (#102416)
* gtk/gtkcalendar.c: Get the information about the first day of the week from
the locale using another instance of the "magic translated string" technique.
Ignore the display option GTK_CALENDAR_WEEK_START_MONDAY with a warning. (#87977)
2003-08-08 Matthias Clasen <maclas@gmx.de> 2003-08-08 Matthias Clasen <maclas@gmx.de>

View File

@ -6,7 +6,11 @@
* gtk/gtkcalendar.c: Complete the RTL flipping support for GtkCalendar, make it * gtk/gtkcalendar.c: Complete the RTL flipping support for GtkCalendar, make it
possible to flip the headings using the "magic translated string" technique. possible to flip the headings using the "magic translated string" technique.
Translators, note the comment in gtk_calendar_init() explaining this. Translators, note the comment in gtk_calendar_init() explaining this. (#102416)
* gtk/gtkcalendar.c: Get the information about the first day of the week from
the locale using another instance of the "magic translated string" technique.
Ignore the display option GTK_CALENDAR_WEEK_START_MONDAY with a warning. (#87977)
2003-08-08 Matthias Clasen <maclas@gmx.de> 2003-08-08 Matthias Clasen <maclas@gmx.de>

View File

@ -6,7 +6,11 @@
* gtk/gtkcalendar.c: Complete the RTL flipping support for GtkCalendar, make it * gtk/gtkcalendar.c: Complete the RTL flipping support for GtkCalendar, make it
possible to flip the headings using the "magic translated string" technique. possible to flip the headings using the "magic translated string" technique.
Translators, note the comment in gtk_calendar_init() explaining this. Translators, note the comment in gtk_calendar_init() explaining this. (#102416)
* gtk/gtkcalendar.c: Get the information about the first day of the week from
the locale using another instance of the "magic translated string" technique.
Ignore the display option GTK_CALENDAR_WEEK_START_MONDAY with a warning. (#87977)
2003-08-08 Matthias Clasen <maclas@gmx.de> 2003-08-08 Matthias Clasen <maclas@gmx.de>

View File

@ -6,7 +6,11 @@
* gtk/gtkcalendar.c: Complete the RTL flipping support for GtkCalendar, make it * gtk/gtkcalendar.c: Complete the RTL flipping support for GtkCalendar, make it
possible to flip the headings using the "magic translated string" technique. possible to flip the headings using the "magic translated string" technique.
Translators, note the comment in gtk_calendar_init() explaining this. Translators, note the comment in gtk_calendar_init() explaining this. (#102416)
* gtk/gtkcalendar.c: Get the information about the first day of the week from
the locale using another instance of the "magic translated string" technique.
Ignore the display option GTK_CALENDAR_WEEK_START_MONDAY with a warning. (#87977)
2003-08-08 Matthias Clasen <maclas@gmx.de> 2003-08-08 Matthias Clasen <maclas@gmx.de>

View File

@ -6,7 +6,11 @@
* gtk/gtkcalendar.c: Complete the RTL flipping support for GtkCalendar, make it * gtk/gtkcalendar.c: Complete the RTL flipping support for GtkCalendar, make it
possible to flip the headings using the "magic translated string" technique. possible to flip the headings using the "magic translated string" technique.
Translators, note the comment in gtk_calendar_init() explaining this. Translators, note the comment in gtk_calendar_init() explaining this. (#102416)
* gtk/gtkcalendar.c: Get the information about the first day of the week from
the locale using another instance of the "magic translated string" technique.
Ignore the display option GTK_CALENDAR_WEEK_START_MONDAY with a warning. (#87977)
2003-08-08 Matthias Clasen <maclas@gmx.de> 2003-08-08 Matthias Clasen <maclas@gmx.de>

View File

@ -1,3 +1,7 @@
2003-08-09 Matthias Clasen <maclas@gmx.de>
* gtk/tmpl/gtkcalendar.sgml: Deprecate GTK_CALENDAR_WEEK_START_MONDAY. (#87977)
2003-08-03 Matthias Clasen <maclas@gmx.de> 2003-08-03 Matthias Clasen <maclas@gmx.de>
* gdk-pixbuf/tmpl/gdk-pixbuf.sgml: Clarify misleading explanation of rowstride. (#119000) * gdk-pixbuf/tmpl/gdk-pixbuf.sgml: Clarify misleading explanation of rowstride. (#119000)

View File

@ -67,40 +67,16 @@ are 0-11) while <structfield>selected_day</structfield> is one-based
<!-- ##### ENUM GtkCalendarDisplayOptions ##### --> <!-- ##### ENUM GtkCalendarDisplayOptions ##### -->
<para> <para>
<informaltable pgwide="1" frame="none" role="enum"> These options can be used to influence the display and behaviour of a #GtkCalendar.
<tgroup cols="2"><colspec colwidth="*"/><colspec colwidth="8*"/>
<tbody>
<row>
<entry>GTK_CALENDAR_SHOW_HEADING</entry>
<entry>Specifies that the month and year should be displayed.</entry>
</row>
<row>
<entry>GTK_CALENDAR_SHOW_DAY_NAMES</entry>
<entry>Specifies that three letter day descriptions should be present.</entry>
</row>
<row>
<entry>GTK_CALENDAR_NO_MONTH_CHANGE</entry>
<entry>Prevents the user from switching months with the calendar.</entry>
</row>
<row>
<entry>GTK_CALENDAR_SHOW_WEEK_NUMBERS</entry>
<entry>Displays each week numbers of the current year, down the left side of
the calendar.</entry>
</row>
<row>
<entry>GTK_CALENDAR_WEEK_START_MONDAY</entry>
<entry>Starts the calendar week on Monday, instead of the default Sunday.</entry>
</row>
</tbody></tgroup></informaltable>
</para> </para>
@GTK_CALENDAR_SHOW_HEADING: @GTK_CALENDAR_SHOW_HEADING: Specifies that the month and year should be displayed.
@GTK_CALENDAR_SHOW_DAY_NAMES: @GTK_CALENDAR_SHOW_DAY_NAMES: Specifies that three letter day descriptions should be present.
@GTK_CALENDAR_NO_MONTH_CHANGE: @GTK_CALENDAR_NO_MONTH_CHANGE: Prevents the user from switching months with the calendar.
@GTK_CALENDAR_SHOW_WEEK_NUMBERS: @GTK_CALENDAR_SHOW_WEEK_NUMBERS: Displays each week numbers of the current year, down the left side
@GTK_CALENDAR_WEEK_START_MONDAY: of the calendar.
@GTK_CALENDAR_WEEK_START_MONDAY: Since GTK+ 2.4, this option is deprecated and ignored by GTK+.
The information on which day the calendar week starts is derived from the locale.
<!-- ##### FUNCTION gtk_calendar_new ##### --> <!-- ##### FUNCTION gtk_calendar_new ##### -->
<para> <para>
@ -295,11 +271,6 @@ calendar.
</para> </para>
<!-- ##### ARG GtkCalendar:week-start-monday ##### -->
<para>
</para>
<!-- ##### ARG GtkCalendar:year ##### --> <!-- ##### ARG GtkCalendar:year ##### -->
<para> <para>

View File

@ -225,7 +225,6 @@ enum
PROP_SHOW_DAY_NAMES, PROP_SHOW_DAY_NAMES,
PROP_NO_MONTH_CHANGE, PROP_NO_MONTH_CHANGE,
PROP_SHOW_WEEK_NUMBERS, PROP_SHOW_WEEK_NUMBERS,
PROP_WEEK_START_MONDAY,
PROP_LAST PROP_LAST
}; };
@ -276,6 +275,8 @@ struct _GtkCalendarPrivateData
guint32 timer; guint32 timer;
gint click_child; gint click_child;
gint week_start;
}; };
#define GTK_CALENDAR_PRIVATE_DATA(widget) (((GtkCalendarPrivateData*)(GTK_CALENDAR (widget)->private_data))) #define GTK_CALENDAR_PRIVATE_DATA(widget) (((GtkCalendarPrivateData*)(GTK_CALENDAR (widget)->private_data)))
@ -499,22 +500,6 @@ gtk_calendar_class_init (GtkCalendarClass *class)
FALSE, FALSE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
/**
* GtkCalendar:week-start-monday:
*
* If this is %TRUE, Monday is displayed as the first day of the week.
*
* Since: 2.4
*/
g_object_class_install_property (gobject_class,
PROP_WEEK_START_MONDAY,
g_param_spec_boolean ("week_start_monday",
_("Week Start Monday"),
_("If TRUE, Monday is displayed as the first day of the week"),
FALSE,
G_PARAM_READWRITE));
gtk_calendar_signals[MONTH_CHANGED_SIGNAL] = gtk_calendar_signals[MONTH_CHANGED_SIGNAL] =
g_signal_new ("month_changed", g_signal_new ("month_changed",
G_OBJECT_CLASS_TYPE (gobject_class), G_OBJECT_CLASS_TYPE (gobject_class),
@ -584,6 +569,7 @@ gtk_calendar_init (GtkCalendar *calendar)
GtkWidget *widget; GtkWidget *widget;
GtkCalendarPrivateData *private_data; GtkCalendarPrivateData *private_data;
gchar *year_before; gchar *year_before;
gchar *week_start;
widget = GTK_WIDGET (calendar); widget = GTK_WIDGET (calendar);
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS); GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
@ -667,6 +653,19 @@ gtk_calendar_init (GtkCalendar *calendar)
private_data->year_before = 1; private_data->year_before = 1;
else if (strcmp (year_before, "calendar:MY") != 0) else if (strcmp (year_before, "calendar:MY") != 0)
g_warning ("Whoever translated calendar:MY did so wrongly.\n"); 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");
} }
GtkWidget* GtkWidget*
@ -1891,7 +1890,7 @@ gtk_calendar_paint_day_names (GtkWidget *widget)
day = 6 - i; day = 6 - i;
else else
day = i; day = i;
if (calendar->display_flags & GTK_CALENDAR_WEEK_START_MONDAY) if (private_data->week_start == 1)
day= (day+1)%7; day= (day+1)%7;
g_snprintf (buffer, sizeof (buffer), "%s", default_abbreviated_dayname[day]); g_snprintf (buffer, sizeof (buffer), "%s", default_abbreviated_dayname[day]);
@ -2196,6 +2195,7 @@ gtk_calendar_paint_main (GtkWidget *widget)
static void static void
gtk_calendar_compute_days (GtkCalendar *calendar) gtk_calendar_compute_days (GtkCalendar *calendar)
{ {
GtkCalendarPrivateData *private_data;
gint month; gint month;
gint year; gint year;
gint ndays_in_month; gint ndays_in_month;
@ -2207,6 +2207,8 @@ gtk_calendar_compute_days (GtkCalendar *calendar)
g_return_if_fail (GTK_IS_CALENDAR (calendar)); g_return_if_fail (GTK_IS_CALENDAR (calendar));
private_data = GTK_CALENDAR_PRIVATE_DATA (GTK_WIDGET (calendar));
year = calendar->year; year = calendar->year;
month = calendar->month + 1; month = calendar->month + 1;
@ -2214,7 +2216,7 @@ gtk_calendar_compute_days (GtkCalendar *calendar)
first_day = day_of_week (year, month, 1); first_day = day_of_week (year, month, 1);
if (calendar->display_flags & GTK_CALENDAR_WEEK_START_MONDAY) if (private_data->week_start == 1)
first_day--; first_day--;
else else
first_day %= 7; first_day %= 7;
@ -2407,17 +2409,7 @@ gtk_calendar_set_display_options (GtkCalendar *calendar,
} }
if ((flags ^ calendar->display_flags) & GTK_CALENDAR_WEEK_START_MONDAY) if ((flags ^ calendar->display_flags) & GTK_CALENDAR_WEEK_START_MONDAY)
{ g_warning ("GTK_CALENDAR_WEEK_START_MONDAY is ignored; the first day of the week is determined from the locale");
if (calendar->display_flags & GTK_CALENDAR_WEEK_START_MONDAY)
calendar->display_flags &= ~GTK_CALENDAR_WEEK_START_MONDAY;
else
calendar->display_flags |= GTK_CALENDAR_WEEK_START_MONDAY;
gtk_calendar_compute_days (calendar);
gtk_calendar_paint_main (GTK_WIDGET (calendar));
if (private_data->day_name_win)
gtk_calendar_paint_day_names (GTK_WIDGET (calendar));
}
calendar->display_flags = flags; calendar->display_flags = flags;
if (resize) if (resize)
@ -2436,8 +2428,6 @@ gtk_calendar_set_display_options (GtkCalendar *calendar,
g_object_notify (G_OBJECT (calendar), "no_month_change"); g_object_notify (G_OBJECT (calendar), "no_month_change");
if ((old_flags ^ calendar->display_flags) & GTK_CALENDAR_SHOW_WEEK_NUMBERS) if ((old_flags ^ calendar->display_flags) & GTK_CALENDAR_SHOW_WEEK_NUMBERS)
g_object_notify (G_OBJECT (calendar), "show_week_numbers"); g_object_notify (G_OBJECT (calendar), "show_week_numbers");
if ((old_flags ^ calendar->display_flags) & GTK_CALENDAR_WEEK_START_MONDAY)
g_object_notify (G_OBJECT (calendar), "week_start_monday");
g_object_thaw_notify (G_OBJECT (calendar)); g_object_thaw_notify (G_OBJECT (calendar));
} }
@ -3248,11 +3238,6 @@ gtk_calendar_set_property (GObject *object,
GTK_CALENDAR_SHOW_WEEK_NUMBERS, GTK_CALENDAR_SHOW_WEEK_NUMBERS,
g_value_get_boolean (value)); g_value_get_boolean (value));
break; break;
case PROP_WEEK_START_MONDAY:
gtk_calendar_set_display_option (calendar,
GTK_CALENDAR_WEEK_START_MONDAY,
g_value_get_boolean (value));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -3296,10 +3281,6 @@ gtk_calendar_get_property (GObject *object,
g_value_set_boolean (value, gtk_calendar_get_display_option (calendar, g_value_set_boolean (value, gtk_calendar_get_display_option (calendar,
GTK_CALENDAR_SHOW_WEEK_NUMBERS)); GTK_CALENDAR_SHOW_WEEK_NUMBERS));
break; break;
case PROP_WEEK_START_MONDAY:
g_value_set_boolean (value, gtk_calendar_get_display_option (calendar,
GTK_CALENDAR_WEEK_START_MONDAY));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;