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