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 ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow,
8 Widget,
9};
10use glib::{
11 object::ObjectType as _,
12 prelude::*,
13 signal::{connect_raw, SignalHandlerId},
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 let f: &F = &*(f as *const F);
895 f(&from_glib_borrow(this))
896 }
897 unsafe {
898 let f: Box_<F> = Box_::new(f);
899 connect_raw(
900 self.as_ptr() as *mut _,
901 c"day-selected".as_ptr() as *const _,
902 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
903 day_selected_trampoline::<F> as *const (),
904 )),
905 Box_::into_raw(f),
906 )
907 }
908 }
909
910 /// Emitted when the user switches to the next month.
911 #[doc(alias = "next-month")]
912 pub fn connect_next_month<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
913 unsafe extern "C" fn next_month_trampoline<F: Fn(&Calendar) + 'static>(
914 this: *mut ffi::GtkCalendar,
915 f: glib::ffi::gpointer,
916 ) {
917 let f: &F = &*(f as *const F);
918 f(&from_glib_borrow(this))
919 }
920 unsafe {
921 let f: Box_<F> = Box_::new(f);
922 connect_raw(
923 self.as_ptr() as *mut _,
924 c"next-month".as_ptr() as *const _,
925 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
926 next_month_trampoline::<F> as *const (),
927 )),
928 Box_::into_raw(f),
929 )
930 }
931 }
932
933 /// Emitted when user switches to the next year.
934 #[doc(alias = "next-year")]
935 pub fn connect_next_year<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
936 unsafe extern "C" fn next_year_trampoline<F: Fn(&Calendar) + 'static>(
937 this: *mut ffi::GtkCalendar,
938 f: glib::ffi::gpointer,
939 ) {
940 let f: &F = &*(f as *const F);
941 f(&from_glib_borrow(this))
942 }
943 unsafe {
944 let f: Box_<F> = Box_::new(f);
945 connect_raw(
946 self.as_ptr() as *mut _,
947 c"next-year".as_ptr() as *const _,
948 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
949 next_year_trampoline::<F> as *const (),
950 )),
951 Box_::into_raw(f),
952 )
953 }
954 }
955
956 /// Emitted when the user switches to the previous month.
957 #[doc(alias = "prev-month")]
958 pub fn connect_prev_month<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
959 unsafe extern "C" fn prev_month_trampoline<F: Fn(&Calendar) + 'static>(
960 this: *mut ffi::GtkCalendar,
961 f: glib::ffi::gpointer,
962 ) {
963 let f: &F = &*(f as *const F);
964 f(&from_glib_borrow(this))
965 }
966 unsafe {
967 let f: Box_<F> = Box_::new(f);
968 connect_raw(
969 self.as_ptr() as *mut _,
970 c"prev-month".as_ptr() as *const _,
971 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
972 prev_month_trampoline::<F> as *const (),
973 )),
974 Box_::into_raw(f),
975 )
976 }
977 }
978
979 /// Emitted when user switches to the previous year.
980 #[doc(alias = "prev-year")]
981 pub fn connect_prev_year<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
982 unsafe extern "C" fn prev_year_trampoline<F: Fn(&Calendar) + 'static>(
983 this: *mut ffi::GtkCalendar,
984 f: glib::ffi::gpointer,
985 ) {
986 let f: &F = &*(f as *const F);
987 f(&from_glib_borrow(this))
988 }
989 unsafe {
990 let f: Box_<F> = Box_::new(f);
991 connect_raw(
992 self.as_ptr() as *mut _,
993 c"prev-year".as_ptr() as *const _,
994 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
995 prev_year_trampoline::<F> as *const (),
996 )),
997 Box_::into_raw(f),
998 )
999 }
1000 }
1001
1002 #[doc(alias = "date")]
1003 pub fn connect_date_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1004 unsafe extern "C" fn notify_date_trampoline<F: Fn(&Calendar) + 'static>(
1005 this: *mut ffi::GtkCalendar,
1006 _param_spec: glib::ffi::gpointer,
1007 f: glib::ffi::gpointer,
1008 ) {
1009 let f: &F = &*(f as *const F);
1010 f(&from_glib_borrow(this))
1011 }
1012 unsafe {
1013 let f: Box_<F> = Box_::new(f);
1014 connect_raw(
1015 self.as_ptr() as *mut _,
1016 c"notify::date".as_ptr() as *const _,
1017 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1018 notify_date_trampoline::<F> as *const (),
1019 )),
1020 Box_::into_raw(f),
1021 )
1022 }
1023 }
1024
1025 #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
1026 #[doc(alias = "day")]
1027 pub fn connect_day_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1028 unsafe extern "C" fn notify_day_trampoline<F: Fn(&Calendar) + 'static>(
1029 this: *mut ffi::GtkCalendar,
1030 _param_spec: glib::ffi::gpointer,
1031 f: glib::ffi::gpointer,
1032 ) {
1033 let f: &F = &*(f as *const F);
1034 f(&from_glib_borrow(this))
1035 }
1036 unsafe {
1037 let f: Box_<F> = Box_::new(f);
1038 connect_raw(
1039 self.as_ptr() as *mut _,
1040 c"notify::day".as_ptr() as *const _,
1041 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1042 notify_day_trampoline::<F> as *const (),
1043 )),
1044 Box_::into_raw(f),
1045 )
1046 }
1047 }
1048
1049 #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
1050 #[doc(alias = "month")]
1051 pub fn connect_month_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1052 unsafe extern "C" fn notify_month_trampoline<F: Fn(&Calendar) + 'static>(
1053 this: *mut ffi::GtkCalendar,
1054 _param_spec: glib::ffi::gpointer,
1055 f: glib::ffi::gpointer,
1056 ) {
1057 let f: &F = &*(f as *const F);
1058 f(&from_glib_borrow(this))
1059 }
1060 unsafe {
1061 let f: Box_<F> = Box_::new(f);
1062 connect_raw(
1063 self.as_ptr() as *mut _,
1064 c"notify::month".as_ptr() as *const _,
1065 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1066 notify_month_trampoline::<F> as *const (),
1067 )),
1068 Box_::into_raw(f),
1069 )
1070 }
1071 }
1072
1073 #[doc(alias = "show-day-names")]
1074 pub fn connect_show_day_names_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1075 unsafe extern "C" fn notify_show_day_names_trampoline<F: Fn(&Calendar) + 'static>(
1076 this: *mut ffi::GtkCalendar,
1077 _param_spec: glib::ffi::gpointer,
1078 f: glib::ffi::gpointer,
1079 ) {
1080 let f: &F = &*(f as *const F);
1081 f(&from_glib_borrow(this))
1082 }
1083 unsafe {
1084 let f: Box_<F> = Box_::new(f);
1085 connect_raw(
1086 self.as_ptr() as *mut _,
1087 c"notify::show-day-names".as_ptr() as *const _,
1088 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1089 notify_show_day_names_trampoline::<F> as *const (),
1090 )),
1091 Box_::into_raw(f),
1092 )
1093 }
1094 }
1095
1096 #[doc(alias = "show-heading")]
1097 pub fn connect_show_heading_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1098 unsafe extern "C" fn notify_show_heading_trampoline<F: Fn(&Calendar) + 'static>(
1099 this: *mut ffi::GtkCalendar,
1100 _param_spec: glib::ffi::gpointer,
1101 f: glib::ffi::gpointer,
1102 ) {
1103 let f: &F = &*(f as *const F);
1104 f(&from_glib_borrow(this))
1105 }
1106 unsafe {
1107 let f: Box_<F> = Box_::new(f);
1108 connect_raw(
1109 self.as_ptr() as *mut _,
1110 c"notify::show-heading".as_ptr() as *const _,
1111 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1112 notify_show_heading_trampoline::<F> as *const (),
1113 )),
1114 Box_::into_raw(f),
1115 )
1116 }
1117 }
1118
1119 #[doc(alias = "show-week-numbers")]
1120 pub fn connect_show_week_numbers_notify<F: Fn(&Self) + 'static>(
1121 &self,
1122 f: F,
1123 ) -> SignalHandlerId {
1124 unsafe extern "C" fn notify_show_week_numbers_trampoline<F: Fn(&Calendar) + 'static>(
1125 this: *mut ffi::GtkCalendar,
1126 _param_spec: glib::ffi::gpointer,
1127 f: glib::ffi::gpointer,
1128 ) {
1129 let f: &F = &*(f as *const F);
1130 f(&from_glib_borrow(this))
1131 }
1132 unsafe {
1133 let f: Box_<F> = Box_::new(f);
1134 connect_raw(
1135 self.as_ptr() as *mut _,
1136 c"notify::show-week-numbers".as_ptr() as *const _,
1137 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1138 notify_show_week_numbers_trampoline::<F> as *const (),
1139 )),
1140 Box_::into_raw(f),
1141 )
1142 }
1143 }
1144
1145 #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
1146 #[doc(alias = "year")]
1147 pub fn connect_year_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1148 unsafe extern "C" fn notify_year_trampoline<F: Fn(&Calendar) + 'static>(
1149 this: *mut ffi::GtkCalendar,
1150 _param_spec: glib::ffi::gpointer,
1151 f: glib::ffi::gpointer,
1152 ) {
1153 let f: &F = &*(f as *const F);
1154 f(&from_glib_borrow(this))
1155 }
1156 unsafe {
1157 let f: Box_<F> = Box_::new(f);
1158 connect_raw(
1159 self.as_ptr() as *mut _,
1160 c"notify::year".as_ptr() as *const _,
1161 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1162 notify_year_trampoline::<F> as *const (),
1163 )),
1164 Box_::into_raw(f),
1165 )
1166 }
1167 }
1168}
1169
1170impl Default for Calendar {
1171 fn default() -> Self {
1172 Self::new()
1173 }
1174}
1175
1176// rustdoc-stripper-ignore-next
1177/// A [builder-pattern] type to construct [`Calendar`] objects.
1178///
1179/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1180#[must_use = "The builder must be built to be used"]
1181pub struct CalendarBuilder {
1182 builder: glib::object::ObjectBuilder<'static, Calendar>,
1183}
1184
1185impl CalendarBuilder {
1186 fn new() -> Self {
1187 Self {
1188 builder: glib::object::Object::builder(),
1189 }
1190 }
1191
1192 /// The selected date.
1193 ///
1194 /// This property gets initially set to the current date.
1195 pub fn date(self, date: &glib::DateTime) -> Self {
1196 Self {
1197 builder: self.builder.property("date", date.clone()),
1198 }
1199 }
1200
1201 /// The selected day (as a number between 1 and 31).
1202 /// This property will be removed in GTK 5.
1203 /// Use [`date`][struct@crate::Calendar#date] instead.
1204 #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
1205 pub fn day(self, day: i32) -> Self {
1206 Self {
1207 builder: self.builder.property("day", day),
1208 }
1209 }
1210
1211 /// The selected month (as a number between 0 and 11).
1212 ///
1213 /// This property gets initially set to the current month.
1214 /// This property will be removed in GTK 5.
1215 /// Use [`date`][struct@crate::Calendar#date] instead.
1216 #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
1217 pub fn month(self, month: i32) -> Self {
1218 Self {
1219 builder: self.builder.property("month", month),
1220 }
1221 }
1222
1223 /// Determines whether day names are displayed.
1224 pub fn show_day_names(self, show_day_names: bool) -> Self {
1225 Self {
1226 builder: self.builder.property("show-day-names", show_day_names),
1227 }
1228 }
1229
1230 /// Determines whether a heading is displayed.
1231 pub fn show_heading(self, show_heading: bool) -> Self {
1232 Self {
1233 builder: self.builder.property("show-heading", show_heading),
1234 }
1235 }
1236
1237 /// Determines whether week numbers are displayed.
1238 pub fn show_week_numbers(self, show_week_numbers: bool) -> Self {
1239 Self {
1240 builder: self
1241 .builder
1242 .property("show-week-numbers", show_week_numbers),
1243 }
1244 }
1245
1246 /// The selected year.
1247 ///
1248 /// This property gets initially set to the current year.
1249 /// This property will be removed in GTK 5.
1250 /// Use [`date`][struct@crate::Calendar#date] instead.
1251 #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
1252 pub fn year(self, year: i32) -> Self {
1253 Self {
1254 builder: self.builder.property("year", year),
1255 }
1256 }
1257
1258 /// Whether the widget or any of its descendents can accept
1259 /// the input focus.
1260 ///
1261 /// This property is meant to be set by widget implementations,
1262 /// typically in their instance init function.
1263 pub fn can_focus(self, can_focus: bool) -> Self {
1264 Self {
1265 builder: self.builder.property("can-focus", can_focus),
1266 }
1267 }
1268
1269 /// Whether the widget can receive pointer events.
1270 pub fn can_target(self, can_target: bool) -> Self {
1271 Self {
1272 builder: self.builder.property("can-target", can_target),
1273 }
1274 }
1275
1276 /// A list of css classes applied to this widget.
1277 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1278 Self {
1279 builder: self.builder.property("css-classes", css_classes.into()),
1280 }
1281 }
1282
1283 /// The name of this widget in the CSS tree.
1284 ///
1285 /// This property is meant to be set by widget implementations,
1286 /// typically in their instance init function.
1287 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1288 Self {
1289 builder: self.builder.property("css-name", css_name.into()),
1290 }
1291 }
1292
1293 /// The cursor used by @widget.
1294 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1295 Self {
1296 builder: self.builder.property("cursor", cursor.clone()),
1297 }
1298 }
1299
1300 /// Whether the widget should grab focus when it is clicked with the mouse.
1301 ///
1302 /// This property is only relevant for widgets that can take focus.
1303 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1304 Self {
1305 builder: self.builder.property("focus-on-click", focus_on_click),
1306 }
1307 }
1308
1309 /// Whether this widget itself will accept the input focus.
1310 pub fn focusable(self, focusable: bool) -> Self {
1311 Self {
1312 builder: self.builder.property("focusable", focusable),
1313 }
1314 }
1315
1316 /// How to distribute horizontal space if widget gets extra space.
1317 pub fn halign(self, halign: Align) -> Self {
1318 Self {
1319 builder: self.builder.property("halign", halign),
1320 }
1321 }
1322
1323 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1324 /// signal on @widget.
1325 ///
1326 /// A true value indicates that @widget can have a tooltip, in this case
1327 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1328 /// determine whether it will provide a tooltip or not.
1329 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1330 Self {
1331 builder: self.builder.property("has-tooltip", has_tooltip),
1332 }
1333 }
1334
1335 /// Overrides for height request of the widget.
1336 ///
1337 /// If this is -1, the natural request will be used.
1338 pub fn height_request(self, height_request: i32) -> Self {
1339 Self {
1340 builder: self.builder.property("height-request", height_request),
1341 }
1342 }
1343
1344 /// Whether to expand horizontally.
1345 pub fn hexpand(self, hexpand: bool) -> Self {
1346 Self {
1347 builder: self.builder.property("hexpand", hexpand),
1348 }
1349 }
1350
1351 /// Whether to use the `hexpand` property.
1352 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1353 Self {
1354 builder: self.builder.property("hexpand-set", hexpand_set),
1355 }
1356 }
1357
1358 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1359 /// the preferred size of the widget, and allocate its children.
1360 ///
1361 /// This property is meant to be set by widget implementations,
1362 /// typically in their instance init function.
1363 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1364 Self {
1365 builder: self
1366 .builder
1367 .property("layout-manager", layout_manager.clone().upcast()),
1368 }
1369 }
1370
1371 /// Makes this widget act like a modal dialog, with respect to
1372 /// event delivery.
1373 ///
1374 /// Global event controllers will not handle events with targets
1375 /// inside the widget, unless they are set up to ignore propagation
1376 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1377 #[cfg(feature = "v4_18")]
1378 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1379 pub fn limit_events(self, limit_events: bool) -> Self {
1380 Self {
1381 builder: self.builder.property("limit-events", limit_events),
1382 }
1383 }
1384
1385 /// Margin on bottom side of widget.
1386 ///
1387 /// This property adds margin outside of the widget's normal size
1388 /// request, the margin will be added in addition to the size from
1389 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1390 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1391 Self {
1392 builder: self.builder.property("margin-bottom", margin_bottom),
1393 }
1394 }
1395
1396 /// Margin on end of widget, horizontally.
1397 ///
1398 /// This property supports left-to-right and right-to-left text
1399 /// directions.
1400 ///
1401 /// This property adds margin outside of the widget's normal size
1402 /// request, the margin will be added in addition to the size from
1403 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1404 pub fn margin_end(self, margin_end: i32) -> Self {
1405 Self {
1406 builder: self.builder.property("margin-end", margin_end),
1407 }
1408 }
1409
1410 /// Margin on start of widget, horizontally.
1411 ///
1412 /// This property supports left-to-right and right-to-left text
1413 /// directions.
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_start(self, margin_start: i32) -> Self {
1419 Self {
1420 builder: self.builder.property("margin-start", margin_start),
1421 }
1422 }
1423
1424 /// Margin on top side of widget.
1425 ///
1426 /// This property adds margin outside of the widget's normal size
1427 /// request, the margin will be added in addition to the size from
1428 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1429 pub fn margin_top(self, margin_top: i32) -> Self {
1430 Self {
1431 builder: self.builder.property("margin-top", margin_top),
1432 }
1433 }
1434
1435 /// The name of the widget.
1436 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1437 Self {
1438 builder: self.builder.property("name", name.into()),
1439 }
1440 }
1441
1442 /// The requested opacity of the widget.
1443 pub fn opacity(self, opacity: f64) -> Self {
1444 Self {
1445 builder: self.builder.property("opacity", opacity),
1446 }
1447 }
1448
1449 /// How content outside the widget's content area is treated.
1450 ///
1451 /// This property is meant to be set by widget implementations,
1452 /// typically in their instance init function.
1453 pub fn overflow(self, overflow: Overflow) -> Self {
1454 Self {
1455 builder: self.builder.property("overflow", overflow),
1456 }
1457 }
1458
1459 /// Whether the widget will receive the default action when it is focused.
1460 pub fn receives_default(self, receives_default: bool) -> Self {
1461 Self {
1462 builder: self.builder.property("receives-default", receives_default),
1463 }
1464 }
1465
1466 /// Whether the widget responds to input.
1467 pub fn sensitive(self, sensitive: bool) -> Self {
1468 Self {
1469 builder: self.builder.property("sensitive", sensitive),
1470 }
1471 }
1472
1473 /// Sets the text of tooltip to be the given string, which is marked up
1474 /// with Pango markup.
1475 ///
1476 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1477 ///
1478 /// This is a convenience property which will take care of getting the
1479 /// tooltip shown if the given string is not `NULL`:
1480 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1481 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1482 /// the default signal handler.
1483 ///
1484 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1485 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1486 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1487 Self {
1488 builder: self
1489 .builder
1490 .property("tooltip-markup", tooltip_markup.into()),
1491 }
1492 }
1493
1494 /// Sets the text of tooltip to be the given string.
1495 ///
1496 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1497 ///
1498 /// This is a convenience property which will take care of getting the
1499 /// tooltip shown if the given string is not `NULL`:
1500 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1501 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1502 /// the default signal handler.
1503 ///
1504 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1505 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1506 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1507 Self {
1508 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1509 }
1510 }
1511
1512 /// How to distribute vertical space if widget gets extra space.
1513 pub fn valign(self, valign: Align) -> Self {
1514 Self {
1515 builder: self.builder.property("valign", valign),
1516 }
1517 }
1518
1519 /// Whether to expand vertically.
1520 pub fn vexpand(self, vexpand: bool) -> Self {
1521 Self {
1522 builder: self.builder.property("vexpand", vexpand),
1523 }
1524 }
1525
1526 /// Whether to use the `vexpand` property.
1527 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1528 Self {
1529 builder: self.builder.property("vexpand-set", vexpand_set),
1530 }
1531 }
1532
1533 /// Whether the widget is visible.
1534 pub fn visible(self, visible: bool) -> Self {
1535 Self {
1536 builder: self.builder.property("visible", visible),
1537 }
1538 }
1539
1540 /// Overrides for width request of the widget.
1541 ///
1542 /// If this is -1, the natural request will be used.
1543 pub fn width_request(self, width_request: i32) -> Self {
1544 Self {
1545 builder: self.builder.property("width-request", width_request),
1546 }
1547 }
1548
1549 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1550 ///
1551 /// The accessible role cannot be changed once set.
1552 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1553 Self {
1554 builder: self.builder.property("accessible-role", accessible_role),
1555 }
1556 }
1557
1558 // rustdoc-stripper-ignore-next
1559 /// Build the [`Calendar`].
1560 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1561 pub fn build(self) -> Calendar {
1562 assert_initialized_main_thread!();
1563 self.builder.build()
1564 }
1565}