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    /// Adds a widget to the grid.
806    ///
807    /// The position of @child is determined by @column and @row.
808    /// The number of “cells” that @child will occupy is determined
809    /// by @width and @height.
810    /// ## `child`
811    /// the widget to add
812    /// ## `column`
813    /// the column number to attach the left side of @child to
814    /// ## `row`
815    /// the row number to attach the top side of @child to
816    /// ## `width`
817    /// the number of columns that @child will span
818    /// ## `height`
819    /// the number of rows that @child will span
820    #[doc(alias = "gtk_grid_attach")]
821    fn attach(&self, child: &impl IsA<Widget>, column: i32, row: i32, width: i32, height: i32) {
822        unsafe {
823            ffi::gtk_grid_attach(
824                self.as_ref().to_glib_none().0,
825                child.as_ref().to_glib_none().0,
826                column,
827                row,
828                width,
829                height,
830            );
831        }
832    }
833
834    /// Adds a widget to the grid.
835    ///
836    /// The widget is placed next to @sibling, on the side determined by
837    /// @side. When @sibling is [`None`], the widget is placed in row (for
838    /// left or right placement) or column 0 (for top or bottom placement),
839    /// at the end indicated by @side.
840    ///
841    /// Attaching widgets labeled `[1]`, `[2]`, `[3]` with `@sibling == [`None`]` and
842    /// `@side == [`PositionType::Left`][crate::PositionType::Left]` yields a layout of `[3][2][1]`.
843    /// ## `child`
844    /// the widget to add
845    /// ## `sibling`
846    /// the child of @self that @child will be placed
847    ///   next to, or [`None`] to place @child at the beginning or end
848    /// ## `side`
849    /// the side of @sibling that @child is positioned next to
850    /// ## `width`
851    /// the number of columns that @child will span
852    /// ## `height`
853    /// the number of rows that @child will span
854    #[doc(alias = "gtk_grid_attach_next_to")]
855    fn attach_next_to(
856        &self,
857        child: &impl IsA<Widget>,
858        sibling: Option<&impl IsA<Widget>>,
859        side: PositionType,
860        width: i32,
861        height: i32,
862    ) {
863        unsafe {
864            ffi::gtk_grid_attach_next_to(
865                self.as_ref().to_glib_none().0,
866                child.as_ref().to_glib_none().0,
867                sibling.map(|p| p.as_ref()).to_glib_none().0,
868                side.into_glib(),
869                width,
870                height,
871            );
872        }
873    }
874
875    /// Returns which row defines the global baseline of @self.
876    ///
877    /// # Returns
878    ///
879    /// the row index defining the global baseline
880    #[doc(alias = "gtk_grid_get_baseline_row")]
881    #[doc(alias = "get_baseline_row")]
882    #[doc(alias = "baseline-row")]
883    fn baseline_row(&self) -> i32 {
884        unsafe { ffi::gtk_grid_get_baseline_row(self.as_ref().to_glib_none().0) }
885    }
886
887    /// Gets the child of @self whose area covers the grid
888    /// cell at @column, @row.
889    /// ## `column`
890    /// the left edge of the cell
891    /// ## `row`
892    /// the top edge of the cell
893    ///
894    /// # Returns
895    ///
896    /// the child at the given position
897    #[doc(alias = "gtk_grid_get_child_at")]
898    #[doc(alias = "get_child_at")]
899    fn child_at(&self, column: i32, row: i32) -> Option<Widget> {
900        unsafe {
901            from_glib_none(ffi::gtk_grid_get_child_at(
902                self.as_ref().to_glib_none().0,
903                column,
904                row,
905            ))
906        }
907    }
908
909    /// Returns whether all columns of @self have the same width.
910    ///
911    /// # Returns
912    ///
913    /// whether all columns of @self have the same width.
914    #[doc(alias = "gtk_grid_get_column_homogeneous")]
915    #[doc(alias = "get_column_homogeneous")]
916    #[doc(alias = "column-homogeneous")]
917    fn is_column_homogeneous(&self) -> bool {
918        unsafe {
919            from_glib(ffi::gtk_grid_get_column_homogeneous(
920                self.as_ref().to_glib_none().0,
921            ))
922        }
923    }
924
925    /// Returns the amount of space between the columns of @self.
926    ///
927    /// # Returns
928    ///
929    /// the column spacing of @self
930    #[doc(alias = "gtk_grid_get_column_spacing")]
931    #[doc(alias = "get_column_spacing")]
932    #[doc(alias = "column-spacing")]
933    fn column_spacing(&self) -> u32 {
934        unsafe { ffi::gtk_grid_get_column_spacing(self.as_ref().to_glib_none().0) }
935    }
936
937    /// Returns the baseline position of @row.
938    ///
939    /// See [`set_row_baseline_position()`][Self::set_row_baseline_position()].
940    /// ## `row`
941    /// a row index
942    ///
943    /// # Returns
944    ///
945    /// the baseline position of @row
946    #[doc(alias = "gtk_grid_get_row_baseline_position")]
947    #[doc(alias = "get_row_baseline_position")]
948    fn row_baseline_position(&self, row: i32) -> BaselinePosition {
949        unsafe {
950            from_glib(ffi::gtk_grid_get_row_baseline_position(
951                self.as_ref().to_glib_none().0,
952                row,
953            ))
954        }
955    }
956
957    /// Returns whether all rows of @self have the same height.
958    ///
959    /// # Returns
960    ///
961    /// whether all rows of @self have the same height.
962    #[doc(alias = "gtk_grid_get_row_homogeneous")]
963    #[doc(alias = "get_row_homogeneous")]
964    #[doc(alias = "row-homogeneous")]
965    fn is_row_homogeneous(&self) -> bool {
966        unsafe {
967            from_glib(ffi::gtk_grid_get_row_homogeneous(
968                self.as_ref().to_glib_none().0,
969            ))
970        }
971    }
972
973    /// Returns the amount of space between the rows of @self.
974    ///
975    /// # Returns
976    ///
977    /// the row spacing of @self
978    #[doc(alias = "gtk_grid_get_row_spacing")]
979    #[doc(alias = "get_row_spacing")]
980    #[doc(alias = "row-spacing")]
981    fn row_spacing(&self) -> u32 {
982        unsafe { ffi::gtk_grid_get_row_spacing(self.as_ref().to_glib_none().0) }
983    }
984
985    /// Inserts a column at the specified position.
986    ///
987    /// Children which are attached at or to the right of this position
988    /// are moved one column to the right. Children which span across this
989    /// position are grown to span the new column.
990    /// ## `position`
991    /// the position to insert the column at
992    #[doc(alias = "gtk_grid_insert_column")]
993    fn insert_column(&self, position: i32) {
994        unsafe {
995            ffi::gtk_grid_insert_column(self.as_ref().to_glib_none().0, position);
996        }
997    }
998
999    /// Inserts a row or column at the specified position.
1000    ///
1001    /// The new row or column is placed next to @sibling, on the side
1002    /// determined by @side. If @side is [`PositionType::Top`][crate::PositionType::Top] or [`PositionType::Bottom`][crate::PositionType::Bottom],
1003    /// a row is inserted. If @side is [`PositionType::Left`][crate::PositionType::Left] of [`PositionType::Right`][crate::PositionType::Right],
1004    /// a column is inserted.
1005    /// ## `sibling`
1006    /// the child of @self that the new row or column will be
1007    ///   placed next to
1008    /// ## `side`
1009    /// the side of @sibling that @child is positioned next to
1010    #[doc(alias = "gtk_grid_insert_next_to")]
1011    fn insert_next_to(&self, sibling: &impl IsA<Widget>, side: PositionType) {
1012        unsafe {
1013            ffi::gtk_grid_insert_next_to(
1014                self.as_ref().to_glib_none().0,
1015                sibling.as_ref().to_glib_none().0,
1016                side.into_glib(),
1017            );
1018        }
1019    }
1020
1021    /// Inserts a row at the specified position.
1022    ///
1023    /// Children which are attached at or below this position
1024    /// are moved one row down. Children which span across this
1025    /// position are grown to span the new row.
1026    /// ## `position`
1027    /// the position to insert the row at
1028    #[doc(alias = "gtk_grid_insert_row")]
1029    fn insert_row(&self, position: i32) {
1030        unsafe {
1031            ffi::gtk_grid_insert_row(self.as_ref().to_glib_none().0, position);
1032        }
1033    }
1034
1035    /// Queries the attach points and spans of @child inside the given [`Grid`][crate::Grid].
1036    /// ## `child`
1037    /// a [`Widget`][crate::Widget] child of @self
1038    ///
1039    /// # Returns
1040    ///
1041    ///
1042    /// ## `column`
1043    /// the column used to attach the left side of @child
1044    ///
1045    /// ## `row`
1046    /// the row used to attach the top side of @child
1047    ///
1048    /// ## `width`
1049    /// the number of columns @child spans
1050    ///
1051    /// ## `height`
1052    /// the number of rows @child spans
1053    #[doc(alias = "gtk_grid_query_child")]
1054    fn query_child(&self, child: &impl IsA<Widget>) -> (i32, i32, i32, i32) {
1055        unsafe {
1056            let mut column = std::mem::MaybeUninit::uninit();
1057            let mut row = std::mem::MaybeUninit::uninit();
1058            let mut width = std::mem::MaybeUninit::uninit();
1059            let mut height = std::mem::MaybeUninit::uninit();
1060            ffi::gtk_grid_query_child(
1061                self.as_ref().to_glib_none().0,
1062                child.as_ref().to_glib_none().0,
1063                column.as_mut_ptr(),
1064                row.as_mut_ptr(),
1065                width.as_mut_ptr(),
1066                height.as_mut_ptr(),
1067            );
1068            (
1069                column.assume_init(),
1070                row.assume_init(),
1071                width.assume_init(),
1072                height.assume_init(),
1073            )
1074        }
1075    }
1076
1077    /// Removes a child from @self.
1078    ///
1079    /// The child must have been added with
1080    /// [`attach()`][Self::attach()] or [`attach_next_to()`][Self::attach_next_to()].
1081    /// ## `child`
1082    /// the child widget to remove
1083    #[doc(alias = "gtk_grid_remove")]
1084    fn remove(&self, child: &impl IsA<Widget>) {
1085        unsafe {
1086            ffi::gtk_grid_remove(
1087                self.as_ref().to_glib_none().0,
1088                child.as_ref().to_glib_none().0,
1089            );
1090        }
1091    }
1092
1093    /// Removes a column from the grid.
1094    ///
1095    /// Children that are placed in this column are removed,
1096    /// spanning children that overlap this column have their
1097    /// width reduced by one, and children after the column
1098    /// are moved to the left.
1099    /// ## `position`
1100    /// the position of the column to remove
1101    #[doc(alias = "gtk_grid_remove_column")]
1102    fn remove_column(&self, position: i32) {
1103        unsafe {
1104            ffi::gtk_grid_remove_column(self.as_ref().to_glib_none().0, position);
1105        }
1106    }
1107
1108    /// Removes a row from the grid.
1109    ///
1110    /// Children that are placed in this row are removed,
1111    /// spanning children that overlap this row have their
1112    /// height reduced by one, and children below the row
1113    /// are moved up.
1114    /// ## `position`
1115    /// the position of the row to remove
1116    #[doc(alias = "gtk_grid_remove_row")]
1117    fn remove_row(&self, position: i32) {
1118        unsafe {
1119            ffi::gtk_grid_remove_row(self.as_ref().to_glib_none().0, position);
1120        }
1121    }
1122
1123    /// Sets which row defines the global baseline for the entire grid.
1124    ///
1125    /// Each row in the grid can have its own local baseline, but only
1126    /// one of those is global, meaning it will be the baseline in the
1127    /// parent of the @self.
1128    /// ## `row`
1129    /// the row index
1130    #[doc(alias = "gtk_grid_set_baseline_row")]
1131    #[doc(alias = "baseline-row")]
1132    fn set_baseline_row(&self, row: i32) {
1133        unsafe {
1134            ffi::gtk_grid_set_baseline_row(self.as_ref().to_glib_none().0, row);
1135        }
1136    }
1137
1138    /// Sets whether all columns of @self will have the same width.
1139    /// ## `homogeneous`
1140    /// [`true`] to make columns homogeneous
1141    #[doc(alias = "gtk_grid_set_column_homogeneous")]
1142    #[doc(alias = "column-homogeneous")]
1143    fn set_column_homogeneous(&self, homogeneous: bool) {
1144        unsafe {
1145            ffi::gtk_grid_set_column_homogeneous(
1146                self.as_ref().to_glib_none().0,
1147                homogeneous.into_glib(),
1148            );
1149        }
1150    }
1151
1152    /// Sets the amount of space between columns of @self.
1153    /// ## `spacing`
1154    /// the amount of space to insert between columns
1155    #[doc(alias = "gtk_grid_set_column_spacing")]
1156    #[doc(alias = "column-spacing")]
1157    fn set_column_spacing(&self, spacing: u32) {
1158        unsafe {
1159            ffi::gtk_grid_set_column_spacing(self.as_ref().to_glib_none().0, spacing);
1160        }
1161    }
1162
1163    /// Sets how the baseline should be positioned on @row of the
1164    /// grid, in case that row is assigned more space than is requested.
1165    ///
1166    /// The default baseline position is [`BaselinePosition::Center`][crate::BaselinePosition::Center].
1167    /// ## `row`
1168    /// a row index
1169    /// ## `pos`
1170    /// a [`BaselinePosition`][crate::BaselinePosition]
1171    #[doc(alias = "gtk_grid_set_row_baseline_position")]
1172    fn set_row_baseline_position(&self, row: i32, pos: BaselinePosition) {
1173        unsafe {
1174            ffi::gtk_grid_set_row_baseline_position(
1175                self.as_ref().to_glib_none().0,
1176                row,
1177                pos.into_glib(),
1178            );
1179        }
1180    }
1181
1182    /// Sets whether all rows of @self will have the same height.
1183    /// ## `homogeneous`
1184    /// [`true`] to make rows homogeneous
1185    #[doc(alias = "gtk_grid_set_row_homogeneous")]
1186    #[doc(alias = "row-homogeneous")]
1187    fn set_row_homogeneous(&self, homogeneous: bool) {
1188        unsafe {
1189            ffi::gtk_grid_set_row_homogeneous(
1190                self.as_ref().to_glib_none().0,
1191                homogeneous.into_glib(),
1192            );
1193        }
1194    }
1195
1196    /// Sets the amount of space between rows of @self.
1197    /// ## `spacing`
1198    /// the amount of space to insert between rows
1199    #[doc(alias = "gtk_grid_set_row_spacing")]
1200    #[doc(alias = "row-spacing")]
1201    fn set_row_spacing(&self, spacing: u32) {
1202        unsafe {
1203            ffi::gtk_grid_set_row_spacing(self.as_ref().to_glib_none().0, spacing);
1204        }
1205    }
1206
1207    #[doc(alias = "baseline-row")]
1208    fn connect_baseline_row_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1209        unsafe extern "C" fn notify_baseline_row_trampoline<P: IsA<Grid>, F: Fn(&P) + 'static>(
1210            this: *mut ffi::GtkGrid,
1211            _param_spec: glib::ffi::gpointer,
1212            f: glib::ffi::gpointer,
1213        ) {
1214            unsafe {
1215                let f: &F = &*(f as *const F);
1216                f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1217            }
1218        }
1219        unsafe {
1220            let f: Box_<F> = Box_::new(f);
1221            connect_raw(
1222                self.as_ptr() as *mut _,
1223                c"notify::baseline-row".as_ptr(),
1224                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1225                    notify_baseline_row_trampoline::<Self, F> as *const (),
1226                )),
1227                Box_::into_raw(f),
1228            )
1229        }
1230    }
1231
1232    #[doc(alias = "column-homogeneous")]
1233    fn connect_column_homogeneous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1234        unsafe extern "C" fn notify_column_homogeneous_trampoline<
1235            P: IsA<Grid>,
1236            F: Fn(&P) + 'static,
1237        >(
1238            this: *mut ffi::GtkGrid,
1239            _param_spec: glib::ffi::gpointer,
1240            f: glib::ffi::gpointer,
1241        ) {
1242            unsafe {
1243                let f: &F = &*(f as *const F);
1244                f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1245            }
1246        }
1247        unsafe {
1248            let f: Box_<F> = Box_::new(f);
1249            connect_raw(
1250                self.as_ptr() as *mut _,
1251                c"notify::column-homogeneous".as_ptr(),
1252                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1253                    notify_column_homogeneous_trampoline::<Self, F> as *const (),
1254                )),
1255                Box_::into_raw(f),
1256            )
1257        }
1258    }
1259
1260    #[doc(alias = "column-spacing")]
1261    fn connect_column_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1262        unsafe extern "C" fn notify_column_spacing_trampoline<P: IsA<Grid>, F: Fn(&P) + 'static>(
1263            this: *mut ffi::GtkGrid,
1264            _param_spec: glib::ffi::gpointer,
1265            f: glib::ffi::gpointer,
1266        ) {
1267            unsafe {
1268                let f: &F = &*(f as *const F);
1269                f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1270            }
1271        }
1272        unsafe {
1273            let f: Box_<F> = Box_::new(f);
1274            connect_raw(
1275                self.as_ptr() as *mut _,
1276                c"notify::column-spacing".as_ptr(),
1277                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1278                    notify_column_spacing_trampoline::<Self, F> as *const (),
1279                )),
1280                Box_::into_raw(f),
1281            )
1282        }
1283    }
1284
1285    #[doc(alias = "row-homogeneous")]
1286    fn connect_row_homogeneous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1287        unsafe extern "C" fn notify_row_homogeneous_trampoline<
1288            P: IsA<Grid>,
1289            F: Fn(&P) + 'static,
1290        >(
1291            this: *mut ffi::GtkGrid,
1292            _param_spec: glib::ffi::gpointer,
1293            f: glib::ffi::gpointer,
1294        ) {
1295            unsafe {
1296                let f: &F = &*(f as *const F);
1297                f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1298            }
1299        }
1300        unsafe {
1301            let f: Box_<F> = Box_::new(f);
1302            connect_raw(
1303                self.as_ptr() as *mut _,
1304                c"notify::row-homogeneous".as_ptr(),
1305                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1306                    notify_row_homogeneous_trampoline::<Self, F> as *const (),
1307                )),
1308                Box_::into_raw(f),
1309            )
1310        }
1311    }
1312
1313    #[doc(alias = "row-spacing")]
1314    fn connect_row_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1315        unsafe extern "C" fn notify_row_spacing_trampoline<P: IsA<Grid>, F: Fn(&P) + 'static>(
1316            this: *mut ffi::GtkGrid,
1317            _param_spec: glib::ffi::gpointer,
1318            f: glib::ffi::gpointer,
1319        ) {
1320            unsafe {
1321                let f: &F = &*(f as *const F);
1322                f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1323            }
1324        }
1325        unsafe {
1326            let f: Box_<F> = Box_::new(f);
1327            connect_raw(
1328                self.as_ptr() as *mut _,
1329                c"notify::row-spacing".as_ptr(),
1330                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1331                    notify_row_spacing_trampoline::<Self, F> as *const (),
1332                )),
1333                Box_::into_raw(f),
1334            )
1335        }
1336    }
1337}
1338
1339impl<O: IsA<Grid>> GridExt for O {}