gtk4/auto/calendar.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4#![allow(deprecated)]
5
6#[cfg(feature = "v4_10")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
8use crate::Accessible;
9use crate::{
10 AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow, Widget, ffi,
11};
12use glib::{
13 object::ObjectType as _,
14 prelude::*,
15 signal::{SignalHandlerId, connect_raw},
16 translate::*,
17};
18use std::boxed::Box as Box_;
19
20#[cfg(feature = "v4_10")]
21#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
22glib::wrapper! {
23 /// Displays a Gregorian calendar, one month at a time.
24 ///
25 /// <picture>
26 /// <source srcset="calendar-dark.png" media="(prefers-color-scheme: dark)">
27 /// <img alt="An example GtkCalendar" src="calendar.png">
28 /// </picture>
29 ///
30 /// A [`Calendar`][crate::Calendar] can be created with [`new()`][Self::new()].
31 ///
32 /// The selected date can be retrieved from a [`Calendar`][crate::Calendar] using
33 /// [`date()`][Self::date()].
34 /// It can be altered with [`set_date()`][Self::set_date()].
35 ///
36 /// To place a visual marker on a particular day, use
37 /// [`mark_day()`][Self::mark_day()] and to remove the marker,
38 /// [`unmark_day()`][Self::unmark_day()]. Alternative, all
39 /// marks can be cleared with [`clear_marks()`][Self::clear_marks()].
40 ///
41 /// Users should be aware that, although the Gregorian calendar is the
42 /// legal calendar in most countries, it was adopted progressively
43 /// between 1582 and 1929. Display before these dates is likely to be
44 /// historically incorrect.
45 ///
46 /// # Shortcuts and Gestures
47 ///
48 /// [`Calendar`][crate::Calendar] supports the following gestures:
49 ///
50 /// - Scrolling up or down will switch to the previous or next month.
51 /// - Date strings can be dropped for setting the current day.
52 ///
53 /// # CSS nodes
54 ///
55 /// ```text
56 /// calendar.view
57 /// ├── header
58 /// │ ├── button
59 /// │ ├── stack.month
60 /// │ ├── button
61 /// │ ├── button
62 /// │ ├── label.year
63 /// │ ╰── button
64 /// ╰── grid
65 /// ╰── label[.day-name][.week-number][.day-number][.other-month][.today]
66 /// ```
67 ///
68 /// [`Calendar`][crate::Calendar] has a main node with name calendar. It contains a subnode
69 /// called header containing the widgets for switching between years and months.
70 ///
71 /// The grid subnode contains all day labels, including week numbers on the left
72 /// (marked with the .week-number css class) and day names on top (marked with the
73 /// .day-name css class).
74 ///
75 /// Day labels that belong to the previous or next month get the .other-month
76 /// style class. The label of the current day get the .today style class.
77 ///
78 /// Marked day labels get the :selected state assigned.
79 ///
80 /// ## Properties
81 ///
82 ///
83 /// #### `date`
84 /// The selected date.
85 ///
86 /// This property gets initially set to the current date.
87 ///
88 /// Readable | Writable
89 ///
90 ///
91 /// #### `day`
92 /// The selected day (as a number between 1 and 31).
93 ///
94 /// Readable | Writable
95 ///
96 ///
97 /// #### `month`
98 /// The selected month (as a number between 0 and 11).
99 ///
100 /// This property gets initially set to the current month.
101 ///
102 /// Readable | Writable
103 ///
104 ///
105 /// #### `show-day-names`
106 /// Determines whether day names are displayed.
107 ///
108 /// Readable | Writable
109 ///
110 ///
111 /// #### `show-heading`
112 /// Determines whether a heading is displayed.
113 ///
114 /// Readable | Writable
115 ///
116 ///
117 /// #### `show-week-numbers`
118 /// Determines whether week numbers are displayed.
119 ///
120 /// Readable | Writable
121 ///
122 ///
123 /// #### `year`
124 /// The selected year.
125 ///
126 /// This property gets initially set to the current year.
127 ///
128 /// Readable | Writable
129 /// <details><summary><h4>Widget</h4></summary>
130 ///
131 ///
132 /// #### `can-focus`
133 /// Whether the widget or any of its descendents can accept
134 /// the input focus.
135 ///
136 /// This property is meant to be set by widget implementations,
137 /// typically in their instance init function.
138 ///
139 /// Readable | Writable
140 ///
141 ///
142 /// #### `can-target`
143 /// Whether the widget can receive pointer events.
144 ///
145 /// Readable | Writable
146 ///
147 ///
148 /// #### `css-classes`
149 /// A list of css classes applied to this widget.
150 ///
151 /// Readable | Writable
152 ///
153 ///
154 /// #### `css-name`
155 /// The name of this widget in the CSS tree.
156 ///
157 /// This property is meant to be set by widget implementations,
158 /// typically in their instance init function.
159 ///
160 /// Readable | Writable | Construct Only
161 ///
162 ///
163 /// #### `cursor`
164 /// The cursor used by @widget.
165 ///
166 /// Readable | Writable
167 ///
168 ///
169 /// #### `focus-on-click`
170 /// Whether the widget should grab focus when it is clicked with the mouse.
171 ///
172 /// This property is only relevant for widgets that can take focus.
173 ///
174 /// Readable | Writable
175 ///
176 ///
177 /// #### `focusable`
178 /// Whether this widget itself will accept the input focus.
179 ///
180 /// Readable | Writable
181 ///
182 ///
183 /// #### `halign`
184 /// How to distribute horizontal space if widget gets extra space.
185 ///
186 /// Readable | Writable
187 ///
188 ///
189 /// #### `has-default`
190 /// Whether the widget is the default widget.
191 ///
192 /// Readable
193 ///
194 ///
195 /// #### `has-focus`
196 /// Whether the widget has the input focus.
197 ///
198 /// Readable
199 ///
200 ///
201 /// #### `has-tooltip`
202 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
203 /// signal on @widget.
204 ///
205 /// A true value indicates that @widget can have a tooltip, in this case
206 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
207 /// determine whether it will provide a tooltip or not.
208 ///
209 /// Readable | Writable
210 ///
211 ///
212 /// #### `height-request`
213 /// Overrides for height request of the widget.
214 ///
215 /// If this is -1, the natural request will be used.
216 ///
217 /// Readable | Writable
218 ///
219 ///
220 /// #### `hexpand`
221 /// Whether to expand horizontally.
222 ///
223 /// Readable | Writable
224 ///
225 ///
226 /// #### `hexpand-set`
227 /// Whether to use the `hexpand` property.
228 ///
229 /// Readable | Writable
230 ///
231 ///
232 /// #### `layout-manager`
233 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
234 /// the preferred size of the widget, and allocate its children.
235 ///
236 /// This property is meant to be set by widget implementations,
237 /// typically in their instance init function.
238 ///
239 /// Readable | Writable
240 ///
241 ///
242 /// #### `limit-events`
243 /// Makes this widget act like a modal dialog, with respect to
244 /// event delivery.
245 ///
246 /// Global event controllers will not handle events with targets
247 /// inside the widget, unless they are set up to ignore propagation
248 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
249 ///
250 /// Readable | Writable
251 ///
252 ///
253 /// #### `margin-bottom`
254 /// Margin on bottom side of widget.
255 ///
256 /// This property adds margin outside of the widget's normal size
257 /// request, the margin will be added in addition to the size from
258 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
259 ///
260 /// Readable | Writable
261 ///
262 ///
263 /// #### `margin-end`
264 /// Margin on end of widget, horizontally.
265 ///
266 /// This property supports left-to-right and right-to-left text
267 /// directions.
268 ///
269 /// This property adds margin outside of the widget's normal size
270 /// request, the margin will be added in addition to the size from
271 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
272 ///
273 /// Readable | Writable
274 ///
275 ///
276 /// #### `margin-start`
277 /// Margin on start of widget, horizontally.
278 ///
279 /// This property supports left-to-right and right-to-left text
280 /// directions.
281 ///
282 /// This property adds margin outside of the widget's normal size
283 /// request, the margin will be added in addition to the size from
284 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
285 ///
286 /// Readable | Writable
287 ///
288 ///
289 /// #### `margin-top`
290 /// Margin on top side of widget.
291 ///
292 /// This property adds margin outside of the widget's normal size
293 /// request, the margin will be added in addition to the size from
294 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
295 ///
296 /// Readable | Writable
297 ///
298 ///
299 /// #### `name`
300 /// The name of the widget.
301 ///
302 /// Readable | Writable
303 ///
304 ///
305 /// #### `opacity`
306 /// The requested opacity of the widget.
307 ///
308 /// Readable | Writable
309 ///
310 ///
311 /// #### `overflow`
312 /// How content outside the widget's content area is treated.
313 ///
314 /// This property is meant to be set by widget implementations,
315 /// typically in their instance init function.
316 ///
317 /// Readable | Writable
318 ///
319 ///
320 /// #### `parent`
321 /// The parent widget of this widget.
322 ///
323 /// Readable
324 ///
325 ///
326 /// #### `receives-default`
327 /// Whether the widget will receive the default action when it is focused.
328 ///
329 /// Readable | Writable
330 ///
331 ///
332 /// #### `root`
333 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
334 ///
335 /// This will be `NULL` if the widget is not contained in a root widget.
336 ///
337 /// Readable
338 ///
339 ///
340 /// #### `scale-factor`
341 /// The scale factor of the widget.
342 ///
343 /// Readable
344 ///
345 ///
346 /// #### `sensitive`
347 /// Whether the widget responds to input.
348 ///
349 /// Readable | Writable
350 ///
351 ///
352 /// #### `tooltip-markup`
353 /// Sets the text of tooltip to be the given string, which is marked up
354 /// with Pango markup.
355 ///
356 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
357 ///
358 /// This is a convenience property which will take care of getting the
359 /// tooltip shown if the given string is not `NULL`:
360 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
361 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
362 /// the default signal handler.
363 ///
364 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
365 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
366 ///
367 /// Readable | Writable
368 ///
369 ///
370 /// #### `tooltip-text`
371 /// Sets the text of tooltip to be the given string.
372 ///
373 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
374 ///
375 /// This is a convenience property which will take care of getting the
376 /// tooltip shown if the given string is not `NULL`:
377 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
378 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
379 /// the default signal handler.
380 ///
381 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
382 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
383 ///
384 /// Readable | Writable
385 ///
386 ///
387 /// #### `valign`
388 /// How to distribute vertical space if widget gets extra space.
389 ///
390 /// Readable | Writable
391 ///
392 ///
393 /// #### `vexpand`
394 /// Whether to expand vertically.
395 ///
396 /// Readable | Writable
397 ///
398 ///
399 /// #### `vexpand-set`
400 /// Whether to use the `vexpand` property.
401 ///
402 /// Readable | Writable
403 ///
404 ///
405 /// #### `visible`
406 /// Whether the widget is visible.
407 ///
408 /// Readable | Writable
409 ///
410 ///
411 /// #### `width-request`
412 /// Overrides for width request of the widget.
413 ///
414 /// If this is -1, the natural request will be used.
415 ///
416 /// Readable | Writable
417 /// </details>
418 /// <details><summary><h4>Accessible</h4></summary>
419 ///
420 ///
421 /// #### `accessible-role`
422 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
423 ///
424 /// The accessible role cannot be changed once set.
425 ///
426 /// Readable | Writable
427 /// </details>
428 ///
429 /// ## Signals
430 ///
431 ///
432 /// #### `day-selected`
433 /// Emitted when the user selects a day.
434 ///
435 ///
436 ///
437 ///
438 /// #### `next-month`
439 /// Emitted when the user switches to the next month.
440 ///
441 ///
442 ///
443 ///
444 /// #### `next-year`
445 /// Emitted when user switches to the next year.
446 ///
447 ///
448 ///
449 ///
450 /// #### `prev-month`
451 /// Emitted when the user switches to the previous month.
452 ///
453 ///
454 ///
455 ///
456 /// #### `prev-year`
457 /// Emitted when user switches to the previous year.
458 ///
459 ///
460 /// <details><summary><h4>Widget</h4></summary>
461 ///
462 ///
463 /// #### `destroy`
464 /// Signals that all holders of a reference to the widget should release
465 /// the reference that they hold.
466 ///
467 /// May result in finalization of the widget if all references are released.
468 ///
469 /// This signal is not suitable for saving widget state.
470 ///
471 ///
472 ///
473 ///
474 /// #### `direction-changed`
475 /// Emitted when the text direction of a widget changes.
476 ///
477 ///
478 ///
479 ///
480 /// #### `hide`
481 /// Emitted when @widget is hidden.
482 ///
483 ///
484 ///
485 ///
486 /// #### `keynav-failed`
487 /// Emitted if keyboard navigation fails.
488 ///
489 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
490 ///
491 ///
492 ///
493 ///
494 /// #### `map`
495 /// Emitted when @widget is going to be mapped.
496 ///
497 /// A widget is mapped when the widget is visible (which is controlled with
498 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
499 /// are also visible.
500 ///
501 /// The `::map` signal can be used to determine whether a widget will be drawn,
502 /// for instance it can resume an animation that was stopped during the
503 /// emission of [`unmap`][struct@crate::Widget#unmap].
504 ///
505 ///
506 ///
507 ///
508 /// #### `mnemonic-activate`
509 /// Emitted when a widget is activated via a mnemonic.
510 ///
511 /// The default handler for this signal activates @widget if @group_cycling
512 /// is false, or just makes @widget grab focus if @group_cycling is true.
513 ///
514 ///
515 ///
516 ///
517 /// #### `move-focus`
518 /// Emitted when the focus is moved.
519 ///
520 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
521 ///
522 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
523 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
524 ///
525 /// Action
526 ///
527 ///
528 /// #### `query-tooltip`
529 /// Emitted when the widget’s tooltip is about to be shown.
530 ///
531 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
532 /// is true and the hover timeout has expired with the cursor hovering
533 /// above @widget; or emitted when @widget got focus in keyboard mode.
534 ///
535 /// Using the given coordinates, the signal handler should determine
536 /// whether a tooltip should be shown for @widget. If this is the case
537 /// true should be returned, false otherwise. Note that if @keyboard_mode
538 /// is true, the values of @x and @y are undefined and should not be used.
539 ///
540 /// The signal handler is free to manipulate @tooltip with the therefore
541 /// destined function calls.
542 ///
543 ///
544 ///
545 ///
546 /// #### `realize`
547 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
548 ///
549 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
550 /// or the widget has been mapped (that is, it is going to be drawn).
551 ///
552 ///
553 ///
554 ///
555 /// #### `show`
556 /// Emitted when @widget is shown.
557 ///
558 ///
559 ///
560 ///
561 /// #### `state-flags-changed`
562 /// Emitted when the widget state changes.
563 ///
564 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
565 ///
566 ///
567 ///
568 ///
569 /// #### `unmap`
570 /// Emitted when @widget is going to be unmapped.
571 ///
572 /// A widget is unmapped when either it or any of its parents up to the
573 /// toplevel widget have been set as hidden.
574 ///
575 /// As `::unmap` indicates that a widget will not be shown any longer,
576 /// it can be used to, for example, stop an animation on the widget.
577 ///
578 ///
579 ///
580 ///
581 /// #### `unrealize`
582 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
583 ///
584 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
585 /// or the widget has been unmapped (that is, it is going to be hidden).
586 ///
587 ///
588 /// </details>
589 ///
590 /// # Implements
591 ///
592 /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
593 #[doc(alias = "GtkCalendar")]
594 pub struct Calendar(Object<ffi::GtkCalendar>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
595
596 match fn {
597 type_ => || ffi::gtk_calendar_get_type(),
598 }
599}
600
601#[cfg(not(feature = "v4_10"))]
602glib::wrapper! {
603 #[doc(alias = "GtkCalendar")]
604 pub struct Calendar(Object<ffi::GtkCalendar>) @extends Widget, @implements Buildable, ConstraintTarget;
605
606 match fn {
607 type_ => || ffi::gtk_calendar_get_type(),
608 }
609}
610
611impl Calendar {
612 /// Creates a new calendar, with the current date being selected.
613 ///
614 /// # Returns
615 ///
616 /// a newly [`Calendar`][crate::Calendar] widget
617 #[doc(alias = "gtk_calendar_new")]
618 pub fn new() -> Calendar {
619 assert_initialized_main_thread!();
620 unsafe { Widget::from_glib_none(ffi::gtk_calendar_new()).unsafe_cast() }
621 }
622
623 // rustdoc-stripper-ignore-next
624 /// Creates a new builder-pattern struct instance to construct [`Calendar`] objects.
625 ///
626 /// This method returns an instance of [`CalendarBuilder`](crate::builders::CalendarBuilder) which can be used to create [`Calendar`] objects.
627 pub fn builder() -> CalendarBuilder {
628 CalendarBuilder::new()
629 }
630
631 /// Remove all visual markers.
632 #[doc(alias = "gtk_calendar_clear_marks")]
633 pub fn clear_marks(&self) {
634 unsafe {
635 ffi::gtk_calendar_clear_marks(self.to_glib_none().0);
636 }
637 }
638
639 /// Returns a `GDateTime` representing the shown
640 /// year, month and the selected day.
641 ///
642 /// The returned date is in the local time zone.
643 ///
644 /// # Returns
645 ///
646 /// the `GDateTime` representing the selected date
647 #[doc(alias = "gtk_calendar_get_date")]
648 #[doc(alias = "get_date")]
649 pub fn date(&self) -> glib::DateTime {
650 unsafe { from_glib_full(ffi::gtk_calendar_get_date(self.to_glib_none().0)) }
651 }
652
653 /// Gets the day of the selected date.
654 ///
655 /// # Returns
656 ///
657 /// the day of the selected date.
658 #[cfg(feature = "v4_14")]
659 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
660 #[doc(alias = "gtk_calendar_get_day")]
661 #[doc(alias = "get_day")]
662 pub fn day(&self) -> i32 {
663 unsafe { ffi::gtk_calendar_get_day(self.to_glib_none().0) }
664 }
665
666 /// Returns if the @day of the @self is already marked.
667 /// ## `day`
668 /// the day number between 1 and 31.
669 ///
670 /// # Returns
671 ///
672 /// whether the day is marked.
673 #[doc(alias = "gtk_calendar_get_day_is_marked")]
674 #[doc(alias = "get_day_is_marked")]
675 pub fn day_is_marked(&self, day: u32) -> bool {
676 unsafe {
677 from_glib(ffi::gtk_calendar_get_day_is_marked(
678 self.to_glib_none().0,
679 day,
680 ))
681 }
682 }
683
684 /// Gets the month of the selected date.
685 ///
686 /// # Returns
687 ///
688 /// The month of the selected date (as a number between 0 and 11).
689 #[cfg(feature = "v4_14")]
690 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
691 #[doc(alias = "gtk_calendar_get_month")]
692 #[doc(alias = "get_month")]
693 pub fn month(&self) -> i32 {
694 unsafe { ffi::gtk_calendar_get_month(self.to_glib_none().0) }
695 }
696
697 /// Returns whether @self is currently showing the names
698 /// of the week days.
699 ///
700 /// This is the value of the [`show-day-names`][struct@crate::Calendar#show-day-names]
701 /// property.
702 ///
703 /// # Returns
704 ///
705 /// Whether the calendar shows day names.
706 #[doc(alias = "gtk_calendar_get_show_day_names")]
707 #[doc(alias = "get_show_day_names")]
708 #[doc(alias = "show-day-names")]
709 pub fn shows_day_names(&self) -> bool {
710 unsafe { from_glib(ffi::gtk_calendar_get_show_day_names(self.to_glib_none().0)) }
711 }
712
713 /// Returns whether @self is currently showing the heading.
714 ///
715 /// This is the value of the [`show-heading`][struct@crate::Calendar#show-heading]
716 /// property.
717 ///
718 /// # Returns
719 ///
720 /// Whether the calendar is showing a heading.
721 #[doc(alias = "gtk_calendar_get_show_heading")]
722 #[doc(alias = "get_show_heading")]
723 #[doc(alias = "show-heading")]
724 pub fn shows_heading(&self) -> bool {
725 unsafe { from_glib(ffi::gtk_calendar_get_show_heading(self.to_glib_none().0)) }
726 }
727
728 /// Returns whether @self is showing week numbers right
729 /// now.
730 ///
731 /// This is the value of the [`show-week-numbers`][struct@crate::Calendar#show-week-numbers]
732 /// property.
733 ///
734 /// # Returns
735 ///
736 /// Whether the calendar is showing week numbers.
737 #[doc(alias = "gtk_calendar_get_show_week_numbers")]
738 #[doc(alias = "get_show_week_numbers")]
739 #[doc(alias = "show-week-numbers")]
740 pub fn shows_week_numbers(&self) -> bool {
741 unsafe {
742 from_glib(ffi::gtk_calendar_get_show_week_numbers(
743 self.to_glib_none().0,
744 ))
745 }
746 }
747
748 /// Gets the year of the selected date.
749 ///
750 /// # Returns
751 ///
752 /// the year of the selected date.
753 #[cfg(feature = "v4_14")]
754 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
755 #[doc(alias = "gtk_calendar_get_year")]
756 #[doc(alias = "get_year")]
757 pub fn year(&self) -> i32 {
758 unsafe { ffi::gtk_calendar_get_year(self.to_glib_none().0) }
759 }
760
761 /// Places a visual marker on a particular day of the current month.
762 /// ## `day`
763 /// the day number to mark between 1 and 31.
764 #[doc(alias = "gtk_calendar_mark_day")]
765 pub fn mark_day(&self, day: u32) {
766 unsafe {
767 ffi::gtk_calendar_mark_day(self.to_glib_none().0, day);
768 }
769 }
770
771 /// Switches to @date's year and month and select its day.
772 ///
773 /// # Deprecated since 4.20
774 ///
775 /// Use [`set_date()`][Self::set_date()] instead.
776 /// ## `date`
777 /// a `GDateTime` representing the day to select
778 #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
779 #[allow(deprecated)]
780 #[doc(alias = "gtk_calendar_select_day")]
781 pub fn select_day(&self, date: &glib::DateTime) {
782 unsafe {
783 ffi::gtk_calendar_select_day(self.to_glib_none().0, date.to_glib_none().0);
784 }
785 }
786
787 /// Switches to @date's year and month and selects its day.
788 /// ## `date`
789 /// a `GDateTime` representing the day to select
790 #[cfg(feature = "v4_20")]
791 #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
792 #[doc(alias = "gtk_calendar_set_date")]
793 #[doc(alias = "date")]
794 pub fn set_date(&self, date: &glib::DateTime) {
795 unsafe {
796 ffi::gtk_calendar_set_date(self.to_glib_none().0, date.to_glib_none().0);
797 }
798 }
799
800 /// Sets the day for the selected date.
801 ///
802 /// The new date must be valid. For example, setting the day to 31 when the
803 /// month is February will fail.
804 /// ## `day`
805 /// The desired day for the selected date (as a number between 1 and 31).
806 #[cfg(feature = "v4_14")]
807 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
808 #[doc(alias = "gtk_calendar_set_day")]
809 #[doc(alias = "day")]
810 pub fn set_day(&self, day: i32) {
811 unsafe {
812 ffi::gtk_calendar_set_day(self.to_glib_none().0, day);
813 }
814 }
815
816 /// Sets the month for the selected date.
817 ///
818 /// The new date must be valid. For example, setting the month to 1 (February)
819 /// when the day is 31 will fail.
820 /// ## `month`
821 /// The desired month for the selected date (as a number between 0 and 11).
822 #[cfg(feature = "v4_14")]
823 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
824 #[doc(alias = "gtk_calendar_set_month")]
825 #[doc(alias = "month")]
826 pub fn set_month(&self, month: i32) {
827 unsafe {
828 ffi::gtk_calendar_set_month(self.to_glib_none().0, month);
829 }
830 }
831
832 /// Sets whether the calendar shows day names.
833 /// ## `value`
834 /// Whether to show day names above the day numbers
835 #[doc(alias = "gtk_calendar_set_show_day_names")]
836 #[doc(alias = "show-day-names")]
837 pub fn set_show_day_names(&self, value: bool) {
838 unsafe {
839 ffi::gtk_calendar_set_show_day_names(self.to_glib_none().0, value.into_glib());
840 }
841 }
842
843 /// Sets whether the calendar should show a heading.
844 ///
845 /// The heading contains the current year and month as well as
846 /// buttons for changing both.
847 /// ## `value`
848 /// Whether to show the heading in the calendar
849 #[doc(alias = "gtk_calendar_set_show_heading")]
850 #[doc(alias = "show-heading")]
851 pub fn set_show_heading(&self, value: bool) {
852 unsafe {
853 ffi::gtk_calendar_set_show_heading(self.to_glib_none().0, value.into_glib());
854 }
855 }
856
857 /// Sets whether week numbers are shown in the calendar.
858 /// ## `value`
859 /// whether to show week numbers alongside the days
860 #[doc(alias = "gtk_calendar_set_show_week_numbers")]
861 #[doc(alias = "show-week-numbers")]
862 pub fn set_show_week_numbers(&self, value: bool) {
863 unsafe {
864 ffi::gtk_calendar_set_show_week_numbers(self.to_glib_none().0, value.into_glib());
865 }
866 }
867
868 /// Sets the year for the selected date.
869 ///
870 /// The new date must be valid. For example, setting the year to 2023 when the
871 /// date is February 29 will fail.
872 /// ## `year`
873 /// The desired year for the selected date (within [`glib::DateTime`][crate::glib::DateTime]
874 /// limits, i.e. from 0001 to 9999).
875 #[cfg(feature = "v4_14")]
876 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
877 #[doc(alias = "gtk_calendar_set_year")]
878 #[doc(alias = "year")]
879 pub fn set_year(&self, year: i32) {
880 unsafe {
881 ffi::gtk_calendar_set_year(self.to_glib_none().0, year);
882 }
883 }
884
885 /// Removes the visual marker from a particular day.
886 /// ## `day`
887 /// the day number to unmark between 1 and 31.
888 #[doc(alias = "gtk_calendar_unmark_day")]
889 pub fn unmark_day(&self, day: u32) {
890 unsafe {
891 ffi::gtk_calendar_unmark_day(self.to_glib_none().0, day);
892 }
893 }
894
895 #[cfg(not(feature = "v4_20"))]
896 #[cfg_attr(docsrs, doc(cfg(not(feature = "v4_20"))))]
897 pub fn set_date(&self, date: Option<&glib::DateTime>) {
898 ObjectExt::set_property(self, "date", date)
899 }
900
901 /// Emitted when the user selects a day.
902 #[doc(alias = "day-selected")]
903 pub fn connect_day_selected<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
904 unsafe extern "C" fn day_selected_trampoline<F: Fn(&Calendar) + 'static>(
905 this: *mut ffi::GtkCalendar,
906 f: glib::ffi::gpointer,
907 ) {
908 unsafe {
909 let f: &F = &*(f as *const F);
910 f(&from_glib_borrow(this))
911 }
912 }
913 unsafe {
914 let f: Box_<F> = Box_::new(f);
915 connect_raw(
916 self.as_ptr() as *mut _,
917 c"day-selected".as_ptr(),
918 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
919 day_selected_trampoline::<F> as *const (),
920 )),
921 Box_::into_raw(f),
922 )
923 }
924 }
925
926 /// Emitted when the user switches to the next month.
927 #[doc(alias = "next-month")]
928 pub fn connect_next_month<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
929 unsafe extern "C" fn next_month_trampoline<F: Fn(&Calendar) + 'static>(
930 this: *mut ffi::GtkCalendar,
931 f: glib::ffi::gpointer,
932 ) {
933 unsafe {
934 let f: &F = &*(f as *const F);
935 f(&from_glib_borrow(this))
936 }
937 }
938 unsafe {
939 let f: Box_<F> = Box_::new(f);
940 connect_raw(
941 self.as_ptr() as *mut _,
942 c"next-month".as_ptr(),
943 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
944 next_month_trampoline::<F> as *const (),
945 )),
946 Box_::into_raw(f),
947 )
948 }
949 }
950
951 /// Emitted when user switches to the next year.
952 #[doc(alias = "next-year")]
953 pub fn connect_next_year<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
954 unsafe extern "C" fn next_year_trampoline<F: Fn(&Calendar) + 'static>(
955 this: *mut ffi::GtkCalendar,
956 f: glib::ffi::gpointer,
957 ) {
958 unsafe {
959 let f: &F = &*(f as *const F);
960 f(&from_glib_borrow(this))
961 }
962 }
963 unsafe {
964 let f: Box_<F> = Box_::new(f);
965 connect_raw(
966 self.as_ptr() as *mut _,
967 c"next-year".as_ptr(),
968 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
969 next_year_trampoline::<F> as *const (),
970 )),
971 Box_::into_raw(f),
972 )
973 }
974 }
975
976 /// Emitted when the user switches to the previous month.
977 #[doc(alias = "prev-month")]
978 pub fn connect_prev_month<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
979 unsafe extern "C" fn prev_month_trampoline<F: Fn(&Calendar) + 'static>(
980 this: *mut ffi::GtkCalendar,
981 f: glib::ffi::gpointer,
982 ) {
983 unsafe {
984 let f: &F = &*(f as *const F);
985 f(&from_glib_borrow(this))
986 }
987 }
988 unsafe {
989 let f: Box_<F> = Box_::new(f);
990 connect_raw(
991 self.as_ptr() as *mut _,
992 c"prev-month".as_ptr(),
993 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
994 prev_month_trampoline::<F> as *const (),
995 )),
996 Box_::into_raw(f),
997 )
998 }
999 }
1000
1001 /// Emitted when user switches to the previous year.
1002 #[doc(alias = "prev-year")]
1003 pub fn connect_prev_year<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1004 unsafe extern "C" fn prev_year_trampoline<F: Fn(&Calendar) + 'static>(
1005 this: *mut ffi::GtkCalendar,
1006 f: glib::ffi::gpointer,
1007 ) {
1008 unsafe {
1009 let f: &F = &*(f as *const F);
1010 f(&from_glib_borrow(this))
1011 }
1012 }
1013 unsafe {
1014 let f: Box_<F> = Box_::new(f);
1015 connect_raw(
1016 self.as_ptr() as *mut _,
1017 c"prev-year".as_ptr(),
1018 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1019 prev_year_trampoline::<F> as *const (),
1020 )),
1021 Box_::into_raw(f),
1022 )
1023 }
1024 }
1025
1026 #[doc(alias = "date")]
1027 pub fn connect_date_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1028 unsafe extern "C" fn notify_date_trampoline<F: Fn(&Calendar) + 'static>(
1029 this: *mut ffi::GtkCalendar,
1030 _param_spec: glib::ffi::gpointer,
1031 f: glib::ffi::gpointer,
1032 ) {
1033 unsafe {
1034 let f: &F = &*(f as *const F);
1035 f(&from_glib_borrow(this))
1036 }
1037 }
1038 unsafe {
1039 let f: Box_<F> = Box_::new(f);
1040 connect_raw(
1041 self.as_ptr() as *mut _,
1042 c"notify::date".as_ptr(),
1043 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1044 notify_date_trampoline::<F> as *const (),
1045 )),
1046 Box_::into_raw(f),
1047 )
1048 }
1049 }
1050
1051 #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
1052 #[doc(alias = "day")]
1053 pub fn connect_day_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1054 unsafe extern "C" fn notify_day_trampoline<F: Fn(&Calendar) + 'static>(
1055 this: *mut ffi::GtkCalendar,
1056 _param_spec: glib::ffi::gpointer,
1057 f: glib::ffi::gpointer,
1058 ) {
1059 unsafe {
1060 let f: &F = &*(f as *const F);
1061 f(&from_glib_borrow(this))
1062 }
1063 }
1064 unsafe {
1065 let f: Box_<F> = Box_::new(f);
1066 connect_raw(
1067 self.as_ptr() as *mut _,
1068 c"notify::day".as_ptr(),
1069 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1070 notify_day_trampoline::<F> as *const (),
1071 )),
1072 Box_::into_raw(f),
1073 )
1074 }
1075 }
1076
1077 #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
1078 #[doc(alias = "month")]
1079 pub fn connect_month_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1080 unsafe extern "C" fn notify_month_trampoline<F: Fn(&Calendar) + 'static>(
1081 this: *mut ffi::GtkCalendar,
1082 _param_spec: glib::ffi::gpointer,
1083 f: glib::ffi::gpointer,
1084 ) {
1085 unsafe {
1086 let f: &F = &*(f as *const F);
1087 f(&from_glib_borrow(this))
1088 }
1089 }
1090 unsafe {
1091 let f: Box_<F> = Box_::new(f);
1092 connect_raw(
1093 self.as_ptr() as *mut _,
1094 c"notify::month".as_ptr(),
1095 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1096 notify_month_trampoline::<F> as *const (),
1097 )),
1098 Box_::into_raw(f),
1099 )
1100 }
1101 }
1102
1103 #[doc(alias = "show-day-names")]
1104 pub fn connect_show_day_names_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1105 unsafe extern "C" fn notify_show_day_names_trampoline<F: Fn(&Calendar) + 'static>(
1106 this: *mut ffi::GtkCalendar,
1107 _param_spec: glib::ffi::gpointer,
1108 f: glib::ffi::gpointer,
1109 ) {
1110 unsafe {
1111 let f: &F = &*(f as *const F);
1112 f(&from_glib_borrow(this))
1113 }
1114 }
1115 unsafe {
1116 let f: Box_<F> = Box_::new(f);
1117 connect_raw(
1118 self.as_ptr() as *mut _,
1119 c"notify::show-day-names".as_ptr(),
1120 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1121 notify_show_day_names_trampoline::<F> as *const (),
1122 )),
1123 Box_::into_raw(f),
1124 )
1125 }
1126 }
1127
1128 #[doc(alias = "show-heading")]
1129 pub fn connect_show_heading_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1130 unsafe extern "C" fn notify_show_heading_trampoline<F: Fn(&Calendar) + 'static>(
1131 this: *mut ffi::GtkCalendar,
1132 _param_spec: glib::ffi::gpointer,
1133 f: glib::ffi::gpointer,
1134 ) {
1135 unsafe {
1136 let f: &F = &*(f as *const F);
1137 f(&from_glib_borrow(this))
1138 }
1139 }
1140 unsafe {
1141 let f: Box_<F> = Box_::new(f);
1142 connect_raw(
1143 self.as_ptr() as *mut _,
1144 c"notify::show-heading".as_ptr(),
1145 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1146 notify_show_heading_trampoline::<F> as *const (),
1147 )),
1148 Box_::into_raw(f),
1149 )
1150 }
1151 }
1152
1153 #[doc(alias = "show-week-numbers")]
1154 pub fn connect_show_week_numbers_notify<F: Fn(&Self) + 'static>(
1155 &self,
1156 f: F,
1157 ) -> SignalHandlerId {
1158 unsafe extern "C" fn notify_show_week_numbers_trampoline<F: Fn(&Calendar) + 'static>(
1159 this: *mut ffi::GtkCalendar,
1160 _param_spec: glib::ffi::gpointer,
1161 f: glib::ffi::gpointer,
1162 ) {
1163 unsafe {
1164 let f: &F = &*(f as *const F);
1165 f(&from_glib_borrow(this))
1166 }
1167 }
1168 unsafe {
1169 let f: Box_<F> = Box_::new(f);
1170 connect_raw(
1171 self.as_ptr() as *mut _,
1172 c"notify::show-week-numbers".as_ptr(),
1173 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1174 notify_show_week_numbers_trampoline::<F> as *const (),
1175 )),
1176 Box_::into_raw(f),
1177 )
1178 }
1179 }
1180
1181 #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
1182 #[doc(alias = "year")]
1183 pub fn connect_year_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1184 unsafe extern "C" fn notify_year_trampoline<F: Fn(&Calendar) + 'static>(
1185 this: *mut ffi::GtkCalendar,
1186 _param_spec: glib::ffi::gpointer,
1187 f: glib::ffi::gpointer,
1188 ) {
1189 unsafe {
1190 let f: &F = &*(f as *const F);
1191 f(&from_glib_borrow(this))
1192 }
1193 }
1194 unsafe {
1195 let f: Box_<F> = Box_::new(f);
1196 connect_raw(
1197 self.as_ptr() as *mut _,
1198 c"notify::year".as_ptr(),
1199 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1200 notify_year_trampoline::<F> as *const (),
1201 )),
1202 Box_::into_raw(f),
1203 )
1204 }
1205 }
1206}
1207
1208impl Default for Calendar {
1209 fn default() -> Self {
1210 Self::new()
1211 }
1212}
1213
1214// rustdoc-stripper-ignore-next
1215/// A [builder-pattern] type to construct [`Calendar`] objects.
1216///
1217/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1218#[must_use = "The builder must be built to be used"]
1219pub struct CalendarBuilder {
1220 builder: glib::object::ObjectBuilder<'static, Calendar>,
1221}
1222
1223impl CalendarBuilder {
1224 fn new() -> Self {
1225 Self {
1226 builder: glib::object::Object::builder(),
1227 }
1228 }
1229
1230 /// The selected date.
1231 ///
1232 /// This property gets initially set to the current date.
1233 pub fn date(self, date: &glib::DateTime) -> Self {
1234 Self {
1235 builder: self.builder.property("date", date.clone()),
1236 }
1237 }
1238
1239 /// The selected day (as a number between 1 and 31).
1240 /// This property will be removed in GTK 5.
1241 /// Use [`date`][struct@crate::Calendar#date] instead.
1242 #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
1243 pub fn day(self, day: i32) -> Self {
1244 Self {
1245 builder: self.builder.property("day", day),
1246 }
1247 }
1248
1249 /// The selected month (as a number between 0 and 11).
1250 ///
1251 /// This property gets initially set to the current month.
1252 /// This property will be removed in GTK 5.
1253 /// Use [`date`][struct@crate::Calendar#date] instead.
1254 #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
1255 pub fn month(self, month: i32) -> Self {
1256 Self {
1257 builder: self.builder.property("month", month),
1258 }
1259 }
1260
1261 /// Determines whether day names are displayed.
1262 pub fn show_day_names(self, show_day_names: bool) -> Self {
1263 Self {
1264 builder: self.builder.property("show-day-names", show_day_names),
1265 }
1266 }
1267
1268 /// Determines whether a heading is displayed.
1269 pub fn show_heading(self, show_heading: bool) -> Self {
1270 Self {
1271 builder: self.builder.property("show-heading", show_heading),
1272 }
1273 }
1274
1275 /// Determines whether week numbers are displayed.
1276 pub fn show_week_numbers(self, show_week_numbers: bool) -> Self {
1277 Self {
1278 builder: self
1279 .builder
1280 .property("show-week-numbers", show_week_numbers),
1281 }
1282 }
1283
1284 /// The selected year.
1285 ///
1286 /// This property gets initially set to the current year.
1287 /// This property will be removed in GTK 5.
1288 /// Use [`date`][struct@crate::Calendar#date] instead.
1289 #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
1290 pub fn year(self, year: i32) -> Self {
1291 Self {
1292 builder: self.builder.property("year", year),
1293 }
1294 }
1295
1296 /// Whether the widget or any of its descendents can accept
1297 /// the input focus.
1298 ///
1299 /// This property is meant to be set by widget implementations,
1300 /// typically in their instance init function.
1301 pub fn can_focus(self, can_focus: bool) -> Self {
1302 Self {
1303 builder: self.builder.property("can-focus", can_focus),
1304 }
1305 }
1306
1307 /// Whether the widget can receive pointer events.
1308 pub fn can_target(self, can_target: bool) -> Self {
1309 Self {
1310 builder: self.builder.property("can-target", can_target),
1311 }
1312 }
1313
1314 /// A list of css classes applied to this widget.
1315 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1316 Self {
1317 builder: self.builder.property("css-classes", css_classes.into()),
1318 }
1319 }
1320
1321 /// The name of this widget in the CSS tree.
1322 ///
1323 /// This property is meant to be set by widget implementations,
1324 /// typically in their instance init function.
1325 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1326 Self {
1327 builder: self.builder.property("css-name", css_name.into()),
1328 }
1329 }
1330
1331 /// The cursor used by @widget.
1332 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1333 Self {
1334 builder: self.builder.property("cursor", cursor.clone()),
1335 }
1336 }
1337
1338 /// Whether the widget should grab focus when it is clicked with the mouse.
1339 ///
1340 /// This property is only relevant for widgets that can take focus.
1341 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1342 Self {
1343 builder: self.builder.property("focus-on-click", focus_on_click),
1344 }
1345 }
1346
1347 /// Whether this widget itself will accept the input focus.
1348 pub fn focusable(self, focusable: bool) -> Self {
1349 Self {
1350 builder: self.builder.property("focusable", focusable),
1351 }
1352 }
1353
1354 /// How to distribute horizontal space if widget gets extra space.
1355 pub fn halign(self, halign: Align) -> Self {
1356 Self {
1357 builder: self.builder.property("halign", halign),
1358 }
1359 }
1360
1361 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1362 /// signal on @widget.
1363 ///
1364 /// A true value indicates that @widget can have a tooltip, in this case
1365 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1366 /// determine whether it will provide a tooltip or not.
1367 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1368 Self {
1369 builder: self.builder.property("has-tooltip", has_tooltip),
1370 }
1371 }
1372
1373 /// Overrides for height request of the widget.
1374 ///
1375 /// If this is -1, the natural request will be used.
1376 pub fn height_request(self, height_request: i32) -> Self {
1377 Self {
1378 builder: self.builder.property("height-request", height_request),
1379 }
1380 }
1381
1382 /// Whether to expand horizontally.
1383 pub fn hexpand(self, hexpand: bool) -> Self {
1384 Self {
1385 builder: self.builder.property("hexpand", hexpand),
1386 }
1387 }
1388
1389 /// Whether to use the `hexpand` property.
1390 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1391 Self {
1392 builder: self.builder.property("hexpand-set", hexpand_set),
1393 }
1394 }
1395
1396 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1397 /// the preferred size of the widget, and allocate its children.
1398 ///
1399 /// This property is meant to be set by widget implementations,
1400 /// typically in their instance init function.
1401 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1402 Self {
1403 builder: self
1404 .builder
1405 .property("layout-manager", layout_manager.clone().upcast()),
1406 }
1407 }
1408
1409 /// Makes this widget act like a modal dialog, with respect to
1410 /// event delivery.
1411 ///
1412 /// Global event controllers will not handle events with targets
1413 /// inside the widget, unless they are set up to ignore propagation
1414 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1415 #[cfg(feature = "v4_18")]
1416 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1417 pub fn limit_events(self, limit_events: bool) -> Self {
1418 Self {
1419 builder: self.builder.property("limit-events", limit_events),
1420 }
1421 }
1422
1423 /// Margin on bottom side of widget.
1424 ///
1425 /// This property adds margin outside of the widget's normal size
1426 /// request, the margin will be added in addition to the size from
1427 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1428 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1429 Self {
1430 builder: self.builder.property("margin-bottom", margin_bottom),
1431 }
1432 }
1433
1434 /// Margin on end of widget, horizontally.
1435 ///
1436 /// This property supports left-to-right and right-to-left text
1437 /// directions.
1438 ///
1439 /// This property adds margin outside of the widget's normal size
1440 /// request, the margin will be added in addition to the size from
1441 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1442 pub fn margin_end(self, margin_end: i32) -> Self {
1443 Self {
1444 builder: self.builder.property("margin-end", margin_end),
1445 }
1446 }
1447
1448 /// Margin on start of widget, horizontally.
1449 ///
1450 /// This property supports left-to-right and right-to-left text
1451 /// directions.
1452 ///
1453 /// This property adds margin outside of the widget's normal size
1454 /// request, the margin will be added in addition to the size from
1455 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1456 pub fn margin_start(self, margin_start: i32) -> Self {
1457 Self {
1458 builder: self.builder.property("margin-start", margin_start),
1459 }
1460 }
1461
1462 /// Margin on top side of widget.
1463 ///
1464 /// This property adds margin outside of the widget's normal size
1465 /// request, the margin will be added in addition to the size from
1466 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1467 pub fn margin_top(self, margin_top: i32) -> Self {
1468 Self {
1469 builder: self.builder.property("margin-top", margin_top),
1470 }
1471 }
1472
1473 /// The name of the widget.
1474 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1475 Self {
1476 builder: self.builder.property("name", name.into()),
1477 }
1478 }
1479
1480 /// The requested opacity of the widget.
1481 pub fn opacity(self, opacity: f64) -> Self {
1482 Self {
1483 builder: self.builder.property("opacity", opacity),
1484 }
1485 }
1486
1487 /// How content outside the widget's content area is treated.
1488 ///
1489 /// This property is meant to be set by widget implementations,
1490 /// typically in their instance init function.
1491 pub fn overflow(self, overflow: Overflow) -> Self {
1492 Self {
1493 builder: self.builder.property("overflow", overflow),
1494 }
1495 }
1496
1497 /// Whether the widget will receive the default action when it is focused.
1498 pub fn receives_default(self, receives_default: bool) -> Self {
1499 Self {
1500 builder: self.builder.property("receives-default", receives_default),
1501 }
1502 }
1503
1504 /// Whether the widget responds to input.
1505 pub fn sensitive(self, sensitive: bool) -> Self {
1506 Self {
1507 builder: self.builder.property("sensitive", sensitive),
1508 }
1509 }
1510
1511 /// Sets the text of tooltip to be the given string, which is marked up
1512 /// with Pango markup.
1513 ///
1514 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1515 ///
1516 /// This is a convenience property which will take care of getting the
1517 /// tooltip shown if the given string is not `NULL`:
1518 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1519 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1520 /// the default signal handler.
1521 ///
1522 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1523 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1524 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1525 Self {
1526 builder: self
1527 .builder
1528 .property("tooltip-markup", tooltip_markup.into()),
1529 }
1530 }
1531
1532 /// Sets the text of tooltip to be the given string.
1533 ///
1534 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1535 ///
1536 /// This is a convenience property which will take care of getting the
1537 /// tooltip shown if the given string is not `NULL`:
1538 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1539 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1540 /// the default signal handler.
1541 ///
1542 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1543 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1544 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1545 Self {
1546 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1547 }
1548 }
1549
1550 /// How to distribute vertical space if widget gets extra space.
1551 pub fn valign(self, valign: Align) -> Self {
1552 Self {
1553 builder: self.builder.property("valign", valign),
1554 }
1555 }
1556
1557 /// Whether to expand vertically.
1558 pub fn vexpand(self, vexpand: bool) -> Self {
1559 Self {
1560 builder: self.builder.property("vexpand", vexpand),
1561 }
1562 }
1563
1564 /// Whether to use the `vexpand` property.
1565 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1566 Self {
1567 builder: self.builder.property("vexpand-set", vexpand_set),
1568 }
1569 }
1570
1571 /// Whether the widget is visible.
1572 pub fn visible(self, visible: bool) -> Self {
1573 Self {
1574 builder: self.builder.property("visible", visible),
1575 }
1576 }
1577
1578 /// Overrides for width request of the widget.
1579 ///
1580 /// If this is -1, the natural request will be used.
1581 pub fn width_request(self, width_request: i32) -> Self {
1582 Self {
1583 builder: self.builder.property("width-request", width_request),
1584 }
1585 }
1586
1587 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1588 ///
1589 /// The accessible role cannot be changed once set.
1590 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1591 Self {
1592 builder: self.builder.property("accessible-role", accessible_role),
1593 }
1594 }
1595
1596 // rustdoc-stripper-ignore-next
1597 /// Build the [`Calendar`].
1598 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1599 pub fn build(self) -> Calendar {
1600 assert_initialized_main_thread!();
1601 self.builder.build()
1602 }
1603}