GtkCalendar — Displays a calendar and allows the user to select a date
GtkWidget * | gtk_calendar_new () |
void | gtk_calendar_select_day () |
void | gtk_calendar_mark_day () |
void | gtk_calendar_unmark_day () |
gboolean | gtk_calendar_get_day_is_marked () |
void | gtk_calendar_clear_marks () |
gboolean | gtk_calendar_get_show_day_names () |
void | gtk_calendar_set_show_day_names () |
gboolean | gtk_calendar_get_show_heading () |
void | gtk_calendar_set_show_heading () |
gboolean | gtk_calendar_get_show_week_numbers () |
void | gtk_calendar_set_show_week_numbers () |
GDateTime * | gtk_calendar_get_date () |
int | day | Read / Write |
int | month | Read / Write |
gboolean | show-day-names | Read / Write |
gboolean | show-heading | Read / Write |
gboolean | show-week-numbers | Read / Write |
int | year | Read / Write |
void | day-selected | Run First |
void | next-month | Run First |
void | next-year | Run First |
void | prev-month | Run First |
void | prev-year | Run First |
GObject ╰── GInitiallyUnowned ╰── GtkWidget ╰── GtkCalendar
GtkCalendar implements GtkAccessible, GtkBuildable and GtkConstraintTarget.
#include <gtk/gtk.h>
GtkCalendar is a widget that displays a Gregorian calendar, one month at a time. It can be created with gtk_calendar_new()
.
The date that is currently displayed can be altered with gtk_calendar_select_day()
.
To place a visual marker on a particular day, use gtk_calendar_mark_day()
and to remove the marker, gtk_calendar_unmark_day()
. Alternative, all marks can be cleared with gtk_calendar_clear_marks()
.
The selected date can be retrieved from a GtkCalendar using gtk_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.
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.
GtkWidget *
gtk_calendar_new (void
);
Creates a new calendar, with the current date being selected.
a newly GtkCalendar widget
void gtk_calendar_select_day (GtkCalendar *self
,GDateTime *date
);
Will switch to date
's year and month and select its day.
self | a GtkCalendar. | |
date | a GDateTime representing the day to select. | [transfer none] |
void gtk_calendar_mark_day (GtkCalendar *calendar
,guint day
);
Places a visual marker on a particular day.
calendar | ||
day | the day number to mark between 1 and 31. |
void gtk_calendar_unmark_day (GtkCalendar *calendar
,guint day
);
Removes the visual marker from a particular day.
calendar | a GtkCalendar. | |
day | the day number to unmark between 1 and 31. |
gboolean gtk_calendar_get_day_is_marked (GtkCalendar *calendar
,guint day
);
Returns if the day
of the calendar
is already marked.
calendar | ||
day | the day number between 1 and 31. |
whether the day is marked.
void
gtk_calendar_clear_marks (GtkCalendar *calendar
);
Remove all visual markers.
calendar |
gboolean
gtk_calendar_get_show_day_names (GtkCalendar *self
);
Returns whether self
is currently showing the names of the week days above the day numbers, i.e. the value of the “show-day-names” property.
self |
Whether the calendar shows day names.
void gtk_calendar_set_show_day_names (GtkCalendar *self
,gboolean value
);
Sets whether the calendar shows day names.
self | ||
value | Whether to show day names above the day numbers |
gboolean
gtk_calendar_get_show_heading (GtkCalendar *self
);
Returns whether self
is currently showing the heading, i.e. the value of the “show-heading” property.
Return: Whether the calendar is showing a heading.
self |
void gtk_calendar_set_show_heading (GtkCalendar *self
,gboolean value
);
Sets whether the calendar should show a heading containing the current year and month as well as buttons for changing both.
self | ||
value | Whether to show the heading in the calendar |
gboolean
gtk_calendar_get_show_week_numbers (GtkCalendar *self
);
Returns whether self
is showing week numbers right now, i.e. the value of the “show-week-numbers” property.
Return: Whether the calendar is showing week numbers.
self |
void gtk_calendar_set_show_week_numbers (GtkCalendar *self
,gboolean value
);
Sets whether week numbers are shown in the calendar.
self | ||
value | whether to show week numbers on the left of the days |
GDateTime *
gtk_calendar_get_date (GtkCalendar *self
);
Returns a GDateTime representing the shown year, month and the selected day, in the local time zone.
self |
the GDate representing the shown date.
[transfer full]
typedef struct _GtkCalendar GtkCalendar;
“day”
property“day” int
The selected day (as a number between 1 and 31, or 0 to unselect the currently selected day). This property gets initially set to the current day.
Owner: GtkCalendar
Flags: Read / Write
Allowed values: [0,31]
Default value: 0
“month”
property“month” int
The selected month (as a number between 0 and 11). This property gets initially set to the current month.
Owner: GtkCalendar
Flags: Read / Write
Allowed values: [0,11]
Default value: 0
“show-day-names”
property“show-day-names” gboolean
Determines whether day names are displayed.
Owner: GtkCalendar
Flags: Read / Write
Default value: TRUE
“show-heading”
property“show-heading” gboolean
Determines whether a heading is displayed.
Owner: GtkCalendar
Flags: Read / Write
Default value: TRUE
“show-week-numbers”
property“show-week-numbers” gboolean
Determines whether week numbers are displayed.
Owner: GtkCalendar
Flags: Read / Write
Default value: FALSE
“year”
property“year” int
The selected year. This property gets initially set to the current year.
Owner: GtkCalendar
Flags: Read / Write
Allowed values: [1,9999]
Default value: 1
“day-selected”
signalvoid user_function (GtkCalendar *calendar, gpointer user_data)
Emitted when the user selects a day.
calendar | the object which received the signal. | |
user_data | user data set when the signal handler was connected. |
Flags: Run First
“next-month”
signalvoid user_function (GtkCalendar *calendar, gpointer user_data)
Emitted when the user switched to the next month.
calendar | the object which received the signal. | |
user_data | user data set when the signal handler was connected. |
Flags: Run First
“next-year”
signalvoid user_function (GtkCalendar *calendar, gpointer user_data)
Emitted when user switched to the next year.
calendar | the object which received the signal. | |
user_data | user data set when the signal handler was connected. |
Flags: Run First
“prev-month”
signalvoid user_function (GtkCalendar *calendar, gpointer user_data)
Emitted when the user switched to the previous month.
calendar | the object which received the signal. | |
user_data | user data set when the signal handler was connected. |
Flags: Run First
“prev-year”
signalvoid user_function (GtkCalendar *calendar, gpointer user_data)
Emitted when user switched to the previous year.
calendar | the object which received the signal. | |
user_data | user data set when the signal handler was connected. |
Flags: Run First
© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/GtkCalendar.html