1.23 <GtkCalendar>

Class: <GtkCalendar>

It derives from <GtkWidget>.

Displays a Gregorian calendar, one month at a time.

A <GtkCalendar> can be created with calendar:new.

The selected date can be retrieved from a <GtkCalendar> using calendar:get-date. It can be altered with calendar:set-date.

To place a visual marker on a particular day, use calendar:mark-day and to remove the marker, calendar:unmark-day. Alternative, all marks can be cleared with calendar:clear-marks.

Users should be aware that, although the Gregorian calendar is the legal calendar in most countries, it was adopted progressively between 1582 and 1929. Display before these dates is likely to be historically incorrect.

Shortcuts and Gestures

<GtkCalendar> supports the following gestures:

  • Scrolling up or down will switch to the previous or next month.
  • Date strings can be dropped for setting the current day.

CSS nodes

calendar.view
├── header
│   ├── button
│   ├── stack.month
│   ├── button
│   ├── button
│   ├── label.year
│   ╰── button
╰── grid
    ╰── label[.day-name][.week-number][.day-number][.other-month][.today]

<GtkCalendar> has a main node with name calendar. It contains a subnode called header containing the widgets for switching between years and months.

The grid subnode contains all day labels, including week numbers on the left (marked with the .week-number css class) and day names on top (marked with the .day-name css class).

Day labels that belong to the previous or next month get the .other-month style class. The label of the current day get the .today style class.

Marked day labels get the :selected state assigned.

Properties

Property: calendar:date self

The selected date.

This property gets initially set to the current date.

Its value is a <GDateTime>, or #f.

Set it with (set! (calendar:date self) value).

Property: calendar:day self

The selected day (as a number between 1 and 31).

Its value is a 32-bit integer.

Set it with (set! (calendar:day self) value).

Property: calendar:month self

The selected month (as a number between 0 and 11).

This property gets initially set to the current month.

Its value is a 32-bit integer.

Set it with (set! (calendar:month self) value).

Property: calendar:show-day-names self

Determines whether day names are displayed.

Its value is a boolean.

Set it with (set! (calendar:show-day-names self) value).

Property: calendar:show-heading self

Determines whether a heading is displayed.

Its value is a boolean.

Set it with (set! (calendar:show-heading self) value).

Property: calendar:show-week-numbers self

Determines whether week numbers are displayed.

Its value is a boolean.

Set it with (set! (calendar:show-week-numbers self) value).

Property: calendar:year self

The selected year.

This property gets initially set to the current year.

Its value is a 32-bit integer.

Set it with (set! (calendar:year self) value).

Procedures

Method: calendar:clear-marks self
Method: clear-marks self

Remove all visual markers.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

Method: calendar:get-date self ⇒ %return
Method: get-date self ⇒ %return

Returns a <GDateTime> representing the shown year, month and the selected day.

The returned date is in the local time zone.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

%return

Returned: a <GDateTime>.

the <GDateTime> representing the selected date

Method: calendar:get-day self ⇒ %return
Method: get-day self ⇒ %return

Gets the day of the selected date.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

%return

Returned: a 32-bit integer.

the day of the selected date.

Method: calendar:get-day-is-marked? self day ⇒ %return
Method: get-day-is-marked? self day ⇒ %return

Returns if the day of the self is already marked.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

day

Passed: an unsigned 32-bit integer.

the day number between 1 and 31.

%return

Returned: a boolean.

whether the day is marked.

Method: calendar:get-month self ⇒ %return
Method: get-month self ⇒ %return

Gets the month of the selected date.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

%return

Returned: a 32-bit integer.

The month of the selected date (as a number between 0 and 11).

Method: calendar:get-show-day-names? self ⇒ %return
Method: get-show-day-names? self ⇒ %return

Returns whether self is currently showing the names of the week days.

This is the value of the calendar:show-day-names property.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

%return

Returned: a boolean.

Whether the calendar shows day names.

Method: calendar:get-show-heading? self ⇒ %return
Method: get-show-heading? self ⇒ %return

Returns whether self is currently showing the heading.

This is the value of the calendar:show-heading property.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

%return

Returned: a boolean.

Whether the calendar is showing a heading.

Method: calendar:get-show-week-numbers? self ⇒ %return
Method: get-show-week-numbers? self ⇒ %return

Returns whether self is showing week numbers right now.

This is the value of the calendar:show-week-numbers property.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

%return

Returned: a boolean.

Whether the calendar is showing week numbers.

Method: calendar:get-year self ⇒ %return
Method: get-year self ⇒ %return

Gets the year of the selected date.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

%return

Returned: a 32-bit integer.

the year of the selected date.

Method: calendar:mark-day self day
Method: mark-day self day

Places a visual marker on a particular day of the current month.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

day

Passed: an unsigned 32-bit integer.

the day number to mark between 1 and 31.

Procedure: calendar:new ⇒ %return

Creates a new calendar, with the current date being selected.

%return

Returned: a <GtkWidget>.

a newly <GtkCalendar> widget

Method: calendar:select-day self date
Method: select-day self date

Switches to date’s year and month and select its day.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>.

date

Passed: a <GDateTime>.

a <GDateTime> representing the day to select

Method: calendar:set-date self date
Method: set-date self date

Switches to date’s year and month and selects its day.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>.

date

Passed: a <GDateTime>.

a <GDateTime> representing the day to select

Method: calendar:set-day self day
Method: set-day self day

Sets the day for the selected date.

The new date must be valid. For example, setting the day to 31 when the month is February will fail.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

day

Passed: a 32-bit integer.

The desired day for the selected date (as a number between 1 and 31).

Method: calendar:set-month self month
Method: set-month self month

Sets the month for the selected date.

The new date must be valid. For example, setting the month to 1 (February) when the day is 31 will fail.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

month

Passed: a 32-bit integer.

The desired month for the selected date (as a number between 0 and 11).

Method: calendar:set-show-day-names self value
Method: set-show-day-names self value

Sets whether the calendar shows day names.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

value

Passed: a boolean.

Whether to show day names above the day numbers

Method: calendar:set-show-heading self value
Method: set-show-heading self value

Sets whether the calendar should show a heading.

The heading contains the current year and month as well as buttons for changing both.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

value

Passed: a boolean.

Whether to show the heading in the calendar

Method: calendar:set-show-week-numbers self value
Method: set-show-week-numbers self value

Sets whether week numbers are shown in the calendar.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

value

Passed: a boolean.

whether to show week numbers alongside the days

Method: calendar:set-year self year
Method: set-year self year

Sets the year for the selected date.

The new date must be valid. For example, setting the year to 2023 when the date is February 29 will fail.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>

year

Passed: a 32-bit integer.

The desired year for the selected date (within <GDateTime> limits, i.e. from 0001 to 9999).

Method: calendar:unmark-day self day
Method: unmark-day self day

Removes the visual marker from a particular day.

self

Passed: a <GtkCalendar>.

a <GtkCalendar>.

day

Passed: an unsigned 32-bit integer.

the day number to unmark between 1 and 31.

Signals

Signal: calendar:day-selected

Connect a handler with (connect object calendar:day-selected handler). It is called as (handler self).

Emitted when the user selects a day.

self

Passed: a <GtkCalendar>.

Signal: calendar:next-month

Connect a handler with (connect object calendar:next-month handler). It is called as (handler self).

Emitted when the user switches to the next month.

self

Passed: a <GtkCalendar>.

Signal: calendar:next-year

Connect a handler with (connect object calendar:next-year handler). It is called as (handler self).

Emitted when user switches to the next year.

self

Passed: a <GtkCalendar>.

Signal: calendar:prev-month

Connect a handler with (connect object calendar:prev-month handler). It is called as (handler self).

Emitted when the user switches to the previous month.

self

Passed: a <GtkCalendar>.

Signal: calendar:prev-year

Connect a handler with (connect object calendar:prev-year handler). It is called as (handler self).

Emitted when user switches to the previous year.

self

Passed: a <GtkCalendar>.