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, ffi,
8};
9use glib::{
10 prelude::*,
11 signal::{SignalHandlerId, connect_raw},
12 translate::*,
13};
14use std::boxed::Box as Box_;
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 | Writable
39 ///
40 ///
41 /// #### `column-homogeneous`
42 /// Readable | Writable
43 ///
44 ///
45 /// #### `column-spacing`
46 /// Readable | Writable
47 ///
48 ///
49 /// #### `row-homogeneous`
50 /// Readable | Writable
51 ///
52 ///
53 /// #### `row-spacing`
54 /// Readable | Writable
55 /// <details><summary><h4>Container</h4></summary>
56 ///
57 ///
58 /// #### `border-width`
59 /// Readable | Writable
60 ///
61 ///
62 /// #### `child`
63 /// Writable
64 ///
65 ///
66 /// #### `resize-mode`
67 /// Readable | Writable
68 /// </details>
69 /// <details><summary><h4>Widget</h4></summary>
70 ///
71 ///
72 /// #### `app-paintable`
73 /// Readable | Writable
74 ///
75 ///
76 /// #### `can-default`
77 /// Readable | Writable
78 ///
79 ///
80 /// #### `can-focus`
81 /// Readable | Writable
82 ///
83 ///
84 /// #### `composite-child`
85 /// Readable
86 ///
87 ///
88 /// #### `double-buffered`
89 /// Whether the widget is double buffered.
90 ///
91 /// Readable | Writable
92 ///
93 ///
94 /// #### `events`
95 /// Readable | Writable
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 | Writable
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 | Writable
113 ///
114 ///
115 /// #### `halign`
116 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
117 ///
118 /// Readable | Writable
119 ///
120 ///
121 /// #### `has-default`
122 /// Readable | Writable
123 ///
124 ///
125 /// #### `has-focus`
126 /// Readable | Writable
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 | Writable
141 ///
142 ///
143 /// #### `height-request`
144 /// Readable | Writable
145 ///
146 ///
147 /// #### `hexpand`
148 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
149 ///
150 /// Readable | Writable
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 | Writable
157 ///
158 ///
159 /// #### `is-focus`
160 /// Readable | Writable
161 ///
162 ///
163 /// #### `margin`
164 /// Sets all four sides' margin at once. If read, returns max
165 /// margin on any side.
166 ///
167 /// Readable | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
230 ///
231 ///
232 /// #### `name`
233 /// Readable | Writable
234 ///
235 ///
236 /// #### `no-show-all`
237 /// Readable | Writable
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 | Writable
247 ///
248 ///
249 /// #### `parent`
250 /// Readable | Writable
251 ///
252 ///
253 /// #### `receives-default`
254 /// Readable | Writable
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 | Writable
266 ///
267 ///
268 /// #### `style`
269 /// The style of the widget, which contains information about how it will look (colors, etc).
270 ///
271 /// Readable | Writable
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 | Writable
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 | Writable
304 ///
305 ///
306 /// #### `valign`
307 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
308 ///
309 /// Readable | Writable
310 ///
311 ///
312 /// #### `vexpand`
313 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
314 ///
315 /// Readable | Writable
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 | Writable
322 ///
323 ///
324 /// #### `visible`
325 /// Readable | Writable
326 ///
327 ///
328 /// #### `width-request`
329 /// Readable | Writable
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 | Writable
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 assert_initialized_main_thread!();
730 self.builder.build()
731 }
732}
733
734/// Trait containing all [`struct@Grid`] methods.
735///
736/// # Implementors
737///
738/// [`Grid`][struct@crate::Grid]
739pub trait GridExt: IsA<Grid> + 'static {
740 /// Adds a widget to the grid.
741 ///
742 /// The position of `child` is determined by `left` and `top`. The
743 /// number of “cells” that `child` will occupy is determined by
744 /// `width` and `height`.
745 /// ## `child`
746 /// the widget to add
747 /// ## `left`
748 /// the column number to attach the left side of `child` to
749 /// ## `top`
750 /// the row number to attach the top side of `child` to
751 /// ## `width`
752 /// the number of columns that `child` will span
753 /// ## `height`
754 /// the number of rows that `child` will span
755 #[doc(alias = "gtk_grid_attach")]
756 fn attach(&self, child: &impl IsA<Widget>, left: i32, top: i32, width: i32, height: i32) {
757 unsafe {
758 ffi::gtk_grid_attach(
759 self.as_ref().to_glib_none().0,
760 child.as_ref().to_glib_none().0,
761 left,
762 top,
763 width,
764 height,
765 );
766 }
767 }
768
769 /// Adds a widget to the grid.
770 ///
771 /// The widget is placed next to `sibling`, on the side determined by
772 /// `side`. When `sibling` is [`None`], the widget is placed in row (for
773 /// left or right placement) or column 0 (for top or bottom placement),
774 /// at the end indicated by `side`.
775 ///
776 /// Attaching widgets labeled [1], [2], [3] with `sibling` == [`None`] and
777 /// `side` == [`PositionType::Left`][crate::PositionType::Left] yields a layout of [3][2][1].
778 /// ## `child`
779 /// the widget to add
780 /// ## `sibling`
781 /// the child of `self` that `child` will be placed
782 /// next to, or [`None`] to place `child` at the beginning or end
783 /// ## `side`
784 /// the side of `sibling` that `child` is positioned next to
785 /// ## `width`
786 /// the number of columns that `child` will span
787 /// ## `height`
788 /// the number of rows that `child` will span
789 #[doc(alias = "gtk_grid_attach_next_to")]
790 fn attach_next_to(
791 &self,
792 child: &impl IsA<Widget>,
793 sibling: Option<&impl IsA<Widget>>,
794 side: PositionType,
795 width: i32,
796 height: i32,
797 ) {
798 unsafe {
799 ffi::gtk_grid_attach_next_to(
800 self.as_ref().to_glib_none().0,
801 child.as_ref().to_glib_none().0,
802 sibling.map(|p| p.as_ref()).to_glib_none().0,
803 side.into_glib(),
804 width,
805 height,
806 );
807 }
808 }
809
810 /// Returns which row defines the global baseline of `self`.
811 ///
812 /// # Returns
813 ///
814 /// the row index defining the global baseline
815 #[doc(alias = "gtk_grid_get_baseline_row")]
816 #[doc(alias = "get_baseline_row")]
817 #[doc(alias = "baseline-row")]
818 fn baseline_row(&self) -> i32 {
819 unsafe { ffi::gtk_grid_get_baseline_row(self.as_ref().to_glib_none().0) }
820 }
821
822 /// Gets the child of `self` whose area covers the grid
823 /// cell whose upper left corner is at `left`, `top`.
824 /// ## `left`
825 /// the left edge of the cell
826 /// ## `top`
827 /// the top edge of the cell
828 ///
829 /// # Returns
830 ///
831 /// the child at the given position, or [`None`]
832 #[doc(alias = "gtk_grid_get_child_at")]
833 #[doc(alias = "get_child_at")]
834 fn child_at(&self, left: i32, top: i32) -> Option<Widget> {
835 unsafe {
836 from_glib_none(ffi::gtk_grid_get_child_at(
837 self.as_ref().to_glib_none().0,
838 left,
839 top,
840 ))
841 }
842 }
843
844 /// Returns whether all columns of `self` have the same width.
845 ///
846 /// # Returns
847 ///
848 /// whether all columns of `self` have the same width.
849 #[doc(alias = "gtk_grid_get_column_homogeneous")]
850 #[doc(alias = "get_column_homogeneous")]
851 #[doc(alias = "column-homogeneous")]
852 fn is_column_homogeneous(&self) -> bool {
853 unsafe {
854 from_glib(ffi::gtk_grid_get_column_homogeneous(
855 self.as_ref().to_glib_none().0,
856 ))
857 }
858 }
859
860 /// Returns the amount of space between the columns of `self`.
861 ///
862 /// # Returns
863 ///
864 /// the column spacing of `self`
865 #[doc(alias = "gtk_grid_get_column_spacing")]
866 #[doc(alias = "get_column_spacing")]
867 #[doc(alias = "column-spacing")]
868 fn column_spacing(&self) -> u32 {
869 unsafe { ffi::gtk_grid_get_column_spacing(self.as_ref().to_glib_none().0) }
870 }
871
872 /// Returns the baseline position of `row` as set
873 /// by [`set_row_baseline_position()`][Self::set_row_baseline_position()] or the default value
874 /// [`BaselinePosition::Center`][crate::BaselinePosition::Center].
875 /// ## `row`
876 /// a row index
877 ///
878 /// # Returns
879 ///
880 /// the baseline position of `row`
881 #[doc(alias = "gtk_grid_get_row_baseline_position")]
882 #[doc(alias = "get_row_baseline_position")]
883 fn row_baseline_position(&self, row: i32) -> BaselinePosition {
884 unsafe {
885 from_glib(ffi::gtk_grid_get_row_baseline_position(
886 self.as_ref().to_glib_none().0,
887 row,
888 ))
889 }
890 }
891
892 /// Returns whether all rows of `self` have the same height.
893 ///
894 /// # Returns
895 ///
896 /// whether all rows of `self` have the same height.
897 #[doc(alias = "gtk_grid_get_row_homogeneous")]
898 #[doc(alias = "get_row_homogeneous")]
899 #[doc(alias = "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 #[doc(alias = "row-spacing")]
916 fn row_spacing(&self) -> u32 {
917 unsafe { ffi::gtk_grid_get_row_spacing(self.as_ref().to_glib_none().0) }
918 }
919
920 /// Inserts a column at the specified position.
921 ///
922 /// Children which are attached at or to the right of this position
923 /// are moved one column to the right. Children which span across this
924 /// position are grown to span the new column.
925 /// ## `position`
926 /// the position to insert the column at
927 #[doc(alias = "gtk_grid_insert_column")]
928 fn insert_column(&self, position: i32) {
929 unsafe {
930 ffi::gtk_grid_insert_column(self.as_ref().to_glib_none().0, position);
931 }
932 }
933
934 /// Inserts a row or column at the specified position.
935 ///
936 /// The new row or column is placed next to `sibling`, on the side
937 /// determined by `side`. If `side` is [`PositionType::Top`][crate::PositionType::Top] or [`PositionType::Bottom`][crate::PositionType::Bottom],
938 /// a row is inserted. If `side` is [`PositionType::Left`][crate::PositionType::Left] of [`PositionType::Right`][crate::PositionType::Right],
939 /// a column is inserted.
940 /// ## `sibling`
941 /// the child of `self` that the new row or column will be
942 /// placed next to
943 /// ## `side`
944 /// the side of `sibling` that `child` is positioned next to
945 #[doc(alias = "gtk_grid_insert_next_to")]
946 fn insert_next_to(&self, sibling: &impl IsA<Widget>, side: PositionType) {
947 unsafe {
948 ffi::gtk_grid_insert_next_to(
949 self.as_ref().to_glib_none().0,
950 sibling.as_ref().to_glib_none().0,
951 side.into_glib(),
952 );
953 }
954 }
955
956 /// Inserts a row at the specified position.
957 ///
958 /// Children which are attached at or below this position
959 /// are moved one row down. Children which span across this
960 /// position are grown to span the new row.
961 /// ## `position`
962 /// the position to insert the row at
963 #[doc(alias = "gtk_grid_insert_row")]
964 fn insert_row(&self, position: i32) {
965 unsafe {
966 ffi::gtk_grid_insert_row(self.as_ref().to_glib_none().0, position);
967 }
968 }
969
970 /// Removes a column from the grid.
971 ///
972 /// Children that are placed in this column are removed,
973 /// spanning children that overlap this column have their
974 /// width reduced by one, and children after the column
975 /// are moved to the left.
976 /// ## `position`
977 /// the position of the column to remove
978 #[doc(alias = "gtk_grid_remove_column")]
979 fn remove_column(&self, position: i32) {
980 unsafe {
981 ffi::gtk_grid_remove_column(self.as_ref().to_glib_none().0, position);
982 }
983 }
984
985 /// Removes a row from the grid.
986 ///
987 /// Children that are placed in this row are removed,
988 /// spanning children that overlap this row have their
989 /// height reduced by one, and children below the row
990 /// are moved up.
991 /// ## `position`
992 /// the position of the row to remove
993 #[doc(alias = "gtk_grid_remove_row")]
994 fn remove_row(&self, position: i32) {
995 unsafe {
996 ffi::gtk_grid_remove_row(self.as_ref().to_glib_none().0, position);
997 }
998 }
999
1000 /// Sets which row defines the global baseline for the entire grid.
1001 /// Each row in the grid can have its own local baseline, but only
1002 /// one of those is global, meaning it will be the baseline in the
1003 /// parent of the `self`.
1004 /// ## `row`
1005 /// the row index
1006 #[doc(alias = "gtk_grid_set_baseline_row")]
1007 #[doc(alias = "baseline-row")]
1008 fn set_baseline_row(&self, row: i32) {
1009 unsafe {
1010 ffi::gtk_grid_set_baseline_row(self.as_ref().to_glib_none().0, row);
1011 }
1012 }
1013
1014 /// Sets whether all columns of `self` will have the same width.
1015 /// ## `homogeneous`
1016 /// [`true`] to make columns homogeneous
1017 #[doc(alias = "gtk_grid_set_column_homogeneous")]
1018 #[doc(alias = "column-homogeneous")]
1019 fn set_column_homogeneous(&self, homogeneous: bool) {
1020 unsafe {
1021 ffi::gtk_grid_set_column_homogeneous(
1022 self.as_ref().to_glib_none().0,
1023 homogeneous.into_glib(),
1024 );
1025 }
1026 }
1027
1028 /// Sets the amount of space between columns of `self`.
1029 /// ## `spacing`
1030 /// the amount of space to insert between columns
1031 #[doc(alias = "gtk_grid_set_column_spacing")]
1032 #[doc(alias = "column-spacing")]
1033 fn set_column_spacing(&self, spacing: u32) {
1034 unsafe {
1035 ffi::gtk_grid_set_column_spacing(self.as_ref().to_glib_none().0, spacing);
1036 }
1037 }
1038
1039 /// Sets how the baseline should be positioned on `row` of the
1040 /// grid, in case that row is assigned more space than is requested.
1041 /// ## `row`
1042 /// a row index
1043 /// ## `pos`
1044 /// a [`BaselinePosition`][crate::BaselinePosition]
1045 #[doc(alias = "gtk_grid_set_row_baseline_position")]
1046 fn set_row_baseline_position(&self, row: i32, pos: BaselinePosition) {
1047 unsafe {
1048 ffi::gtk_grid_set_row_baseline_position(
1049 self.as_ref().to_glib_none().0,
1050 row,
1051 pos.into_glib(),
1052 );
1053 }
1054 }
1055
1056 /// Sets whether all rows of `self` will have the same height.
1057 /// ## `homogeneous`
1058 /// [`true`] to make rows homogeneous
1059 #[doc(alias = "gtk_grid_set_row_homogeneous")]
1060 #[doc(alias = "row-homogeneous")]
1061 fn set_row_homogeneous(&self, homogeneous: bool) {
1062 unsafe {
1063 ffi::gtk_grid_set_row_homogeneous(
1064 self.as_ref().to_glib_none().0,
1065 homogeneous.into_glib(),
1066 );
1067 }
1068 }
1069
1070 /// Sets the amount of space between rows of `self`.
1071 /// ## `spacing`
1072 /// the amount of space to insert between rows
1073 #[doc(alias = "gtk_grid_set_row_spacing")]
1074 #[doc(alias = "row-spacing")]
1075 fn set_row_spacing(&self, spacing: u32) {
1076 unsafe {
1077 ffi::gtk_grid_set_row_spacing(self.as_ref().to_glib_none().0, spacing);
1078 }
1079 }
1080
1081 fn cell_height<T: IsA<crate::Widget>>(&self, item: &T) -> i32 {
1082 crate::prelude::ContainerExtManual::child_property(
1083 self.as_ref(),
1084 &item.clone().upcast(),
1085 "height",
1086 )
1087 }
1088
1089 fn set_cell_height<T: IsA<crate::Widget>>(&self, item: &T, height: i32) {
1090 crate::prelude::ContainerExtManual::child_set_property(
1091 self.as_ref(),
1092 &item.clone().upcast(),
1093 "height",
1094 &height,
1095 )
1096 }
1097
1098 fn cell_width<T: IsA<crate::Widget>>(&self, item: &T) -> i32 {
1099 crate::prelude::ContainerExtManual::child_property(
1100 self.as_ref(),
1101 &item.clone().upcast(),
1102 "width",
1103 )
1104 }
1105
1106 fn set_cell_width<T: IsA<crate::Widget>>(&self, item: &T, width: i32) {
1107 crate::prelude::ContainerExtManual::child_set_property(
1108 self.as_ref(),
1109 &item.clone().upcast(),
1110 "width",
1111 &width,
1112 )
1113 }
1114
1115 #[doc(alias = "cell.left-attach")]
1116 fn cell_left_attach<T: IsA<crate::Widget>>(&self, item: &T) -> i32 {
1117 crate::prelude::ContainerExtManual::child_property(
1118 self.as_ref(),
1119 &item.clone().upcast(),
1120 "left-attach",
1121 )
1122 }
1123
1124 #[doc(alias = "cell.left-attach")]
1125 fn set_cell_left_attach<T: IsA<crate::Widget>>(&self, item: &T, left_attach: i32) {
1126 crate::prelude::ContainerExtManual::child_set_property(
1127 self.as_ref(),
1128 &item.clone().upcast(),
1129 "left-attach",
1130 &left_attach,
1131 )
1132 }
1133
1134 #[doc(alias = "cell.top-attach")]
1135 fn cell_top_attach<T: IsA<crate::Widget>>(&self, item: &T) -> i32 {
1136 crate::prelude::ContainerExtManual::child_property(
1137 self.as_ref(),
1138 &item.clone().upcast(),
1139 "top-attach",
1140 )
1141 }
1142
1143 #[doc(alias = "cell.top-attach")]
1144 fn set_cell_top_attach<T: IsA<crate::Widget>>(&self, item: &T, top_attach: i32) {
1145 crate::prelude::ContainerExtManual::child_set_property(
1146 self.as_ref(),
1147 &item.clone().upcast(),
1148 "top-attach",
1149 &top_attach,
1150 )
1151 }
1152
1153 #[doc(alias = "baseline-row")]
1154 fn connect_baseline_row_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1155 unsafe extern "C" fn notify_baseline_row_trampoline<P: IsA<Grid>, F: Fn(&P) + 'static>(
1156 this: *mut ffi::GtkGrid,
1157 _param_spec: glib::ffi::gpointer,
1158 f: glib::ffi::gpointer,
1159 ) {
1160 unsafe {
1161 let f: &F = &*(f as *const F);
1162 f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1163 }
1164 }
1165 unsafe {
1166 let f: Box_<F> = Box_::new(f);
1167 connect_raw(
1168 self.as_ptr() as *mut _,
1169 c"notify::baseline-row".as_ptr(),
1170 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1171 notify_baseline_row_trampoline::<Self, F> as *const (),
1172 )),
1173 Box_::into_raw(f),
1174 )
1175 }
1176 }
1177
1178 #[doc(alias = "column-homogeneous")]
1179 fn connect_column_homogeneous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1180 unsafe extern "C" fn notify_column_homogeneous_trampoline<
1181 P: IsA<Grid>,
1182 F: Fn(&P) + 'static,
1183 >(
1184 this: *mut ffi::GtkGrid,
1185 _param_spec: glib::ffi::gpointer,
1186 f: glib::ffi::gpointer,
1187 ) {
1188 unsafe {
1189 let f: &F = &*(f as *const F);
1190 f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1191 }
1192 }
1193 unsafe {
1194 let f: Box_<F> = Box_::new(f);
1195 connect_raw(
1196 self.as_ptr() as *mut _,
1197 c"notify::column-homogeneous".as_ptr(),
1198 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1199 notify_column_homogeneous_trampoline::<Self, F> as *const (),
1200 )),
1201 Box_::into_raw(f),
1202 )
1203 }
1204 }
1205
1206 #[doc(alias = "column-spacing")]
1207 fn connect_column_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1208 unsafe extern "C" fn notify_column_spacing_trampoline<P: IsA<Grid>, F: Fn(&P) + 'static>(
1209 this: *mut ffi::GtkGrid,
1210 _param_spec: glib::ffi::gpointer,
1211 f: glib::ffi::gpointer,
1212 ) {
1213 unsafe {
1214 let f: &F = &*(f as *const F);
1215 f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1216 }
1217 }
1218 unsafe {
1219 let f: Box_<F> = Box_::new(f);
1220 connect_raw(
1221 self.as_ptr() as *mut _,
1222 c"notify::column-spacing".as_ptr(),
1223 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1224 notify_column_spacing_trampoline::<Self, F> as *const (),
1225 )),
1226 Box_::into_raw(f),
1227 )
1228 }
1229 }
1230
1231 #[doc(alias = "row-homogeneous")]
1232 fn connect_row_homogeneous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1233 unsafe extern "C" fn notify_row_homogeneous_trampoline<
1234 P: IsA<Grid>,
1235 F: Fn(&P) + 'static,
1236 >(
1237 this: *mut ffi::GtkGrid,
1238 _param_spec: glib::ffi::gpointer,
1239 f: glib::ffi::gpointer,
1240 ) {
1241 unsafe {
1242 let f: &F = &*(f as *const F);
1243 f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1244 }
1245 }
1246 unsafe {
1247 let f: Box_<F> = Box_::new(f);
1248 connect_raw(
1249 self.as_ptr() as *mut _,
1250 c"notify::row-homogeneous".as_ptr(),
1251 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1252 notify_row_homogeneous_trampoline::<Self, F> as *const (),
1253 )),
1254 Box_::into_raw(f),
1255 )
1256 }
1257 }
1258
1259 #[doc(alias = "row-spacing")]
1260 fn connect_row_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1261 unsafe extern "C" fn notify_row_spacing_trampoline<P: IsA<Grid>, F: Fn(&P) + 'static>(
1262 this: *mut ffi::GtkGrid,
1263 _param_spec: glib::ffi::gpointer,
1264 f: glib::ffi::gpointer,
1265 ) {
1266 unsafe {
1267 let f: &F = &*(f as *const F);
1268 f(Grid::from_glib_borrow(this).unsafe_cast_ref())
1269 }
1270 }
1271 unsafe {
1272 let f: Box_<F> = Box_::new(f);
1273 connect_raw(
1274 self.as_ptr() as *mut _,
1275 c"notify::row-spacing".as_ptr(),
1276 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1277 notify_row_spacing_trampoline::<Self, F> as *const (),
1278 )),
1279 Box_::into_raw(f),
1280 )
1281 }
1282 }
1283}
1284
1285impl<O: IsA<Grid>> GridExt for O {}