CalendarProtocol
public protocol CalendarProtocol : WidgetProtocol
GtkCalendar
is a widget that displays a Gregorian calendar, one month
at a time.
A GtkCalendar
can be created with [ctorGtk.Calendar.new
].
The date that is currently displayed can be altered with
[methodGtk.Calendar.select_day
].
To place a visual marker on a particular day, use
[methodGtk.Calendar.mark_day
] and to remove the marker,
[methodGtk.Calendar.unmark_day
]. Alternative, all
marks can be cleared with [methodGtk.Calendar.clear_marks
].
The selected date can be retrieved from a GtkCalendar
using
[methodGtk.Calendar.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
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.
The CalendarProtocol
protocol exposes the methods and properties of an underlying GtkCalendar
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see Calendar
.
Alternatively, use CalendarRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkCalendar
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
calendar_ptr
Default implementationTyped pointer to the underlying
GtkCalendar
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkCalendar
instance.Declaration
Swift
var calendar_ptr: UnsafeMutablePointer<GtkCalendar>! { get }
-
Required Initialiser for types conforming to
CalendarProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
CalendarPropertyName
source property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: CalendarPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol
Parameters
source_property
the source property to bind
target
the target object to bind to
target_property
the target property to bind to
flags
the flags to pass to the
Binding
transform_from
ValueTransformer
to use for forward transformationtransform_to
ValueTransformer
to use for backwards transformationReturn Value
binding reference or
nil
in case of an error -
get(property:
Extension method) Get the value of a Calendar property
Declaration
Swift
@inlinable func get(property: CalendarPropertyName) -> GLibObject.Value
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
set(property:
Extension methodvalue: ) Set the value of a Calendar property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: CalendarPropertyName, value v: GLibObject.Value)
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
connect(signal:
Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
CalendarSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: CalendarSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
handler
The Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:
Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
CalendarSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: CalendarSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
signalHandler
The C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onDaySelected(flags:
Extension methodhandler: ) Emitted when the user selects a day.
Note
This represents the underlyingday-selected
signalDeclaration
Swift
@discardableResult @inlinable func onDaySelected(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CalendarRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
handler
The signal handler to call Run the given callback whenever the
daySelected
signal is emitted -
daySelectedSignal
Extension methodTyped
day-selected
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var daySelectedSignal: CalendarSignalName { get }
-
onNextMonth(flags:
Extension methodhandler: ) Emitted when the user switched to the next month.
Note
This represents the underlyingnext-month
signalDeclaration
Swift
@discardableResult @inlinable func onNextMonth(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CalendarRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
handler
The signal handler to call Run the given callback whenever the
nextMonth
signal is emitted -
nextMonthSignal
Extension methodTyped
next-month
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var nextMonthSignal: CalendarSignalName { get }
-
onNextYear(flags:
Extension methodhandler: ) Emitted when user switched to the next year.
Note
This represents the underlyingnext-year
signalDeclaration
Swift
@discardableResult @inlinable func onNextYear(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CalendarRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
handler
The signal handler to call Run the given callback whenever the
nextYear
signal is emitted -
nextYearSignal
Extension methodTyped
next-year
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var nextYearSignal: CalendarSignalName { get }
-
onPrevMonth(flags:
Extension methodhandler: ) Emitted when the user switched to the previous month.
Note
This represents the underlyingprev-month
signalDeclaration
Swift
@discardableResult @inlinable func onPrevMonth(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CalendarRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
handler
The signal handler to call Run the given callback whenever the
prevMonth
signal is emitted -
prevMonthSignal
Extension methodTyped
prev-month
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var prevMonthSignal: CalendarSignalName { get }
-
onPrevYear(flags:
Extension methodhandler: ) Emitted when user switched to the previous year.
Note
This represents the underlyingprev-year
signalDeclaration
Swift
@discardableResult @inlinable func onPrevYear(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CalendarRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
handler
The signal handler to call Run the given callback whenever the
prevYear
signal is emitted -
prevYearSignal
Extension methodTyped
prev-year
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var prevYearSignal: CalendarSignalName { get }
-
onNotifyDay(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::day
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyDay(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CalendarRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyDay
signal is emitted -
notifyDaySignal
Extension methodTyped
notify::day
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyDaySignal: CalendarSignalName { get }
-
onNotifyMonth(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::month
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyMonth(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CalendarRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyMonth
signal is emitted -
notifyMonthSignal
Extension methodTyped
notify::month
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyMonthSignal: CalendarSignalName { get }
-
onNotifyShowDayNames(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::show-day-names
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyShowDayNames(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CalendarRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyShowDayNames
signal is emitted -
notifyShowDayNamesSignal
Extension methodTyped
notify::show-day-names
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyShowDayNamesSignal: CalendarSignalName { get }
-
onNotifyShowHeading(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::show-heading
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyShowHeading(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CalendarRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyShowHeading
signal is emitted -
notifyShowHeadingSignal
Extension methodTyped
notify::show-heading
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyShowHeadingSignal: CalendarSignalName { get }
-
onNotifyShowWeekNumbers(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::show-week-numbers
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyShowWeekNumbers(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CalendarRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyShowWeekNumbers
signal is emitted -
notifyShowWeekNumbersSignal
Extension methodTyped
notify::show-week-numbers
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyShowWeekNumbersSignal: CalendarSignalName { get }
-
onNotifyYear(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::year
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyYear(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CalendarRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyYear
signal is emitted -
notifyYearSignal
Extension methodTyped
notify::year
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyYearSignal: CalendarSignalName { get }
-
clearMarks()
Extension methodRemove all visual markers.
Declaration
Swift
@inlinable func clearMarks()
-
getDate()
Extension methodReturns a
GDateTime
representing the shown year, month and the selected day.The returned date is in the local time zone.
Declaration
Swift
@inlinable func getDate() -> GLib.DateTimeRef!
-
getDayIsMarked(day:
Extension method) Returns if the
day
of thecalendar
is already marked.Declaration
Swift
@inlinable func getDayIsMarked(day: Int) -> Bool
-
getShowDayNames()
Extension methodReturns whether
self
is currently showing the names of the week days.This is the value of the [property
Gtk.Calendar:show-day-names
] property.Declaration
Swift
@inlinable func getShowDayNames() -> Bool
-
getShowHeading()
Extension methodReturns whether
self
is currently showing the heading.This is the value of the [property
Gtk.Calendar:show-heading
] property.Declaration
Swift
@inlinable func getShowHeading() -> Bool
-
getShowWeekNumbers()
Extension methodReturns whether
self
is showing week numbers right now.This is the value of the [property
Gtk.Calendar:show-week-numbers
] property.Declaration
Swift
@inlinable func getShowWeekNumbers() -> Bool
-
mark(day:
Extension method) Places a visual marker on a particular day.
Declaration
Swift
@inlinable func mark(day: Int)
-
selectDay(date:
Extension method) Switches to
date
‘s year and month and select its day.Declaration
Swift
@inlinable func selectDay<DateTimeT>(date: DateTimeT) where DateTimeT : DateTimeProtocol
-
setShowDayNames(value:
Extension method) Sets whether the calendar shows day names.
Declaration
Swift
@inlinable func setShowDayNames(value: Bool)
-
setShowHeading(value:
Extension method) Sets whether the calendar should show a heading.
The heading contains the current year and month as well as buttons for changing both.
Declaration
Swift
@inlinable func setShowHeading(value: Bool)
-
setShowWeekNumbers(value:
Extension method) Sets whether week numbers are shown in the calendar.
Declaration
Swift
@inlinable func setShowWeekNumbers(value: Bool)
-
unmark(day:
Extension method) Removes the visual marker from a particular day.
Declaration
Swift
@inlinable func unmark(day: Int)
-
date
Extension methodReturns a
GDateTime
representing the shown year, month and the selected day.The returned date is in the local time zone.
Declaration
Swift
@inlinable var date: GLib.DateTimeRef! { get }
-
showDayNames
Extension methodReturns whether
self
is currently showing the names of the week days.This is the value of the [property
Gtk.Calendar:show-day-names
] property.Declaration
Swift
@inlinable var showDayNames: Bool { get nonmutating set }
-
showHeading
Extension methodReturns whether
self
is currently showing the heading.This is the value of the [property
Gtk.Calendar:show-heading
] property.Declaration
Swift
@inlinable var showHeading: Bool { get nonmutating set }
-
showWeekNumbers
Extension methodReturns whether
self
is showing week numbers right now.This is the value of the [property
Gtk.Calendar:show-week-numbers
] property.Declaration
Swift
@inlinable var showWeekNumbers: Bool { get nonmutating set }