Skip to main content

gtk/auto/
layout.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    Adjustment, Align, Buildable, Container, ResizeMode, Scrollable, ScrollablePolicy, Widget, ffi,
7};
8use glib::{
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    /// [`Layout`][crate::Layout] is similar to [`DrawingArea`][crate::DrawingArea] in that it’s a “blank slate” and
17    /// doesn’t do anything except paint a blank background by default. It’s
18    /// different in that it supports scrolling natively due to implementing
19    /// [`Scrollable`][crate::Scrollable], and can contain child widgets since it’s a [`Container`][crate::Container].
20    ///
21    /// If you just want to draw, a [`DrawingArea`][crate::DrawingArea] is a better choice since it has
22    /// lower overhead. If you just need to position child widgets at specific
23    /// points, then [`Fixed`][crate::Fixed] provides that functionality on its own.
24    ///
25    /// When handling expose events on a [`Layout`][crate::Layout], you must draw to the [`gdk::Window`][crate::gdk::Window]
26    /// returned by [`LayoutExt::bin_window()`][crate::prelude::LayoutExt::bin_window()], rather than to the one returned by
27    /// [`WidgetExt::window()`][crate::prelude::WidgetExt::window()] as you would for a [`DrawingArea`][crate::DrawingArea].
28    ///
29    /// ## Properties
30    ///
31    ///
32    /// #### `height`
33    ///  Readable | Writable
34    ///
35    ///
36    /// #### `width`
37    ///  Readable | Writable
38    /// <details><summary><h4>Container</h4></summary>
39    ///
40    ///
41    /// #### `border-width`
42    ///  Readable | Writable
43    ///
44    ///
45    /// #### `child`
46    ///  Writable
47    ///
48    ///
49    /// #### `resize-mode`
50    ///  Readable | Writable
51    /// </details>
52    /// <details><summary><h4>Widget</h4></summary>
53    ///
54    ///
55    /// #### `app-paintable`
56    ///  Readable | Writable
57    ///
58    ///
59    /// #### `can-default`
60    ///  Readable | Writable
61    ///
62    ///
63    /// #### `can-focus`
64    ///  Readable | Writable
65    ///
66    ///
67    /// #### `composite-child`
68    ///  Readable
69    ///
70    ///
71    /// #### `double-buffered`
72    ///  Whether the widget is double buffered.
73    ///
74    /// Readable | Writable
75    ///
76    ///
77    /// #### `events`
78    ///  Readable | Writable
79    ///
80    ///
81    /// #### `expand`
82    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
83    ///
84    /// Readable | Writable
85    ///
86    ///
87    /// #### `focus-on-click`
88    ///  Whether the widget should grab focus when it is clicked with the mouse.
89    ///
90    /// This property is only relevant for widgets that can take focus.
91    ///
92    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
93    /// GtkComboBox) implemented this property individually.
94    ///
95    /// Readable | Writable
96    ///
97    ///
98    /// #### `halign`
99    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
100    ///
101    /// Readable | Writable
102    ///
103    ///
104    /// #### `has-default`
105    ///  Readable | Writable
106    ///
107    ///
108    /// #### `has-focus`
109    ///  Readable | Writable
110    ///
111    ///
112    /// #### `has-tooltip`
113    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
114    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
115    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
116    /// whether it will provide a tooltip or not.
117    ///
118    /// Note that setting this property to [`true`] for the first time will change
119    /// the event masks of the GdkWindows of this widget to include leave-notify
120    /// and motion-notify events. This cannot and will not be undone when the
121    /// property is set to [`false`] again.
122    ///
123    /// Readable | Writable
124    ///
125    ///
126    /// #### `height-request`
127    ///  Readable | Writable
128    ///
129    ///
130    /// #### `hexpand`
131    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
132    ///
133    /// Readable | Writable
134    ///
135    ///
136    /// #### `hexpand-set`
137    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
138    ///
139    /// Readable | Writable
140    ///
141    ///
142    /// #### `is-focus`
143    ///  Readable | Writable
144    ///
145    ///
146    /// #### `margin`
147    ///  Sets all four sides' margin at once. If read, returns max
148    /// margin on any side.
149    ///
150    /// Readable | Writable
151    ///
152    ///
153    /// #### `margin-bottom`
154    ///  Margin on bottom side of widget.
155    ///
156    /// This property adds margin outside of the widget's normal size
157    /// request, the margin will be added in addition to the size from
158    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
159    ///
160    /// Readable | Writable
161    ///
162    ///
163    /// #### `margin-end`
164    ///  Margin on end of widget, horizontally. This property supports
165    /// left-to-right and right-to-left text directions.
166    ///
167    /// This property adds margin outside of the widget's normal size
168    /// request, the margin will be added in addition to the size from
169    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
170    ///
171    /// Readable | Writable
172    ///
173    ///
174    /// #### `margin-left`
175    ///  Margin on left side of widget.
176    ///
177    /// This property adds margin outside of the widget's normal size
178    /// request, the margin will be added in addition to the size from
179    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
180    ///
181    /// Readable | Writable
182    ///
183    ///
184    /// #### `margin-right`
185    ///  Margin on right side of widget.
186    ///
187    /// This property adds margin outside of the widget's normal size
188    /// request, the margin will be added in addition to the size from
189    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
190    ///
191    /// Readable | Writable
192    ///
193    ///
194    /// #### `margin-start`
195    ///  Margin on start of widget, horizontally. This property supports
196    /// left-to-right and right-to-left text directions.
197    ///
198    /// This property adds margin outside of the widget's normal size
199    /// request, the margin will be added in addition to the size from
200    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
201    ///
202    /// Readable | Writable
203    ///
204    ///
205    /// #### `margin-top`
206    ///  Margin on top side of widget.
207    ///
208    /// This property adds margin outside of the widget's normal size
209    /// request, the margin will be added in addition to the size from
210    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
211    ///
212    /// Readable | Writable
213    ///
214    ///
215    /// #### `name`
216    ///  Readable | Writable
217    ///
218    ///
219    /// #### `no-show-all`
220    ///  Readable | Writable
221    ///
222    ///
223    /// #### `opacity`
224    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
225    /// more details about window opacity.
226    ///
227    /// Before 3.8 this was only available in GtkWindow
228    ///
229    /// Readable | Writable
230    ///
231    ///
232    /// #### `parent`
233    ///  Readable | Writable
234    ///
235    ///
236    /// #### `receives-default`
237    ///  Readable | Writable
238    ///
239    ///
240    /// #### `scale-factor`
241    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
242    /// more details about widget scaling.
243    ///
244    /// Readable
245    ///
246    ///
247    /// #### `sensitive`
248    ///  Readable | Writable
249    ///
250    ///
251    /// #### `style`
252    ///  The style of the widget, which contains information about how it will look (colors, etc).
253    ///
254    /// Readable | Writable
255    ///
256    ///
257    /// #### `tooltip-markup`
258    ///  Sets the text of tooltip to be the given string, which is marked up
259    /// with the [Pango text markup language][PangoMarkupFormat].
260    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
261    ///
262    /// This is a convenience property which will take care of getting the
263    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
264    /// will automatically be set to [`true`] and there will be taken care of
265    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
266    ///
267    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
268    /// are set, the last one wins.
269    ///
270    /// Readable | Writable
271    ///
272    ///
273    /// #### `tooltip-text`
274    ///  Sets the text of tooltip to be the given string.
275    ///
276    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
277    ///
278    /// This is a convenience property which will take care of getting the
279    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
280    /// will automatically be set to [`true`] and there will be taken care of
281    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
282    ///
283    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
284    /// are set, the last one wins.
285    ///
286    /// Readable | Writable
287    ///
288    ///
289    /// #### `valign`
290    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
291    ///
292    /// Readable | Writable
293    ///
294    ///
295    /// #### `vexpand`
296    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
297    ///
298    /// Readable | Writable
299    ///
300    ///
301    /// #### `vexpand-set`
302    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
303    ///
304    /// Readable | Writable
305    ///
306    ///
307    /// #### `visible`
308    ///  Readable | Writable
309    ///
310    ///
311    /// #### `width-request`
312    ///  Readable | Writable
313    ///
314    ///
315    /// #### `window`
316    ///  The widget's window if it is realized, [`None`] otherwise.
317    ///
318    /// Readable
319    /// </details>
320    /// <details><summary><h4>Scrollable</h4></summary>
321    ///
322    ///
323    /// #### `hadjustment`
324    ///  Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget. This adjustment is
325    /// shared between the scrollable widget and its parent.
326    ///
327    /// Readable | Writable | Construct
328    ///
329    ///
330    /// #### `hscroll-policy`
331    ///  Determines whether horizontal scrolling should start once the scrollable
332    /// widget is allocated less than its minimum width or less than its natural width.
333    ///
334    /// Readable | Writable
335    ///
336    ///
337    /// #### `vadjustment`
338    ///  Verical [`Adjustment`][crate::Adjustment] of the scrollable widget. This adjustment is shared
339    /// between the scrollable widget and its parent.
340    ///
341    /// Readable | Writable | Construct
342    ///
343    ///
344    /// #### `vscroll-policy`
345    ///  Determines whether vertical scrolling should start once the scrollable
346    /// widget is allocated less than its minimum height or less than its natural height.
347    ///
348    /// Readable | Writable
349    /// </details>
350    ///
351    /// # Implements
352    ///
353    /// [`LayoutExt`][trait@crate::prelude::LayoutExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ScrollableExt`][trait@crate::prelude::ScrollableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
354    #[doc(alias = "GtkLayout")]
355    pub struct Layout(Object<ffi::GtkLayout, ffi::GtkLayoutClass>) @extends Container, Widget, @implements Buildable, Scrollable;
356
357    match fn {
358        type_ => || ffi::gtk_layout_get_type(),
359    }
360}
361
362impl Layout {
363    pub const NONE: Option<&'static Layout> = None;
364
365    /// Creates a new [`Layout`][crate::Layout]. Unless you have a specific adjustment
366    /// you’d like the layout to use for scrolling, pass [`None`] for
367    /// `hadjustment` and `vadjustment`.
368    /// ## `hadjustment`
369    /// horizontal scroll adjustment, or [`None`]
370    /// ## `vadjustment`
371    /// vertical scroll adjustment, or [`None`]
372    ///
373    /// # Returns
374    ///
375    /// a new [`Layout`][crate::Layout]
376    #[doc(alias = "gtk_layout_new")]
377    pub fn new(
378        hadjustment: Option<&impl IsA<Adjustment>>,
379        vadjustment: Option<&impl IsA<Adjustment>>,
380    ) -> Layout {
381        assert_initialized_main_thread!();
382        unsafe {
383            Widget::from_glib_none(ffi::gtk_layout_new(
384                hadjustment.map(|p| p.as_ref()).to_glib_none().0,
385                vadjustment.map(|p| p.as_ref()).to_glib_none().0,
386            ))
387            .unsafe_cast()
388        }
389    }
390
391    // rustdoc-stripper-ignore-next
392    /// Creates a new builder-pattern struct instance to construct [`Layout`] objects.
393    ///
394    /// This method returns an instance of [`LayoutBuilder`](crate::builders::LayoutBuilder) which can be used to create [`Layout`] objects.
395    pub fn builder() -> LayoutBuilder {
396        LayoutBuilder::new()
397    }
398}
399
400impl Default for Layout {
401    fn default() -> Self {
402        glib::object::Object::new::<Self>()
403    }
404}
405
406// rustdoc-stripper-ignore-next
407/// A [builder-pattern] type to construct [`Layout`] objects.
408///
409/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
410#[must_use = "The builder must be built to be used"]
411pub struct LayoutBuilder {
412    builder: glib::object::ObjectBuilder<'static, Layout>,
413}
414
415impl LayoutBuilder {
416    fn new() -> Self {
417        Self {
418            builder: glib::object::Object::builder(),
419        }
420    }
421
422    pub fn height(self, height: u32) -> Self {
423        Self {
424            builder: self.builder.property("height", height),
425        }
426    }
427
428    pub fn width(self, width: u32) -> Self {
429        Self {
430            builder: self.builder.property("width", width),
431        }
432    }
433
434    pub fn border_width(self, border_width: u32) -> Self {
435        Self {
436            builder: self.builder.property("border-width", border_width),
437        }
438    }
439
440    pub fn child(self, child: &impl IsA<Widget>) -> Self {
441        Self {
442            builder: self.builder.property("child", child.clone().upcast()),
443        }
444    }
445
446    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
447        Self {
448            builder: self.builder.property("resize-mode", resize_mode),
449        }
450    }
451
452    pub fn app_paintable(self, app_paintable: bool) -> Self {
453        Self {
454            builder: self.builder.property("app-paintable", app_paintable),
455        }
456    }
457
458    pub fn can_default(self, can_default: bool) -> Self {
459        Self {
460            builder: self.builder.property("can-default", can_default),
461        }
462    }
463
464    pub fn can_focus(self, can_focus: bool) -> Self {
465        Self {
466            builder: self.builder.property("can-focus", can_focus),
467        }
468    }
469
470    pub fn events(self, events: gdk::EventMask) -> Self {
471        Self {
472            builder: self.builder.property("events", events),
473        }
474    }
475
476    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
477    pub fn expand(self, expand: bool) -> Self {
478        Self {
479            builder: self.builder.property("expand", expand),
480        }
481    }
482
483    /// Whether the widget should grab focus when it is clicked with the mouse.
484    ///
485    /// This property is only relevant for widgets that can take focus.
486    ///
487    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
488    /// GtkComboBox) implemented this property individually.
489    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
490        Self {
491            builder: self.builder.property("focus-on-click", focus_on_click),
492        }
493    }
494
495    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
496    pub fn halign(self, halign: Align) -> Self {
497        Self {
498            builder: self.builder.property("halign", halign),
499        }
500    }
501
502    pub fn has_default(self, has_default: bool) -> Self {
503        Self {
504            builder: self.builder.property("has-default", has_default),
505        }
506    }
507
508    pub fn has_focus(self, has_focus: bool) -> Self {
509        Self {
510            builder: self.builder.property("has-focus", has_focus),
511        }
512    }
513
514    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
515    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
516    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
517    /// whether it will provide a tooltip or not.
518    ///
519    /// Note that setting this property to [`true`] for the first time will change
520    /// the event masks of the GdkWindows of this widget to include leave-notify
521    /// and motion-notify events. This cannot and will not be undone when the
522    /// property is set to [`false`] again.
523    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
524        Self {
525            builder: self.builder.property("has-tooltip", has_tooltip),
526        }
527    }
528
529    pub fn height_request(self, height_request: i32) -> Self {
530        Self {
531            builder: self.builder.property("height-request", height_request),
532        }
533    }
534
535    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
536    pub fn hexpand(self, hexpand: bool) -> Self {
537        Self {
538            builder: self.builder.property("hexpand", hexpand),
539        }
540    }
541
542    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
543    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
544        Self {
545            builder: self.builder.property("hexpand-set", hexpand_set),
546        }
547    }
548
549    pub fn is_focus(self, is_focus: bool) -> Self {
550        Self {
551            builder: self.builder.property("is-focus", is_focus),
552        }
553    }
554
555    /// Sets all four sides' margin at once. If read, returns max
556    /// margin on any side.
557    pub fn margin(self, margin: i32) -> Self {
558        Self {
559            builder: self.builder.property("margin", margin),
560        }
561    }
562
563    /// Margin on bottom side of widget.
564    ///
565    /// This property adds margin outside of the widget's normal size
566    /// request, the margin will be added in addition to the size from
567    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
568    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
569        Self {
570            builder: self.builder.property("margin-bottom", margin_bottom),
571        }
572    }
573
574    /// Margin on end of widget, horizontally. This property supports
575    /// left-to-right and right-to-left text directions.
576    ///
577    /// This property adds margin outside of the widget's normal size
578    /// request, the margin will be added in addition to the size from
579    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
580    pub fn margin_end(self, margin_end: i32) -> Self {
581        Self {
582            builder: self.builder.property("margin-end", margin_end),
583        }
584    }
585
586    /// Margin on start of widget, horizontally. This property supports
587    /// left-to-right and right-to-left text directions.
588    ///
589    /// This property adds margin outside of the widget's normal size
590    /// request, the margin will be added in addition to the size from
591    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
592    pub fn margin_start(self, margin_start: i32) -> Self {
593        Self {
594            builder: self.builder.property("margin-start", margin_start),
595        }
596    }
597
598    /// Margin on top side of widget.
599    ///
600    /// This property adds margin outside of the widget's normal size
601    /// request, the margin will be added in addition to the size from
602    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
603    pub fn margin_top(self, margin_top: i32) -> Self {
604        Self {
605            builder: self.builder.property("margin-top", margin_top),
606        }
607    }
608
609    pub fn name(self, name: impl Into<glib::GString>) -> Self {
610        Self {
611            builder: self.builder.property("name", name.into()),
612        }
613    }
614
615    pub fn no_show_all(self, no_show_all: bool) -> Self {
616        Self {
617            builder: self.builder.property("no-show-all", no_show_all),
618        }
619    }
620
621    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
622    /// more details about window opacity.
623    ///
624    /// Before 3.8 this was only available in GtkWindow
625    pub fn opacity(self, opacity: f64) -> Self {
626        Self {
627            builder: self.builder.property("opacity", opacity),
628        }
629    }
630
631    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
632        Self {
633            builder: self.builder.property("parent", parent.clone().upcast()),
634        }
635    }
636
637    pub fn receives_default(self, receives_default: bool) -> Self {
638        Self {
639            builder: self.builder.property("receives-default", receives_default),
640        }
641    }
642
643    pub fn sensitive(self, sensitive: bool) -> Self {
644        Self {
645            builder: self.builder.property("sensitive", sensitive),
646        }
647    }
648
649    /// Sets the text of tooltip to be the given string, which is marked up
650    /// with the [Pango text markup language][PangoMarkupFormat].
651    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
652    ///
653    /// This is a convenience property which will take care of getting the
654    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
655    /// will automatically be set to [`true`] and there will be taken care of
656    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
657    ///
658    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
659    /// are set, the last one wins.
660    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
661        Self {
662            builder: self
663                .builder
664                .property("tooltip-markup", tooltip_markup.into()),
665        }
666    }
667
668    /// Sets the text of tooltip to be the given string.
669    ///
670    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
671    ///
672    /// This is a convenience property which will take care of getting the
673    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
674    /// will automatically be set to [`true`] and there will be taken care of
675    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
676    ///
677    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
678    /// are set, the last one wins.
679    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
680        Self {
681            builder: self.builder.property("tooltip-text", tooltip_text.into()),
682        }
683    }
684
685    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
686    pub fn valign(self, valign: Align) -> Self {
687        Self {
688            builder: self.builder.property("valign", valign),
689        }
690    }
691
692    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
693    pub fn vexpand(self, vexpand: bool) -> Self {
694        Self {
695            builder: self.builder.property("vexpand", vexpand),
696        }
697    }
698
699    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
700    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
701        Self {
702            builder: self.builder.property("vexpand-set", vexpand_set),
703        }
704    }
705
706    pub fn visible(self, visible: bool) -> Self {
707        Self {
708            builder: self.builder.property("visible", visible),
709        }
710    }
711
712    pub fn width_request(self, width_request: i32) -> Self {
713        Self {
714            builder: self.builder.property("width-request", width_request),
715        }
716    }
717
718    /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget. This adjustment is
719    /// shared between the scrollable widget and its parent.
720    pub fn hadjustment(self, hadjustment: &impl IsA<Adjustment>) -> Self {
721        Self {
722            builder: self
723                .builder
724                .property("hadjustment", hadjustment.clone().upcast()),
725        }
726    }
727
728    /// Determines whether horizontal scrolling should start once the scrollable
729    /// widget is allocated less than its minimum width or less than its natural width.
730    pub fn hscroll_policy(self, hscroll_policy: ScrollablePolicy) -> Self {
731        Self {
732            builder: self.builder.property("hscroll-policy", hscroll_policy),
733        }
734    }
735
736    /// Verical [`Adjustment`][crate::Adjustment] of the scrollable widget. This adjustment is shared
737    /// between the scrollable widget and its parent.
738    pub fn vadjustment(self, vadjustment: &impl IsA<Adjustment>) -> Self {
739        Self {
740            builder: self
741                .builder
742                .property("vadjustment", vadjustment.clone().upcast()),
743        }
744    }
745
746    /// Determines whether vertical scrolling should start once the scrollable
747    /// widget is allocated less than its minimum height or less than its natural height.
748    pub fn vscroll_policy(self, vscroll_policy: ScrollablePolicy) -> Self {
749        Self {
750            builder: self.builder.property("vscroll-policy", vscroll_policy),
751        }
752    }
753
754    // rustdoc-stripper-ignore-next
755    /// Build the [`Layout`].
756    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
757    pub fn build(self) -> Layout {
758        assert_initialized_main_thread!();
759        self.builder.build()
760    }
761}
762
763/// Trait containing all [`struct@Layout`] methods.
764///
765/// # Implementors
766///
767/// [`Layout`][struct@crate::Layout]
768pub trait LayoutExt: IsA<Layout> + 'static {
769    /// Retrieve the bin window of the layout used for drawing operations.
770    ///
771    /// # Returns
772    ///
773    /// a [`gdk::Window`][crate::gdk::Window]
774    #[doc(alias = "gtk_layout_get_bin_window")]
775    #[doc(alias = "get_bin_window")]
776    fn bin_window(&self) -> Option<gdk::Window> {
777        unsafe {
778            from_glib_none(ffi::gtk_layout_get_bin_window(
779                self.as_ref().to_glib_none().0,
780            ))
781        }
782    }
783
784    /// Gets the size that has been set on the layout, and that determines
785    /// the total extents of the layout’s scrollbar area. See
786    /// gtk_layout_set_size ().
787    ///
788    /// # Returns
789    ///
790    ///
791    /// ## `width`
792    /// location to store the width set on
793    ///  `self`, or [`None`]
794    ///
795    /// ## `height`
796    /// location to store the height set on
797    ///  `self`, or [`None`]
798    #[doc(alias = "gtk_layout_get_size")]
799    #[doc(alias = "get_size")]
800    fn size(&self) -> (u32, u32) {
801        unsafe {
802            let mut width = std::mem::MaybeUninit::uninit();
803            let mut height = std::mem::MaybeUninit::uninit();
804            ffi::gtk_layout_get_size(
805                self.as_ref().to_glib_none().0,
806                width.as_mut_ptr(),
807                height.as_mut_ptr(),
808            );
809            (width.assume_init(), height.assume_init())
810        }
811    }
812
813    /// Moves a current child of `self` to a new position.
814    /// ## `child_widget`
815    /// a current child of `self`
816    /// ## `x`
817    /// X position to move to
818    /// ## `y`
819    /// Y position to move to
820    #[doc(alias = "gtk_layout_move")]
821    #[doc(alias = "move")]
822    fn move_(&self, child_widget: &impl IsA<Widget>, x: i32, y: i32) {
823        unsafe {
824            ffi::gtk_layout_move(
825                self.as_ref().to_glib_none().0,
826                child_widget.as_ref().to_glib_none().0,
827                x,
828                y,
829            );
830        }
831    }
832
833    /// Adds `child_widget` to `self`, at position (`x`,`y`).
834    /// `self` becomes the new parent container of `child_widget`.
835    /// ## `child_widget`
836    /// child widget
837    /// ## `x`
838    /// X position of child widget
839    /// ## `y`
840    /// Y position of child widget
841    #[doc(alias = "gtk_layout_put")]
842    fn put(&self, child_widget: &impl IsA<Widget>, x: i32, y: i32) {
843        unsafe {
844            ffi::gtk_layout_put(
845                self.as_ref().to_glib_none().0,
846                child_widget.as_ref().to_glib_none().0,
847                x,
848                y,
849            );
850        }
851    }
852
853    /// Sets the size of the scrollable area of the layout.
854    /// ## `width`
855    /// width of entire scrollable area
856    /// ## `height`
857    /// height of entire scrollable area
858    #[doc(alias = "gtk_layout_set_size")]
859    fn set_size(&self, width: u32, height: u32) {
860        unsafe {
861            ffi::gtk_layout_set_size(self.as_ref().to_glib_none().0, width, height);
862        }
863    }
864
865    fn height(&self) -> u32 {
866        ObjectExt::property(self.as_ref(), "height")
867    }
868
869    fn set_height(&self, height: u32) {
870        ObjectExt::set_property(self.as_ref(), "height", height)
871    }
872
873    fn width(&self) -> u32 {
874        ObjectExt::property(self.as_ref(), "width")
875    }
876
877    fn set_width(&self, width: u32) {
878        ObjectExt::set_property(self.as_ref(), "width", width)
879    }
880
881    fn child_x<T: IsA<crate::Widget>>(&self, item: &T) -> i32 {
882        crate::prelude::ContainerExtManual::child_property(
883            self.as_ref(),
884            &item.clone().upcast(),
885            "x",
886        )
887    }
888
889    fn set_child_x<T: IsA<crate::Widget>>(&self, item: &T, x: i32) {
890        crate::prelude::ContainerExtManual::child_set_property(
891            self.as_ref(),
892            &item.clone().upcast(),
893            "x",
894            &x,
895        )
896    }
897
898    fn child_y<T: IsA<crate::Widget>>(&self, item: &T) -> i32 {
899        crate::prelude::ContainerExtManual::child_property(
900            self.as_ref(),
901            &item.clone().upcast(),
902            "y",
903        )
904    }
905
906    fn set_child_y<T: IsA<crate::Widget>>(&self, item: &T, y: i32) {
907        crate::prelude::ContainerExtManual::child_set_property(
908            self.as_ref(),
909            &item.clone().upcast(),
910            "y",
911            &y,
912        )
913    }
914
915    #[doc(alias = "height")]
916    fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
917        unsafe extern "C" fn notify_height_trampoline<P: IsA<Layout>, F: Fn(&P) + 'static>(
918            this: *mut ffi::GtkLayout,
919            _param_spec: glib::ffi::gpointer,
920            f: glib::ffi::gpointer,
921        ) {
922            unsafe {
923                let f: &F = &*(f as *const F);
924                f(Layout::from_glib_borrow(this).unsafe_cast_ref())
925            }
926        }
927        unsafe {
928            let f: Box_<F> = Box_::new(f);
929            connect_raw(
930                self.as_ptr() as *mut _,
931                c"notify::height".as_ptr(),
932                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
933                    notify_height_trampoline::<Self, F> as *const (),
934                )),
935                Box_::into_raw(f),
936            )
937        }
938    }
939
940    #[doc(alias = "width")]
941    fn connect_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
942        unsafe extern "C" fn notify_width_trampoline<P: IsA<Layout>, F: Fn(&P) + 'static>(
943            this: *mut ffi::GtkLayout,
944            _param_spec: glib::ffi::gpointer,
945            f: glib::ffi::gpointer,
946        ) {
947            unsafe {
948                let f: &F = &*(f as *const F);
949                f(Layout::from_glib_borrow(this).unsafe_cast_ref())
950            }
951        }
952        unsafe {
953            let f: Box_<F> = Box_::new(f);
954            connect_raw(
955                self.as_ptr() as *mut _,
956                c"notify::width".as_ptr(),
957                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
958                    notify_width_trampoline::<Self, F> as *const (),
959                )),
960                Box_::into_raw(f),
961            )
962        }
963    }
964}
965
966impl<O: IsA<Layout>> LayoutExt for O {}