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