mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 05:31:07 +00:00
GtkCalendar: Disable navigation buttons for out of range months
`GtkCalendar`s span 0001-01/9999-12.
This commit is contained in:
parent
6c9edbf0da
commit
ca9664cdfd
@ -1044,6 +1044,29 @@ calendar_update_day_labels (GtkCalendar *calendar)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
calendar_update_navigation_buttons (GtkCalendar *calendar)
|
||||
{
|
||||
int year, month;
|
||||
g_date_time_get_ymd (calendar->date, &year, &month, NULL);
|
||||
for (int i = 0; i < 4; i++)
|
||||
gtk_widget_set_sensitive (calendar->arrow_widgets[i], TRUE);
|
||||
if (year == YEAR_MIN)
|
||||
{
|
||||
/* Cannot go back */
|
||||
gtk_widget_set_sensitive (calendar->arrow_widgets[2], FALSE);
|
||||
if (month == G_DATE_JANUARY)
|
||||
gtk_widget_set_sensitive (calendar->arrow_widgets[0], FALSE);
|
||||
}
|
||||
else if (year == YEAR_MAX)
|
||||
{
|
||||
/* Cannot move forward */
|
||||
gtk_widget_set_sensitive (calendar->arrow_widgets[3], FALSE);
|
||||
if (month == G_DATE_DECEMBER)
|
||||
gtk_widget_set_sensitive (calendar->arrow_widgets[1], FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
calendar_select_day_internal (GtkCalendar *calendar,
|
||||
GDateTime *date,
|
||||
@ -1091,6 +1114,8 @@ calendar_select_day_internal (GtkCalendar *calendar,
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (calendar->month_name_stack),
|
||||
default_monthname[new_month - 1]);
|
||||
|
||||
calendar_update_navigation_buttons (calendar);
|
||||
|
||||
calendar_update_day_labels (calendar);
|
||||
|
||||
/* Update week number labels.
|
||||
|
Loading…
Reference in New Issue
Block a user