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