libadwaita/auto/
clamp_scrollable.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::ffi;
7#[cfg(feature = "v1_4")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
9use crate::LengthUnit;
10use glib::{
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    /// A scrollable [`Clamp`][crate::Clamp].
19    ///
20    /// [`ClampScrollable`][crate::ClampScrollable] is a variant of [`Clamp`][crate::Clamp] that implements the
21    /// [`gtk::Scrollable`][crate::gtk::Scrollable] interface.
22    ///
23    /// The primary use case for [`ClampScrollable`][crate::ClampScrollable] is clamping
24    /// [`gtk::ListView`][crate::gtk::ListView].
25    ///
26    /// See also: [`ClampLayout`][crate::ClampLayout].
27    ///
28    /// ## Properties
29    ///
30    ///
31    /// #### `child`
32    ///  The child widget of the [`ClampScrollable`][crate::ClampScrollable].
33    ///
34    /// Readable | Writeable
35    ///
36    ///
37    /// #### `maximum-size`
38    ///  The maximum size allocated to the child.
39    ///
40    /// It is the width if the clamp is horizontal, or the height if it is vertical.
41    ///
42    /// Readable | Writeable
43    ///
44    ///
45    /// #### `tightening-threshold`
46    ///  The size above which the child is clamped.
47    ///
48    /// Starting from this size, the clamp will tighten its grip on the child,
49    /// slowly allocating less and less of the available size up to the maximum
50    /// allocated size. Below that threshold and below the maximum width, the child
51    /// will be allocated all the available size.
52    ///
53    /// If the threshold is greater than the maximum size to allocate to the child,
54    /// the child will be allocated all the width up to the maximum.
55    /// If the threshold is lower than the minimum size to allocate to the child,
56    /// that size will be used as the tightening threshold.
57    ///
58    /// Effectively, tightening the grip on the child before it reaches its maximum
59    /// size makes transitions to and from the maximum size smoother when resizing.
60    ///
61    /// Readable | Writeable
62    ///
63    ///
64    /// #### `unit`
65    ///  The length unit for maximum size and tightening threshold.
66    ///
67    /// Allows the sizes to vary depending on the text scale factor.
68    ///
69    /// Readable | Writeable
70    /// <details><summary><h4>Widget</h4></summary>
71    ///
72    ///
73    /// #### `can-focus`
74    ///  Whether the widget or any of its descendents can accept
75    /// the input focus.
76    ///
77    /// This property is meant to be set by widget implementations,
78    /// typically in their instance init function.
79    ///
80    /// Readable | Writeable
81    ///
82    ///
83    /// #### `can-target`
84    ///  Whether the widget can receive pointer events.
85    ///
86    /// Readable | Writeable
87    ///
88    ///
89    /// #### `css-classes`
90    ///  A list of css classes applied to this widget.
91    ///
92    /// Readable | Writeable
93    ///
94    ///
95    /// #### `css-name`
96    ///  The name of this widget in the CSS tree.
97    ///
98    /// This property is meant to be set by widget implementations,
99    /// typically in their instance init function.
100    ///
101    /// Readable | Writeable | Construct Only
102    ///
103    ///
104    /// #### `cursor`
105    ///  The cursor used by @widget.
106    ///
107    /// Readable | Writeable
108    ///
109    ///
110    /// #### `focus-on-click`
111    ///  Whether the widget should grab focus when it is clicked with the mouse.
112    ///
113    /// This property is only relevant for widgets that can take focus.
114    ///
115    /// Readable | Writeable
116    ///
117    ///
118    /// #### `focusable`
119    ///  Whether this widget itself will accept the input focus.
120    ///
121    /// Readable | Writeable
122    ///
123    ///
124    /// #### `halign`
125    ///  How to distribute horizontal space if widget gets extra space.
126    ///
127    /// Readable | Writeable
128    ///
129    ///
130    /// #### `has-default`
131    ///  Whether the widget is the default widget.
132    ///
133    /// Readable
134    ///
135    ///
136    /// #### `has-focus`
137    ///  Whether the widget has the input focus.
138    ///
139    /// Readable
140    ///
141    ///
142    /// #### `has-tooltip`
143    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
144    /// signal on @widget.
145    ///
146    /// A true value indicates that @widget can have a tooltip, in this case
147    /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
148    /// determine whether it will provide a tooltip or not.
149    ///
150    /// Readable | Writeable
151    ///
152    ///
153    /// #### `height-request`
154    ///  Overrides for height request of the widget.
155    ///
156    /// If this is -1, the natural request will be used.
157    ///
158    /// Readable | Writeable
159    ///
160    ///
161    /// #### `hexpand`
162    ///  Whether to expand horizontally.
163    ///
164    /// Readable | Writeable
165    ///
166    ///
167    /// #### `hexpand-set`
168    ///  Whether to use the `hexpand` property.
169    ///
170    /// Readable | Writeable
171    ///
172    ///
173    /// #### `layout-manager`
174    ///  The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
175    /// the preferred size of the widget, and allocate its children.
176    ///
177    /// This property is meant to be set by widget implementations,
178    /// typically in their instance init function.
179    ///
180    /// Readable | Writeable
181    ///
182    ///
183    /// #### `limit-events`
184    ///  Makes this widget act like a modal dialog, with respect to
185    /// event delivery.
186    ///
187    /// Global event controllers will not handle events with targets
188    /// inside the widget, unless they are set up to ignore propagation
189    /// limits. See `Gtk::EventController::set_propagation_limit()`.
190    ///
191    /// Readable | Writeable
192    ///
193    ///
194    /// #### `margin-bottom`
195    ///  Margin on bottom side of widget.
196    ///
197    /// This property adds margin outside of the widget's normal size
198    /// request, the margin will be added in addition to the size from
199    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
200    ///
201    /// Readable | Writeable
202    ///
203    ///
204    /// #### `margin-end`
205    ///  Margin on end of widget, horizontally.
206    ///
207    /// This property supports left-to-right and right-to-left text
208    /// directions.
209    ///
210    /// This property adds margin outside of the widget's normal size
211    /// request, the margin will be added in addition to the size from
212    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
213    ///
214    /// Readable | Writeable
215    ///
216    ///
217    /// #### `margin-start`
218    ///  Margin on start of widget, horizontally.
219    ///
220    /// This property supports left-to-right and right-to-left text
221    /// directions.
222    ///
223    /// This property adds margin outside of the widget's normal size
224    /// request, the margin will be added in addition to the size from
225    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
226    ///
227    /// Readable | Writeable
228    ///
229    ///
230    /// #### `margin-top`
231    ///  Margin on top side of widget.
232    ///
233    /// This property adds margin outside of the widget's normal size
234    /// request, the margin will be added in addition to the size from
235    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
236    ///
237    /// Readable | Writeable
238    ///
239    ///
240    /// #### `name`
241    ///  The name of the widget.
242    ///
243    /// Readable | Writeable
244    ///
245    ///
246    /// #### `opacity`
247    ///  The requested opacity of the widget.
248    ///
249    /// Readable | Writeable
250    ///
251    ///
252    /// #### `overflow`
253    ///  How content outside the widget's content area is treated.
254    ///
255    /// This property is meant to be set by widget implementations,
256    /// typically in their instance init function.
257    ///
258    /// Readable | Writeable
259    ///
260    ///
261    /// #### `parent`
262    ///  The parent widget of this widget.
263    ///
264    /// Readable
265    ///
266    ///
267    /// #### `receives-default`
268    ///  Whether the widget will receive the default action when it is focused.
269    ///
270    /// Readable | Writeable
271    ///
272    ///
273    /// #### `root`
274    ///  The [`gtk::Root`][crate::gtk::Root] widget of the widget tree containing this widget.
275    ///
276    /// This will be `NULL` if the widget is not contained in a root widget.
277    ///
278    /// Readable
279    ///
280    ///
281    /// #### `scale-factor`
282    ///  The scale factor of the widget.
283    ///
284    /// Readable
285    ///
286    ///
287    /// #### `sensitive`
288    ///  Whether the widget responds to input.
289    ///
290    /// Readable | Writeable
291    ///
292    ///
293    /// #### `tooltip-markup`
294    ///  Sets the text of tooltip to be the given string, which is marked up
295    /// with Pango markup.
296    ///
297    /// Also see `Gtk::Tooltip::set_markup()`.
298    ///
299    /// This is a convenience property which will take care of getting the
300    /// tooltip shown if the given string is not `NULL`:
301    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
302    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
303    /// the default signal handler.
304    ///
305    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
306    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
307    ///
308    /// Readable | Writeable
309    ///
310    ///
311    /// #### `tooltip-text`
312    ///  Sets the text of tooltip to be the given string.
313    ///
314    /// Also see `Gtk::Tooltip::set_text()`.
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::gtk::Widget#has-tooltip] will automatically be set to true
319    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
320    /// the default signal handler.
321    ///
322    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
323    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
324    ///
325    /// Readable | Writeable
326    ///
327    ///
328    /// #### `valign`
329    ///  How to distribute vertical space if widget gets extra space.
330    ///
331    /// Readable | Writeable
332    ///
333    ///
334    /// #### `vexpand`
335    ///  Whether to expand vertically.
336    ///
337    /// Readable | Writeable
338    ///
339    ///
340    /// #### `vexpand-set`
341    ///  Whether to use the `vexpand` property.
342    ///
343    /// Readable | Writeable
344    ///
345    ///
346    /// #### `visible`
347    ///  Whether the widget is visible.
348    ///
349    /// Readable | Writeable
350    ///
351    ///
352    /// #### `width-request`
353    ///  Overrides for width request of the widget.
354    ///
355    /// If this is -1, the natural request will be used.
356    ///
357    /// Readable | Writeable
358    /// </details>
359    /// <details><summary><h4>Accessible</h4></summary>
360    ///
361    ///
362    /// #### `accessible-role`
363    ///  The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
364    ///
365    /// The accessible role cannot be changed once set.
366    ///
367    /// Readable | Writeable
368    /// </details>
369    /// <details><summary><h4>Orientable</h4></summary>
370    ///
371    ///
372    /// #### `orientation`
373    ///  The orientation of the orientable.
374    ///
375    /// Readable | Writeable
376    /// </details>
377    /// <details><summary><h4>Scrollable</h4></summary>
378    ///
379    ///
380    /// #### `hadjustment`
381    ///  Horizontal [`gtk::Adjustment`][crate::gtk::Adjustment] of the scrollable widget.
382    ///
383    /// This adjustment is shared between the scrollable widget and its parent.
384    ///
385    /// Readable | Writeable | Construct
386    ///
387    ///
388    /// #### `hscroll-policy`
389    ///  Determines when horizontal scrolling should start.
390    ///
391    /// Readable | Writeable
392    ///
393    ///
394    /// #### `vadjustment`
395    ///  Vertical [`gtk::Adjustment`][crate::gtk::Adjustment] of the scrollable widget.
396    ///
397    /// This adjustment is shared between the scrollable widget and its parent.
398    ///
399    /// Readable | Writeable | Construct
400    ///
401    ///
402    /// #### `vscroll-policy`
403    ///  Determines when vertical scrolling should start.
404    ///
405    /// Readable | Writeable
406    /// </details>
407    ///
408    /// # Implements
409    ///
410    /// [`trait@gtk::prelude::WidgetExt`], [`trait@glib::ObjectExt`], [`trait@gtk::prelude::AccessibleExt`], [`trait@gtk::prelude::BuildableExt`], [`trait@gtk::prelude::ConstraintTargetExt`], [`trait@gtk::prelude::OrientableExt`], [`trait@gtk::prelude::ScrollableExt`]
411    #[doc(alias = "AdwClampScrollable")]
412    pub struct ClampScrollable(Object<ffi::AdwClampScrollable, ffi::AdwClampScrollableClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable, gtk::Scrollable;
413
414    match fn {
415        type_ => || ffi::adw_clamp_scrollable_get_type(),
416    }
417}
418
419impl ClampScrollable {
420    /// Creates a new [`ClampScrollable`][crate::ClampScrollable].
421    ///
422    /// # Returns
423    ///
424    /// the newly created [`ClampScrollable`][crate::ClampScrollable]
425    #[doc(alias = "adw_clamp_scrollable_new")]
426    pub fn new() -> ClampScrollable {
427        assert_initialized_main_thread!();
428        unsafe { gtk::Widget::from_glib_none(ffi::adw_clamp_scrollable_new()).unsafe_cast() }
429    }
430
431    // rustdoc-stripper-ignore-next
432    /// Creates a new builder-pattern struct instance to construct [`ClampScrollable`] objects.
433    ///
434    /// This method returns an instance of [`ClampScrollableBuilder`](crate::builders::ClampScrollableBuilder) which can be used to create [`ClampScrollable`] objects.
435    pub fn builder() -> ClampScrollableBuilder {
436        ClampScrollableBuilder::new()
437    }
438
439    /// Gets the child widget of @self.
440    ///
441    /// # Returns
442    ///
443    /// the child widget of @self
444    #[doc(alias = "adw_clamp_scrollable_get_child")]
445    #[doc(alias = "get_child")]
446    pub fn child(&self) -> Option<gtk::Widget> {
447        unsafe { from_glib_none(ffi::adw_clamp_scrollable_get_child(self.to_glib_none().0)) }
448    }
449
450    /// Gets the maximum size allocated to the child.
451    ///
452    /// # Returns
453    ///
454    /// the maximum size to allocate to the child
455    #[doc(alias = "adw_clamp_scrollable_get_maximum_size")]
456    #[doc(alias = "get_maximum_size")]
457    #[doc(alias = "maximum-size")]
458    pub fn maximum_size(&self) -> i32 {
459        unsafe { ffi::adw_clamp_scrollable_get_maximum_size(self.to_glib_none().0) }
460    }
461
462    /// Gets the size above which the child is clamped.
463    ///
464    /// # Returns
465    ///
466    /// the size above which the child is clamped
467    #[doc(alias = "adw_clamp_scrollable_get_tightening_threshold")]
468    #[doc(alias = "get_tightening_threshold")]
469    #[doc(alias = "tightening-threshold")]
470    pub fn tightening_threshold(&self) -> i32 {
471        unsafe { ffi::adw_clamp_scrollable_get_tightening_threshold(self.to_glib_none().0) }
472    }
473
474    /// Gets the length unit for maximum size and tightening threshold.
475    ///
476    /// # Returns
477    ///
478    /// the length unit
479    #[cfg(feature = "v1_4")]
480    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
481    #[doc(alias = "adw_clamp_scrollable_get_unit")]
482    #[doc(alias = "get_unit")]
483    pub fn unit(&self) -> LengthUnit {
484        unsafe { from_glib(ffi::adw_clamp_scrollable_get_unit(self.to_glib_none().0)) }
485    }
486
487    /// Sets the child widget of @self.
488    /// ## `child`
489    /// the child widget
490    #[doc(alias = "adw_clamp_scrollable_set_child")]
491    #[doc(alias = "child")]
492    pub fn set_child(&self, child: Option<&impl IsA<gtk::Widget>>) {
493        unsafe {
494            ffi::adw_clamp_scrollable_set_child(
495                self.to_glib_none().0,
496                child.map(|p| p.as_ref()).to_glib_none().0,
497            );
498        }
499    }
500
501    /// Sets the maximum size allocated to the child.
502    ///
503    /// It is the width if the clamp is horizontal, or the height if it is vertical.
504    /// ## `maximum_size`
505    /// the maximum size
506    #[doc(alias = "adw_clamp_scrollable_set_maximum_size")]
507    #[doc(alias = "maximum-size")]
508    pub fn set_maximum_size(&self, maximum_size: i32) {
509        unsafe {
510            ffi::adw_clamp_scrollable_set_maximum_size(self.to_glib_none().0, maximum_size);
511        }
512    }
513
514    /// Sets the size above which the child is clamped.
515    ///
516    /// Starting from this size, the clamp will tighten its grip on the child, slowly
517    /// allocating less and less of the available size up to the maximum allocated
518    /// size. Below that threshold and below the maximum width, the child will be
519    /// allocated all the available size.
520    ///
521    /// If the threshold is greater than the maximum size to allocate to the child,
522    /// the child will be allocated all the width up to the maximum. If the threshold
523    /// is lower than the minimum size to allocate to the child, that size will be
524    /// used as the tightening threshold.
525    ///
526    /// Effectively, tightening the grip on the child before it reaches its maximum
527    /// size makes transitions to and from the maximum size smoother when resizing.
528    /// ## `tightening_threshold`
529    /// the tightening threshold
530    #[doc(alias = "adw_clamp_scrollable_set_tightening_threshold")]
531    #[doc(alias = "tightening-threshold")]
532    pub fn set_tightening_threshold(&self, tightening_threshold: i32) {
533        unsafe {
534            ffi::adw_clamp_scrollable_set_tightening_threshold(
535                self.to_glib_none().0,
536                tightening_threshold,
537            );
538        }
539    }
540
541    /// Sets the length unit for maximum size and tightening threshold.
542    ///
543    /// Allows the sizes to vary depending on the text scale factor.
544    /// ## `unit`
545    /// the length unit
546    #[cfg(feature = "v1_4")]
547    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
548    #[doc(alias = "adw_clamp_scrollable_set_unit")]
549    #[doc(alias = "unit")]
550    pub fn set_unit(&self, unit: LengthUnit) {
551        unsafe {
552            ffi::adw_clamp_scrollable_set_unit(self.to_glib_none().0, unit.into_glib());
553        }
554    }
555
556    #[doc(alias = "child")]
557    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
558        unsafe extern "C" fn notify_child_trampoline<F: Fn(&ClampScrollable) + 'static>(
559            this: *mut ffi::AdwClampScrollable,
560            _param_spec: glib::ffi::gpointer,
561            f: glib::ffi::gpointer,
562        ) {
563            let f: &F = &*(f as *const F);
564            f(&from_glib_borrow(this))
565        }
566        unsafe {
567            let f: Box_<F> = Box_::new(f);
568            connect_raw(
569                self.as_ptr() as *mut _,
570                c"notify::child".as_ptr() as *const _,
571                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
572                    notify_child_trampoline::<F> as *const (),
573                )),
574                Box_::into_raw(f),
575            )
576        }
577    }
578
579    #[doc(alias = "maximum-size")]
580    pub fn connect_maximum_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
581        unsafe extern "C" fn notify_maximum_size_trampoline<F: Fn(&ClampScrollable) + 'static>(
582            this: *mut ffi::AdwClampScrollable,
583            _param_spec: glib::ffi::gpointer,
584            f: glib::ffi::gpointer,
585        ) {
586            let f: &F = &*(f as *const F);
587            f(&from_glib_borrow(this))
588        }
589        unsafe {
590            let f: Box_<F> = Box_::new(f);
591            connect_raw(
592                self.as_ptr() as *mut _,
593                c"notify::maximum-size".as_ptr() as *const _,
594                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
595                    notify_maximum_size_trampoline::<F> as *const (),
596                )),
597                Box_::into_raw(f),
598            )
599        }
600    }
601
602    #[doc(alias = "tightening-threshold")]
603    pub fn connect_tightening_threshold_notify<F: Fn(&Self) + 'static>(
604        &self,
605        f: F,
606    ) -> SignalHandlerId {
607        unsafe extern "C" fn notify_tightening_threshold_trampoline<
608            F: Fn(&ClampScrollable) + 'static,
609        >(
610            this: *mut ffi::AdwClampScrollable,
611            _param_spec: glib::ffi::gpointer,
612            f: glib::ffi::gpointer,
613        ) {
614            let f: &F = &*(f as *const F);
615            f(&from_glib_borrow(this))
616        }
617        unsafe {
618            let f: Box_<F> = Box_::new(f);
619            connect_raw(
620                self.as_ptr() as *mut _,
621                c"notify::tightening-threshold".as_ptr() as *const _,
622                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
623                    notify_tightening_threshold_trampoline::<F> as *const (),
624                )),
625                Box_::into_raw(f),
626            )
627        }
628    }
629
630    #[cfg(feature = "v1_4")]
631    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
632    #[doc(alias = "unit")]
633    pub fn connect_unit_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
634        unsafe extern "C" fn notify_unit_trampoline<F: Fn(&ClampScrollable) + 'static>(
635            this: *mut ffi::AdwClampScrollable,
636            _param_spec: glib::ffi::gpointer,
637            f: glib::ffi::gpointer,
638        ) {
639            let f: &F = &*(f as *const F);
640            f(&from_glib_borrow(this))
641        }
642        unsafe {
643            let f: Box_<F> = Box_::new(f);
644            connect_raw(
645                self.as_ptr() as *mut _,
646                c"notify::unit".as_ptr() as *const _,
647                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
648                    notify_unit_trampoline::<F> as *const (),
649                )),
650                Box_::into_raw(f),
651            )
652        }
653    }
654}
655
656impl Default for ClampScrollable {
657    fn default() -> Self {
658        Self::new()
659    }
660}
661
662// rustdoc-stripper-ignore-next
663/// A [builder-pattern] type to construct [`ClampScrollable`] objects.
664///
665/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
666#[must_use = "The builder must be built to be used"]
667pub struct ClampScrollableBuilder {
668    builder: glib::object::ObjectBuilder<'static, ClampScrollable>,
669}
670
671impl ClampScrollableBuilder {
672    fn new() -> Self {
673        Self {
674            builder: glib::object::Object::builder(),
675        }
676    }
677
678    /// The child widget of the [`ClampScrollable`][crate::ClampScrollable].
679    pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
680        Self {
681            builder: self.builder.property("child", child.clone().upcast()),
682        }
683    }
684
685    /// The maximum size allocated to the child.
686    ///
687    /// It is the width if the clamp is horizontal, or the height if it is vertical.
688    pub fn maximum_size(self, maximum_size: i32) -> Self {
689        Self {
690            builder: self.builder.property("maximum-size", maximum_size),
691        }
692    }
693
694    /// The size above which the child is clamped.
695    ///
696    /// Starting from this size, the clamp will tighten its grip on the child,
697    /// slowly allocating less and less of the available size up to the maximum
698    /// allocated size. Below that threshold and below the maximum width, the child
699    /// will be allocated all the available size.
700    ///
701    /// If the threshold is greater than the maximum size to allocate to the child,
702    /// the child will be allocated all the width up to the maximum.
703    /// If the threshold is lower than the minimum size to allocate to the child,
704    /// that size will be used as the tightening threshold.
705    ///
706    /// Effectively, tightening the grip on the child before it reaches its maximum
707    /// size makes transitions to and from the maximum size smoother when resizing.
708    pub fn tightening_threshold(self, tightening_threshold: i32) -> Self {
709        Self {
710            builder: self
711                .builder
712                .property("tightening-threshold", tightening_threshold),
713        }
714    }
715
716    /// The length unit for maximum size and tightening threshold.
717    ///
718    /// Allows the sizes to vary depending on the text scale factor.
719    #[cfg(feature = "v1_4")]
720    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
721    pub fn unit(self, unit: LengthUnit) -> Self {
722        Self {
723            builder: self.builder.property("unit", unit),
724        }
725    }
726
727    /// Whether the widget or any of its descendents can accept
728    /// the input focus.
729    ///
730    /// This property is meant to be set by widget implementations,
731    /// typically in their instance init function.
732    pub fn can_focus(self, can_focus: bool) -> Self {
733        Self {
734            builder: self.builder.property("can-focus", can_focus),
735        }
736    }
737
738    /// Whether the widget can receive pointer events.
739    pub fn can_target(self, can_target: bool) -> Self {
740        Self {
741            builder: self.builder.property("can-target", can_target),
742        }
743    }
744
745    /// A list of css classes applied to this widget.
746    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
747        Self {
748            builder: self.builder.property("css-classes", css_classes.into()),
749        }
750    }
751
752    /// The name of this widget in the CSS tree.
753    ///
754    /// This property is meant to be set by widget implementations,
755    /// typically in their instance init function.
756    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
757        Self {
758            builder: self.builder.property("css-name", css_name.into()),
759        }
760    }
761
762    /// The cursor used by @widget.
763    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
764        Self {
765            builder: self.builder.property("cursor", cursor.clone()),
766        }
767    }
768
769    /// Whether the widget should grab focus when it is clicked with the mouse.
770    ///
771    /// This property is only relevant for widgets that can take focus.
772    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
773        Self {
774            builder: self.builder.property("focus-on-click", focus_on_click),
775        }
776    }
777
778    /// Whether this widget itself will accept the input focus.
779    pub fn focusable(self, focusable: bool) -> Self {
780        Self {
781            builder: self.builder.property("focusable", focusable),
782        }
783    }
784
785    /// How to distribute horizontal space if widget gets extra space.
786    pub fn halign(self, halign: gtk::Align) -> Self {
787        Self {
788            builder: self.builder.property("halign", halign),
789        }
790    }
791
792    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
793    /// signal on @widget.
794    ///
795    /// A true value indicates that @widget can have a tooltip, in this case
796    /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
797    /// determine whether it will provide a tooltip or not.
798    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
799        Self {
800            builder: self.builder.property("has-tooltip", has_tooltip),
801        }
802    }
803
804    /// Overrides for height request of the widget.
805    ///
806    /// If this is -1, the natural request will be used.
807    pub fn height_request(self, height_request: i32) -> Self {
808        Self {
809            builder: self.builder.property("height-request", height_request),
810        }
811    }
812
813    /// Whether to expand horizontally.
814    pub fn hexpand(self, hexpand: bool) -> Self {
815        Self {
816            builder: self.builder.property("hexpand", hexpand),
817        }
818    }
819
820    /// Whether to use the `hexpand` property.
821    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
822        Self {
823            builder: self.builder.property("hexpand-set", hexpand_set),
824        }
825    }
826
827    /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
828    /// the preferred size of the widget, and allocate its children.
829    ///
830    /// This property is meant to be set by widget implementations,
831    /// typically in their instance init function.
832    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
833        Self {
834            builder: self
835                .builder
836                .property("layout-manager", layout_manager.clone().upcast()),
837        }
838    }
839
840    /// Makes this widget act like a modal dialog, with respect to
841    /// event delivery.
842    ///
843    /// Global event controllers will not handle events with targets
844    /// inside the widget, unless they are set up to ignore propagation
845    /// limits. See `Gtk::EventController::set_propagation_limit()`.
846    #[cfg(feature = "gtk_v4_18")]
847    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
848    pub fn limit_events(self, limit_events: bool) -> Self {
849        Self {
850            builder: self.builder.property("limit-events", limit_events),
851        }
852    }
853
854    /// Margin on bottom side of widget.
855    ///
856    /// This property adds margin outside of the widget's normal size
857    /// request, the margin will be added in addition to the size from
858    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
859    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
860        Self {
861            builder: self.builder.property("margin-bottom", margin_bottom),
862        }
863    }
864
865    /// Margin on end of widget, horizontally.
866    ///
867    /// This property supports left-to-right and right-to-left text
868    /// directions.
869    ///
870    /// This property adds margin outside of the widget's normal size
871    /// request, the margin will be added in addition to the size from
872    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
873    pub fn margin_end(self, margin_end: i32) -> Self {
874        Self {
875            builder: self.builder.property("margin-end", margin_end),
876        }
877    }
878
879    /// Margin on start of widget, horizontally.
880    ///
881    /// This property supports left-to-right and right-to-left text
882    /// directions.
883    ///
884    /// This property adds margin outside of the widget's normal size
885    /// request, the margin will be added in addition to the size from
886    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
887    pub fn margin_start(self, margin_start: i32) -> Self {
888        Self {
889            builder: self.builder.property("margin-start", margin_start),
890        }
891    }
892
893    /// Margin on top side of widget.
894    ///
895    /// This property adds margin outside of the widget's normal size
896    /// request, the margin will be added in addition to the size from
897    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
898    pub fn margin_top(self, margin_top: i32) -> Self {
899        Self {
900            builder: self.builder.property("margin-top", margin_top),
901        }
902    }
903
904    /// The name of the widget.
905    pub fn name(self, name: impl Into<glib::GString>) -> Self {
906        Self {
907            builder: self.builder.property("name", name.into()),
908        }
909    }
910
911    /// The requested opacity of the widget.
912    pub fn opacity(self, opacity: f64) -> Self {
913        Self {
914            builder: self.builder.property("opacity", opacity),
915        }
916    }
917
918    /// How content outside the widget's content area is treated.
919    ///
920    /// This property is meant to be set by widget implementations,
921    /// typically in their instance init function.
922    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
923        Self {
924            builder: self.builder.property("overflow", overflow),
925        }
926    }
927
928    /// Whether the widget will receive the default action when it is focused.
929    pub fn receives_default(self, receives_default: bool) -> Self {
930        Self {
931            builder: self.builder.property("receives-default", receives_default),
932        }
933    }
934
935    /// Whether the widget responds to input.
936    pub fn sensitive(self, sensitive: bool) -> Self {
937        Self {
938            builder: self.builder.property("sensitive", sensitive),
939        }
940    }
941
942    /// Sets the text of tooltip to be the given string, which is marked up
943    /// with Pango markup.
944    ///
945    /// Also see `Gtk::Tooltip::set_markup()`.
946    ///
947    /// This is a convenience property which will take care of getting the
948    /// tooltip shown if the given string is not `NULL`:
949    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
950    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
951    /// the default signal handler.
952    ///
953    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
954    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
955    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
956        Self {
957            builder: self
958                .builder
959                .property("tooltip-markup", tooltip_markup.into()),
960        }
961    }
962
963    /// Sets the text of tooltip to be the given string.
964    ///
965    /// Also see `Gtk::Tooltip::set_text()`.
966    ///
967    /// This is a convenience property which will take care of getting the
968    /// tooltip shown if the given string is not `NULL`:
969    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
970    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
971    /// the default signal handler.
972    ///
973    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
974    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
975    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
976        Self {
977            builder: self.builder.property("tooltip-text", tooltip_text.into()),
978        }
979    }
980
981    /// How to distribute vertical space if widget gets extra space.
982    pub fn valign(self, valign: gtk::Align) -> Self {
983        Self {
984            builder: self.builder.property("valign", valign),
985        }
986    }
987
988    /// Whether to expand vertically.
989    pub fn vexpand(self, vexpand: bool) -> Self {
990        Self {
991            builder: self.builder.property("vexpand", vexpand),
992        }
993    }
994
995    /// Whether to use the `vexpand` property.
996    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
997        Self {
998            builder: self.builder.property("vexpand-set", vexpand_set),
999        }
1000    }
1001
1002    /// Whether the widget is visible.
1003    pub fn visible(self, visible: bool) -> Self {
1004        Self {
1005            builder: self.builder.property("visible", visible),
1006        }
1007    }
1008
1009    /// Overrides for width request of the widget.
1010    ///
1011    /// If this is -1, the natural request will be used.
1012    pub fn width_request(self, width_request: i32) -> Self {
1013        Self {
1014            builder: self.builder.property("width-request", width_request),
1015        }
1016    }
1017
1018    /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
1019    ///
1020    /// The accessible role cannot be changed once set.
1021    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
1022        Self {
1023            builder: self.builder.property("accessible-role", accessible_role),
1024        }
1025    }
1026
1027    /// The orientation of the orientable.
1028    pub fn orientation(self, orientation: gtk::Orientation) -> Self {
1029        Self {
1030            builder: self.builder.property("orientation", orientation),
1031        }
1032    }
1033
1034    /// Horizontal [`gtk::Adjustment`][crate::gtk::Adjustment] of the scrollable widget.
1035    ///
1036    /// This adjustment is shared between the scrollable widget and its parent.
1037    pub fn hadjustment(self, hadjustment: &impl IsA<gtk::Adjustment>) -> Self {
1038        Self {
1039            builder: self
1040                .builder
1041                .property("hadjustment", hadjustment.clone().upcast()),
1042        }
1043    }
1044
1045    /// Determines when horizontal scrolling should start.
1046    pub fn hscroll_policy(self, hscroll_policy: gtk::ScrollablePolicy) -> Self {
1047        Self {
1048            builder: self.builder.property("hscroll-policy", hscroll_policy),
1049        }
1050    }
1051
1052    /// Vertical [`gtk::Adjustment`][crate::gtk::Adjustment] of the scrollable widget.
1053    ///
1054    /// This adjustment is shared between the scrollable widget and its parent.
1055    pub fn vadjustment(self, vadjustment: &impl IsA<gtk::Adjustment>) -> Self {
1056        Self {
1057            builder: self
1058                .builder
1059                .property("vadjustment", vadjustment.clone().upcast()),
1060        }
1061    }
1062
1063    /// Determines when vertical scrolling should start.
1064    pub fn vscroll_policy(self, vscroll_policy: gtk::ScrollablePolicy) -> Self {
1065        Self {
1066            builder: self.builder.property("vscroll-policy", vscroll_policy),
1067        }
1068    }
1069
1070    // rustdoc-stripper-ignore-next
1071    /// Build the [`ClampScrollable`].
1072    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1073    pub fn build(self) -> ClampScrollable {
1074        assert_initialized_main_thread!();
1075        self.builder.build()
1076    }
1077}