Skip to main content

gtk4/auto/
grid.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
5#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::Accessible;
8use crate::{
9    AccessibleRole, Align, BaselinePosition, Buildable, ConstraintTarget, LayoutManager,
10    Orientable, Orientation, Overflow, PositionType, Widget, ffi,
11};
12use glib::{
13    prelude::*,
14    signal::{SignalHandlerId, connect_raw},
15    translate::*,
16};
17use std::boxed::Box as Box_;
18
19#[cfg(feature = "v4_10")]
20#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
21glib::wrapper! {
22    ///
23    /// ```text
24    ///
25    /// It organizes the first two buttons side-by-side in one cell each.
26    /// The third button is in the last column but spans across two rows.
27    /// This is defined by the `row-span` property. The last button is
28    /// located in the second row and spans across two columns, which is
29    /// defined by the `column-span` property.
30    ///
31    /// # CSS nodes
32    ///
33    /// [`Grid`][crate::Grid] uses a single CSS node with name `grid`.
34    ///
35    /// # Accessibility
36    ///
37    /// Until GTK 4.10, [`Grid`][crate::Grid] used the [enum@Gtk.AccessibleRole.group] role.
38    ///
39    /// Starting from GTK 4.12, [`Grid`][crate::Grid] uses the [enum@Gtk.AccessibleRole.generic] role.
40    ///
41    /// ## Properties
42    ///
43    ///
44    /// #### `baseline-row`
45    ///  The row to align to the baseline when valign is using baseline alignment.
46    ///
47    /// Readable | Writable
48    ///
49    ///
50    /// #### `column-homogeneous`
51    ///  If [`true`], the columns are all the same width.
52    ///
53    /// Readable | Writable
54    ///
55    ///
56    /// #### `column-spacing`
57    ///  The amount of space between two consecutive columns.
58    ///
59    /// Readable | Writable
60    ///
61    ///
62    /// #### `row-homogeneous`
63    ///  If [`true`], the rows are all the same height.
64    ///
65    /// Readable | Writable
66    ///
67    ///
68    /// #### `row-spacing`
69    ///  The amount of space between two consecutive rows.
70    ///
71    /// Readable | Writable
72    /// <details><summary><h4>Widget</h4></summary>
73    ///
74    ///
75    /// #### `can-focus`
76    ///  Whether the widget or any of its descendents can accept
77    /// the input focus.
78    ///
79    /// This property is meant to be set by widget implementations,
80    /// typically in their instance init function.
81    ///
82    /// Readable | Writable
83    ///
84    ///
85    /// #### `can-target`
86    ///  Whether the widget can receive pointer events.
87    ///
88    /// Readable | Writable
89    ///
90    ///
91    /// #### `css-classes`
92    ///  A list of css classes applied to this widget.
93    ///
94    /// Readable | Writable
95    ///
96    ///
97    /// #### `css-name`
98    ///  The name of this widget in the CSS tree.
99    ///
100    /// This property is meant to be set by widget implementations,
101    /// typically in their instance init function.
102    ///
103    /// Readable | Writable | Construct Only
104    ///
105    ///
106    /// #### `cursor`
107    ///  The cursor used by @widget.
108    ///
109    /// Readable | Writable
110    ///
111    ///
112    /// #### `focus-on-click`
113    ///  Whether the widget should grab focus when it is clicked with the mouse.
114    ///
115    /// This property is only relevant for widgets that can take focus.
116    ///
117    /// Readable | Writable
118    ///
119    ///
120    /// #### `focusable`
121    ///  Whether this widget itself will accept the input focus.
122    ///
123    /// Readable | Writable
124    ///
125    ///
126    /// #### `halign`
127    ///  How to distribute horizontal space if widget gets extra space.
128    ///
129    /// Readable | Writable
130    ///
131    ///
132    /// #### `has-default`
133    ///  Whether the widget is the default widget.
134    ///
135    /// Readable
136    ///
137    ///
138    /// #### `has-focus`
139    ///  Whether the widget has the input focus.
140    ///
141    /// Readable
142    ///
143    ///
144    /// #### `has-tooltip`
145    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
146    /// signal on @widget.
147    ///
148    /// A true value indicates that @widget can have a tooltip, in this case
149    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
150    /// determine whether it will provide a tooltip or not.
151    ///
152    /// Readable | Writable
153    ///
154    ///
155    /// #### `height-request`
156    ///  Overrides for height request of the widget.
157    ///
158    /// If this is -1, the natural request will be used.
159    ///
160    /// Readable | Writable
161    ///
162    ///
163    /// #### `hexpand`
164    ///  Whether to expand horizontally.
165    ///
166    /// Readable | Writable
167    ///
168    ///
169    /// #### `hexpand-set`
170    ///  Whether to use the `hexpand` property.
171    ///
172    /// Readable | Writable
173    ///
174    ///
175    /// #### `layout-manager`
176    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
177    /// the preferred size of the widget, and allocate its children.
178    ///
179    /// This property is meant to be set by widget implementations,
180    /// typically in their instance init function.
181    ///
182    /// Readable | Writable
183    ///
184    ///
185    /// #### `limit-events`
186    ///  Makes this widget act like a modal dialog, with respect to
187    /// event delivery.
188    ///
189    /// Global event controllers will not handle events with targets
190    /// inside the widget, unless they are set up to ignore propagation
191    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
192    ///
193    /// Readable | Writable
194    ///
195    ///
196    /// #### `margin-bottom`
197    ///  Margin on bottom side of widget.
198    ///
199    /// This property adds margin outside of the widget's normal size
200    /// request, the margin will be added in addition to the size from
201    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
202    ///
203    /// Readable | Writable
204    ///
205    ///
206    /// #### `margin-end`
207    ///  Margin on end of widget, horizontally.
208    ///
209    /// This property supports left-to-right and right-to-left text
210    /// directions.
211    ///
212    /// This property adds margin outside of the widget's normal size
213    /// request, the margin will be added in addition to the size from
214    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
215    ///
216    /// Readable | Writable
217    ///
218    ///
219    /// #### `margin-start`
220    ///  Margin on start of widget, horizontally.
221    ///
222    /// This property supports left-to-right and right-to-left text
223    /// directions.
224    ///
225    /// This property adds margin outside of the widget's normal size
226    /// request, the margin will be added in addition to the size from
227    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
228    ///
229    /// Readable | Writable
230    ///
231    ///
232    /// #### `margin-top`
233    ///  Margin on top side of widget.
234    ///
235    /// This property adds margin outside of the widget's normal size
236    /// request, the margin will be added in addition to the size from
237    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
238    ///
239    /// Readable | Writable
240    ///
241    ///
242    /// #### `name`
243    ///  The name of the widget.
244    ///
245    /// Readable | Writable
246    ///
247    ///
248    /// #### `opacity`
249    ///  The requested opacity of the widget.
250    ///
251    /// Readable | Writable
252    ///
253    ///
254    /// #### `overflow`
255    ///  How content outside the widget's content area is treated.
256    ///
257    /// This property is meant to be set by widget implementations,
258    /// typically in their instance init function.
259    ///
260    /// Readable | Writable
261    ///
262    ///
263    /// #### `parent`
264    ///  The parent widget of this widget.
265    ///
266    /// Readable
267    ///
268    ///
269    /// #### `receives-default`
270    ///  Whether the widget will receive the default action when it is focused.
271    ///
272    /// Readable | Writable
273    ///
274    ///
275    /// #### `root`
276    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
277    ///
278    /// This will be `NULL` if the widget is not contained in a root widget.
279    ///
280    /// Readable
281    ///
282    ///
283    /// #### `scale-factor`
284    ///  The scale factor of the widget.
285    ///
286    /// Readable
287    ///
288    ///
289    /// #### `sensitive`
290    ///  Whether the widget responds to input.
291    ///
292    /// Readable | Writable
293    ///
294    ///
295    /// #### `tooltip-markup`
296    ///  Sets the text of tooltip to be the given string, which is marked up
297    /// with Pango markup.
298    ///
299    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
300    ///
301    /// This is a convenience property which will take care of getting the
302    /// tooltip shown if the given string is not `NULL`:
303    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
304    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
305    /// the default signal handler.
306    ///
307    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
308    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
309    ///
310    /// Readable | Writable
311    ///
312    ///
313    /// #### `tooltip-text`
314    ///  Sets the text of tooltip to be the given string.
315    ///
316    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
317    ///
318    /// This is a convenience property which will take care of getting the
319    /// tooltip shown if the given string is not `NULL`:
320    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
321    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
322    /// the default signal handler.
323    ///
324    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
325    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
326    ///
327    /// Readable | Writable
328    ///
329    ///
330    /// #### `valign`
331    ///  How to distribute vertical space if widget gets extra space.
332    ///
333    /// Readable | Writable
334    ///
335    ///
336    /// #### `vexpand`
337    ///  Whether to expand vertically.
338    ///
339    /// Readable | Writable
340    ///
341    ///
342    /// #### `vexpand-set`
343    ///  Whether to use the `vexpand` property.
344    ///
345    /// Readable | Writable
346    ///
347    ///
348    /// #### `visible`
349    ///  Whether the widget is visible.
350    ///
351    /// Readable | Writable
352    ///
353    ///
354    /// #### `width-request`
355    ///  Overrides for width request of the widget.
356    ///
357    /// If this is -1, the natural request will be used.
358    ///
359    /// Readable | Writable
360    /// </details>
361    /// <details><summary><h4>Accessible</h4></summary>
362    ///
363    ///
364    /// #### `accessible-role`
365    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
366    ///
367    /// The accessible role cannot be changed once set.
368    ///
369    /// Readable | Writable
370    /// </details>
371    /// <details><summary><h4>Orientable</h4></summary>
372    ///
373    ///
374    /// #### `orientation`
375    ///  The orientation of the orientable.
376    ///
377    /// Readable | Writable
378    /// </details>
379    ///
380    /// # Implements
381    ///
382    /// [`GridExt`][trait@crate::prelude::GridExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
383    #[doc(alias = "GtkGrid")]
384    pub struct Grid(Object<ffi::GtkGrid, ffi::GtkGridClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable;
385
386    match fn {
387        type_ => || ffi::gtk_grid_get_type(),
388    }
389}
390
391#[cfg(not(feature = "v4_10"))]
392glib::wrapper! {
393    #[doc(alias = "GtkGrid")]
394    pub struct Grid(Object<ffi::GtkGrid, ffi::GtkGridClass>) @extends Widget, @implements Buildable, ConstraintTarget, Orientable;
395
396    match fn {
397        type_ => || ffi::gtk_grid_get_type(),
398    }
399}
400
401impl Grid {
402    pub const NONE: Option<&'static Grid> = None;
403
404    /// Creates a new grid widget.
405    ///
406    /// # Returns
407    ///
408    /// the new [`Grid`][crate::Grid]
409    #[doc(alias = "gtk_grid_new")]
410    pub fn new() -> Grid {
411        assert_initialized_main_thread!();
412        unsafe { Widget::from_glib_none(ffi::gtk_grid_new()).unsafe_cast() }
413    }
414
415    // rustdoc-stripper-ignore-next
416    /// Creates a new builder-pattern struct instance to construct [`Grid`] objects.
417    ///
418    /// This method returns an instance of [`GridBuilder`](crate::builders::GridBuilder) which can be used to create [`Grid`] objects.
419    pub fn builder() -> GridBuilder {
420        GridBuilder::new()
421    }
422}
423
424impl Default for Grid {
425    fn default() -> Self {
426        Self::new()
427    }
428}
429
430// rustdoc-stripper-ignore-next
431/// A [builder-pattern] type to construct [`Grid`] objects.
432///
433/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
434#[must_use = "The builder must be built to be used"]
435pub struct GridBuilder {
436    builder: glib::object::ObjectBuilder<'static, Grid>,
437}
438
439impl GridBuilder {
440    fn new() -> Self {
441        Self {
442            builder: glib::object::Object::builder(),
443        }
444    }
445
446    /// The row to align to the baseline when valign is using baseline alignment.
447    pub fn baseline_row(self, baseline_row: i32) -> Self {
448        Self {
449            builder: self.builder.property("baseline-row", baseline_row),
450        }
451    }
452
453    /// If [`true`], the columns are all the same width.
454    pub fn column_homogeneous(self, column_homogeneous: bool) -> Self {
455        Self {
456            builder: self
457                .builder
458                .property("column-homogeneous", column_homogeneous),
459        }
460    }
461
462    /// The amount of space between two consecutive columns.
463    pub fn column_spacing(self, column_spacing: i32) -> Self {
464        Self {
465            builder: self.builder.property("column-spacing", column_spacing),
466        }
467    }
468
469    /// If [`true`], the rows are all the same height.
470    pub fn row_homogeneous(self, row_homogeneous: bool) -> Self {
471        Self {
472            builder: self.builder.property("row-homogeneous", row_homogeneous),
473        }
474    }
475
476    /// The amount of space between two consecutive rows.
477    pub fn row_spacing(self, row_spacing: i32) -> Self {
478        Self {
479            builder: self.builder.property("row-spacing", row_spacing),
480        }
481    }
482
483    /// Whether the widget or any of its descendents can accept
484    /// the input focus.
485    ///
486    /// This property is meant to be set by widget implementations,
487    /// typically in their instance init function.
488    pub fn can_focus(self, can_focus: bool) -> Self {
489        Self {
490            builder: self.builder.property("can-focus", can_focus),
491        }
492    }
493
494    /// Whether the widget can receive pointer events.
495    pub fn can_target(self, can_target: bool) -> Self {
496        Self {
497            builder: self.builder.property("can-target", can_target),
498        }
499    }
500
501    /// A list of css classes applied to this widget.
502    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
503        Self {
504            builder: self.builder.property("css-classes", css_classes.into()),
505        }
506    }
507
508    /// The name of this widget in the CSS tree.
509    ///
510    /// This property is meant to be set by widget implementations,
511    /// typically in their instance init function.
512    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
513        Self {
514            builder: self.builder.property("css-name", css_name.into()),
515        }
516    }
517
518    /// The cursor used by @widget.
519    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
520        Self {
521            builder: self.builder.property("cursor", cursor.clone()),
522        }
523    }
524
525    /// Whether the widget should grab focus when it is clicked with the mouse.
526    ///
527    /// This property is only relevant for widgets that can take focus.
528    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
529        Self {
530            builder: self.builder.property("focus-on-click", focus_on_click),
531        }
532    }
533
534    /// Whether this widget itself will accept the input focus.
535    pub fn focusable(self, focusable: bool) -> Self {
536        Self {
537            builder: self.builder.property("focusable", focusable),
538        }
539    }
540
541    /// How to distribute horizontal space if widget gets extra space.
542    pub fn halign(self, halign: Align) -> Self {
543        Self {
544            builder: self.builder.property("halign", halign),
545        }
546    }
547
548    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
549    /// signal on @widget.
550    ///
551    /// A true value indicates that @widget can have a tooltip, in this case
552    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
553    /// determine whether it will provide a tooltip or not.
554    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
555        Self {
556            builder: self.builder.property("has-tooltip", has_tooltip),
557        }
558    }
559
560    /// Overrides for height request of the widget.
561    ///
562    /// If this is -1, the natural request will be used.
563    pub fn height_request(self, height_request: i32) -> Self {
564        Self {
565            builder: self.builder.property("height-request", height_request),
566        }
567    }
568
569    /// Whether to expand horizontally.
570    pub fn hexpand(self, hexpand: bool) -> Self {
571        Self {
572            builder: self.builder.property("hexpand", hexpand),
573        }
574    }
575
576    /// Whether to use the `hexpand` property.
577    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
578        Self {
579            builder: self.builder.property("hexpand-set", hexpand_set),
580        }
581    }
582
583    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
584    /// the preferred size of the widget, and allocate its children.
585    ///
586    /// This property is meant to be set by widget implementations,
587    /// typically in their instance init function.
588    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
589        Self {
590            builder: self
591                .builder
592                .property("layout-manager", layout_manager.clone().upcast()),
593        }
594    }
595
596    /// Makes this widget act like a modal dialog, with respect to
597    /// event delivery.
598    ///
599    /// Global event controllers will not handle events with targets
600    /// inside the widget, unless they are set up to ignore propagation
601    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
602    #[cfg(feature = "v4_18")]
603    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
604    pub fn limit_events(self, limit_events: bool) -> Self {
605        Self {
606            builder: self.builder.property("limit-events", limit_events),
607        }
608    }
609
610    /// Margin on bottom side of widget.
611    ///
612    /// This property adds margin outside of the widget's normal size
613    /// request, the margin will be added in addition to the size from
614    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
615    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
616        Self {
617            builder: self.builder.property("margin-bottom", margin_bottom),
618        }
619    }
620
621    /// Margin on end of widget, horizontally.
622    ///
623    /// This property supports left-to-right and right-to-left text
624    /// directions.
625    ///
626    /// This property adds margin outside of the widget's normal size
627    /// request, the margin will be added in addition to the size from
628    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
629    pub fn margin_end(self, margin_end: i32) -> Self {
630        Self {
631            builder: self.builder.property("margin-end", margin_end),
632        }
633    }
634
635    /// Margin on start of widget, horizontally.
636    ///
637    /// This property supports left-to-right and right-to-left text
638    /// directions.
639    ///
640    /// This property adds margin outside of the widget's normal size
641    /// request, the margin will be added in addition to the size from
642    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
643    pub fn margin_start(self, margin_start: i32) -> Self {
644        Self {
645            builder: self.builder.property("margin-start", margin_start),
646        }
647    }
648
649    /// Margin on top side of widget.
650    ///
651    /// This property adds margin outside of the widget's normal size
652    /// request, the margin will be added in addition to the size from
653    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
654    pub fn margin_top(self, margin_top: i32) -> Self {
655        Self {
656            builder: self.builder.property("margin-top", margin_top),
657        }
658    }
659
660    /// The name of the widget.
661    pub fn name(self, name: impl Into<glib::GString>) -> Self {
662        Self {
663            builder: self.builder.property("name", name.into()),
664        }
665    }
666
667    /// The requested opacity of the widget.
668    pub fn opacity(self, opacity: f64) -> Self {
669        Self {
670            builder: self.builder.property("opacity", opacity),
671        }
672    }
673
674    /// How content outside the widget's content area is treated.
675    ///
676    /// This property is meant to be set by widget implementations,
677    /// typically in their instance init function.
678    pub fn overflow(self, overflow: Overflow) -> Self {
679        Self {
680            builder: self.builder.property("overflow", overflow),
681        }
682    }
683
684    /// Whether the widget will receive the default action when it is focused.
685    pub fn receives_default(self, receives_default: bool) -> Self {
686        Self {
687            builder: self.builder.property("receives-default", receives_default),
688        }
689    }
690
691    /// Whether the widget responds to input.
692    pub fn sensitive(self, sensitive: bool) -> Self {
693        Self {
694            builder: self.builder.property("sensitive", sensitive),
695        }
696    }
697
698    /// Sets the text of tooltip to be the given string, which is marked up
699    /// with Pango markup.
700    ///
701    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
702    ///
703    /// This is a convenience property which will take care of getting the
704    /// tooltip shown if the given string is not `NULL`:
705    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
706    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
707    /// the default signal handler.
708    ///
709    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
710    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
711    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
712        Self {
713            builder: self
714                .builder
715                .property("tooltip-markup", tooltip_markup.into()),
716        }
717    }
718
719    /// Sets the text of tooltip to be the given string.
720    ///
721    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
722    ///
723    /// This is a convenience property which will take care of getting the
724    /// tooltip shown if the given string is not `NULL`:
725    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
726    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
727    /// the default signal handler.
728    ///
729    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
730    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
731    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
732        Self {
733            builder: self.builder.property("tooltip-text", tooltip_text.into()),
734        }
735    }
736
737    /// How to distribute vertical space if widget gets extra space.
738    pub fn valign(self, valign: Align) -> Self {
739        Self {
740            builder: self.builder.property("valign", valign),
741        }
742    }
743
744    /// Whether to expand vertically.
745    pub fn vexpand(self, vexpand: bool) -> Self {
746        Self {
747            builder: self.builder.property("vexpand", vexpand),
748        }
749    }
750
751    /// Whether to use the `vexpand` property.
752    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
753        Self {
754            builder: self.builder.property("vexpand-set", vexpand_set),
755        }
756    }
757
758    /// Whether the widget is visible.
759    pub fn visible(self, visible: bool) -> Self {
760        Self {
761            builder: self.builder.property("visible", visible),
762        }
763    }
764
765    /// Overrides for width request of the widget.
766    ///
767    /// If this is -1, the natural request will be used.
768    pub fn width_request(self, width_request: i32) -> Self {
769        Self {
770            builder: self.builder.property("width-request", width_request),
771        }
772    }
773
774    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
775    ///
776    /// The accessible role cannot be changed once set.
777    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
778        Self {
779            builder: self.builder.property("accessible-role", accessible_role),
780        }
781    }
782
783    /// The orientation of the orientable.
784    pub fn orientation(self, orientation: Orientation) -> Self {
785        Self {
786            builder: self.builder.property("orientation", orientation),
787        }
788    }
789
790    // rustdoc-stripper-ignore-next
791    /// Build the [`Grid`].
792    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
793    pub fn build(self) -> Grid {
794        assert_initialized_main_thread!();
795        self.builder.build()
796    }
797}
798
799/// Trait containing all [`struct@Grid`] methods.
800///
801/// # Implementors
802///
803/// [`Grid`][struct@crate::Grid]
804pub trait GridExt: IsA<Grid> + 'static {
805    ///  that @child will occupy is determined
806    /// by @width and @height.
807    /// ## `child`
808    /// the widget to add
809    /// ## `column`
810    /// the column number to attach the left side of @child to
811    /// ## `row`
812    /// the row number to attach the top side of @child to
813    /// ## `width`
814    /// the number of columns that @child will span
815    /// ## `height`
816    /// the number of rows that @child will span
817    #[doc(alias = "gtk_grid_attach")]
818    fn attach(&self, child: &impl IsA<Widget>, column: i32, row: i32, width: i32, height: i32) {
819        unsafe {
820            ffi::gtk_grid_attach(
821                self.as_ref().to_glib_none().0,
822                child.as_ref().to_glib_none().0,
823                column,
824                row,
825                width,
826                height,
827            );
828        }
829    }
830
831    /// Adds a widget to the grid.
832    ///
833    /// The widget is placed next to @sibling, on the side determined by
834    /// @side. When @sibling is [`None`], the widget is placed in row (for
835    /// left or right placement) or column 0 (for top or bottom placement),
836    /// at the end indicated by @side.
837    ///
838    /// Attaching widgets labeled `[1]`, `[2]`, `[3]` with `@sibling == [`None`]` and
839    /// `@side == [`PositionType::Left`][crate::PositionType::Left]` yields a layout of `[3][2][1]`.
840    /// ## `child`
841    /// the widget to add
842    /// ## `sibling`
843    /// the child of @self that @child will be placed
844    ///   next to, or [`None`] to place @child at the beginning or end
845    /// ## `side`
846    /// the side of @sibling that @child is positioned next to
847    /// ## `width`
848    /// the number of columns that @child will span
849    /// ## `height`
850    /// the number of rows that @child will span
851    #[doc(alias = "gtk_grid_attach_next_to")]
852    fn attach_next_to(
853        &self,
854        child: &impl IsA<Widget>,
855        sibling: Option<&impl IsA<Widget>>,
856        side: PositionType,
857        width: i32,
858        height: i32,
859    ) {
860        unsafe {
861            ffi::gtk_grid_attach_next_to(
862                self.as_ref().to_glib_none().0,
863                child.as_ref().to_glib_none().0,
864                sibling.map(|p| p.as_ref()).to_glib_none().0,
865                side.into_glib(),
866                width,
867                height,
868            );
869        }
870    }
871
872    /// Returns which row defines the global baseline of @self.
873    ///
874    /// # Returns
875    ///
876    /// the row index defining the global baseline
877    #[doc(alias = "gtk_grid_get_baseline_row")]
878    #[doc(alias = "get_baseline_row")]
879    #[doc(alias = "baseline-row")]
880    fn baseline_row(&self) -> i32 {
881        unsafe { ffi::gtk_grid_get_baseline_row(self.as_ref().to_glib_none().0) }
882    }
883
884    /// Gets the child of @self whose area covers the grid
885    /// cell at @column, @row.
886    /// ## `column`
887    /// the left edge of the cell
888    /// ## `row`
889    /// the top edge of the cell
890    ///
891    /// # Returns
892    ///
893    /// the child at the given position
894    #[doc(alias = "gtk_grid_get_child_at")]
895    #[doc(alias = "get_child_at")]
896    fn child_at(&self, column: i32, row: i32) -> Option<Widget> {
897        unsafe {
898            from_glib_none(ffi::gtk_grid_get_child_at(
899                self.as_ref().to_glib_none().0,
900                column,
901                row,
902            ))
903        }
904    }
905
906    /// Returns whether all columns of @self have the same width.
907    ///
908    /// # Returns
909    ///
910    /// whether all columns of @self have the same width.
911    #[doc(alias = "gtk_grid_get_column_homogeneous")]
912    #[doc(alias = "get_column_homogeneous")]
913    #[doc(alias = "column-homogeneous")]
914    fn is_column_homogeneous(&self) -> bool {
915        unsafe {
916            from_glib(ffi::gtk_grid_get_column_homogeneous(
917                self.as_ref().to_glib_none().0,
918            ))
919        }
920    }
921
922    /// Returns the amount of space between the columns of @self.
923    ///
924    /// # Returns
925    ///
926    /// the column spacing of @self
927    #[doc(alias = "gtk_grid_get_column_spacing")]
928    #[doc(alias = "get_column_spacing")]
929    #[doc(alias = "column-spacing")]
930    fn column_spacing(&self) -> u32 {
931        unsafe { ffi::gtk_grid_get_column_spacing(self.as_ref().to_glib_none().0) }
932    }
933
934    /// Returns the baseline position of @row.
935    ///
936    /// See [`set_row_baseline_position()`][Self::set_row_baseline_position()].
937    /// ## `row`
938    /// a row index
939    ///
940    /// # Returns
941    ///
942    /// the baseline position of @row
943    #[doc(alias = "gtk_grid_get_row_baseline_position")]
944    #[doc(alias = "get_row_baseline_position")]
945    fn row_baseline_position(&self, row: i32) -> BaselinePosition {
946        unsafe {
947            from_glib(ffi::gtk_grid_get_row_baseline_position(
948                self.as_ref().to_glib_none().0,
949                row,
950            ))
951        }
952    }
953
954    /// Returns whether all rows of @self have the same height.
955    ///
956    /// # Returns
957    ///
958    /// whether all rows of @self have the same height.
959    #[doc(alias = "gtk_grid_get_row_homogeneous")]
960    #[doc(alias = "get_row_homogeneous")]
961    #[doc(alias = "row-homogeneous")]
962    fn is_row_homogeneous(&self) -> bool {
963        unsafe {
964            from_glib(ffi::gtk_grid_get_row_homogeneous(
965                self.as_ref().to_glib_none().0,
966            ))
967        }
968    }
969
970    /// Returns the amount of space between the rows of @self.
971    ///
972    /// # Returns
973    ///
974    /// the row spacing of @self
975    #[doc(alias = "gtk_grid_get_row_spacing")]
976    #[doc(alias = "get_row_spacing")]
977    #[doc(alias = "row-spacing")]
978    fn row_spacing(&self) -> u32 {
979        unsafe { ffi::gtk_grid_get_row_spacing(self.as_ref().to_glib_none().0) }
980    }
981
982    /// Inserts a column at the specified position.
983    ///
984    /// Children which are attached at or to the right of this position
985    /// are moved one column to the right. Children which span across this
986    /// position are grown to span the new column.
987    /// ## `position`
988    /// the position to insert the column at
989    #[doc(alias = "gtk_grid_insert_column")]
990    fn insert_column(&self, position: i32) {
991        unsafe {
992            ffi::gtk_grid_insert_column(self.as_ref().to_glib_none().0, position);
993        }
994    }
995
996    /// Inserts a row or column at the specified position.
997    ///
998    /// The new row or column is placed next to @sibling, on the side
999    /// determined by @side. If @side is [`PositionType::Top`][crate::PositionType::Top] or [`PositionType::Bottom`][crate::PositionType::Bottom],
1000    /// a row is inserted. If @side is [`PositionType::Left`][crate::PositionType::Left] of [`PositionType::Right`][crate::PositionType::Right],
1001    /// a column is inserted.
1002    /// ## `sibling`
1003    /// the child of @self that the new row or column will be
1004    ///   placed next to
1005    /// ## `side`
1006    /// the side of @sibling that @child is positioned next to
1007    #[doc(alias = "gtk_grid_insert_next_to")]
1008    fn insert_next_to(&self, sibling: &impl IsA<Widget>, side: PositionType) {
1009        unsafe {
1010            ffi::gtk_grid_insert_next_to(
1011                self.as_ref().to_glib_none().0,
1012                sibling.as_ref().to_glib_none().0,
1013                side.into_glib(),
1014            );
1015        }
1016    }
1017
1018    /// Inserts a row at the specified position.
1019    ///
1020    /// Children which are attached at or below this position
1021    /// are moved one row down. Children which span across this
1022    /// position are grown to span the new row.
1023    /// ## `position`
1024    /// the position to insert the row at
1025    #[doc(alias = "gtk_grid_insert_row")]
1026    fn insert_row(&self, position: i32) {
1027        unsafe {
1028            ffi::gtk_grid_insert_row(self.as_ref().to_glib_none().0, position);
1029        }
1030    }
1031
1032    /// Queries the attach points and spans of @child inside the given [`Grid`][crate::Grid].
1033    /// ## `child`
1034    /// a [`Widget`][crate::Widget] child of @self
1035    ///
1036    /// # Returns
1037    ///
1038    ///
1039    /// ## `column`
1040    /// the column used to attach the left side of @child
1041    ///
1042    /// ## `row`
1043    /// the row used to attach the top side of @child
1044    ///
1045    /// ## `width`
1046    /// the number of columns @child spans
1047    ///
1048    /// ## `height`
1049    /// the number of rows @child spans
1050    #[doc(alias = "gtk_grid_query_child")]
1051    fn query_child(&self, child: &impl IsA<Widget>) -> (i32, i32, i32, i32) {
1052        unsafe {
1053            let mut column = std::mem::MaybeUninit::uninit();
1054            let mut row = std::mem::MaybeUninit::uninit();
1055            let mut width = std::mem::MaybeUninit::uninit();
1056            let mut height = std::mem::MaybeUninit::uninit();
1057            ffi::gtk_grid_query_child(
1058                self.as_ref().to_glib_none().0,
1059                child.as_ref().to_glib_none().0,
1060                column.as_mut_ptr(),
1061                row.as_mut_ptr(),
1062                width.as_mut_ptr(),
1063                height.as_mut_ptr(),
1064            );
1065            (
1066                column.assume_init(),
1067                row.assume_init(),
1068                width.assume_init(),
1069                height.assume_init(),
1070            )
1071        }
1072    }
1073
1074    /// Removes a child from @self.
1075    ///
1076    /// The child must have been added with
1077    /// [`attach()`][Self::attach()] or [`attach_next_to()`][Self::attach_next_to()].
1078    /// ## `child`
1079    /// the child widget to remove
1080    #[doc(alias = "gtk_grid_remove")]
1081    fn remove(&self, child: &impl IsA<Widget>) {
1082        unsafe {
1083            ffi::gtk_grid_remove(
1084                self.as_ref().to_glib_none().0,
1085                child.as_ref().to_glib_none().0,
1086            );
1087        }
1088    }
1089
1090    /// Removes a column from the grid.
1091    ///
1092    /// Children that are placed in this column are removed,
1093    /// spanning children that overlap this column have their
1094    /// width reduced by one, and children after the column
1095    /// are moved to the left.
1096    /// ## `position`
1097    /// the position of the column to remove
1098    #[doc(alias = "gtk_grid_remove_column")]
1099    fn remove_column(&self, position: i32) {
1100        unsafe {
1101            ffi::gtk_grid_remove_column(self.as_ref().to_glib_none().0, position);
1102        }
1103    }
1104
1105    /// Removes a row from the grid.
1106    ///
1107    /// Children that are placed in this row are removed,
1108    /// spanning children that overlap this row have their
1109    /// height reduced by one, and children below the row
1110    /// are moved up.
1111    /// ## `position`
1112    /// the position of the row to remove
1113    #[doc(alias = "gtk_grid_remove_row")]
1114    fn remove_row(&self, position: i32) {
1115        unsafe {
1116            ffi::gtk_grid_remove_row(self.as_ref().to_glib_none().0, position);
1117        }
1118    }
1119
1120    /// Sets which row defines the global baseline for the entire grid.
1121    ///
1122    /// Each row in the grid can have its own local baseline, but only
1123    /// one of those is global, meaning it will be the baseline in the
1124    /// parent of the @self.
1125    /// ## `row`
1126    /// the row index
1127    #[doc(alias = "gtk_grid_set_baseline_row")]
1128    #[doc(alias = "baseline-row")]
1129    fn set_baseline_row(&self, row: i32) {
1130        unsafe {
1131            ffi::gtk_grid_set_baseline_row(self.as_ref().to_glib_none().0, row);
1132        }
1133    }
1134
1135    /// Sets whether all columns of @self will have the same width.
1136    /// ## `homogeneous`
1137    /// [`true`] to make columns homogeneous
1138    #[doc(alias = "gtk_grid_set_column_homogeneous")]
1139    #[doc(alias = "column-homogeneous")]
1140    fn set_column_homogeneous(&self, homogeneous: bool) {
1141        unsafe {
1142            ffi::gtk_grid_set_column_homogeneous(
1143                self.as_ref().to_glib_none().0,
1144                homogeneous.into_glib(),
1145            );
1146        }
1147    }
1148
1149    /// Sets the amount of space between columns of @self.
1150    /// ## `spacing`
1151    /// the amount of space to insert between columns
1152    #[doc(alias = "gtk_grid_set_column_spacing")]
1153    #[doc(alias = "column-spacing")]
1154    fn set_column_spacing(&self, spacing: u32) {
1155        unsafe {
1156            ffi::gtk_grid_set_column_spacing(self.as_ref().to_glib_none().0, spacing);
1157        }
1158    }
1159
1160    /// Sets how the baseline should be positioned on @row of the
1161    /// grid, in case that row is assigned more space than is requested.
1162    ///
1163    /// The default baseline position is [`BaselinePosition::Center`][crate::BaselinePosition::Center].
1164    /// ## `row`
1165    /// a row index
1166    /// ## `pos`
1167    /// a [`BaselinePosition`][crate::BaselinePosition]
1168    #[doc(alias = "gtk_grid_set_row_baseline_position")]
1169    fn set_row_baseline_position(&self, row: i32, pos: BaselinePosition) {
1170        unsafe {
1171            ffi::gtk_grid_set_row_baseline_position(
1172                self.as_ref().to_glib_none().0,
1173                row,
1174                pos.into_glib(),
1175            );
1176        }
1177    }
1178
1179    /// Sets whether all rows of @self will have the same height.
1180    /// ## `homogeneous`
1181    /// [`true`] to make rows homogeneous
1182    #[doc(alias = "gtk_grid_set_row_homogeneous")]
1183    #[doc(alias = "row-homogeneous")]
1184    fn set_row_homogeneous(&self, homogeneous: bool) {
1185        unsafe {
1186            ffi::gtk_grid_set_row_homogeneous(
1187                self.as_ref().to_glib_none().0,
1188                homogeneous.into_glib(),
1189            );
1190        }
1191    }
1192
1193    /// Sets the amount of space between rows of @self.
1194    /// ## `spacing`
1195    /// the amount of space to insert between rows
1196    #[doc(alias = "gtk_grid_set_row_spacing")]
1197    #[doc(alias = "row-spacing")]
1198    fn set_row_spacing(&self, spacing: u32) {
1199        unsafe {
1200            ffi::gtk_grid_set_row_spacing(self.as_ref().to_glib_none().0, spacing);
1201        }
1202    }
1203
1204    #[doc(alias = "baseline-row")]
1205    fn connect_baseline_row_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1206        unsafe extern "C" fn notify_baseline_row_trampoline<P: IsA<Grid>, F: Fn(&P) + 'static>(
1207            this: *mut ffi::GtkGrid,
1208            _param_spec: glib::ffi::gpointer,
1209            f: glib::ffi::gpointer,
1210        ) {
1211            unsafe {
1212                let f: &F = &*(f as *const F);
1213                f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1214            }
1215        }
1216        unsafe {
1217            let f: Box_<F> = Box_::new(f);
1218            connect_raw(
1219                self.as_ptr() as *mut _,
1220                c"notify::baseline-row".as_ptr(),
1221                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1222                    notify_baseline_row_trampoline::<Self, F> as *const (),
1223                )),
1224                Box_::into_raw(f),
1225            )
1226        }
1227    }
1228
1229    #[doc(alias = "column-homogeneous")]
1230    fn connect_column_homogeneous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1231        unsafe extern "C" fn notify_column_homogeneous_trampoline<
1232            P: IsA<Grid>,
1233            F: Fn(&P) + 'static,
1234        >(
1235            this: *mut ffi::GtkGrid,
1236            _param_spec: glib::ffi::gpointer,
1237            f: glib::ffi::gpointer,
1238        ) {
1239            unsafe {
1240                let f: &F = &*(f as *const F);
1241                f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1242            }
1243        }
1244        unsafe {
1245            let f: Box_<F> = Box_::new(f);
1246            connect_raw(
1247                self.as_ptr() as *mut _,
1248                c"notify::column-homogeneous".as_ptr(),
1249                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1250                    notify_column_homogeneous_trampoline::<Self, F> as *const (),
1251                )),
1252                Box_::into_raw(f),
1253            )
1254        }
1255    }
1256
1257    #[doc(alias = "column-spacing")]
1258    fn connect_column_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1259        unsafe extern "C" fn notify_column_spacing_trampoline<P: IsA<Grid>, F: Fn(&P) + 'static>(
1260            this: *mut ffi::GtkGrid,
1261            _param_spec: glib::ffi::gpointer,
1262            f: glib::ffi::gpointer,
1263        ) {
1264            unsafe {
1265                let f: &F = &*(f as *const F);
1266                f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1267            }
1268        }
1269        unsafe {
1270            let f: Box_<F> = Box_::new(f);
1271            connect_raw(
1272                self.as_ptr() as *mut _,
1273                c"notify::column-spacing".as_ptr(),
1274                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1275                    notify_column_spacing_trampoline::<Self, F> as *const (),
1276                )),
1277                Box_::into_raw(f),
1278            )
1279        }
1280    }
1281
1282    #[doc(alias = "row-homogeneous")]
1283    fn connect_row_homogeneous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1284        unsafe extern "C" fn notify_row_homogeneous_trampoline<
1285            P: IsA<Grid>,
1286            F: Fn(&P) + 'static,
1287        >(
1288            this: *mut ffi::GtkGrid,
1289            _param_spec: glib::ffi::gpointer,
1290            f: glib::ffi::gpointer,
1291        ) {
1292            unsafe {
1293                let f: &F = &*(f as *const F);
1294                f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1295            }
1296        }
1297        unsafe {
1298            let f: Box_<F> = Box_::new(f);
1299            connect_raw(
1300                self.as_ptr() as *mut _,
1301                c"notify::row-homogeneous".as_ptr(),
1302                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1303                    notify_row_homogeneous_trampoline::<Self, F> as *const (),
1304                )),
1305                Box_::into_raw(f),
1306            )
1307        }
1308    }
1309
1310    #[doc(alias = "row-spacing")]
1311    fn connect_row_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1312        unsafe extern "C" fn notify_row_spacing_trampoline<P: IsA<Grid>, F: Fn(&P) + 'static>(
1313            this: *mut ffi::GtkGrid,
1314            _param_spec: glib::ffi::gpointer,
1315            f: glib::ffi::gpointer,
1316        ) {
1317            unsafe {
1318                let f: &F = &*(f as *const F);
1319                f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1320            }
1321        }
1322        unsafe {
1323            let f: Box_<F> = Box_::new(f);
1324            connect_raw(
1325                self.as_ptr() as *mut _,
1326                c"notify::row-spacing".as_ptr(),
1327                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1328                    notify_row_spacing_trampoline::<Self, F> as *const (),
1329                )),
1330                Box_::into_raw(f),
1331            )
1332        }
1333    }
1334}
1335
1336impl<O: IsA<Grid>> GridExt for O {}