Skip to main content

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