Gnome::Gtk4::Calendar
Description
Gnome::Gtk4::Calendar is a widget that displays a Gregorian calendar, one month at a time.
A Gnome::Gtk4::Calendar can be created with .newcalendar()
.
The date that is currently displayed can be altered with .select-day()
.
To place a visual marker on a particular day, use .mark-day()
and to remove the marker, .unmark-day()
. Alternative, all marks can be cleared with .clear-marks()
.
The selected date can be retrieved from a Gnome::Gtk4::Calendar using .get-date()
.
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.
CSS nodes
Gnome::Gtk4::Calendar 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.
Class initialization
new
:native-object
Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.
multi method new ( N-Object :$native-object! )
new-calendar
Creates a new calendar, with the current date being selected.
method new-calendar ( --> Gnome::Gtk4::Calendar \)
Methods
clear-marks
Remove all visual markers.
method clear-marks ( )
get-date
Returns a Gnome::Glib::N-DateTime representing the shown year, month and the selected day.
The returned date is in the local time zone.
method get-date (--> N-Object )
Return value; the Gnome::Glib::N-DateTime representing the shown date.
get-day
Gets the day of the selected date.
method get-day (--> Int )
Return value; the day of the selected date..
get-day-is-marked
Returns if the $day
of the $calendar
is already marked.
method get-day-is-marked ( UInt() $day --> Bool )
$day; the day number between 1 and 31..
Return value; whether the day is marked..
get-month
Gets the month of the selected date.
method get-month (--> Int )
Return value; The month of the selected date (as a number between 0 and 11)..
get-show-day-names
Returns whether $self
is currently showing the names of the week days.
This is the value of the show-day-names property.
method get-show-day-names (--> Bool )
Return value; Whether the calendar shows day names..
get-show-heading
Returns whether $self
is currently showing the heading.
This is the value of the show-heading property.
method get-show-heading (--> Bool )
Return value; Whether the calendar is showing a heading..
get-show-week-numbers
Returns whether $self
is showing week numbers right now.
This is the value of the show-week-numbers property.
method get-show-week-numbers (--> Bool )
Return value; Whether the calendar is showing week numbers..
get-year
Gets the year of the selected date.
method get-year (--> Int )
Return value; the year of the selected date..
mark-day
Places a visual marker on a particular day of the current month.
method mark-day ( UInt() $day )
$day; the day number to mark between 1 and 31..
select-day
Switches to $date
's year and month and select its day.
method select-day ( N-Object $date )
$date; a Gnome::Glib::N-DateTime representing the day to select
set-day
Sets the day for the selected date.
The new date must be valid. For example, setting 31 for the day when the month is February, fails.
method set-day ( Int() $day )
$day; The desired day for the selected date (as a number between 1 and 31)..
set-month
Sets the month for the selected date.
The new date must be valid. For example, setting 1 (February) for the month when the day is 31, fails.
method set-month ( Int() $month )
$month; The desired month for the selected date (as a number between 0 and 11)..
set-show-day-names
Sets whether the calendar shows day names.
method set-show-day-names ( Bool() $value )
$value; Whether to show day names above the day numbers.
set-show-heading
Sets whether the calendar should show a heading.
The heading contains the current year and month as well as buttons for changing both.
method set-show-heading ( Bool() $value )
$value; Whether to show the heading in the calendar.
set-show-week-numbers
Sets whether week numbers are shown in the calendar.
method set-show-week-numbers ( Bool() $value )
$value; whether to show week numbers on the left of the days.
set-year
Sets the year for the selected date.
The new date must be valid. For example, setting 2023 for the year when then the date is 2024-02-29, fails.
method set-year ( Int() $year )
$year; The desired year for the selected date (within DateTime limits, i.e. from 0001 to 9999)..
unmark-day
Removes the visual marker from a particular day.
method unmark-day ( UInt() $day )
$day; the day number to unmark between 1 and 31..
Signals
day-selected
Emitted when the user selects a day.
method handler ( Int :$_handle_id, N-GObject :$_native-object, Gnome::Gtk4::Calendar :$_widget, *C<user>-options )
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Calendar object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.
next-month
Emitted when the user switched to the next month.
method handler ( Int :$_handle_id, N-GObject :$_native-object, Gnome::Gtk4::Calendar :$_widget, *C<user>-options )
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Calendar object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.
next-year
Emitted when user switched to the next year.
method handler ( Int :$_handle_id, N-GObject :$_native-object, Gnome::Gtk4::Calendar :$_widget, *C<user>-options )
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Calendar object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.
prev-month
Emitted when the user switched to the previous month.
method handler ( Int :$_handle_id, N-GObject :$_native-object, Gnome::Gtk4::Calendar :$_widget, *C<user>-options )
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Calendar object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.
prev-year
Emitted when user switched to the previous year.
method handler ( Int :$_handle_id, N-GObject :$_native-object, Gnome::Gtk4::Calendar :$_widget, *C<user>-options )
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Calendar object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.