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