GtkCalendar

GtkCalendar — Displays a calendar and allows the user to select a date

Functions

Properties

gint day Read
gint month Read
gboolean show-day-names Read / Write
gboolean show-heading Read / Write
gboolean show-week-numbers Read / Write
gint year Read

Signals

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

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── GtkCalendar

Implemented Interfaces

GtkCalendar implements AtkImplementorIface, GtkBuildable and GtkConstraintTarget.

Includes

#include <gtk/gtk.h>

Description

GtkCalendar is a widget that displays a Gregorian calendar, one month at a time. It can be created with gtk_calendar_new().

The month and year currently displayed can be altered with gtk_calendar_select_month(). The exact day can be selected from the displayed month using 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 way in which the calendar itself is displayed can be altered using gtk_calendar_set_display_options().

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.

Functions

gtk_calendar_new ()

GtkWidget *
gtk_calendar_new (void);

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

Returns

a newly GtkCalendar widget


gtk_calendar_select_day ()

void
gtk_calendar_select_day (GtkCalendar *self,
                         GDateTime *date);

Will switch to date 's year and month and select its day.

Parameters

calendar

a GtkCalendar.

 

date

a GDateTime representing the day to select.

[transfer none]

gtk_calendar_mark_day ()

void
gtk_calendar_mark_day (GtkCalendar *calendar,
                       guint day);

Places a visual marker on a particular day.

Parameters

calendar

a GtkCalendar

 

day

the day number to mark between 1 and 31.

 

gtk_calendar_unmark_day ()

void
gtk_calendar_unmark_day (GtkCalendar *calendar,
                         guint day);

Removes the visual marker from a particular day.

Parameters

calendar

a GtkCalendar.

 

day

the day number to unmark between 1 and 31.

 

gtk_calendar_get_day_is_marked ()

gboolean
gtk_calendar_get_day_is_marked (GtkCalendar *calendar,
                                guint day);

Returns if the day of the calendar is already marked.

Parameters

calendar

a GtkCalendar

 

day

the day number between 1 and 31.

 

Returns

whether the day is marked.


gtk_calendar_clear_marks ()

void
gtk_calendar_clear_marks (GtkCalendar *calendar);

Remove all visual markers.

Parameters

calendar

a GtkCalendar

 

gtk_calendar_get_date ()

GDateTime *
gtk_calendar_get_date (GtkCalendar *self);

Parameters

calendar

a GtkCalendar

 

Returns

A GDateTime representing the shown year, month and the selected day, in the local time zone.

[transfer full]

Property Details

The “day” property

  “day”                      gint

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

Allowed values: [0,31]

Default value: 0


The “month” property

  “month”                    gint

The selected month (as a number between 0 and 11). This property gets initially set to the current month.

Owner: GtkCalendar

Flags: Read

Allowed values: [0,11]

Default value: 0


The “show-day-names” property

  “show-day-names”           gboolean

Determines whether day names are displayed.

Owner: GtkCalendar

Flags: Read / Write

Default value: TRUE


The “show-heading” property

  “show-heading”             gboolean

Determines whether a heading is displayed.

Owner: GtkCalendar

Flags: Read / Write

Default value: TRUE


The “show-week-numbers” property

  “show-week-numbers”        gboolean

Determines whether week numbers are displayed.

Owner: GtkCalendar

Flags: Read / Write

Default value: FALSE


The “year” property

  “year”                     gint

The selected year. This property gets initially set to the current year.

Owner: GtkCalendar

Flags: Read

Allowed values: [0,4194303]

Default value: 0

Signal Details

The “day-selected” signal

void
user_function (GtkCalendar *calendar,
               gpointer     user_data)

Emitted when the user selects a day.

Parameters

calendar

the object which received the signal.

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First


The “next-month” signal

void
user_function (GtkCalendar *calendar,
               gpointer     user_data)

Emitted when the user switched to the next month.

Parameters

calendar

the object which received the signal.

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First


The “next-year” signal

void
user_function (GtkCalendar *calendar,
               gpointer     user_data)

Emitted when user switched to the next year.

Parameters

calendar

the object which received the signal.

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First


The “prev-month” signal

void
user_function (GtkCalendar *calendar,
               gpointer     user_data)

Emitted when the user switched to the previous month.

Parameters

calendar

the object which received the signal.

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First


The “prev-year” signal

void
user_function (GtkCalendar *calendar,
               gpointer     user_data)

Emitted when user switched to the previous year.

Parameters

calendar

the object which received the signal.

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First