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