Class: Gtk::Calendar

Inherits:
Widget
  • Object
show all
Defined in:
(unknown)

Overview

GtkCalendar is a widget that displays a Gregorian calendar, one month at a time.

An example GtkCalendar

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.

Instance Method Summary collapse

Methods inherited from Widget

#accessible_role, #accessible_role=, #action_set_enabled, #activate, #activate_action, #activate_action_variant, #activate_default, #activate_signal, #activate_signal=, #activate_signal_from_name=, #add_binding, #add_binding_action, #add_binding_signal, #add_controller, #add_css_class, #add_mnemonic_label, #add_shortcut, #add_tick_callback, #allocate, #allocated_baseline, #allocated_height, #allocated_width, #baseline, #bind_template_callback_full, #bind_template_child_full, #can_focus, #can_focus=, #can_focus?, #can_target, #can_target=, #can_target?, #child_focus, #child_visible, #child_visible=, #clipboard, #compute_bounds, #compute_expand, #compute_point, #compute_transform, #contains, #create_pango_context, #create_pango_layout, #css_classes, #css_classes=, #css_name, #css_name=, #cursor, #cursor=, #cursor_from_name=, default_direction, default_direction=, #direction, #direction=, #display, #dispose_template, #drag_check_threshold, #error_bell, #first_child, #focus_child, #focus_child=, #focus_on_click, #focus_on_click=, #focus_on_click?, #focusable, #focusable=, #focusable?, #font_map, #font_map=, #font_options, #font_options=, #frame_clock, #get_allocation, #get_ancestor, #get_color, #get_preferred_size, #get_size, #get_size_request, #get_template_child, #grab_focus, #halign, #halign=, #has_css_class, #has_default, #has_default=, #has_default?, #has_focus, #has_focus=, #has_focus?, #has_tooltip, #has_tooltip=, #has_tooltip?, #has_visible_focus, #height, #height_request, #height_request=, #hexpand, #hexpand=, #hexpand?, #hexpand_set, #hexpand_set=, #hexpand_set?, #hide, #in_destruction, #init_template, #insert_action_group, #insert_after, #insert_before, #install_action, #install_property_action, #is_ancestor, #is_drawable, #is_focus, #is_sensitive, #is_visible, #keynav_failed, #last_child, #layout_manager, #layout_manager=, #layout_manager_type, #layout_manager_type=, #list_mnemonic_labels, #map, #mapped, #margin_bottom, #margin_bottom=, #margin_end, #margin_end=, #margin_start, #margin_start=, #margin_top, #margin_top=, #measure, #mnemonic_activate, #name, #name=, #native, #next_sibling, #observe_children, #observe_controllers, #opacity, #opacity=, #overflow, #overflow=, #pango_context, #parent, #parent=, #pick, #prev_sibling, #primary_clipboard, #query_action, #queue_allocate, #queue_draw, #queue_resize, #realize, #realized, #receives_default, #receives_default=, #receives_default?, #remove_controller, #remove_css_class, #remove_mnemonic_label, #remove_tick_callback, #request_mode, #root, #root=, #scale_factor, #scale_factor=, #sensitive, #sensitive=, #sensitive?, #set_size_request, #set_state_flags, #settings, #should_layout, #show, #size_allocate, #snapshot_child, #state_flags, #style_context, #template=, #template_from_resource=, #template_scope=, #tooltip_markup, #tooltip_markup=, #tooltip_text, #tooltip_text=, #translate_coordinates, #trigger_tooltip_query, #unmap, #unparent, #unrealize, #unset_state_flags, #valign, #valign=, #vexpand, #vexpand=, #vexpand?, #vexpand_set, #vexpand_set=, #vexpand_set?, #visible, #visible=, #visible?, #width, #width_request, #width_request=

Constructor Details

#initializeGtk::Widget

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

Instance Method Details

#clear_marksnil

Remove all visual markers.

Returns:

  • (nil)

#dateGLib::DateTime

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

The returned date is in the local time zone.

Returns:

  • (GLib::DateTime)

    the GDateTime representing the shown date

#dayInteger

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

Returns:

  • (Integer)

    day

#day=(day) ⇒ Integer

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

Parameters:

  • day (Integer)

Returns:

  • (Integer)

    day

  • (Integer)

    day

#get_day_is_marked(day) ⇒ Boolean

Returns if the day of the calendar is already marked.

Parameters:

  • day (Integer)

    the day number between 1 and 31.

Returns:

  • (Boolean)

    whether the day is marked.

#mark_day(day) ⇒ nil

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

Parameters:

  • day (Integer)

    the day number to mark between 1 and 31.

Returns:

  • (nil)

#monthInteger

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

This property gets initially set to the current month.

Returns:

  • (Integer)

    month

#month=(month) ⇒ Integer

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

This property gets initially set to the current month.

Parameters:

  • month (Integer)

Returns:

  • (Integer)

    month

  • (Integer)

    month

#select_day(date) ⇒ nil

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

Parameters:

  • date (GLib::DateTime)

    a GDateTime representing the day to select

Returns:

  • (nil)

#show_day_namesBoolean

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

This is the value of the [propertyGtk.Calendar:show-day-names] property.

Returns:

  • (Boolean)

    Whether the calendar shows day names.

#show_day_names=(show_day_names) ⇒ Boolean

Determines whether day names are displayed.

Parameters:

  • show_day_names (Boolean)

Returns:

  • (Boolean)

    show-day-names

  • (Boolean)

    show-day-names

#show_day_names?Boolean

Determines whether day names are displayed.

Returns:

  • (Boolean)

    show-day-names

#show_headingBoolean

Returns whether self is currently showing the heading.

This is the value of the [propertyGtk.Calendar:show-heading] property.

Returns:

  • (Boolean)

    Whether the calendar is showing a heading.

#show_heading=(show_heading) ⇒ Boolean

Determines whether a heading is displayed.

Parameters:

  • show_heading (Boolean)

Returns:

  • (Boolean)

    show-heading

  • (Boolean)

    show-heading

#show_heading?Boolean

Determines whether a heading is displayed.

Returns:

  • (Boolean)

    show-heading

#show_week_numbersBoolean

Returns whether self is showing week numbers right now.

This is the value of the [propertyGtk.Calendar:show-week-numbers] property.

Returns:

  • (Boolean)

    Whether the calendar is showing week numbers.

#show_week_numbers=(show_week_numbers) ⇒ Boolean

Determines whether week numbers are displayed.

Parameters:

  • show_week_numbers (Boolean)

Returns:

  • (Boolean)

    show-week-numbers

  • (Boolean)

    show-week-numbers

#show_week_numbers?Boolean

Determines whether week numbers are displayed.

Returns:

  • (Boolean)

    show-week-numbers

#unmark_day(day) ⇒ nil

Removes the visual marker from a particular day.

Parameters:

  • day (Integer)

    the day number to unmark between 1 and 31.

Returns:

  • (nil)

#yearInteger

The selected year.

This property gets initially set to the current year.

Returns:

  • (Integer)

    year

#year=(year) ⇒ Integer

The selected year.

This property gets initially set to the current year.

Parameters:

  • year (Integer)

Returns:

  • (Integer)

    year

  • (Integer)

    year