Skip to main content

gtk4/auto/
grid_layout_child.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::{LayoutChild, ffi};
6use glib::{
7    prelude::*,
8    signal::{SignalHandlerId, connect_raw},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    /// [`LayoutChild`][crate::LayoutChild] subclass for children in a [`GridLayout`][crate::GridLayout].
15    ///
16    /// ## Properties
17    ///
18    ///
19    /// #### `column`
20    ///  The column to place the child in.
21    ///
22    /// Readable | Writeable
23    ///
24    ///
25    /// #### `column-span`
26    ///  The number of columns the child spans to.
27    ///
28    /// Readable | Writeable
29    ///
30    ///
31    /// #### `row`
32    ///  The row to place the child in.
33    ///
34    /// Readable | Writeable
35    ///
36    ///
37    /// #### `row-span`
38    ///  The number of rows the child spans to.
39    ///
40    /// Readable | Writeable
41    /// <details><summary><h4>LayoutChild</h4></summary>
42    ///
43    ///
44    /// #### `child-widget`
45    ///  The widget that is associated to the [`LayoutChild`][crate::LayoutChild] instance.
46    ///
47    /// Readable | Writeable | Construct Only
48    ///
49    ///
50    /// #### `layout-manager`
51    ///  The layout manager that created the [`LayoutChild`][crate::LayoutChild] instance.
52    ///
53    /// Readable | Writeable | Construct Only
54    /// </details>
55    ///
56    /// # Implements
57    ///
58    /// [`LayoutChildExt`][trait@crate::prelude::LayoutChildExt], [`trait@glib::ObjectExt`]
59    #[doc(alias = "GtkGridLayoutChild")]
60    pub struct GridLayoutChild(Object<ffi::GtkGridLayoutChild, ffi::GtkGridLayoutChildClass>) @extends LayoutChild;
61
62    match fn {
63        type_ => || ffi::gtk_grid_layout_child_get_type(),
64    }
65}
66
67impl GridLayoutChild {
68    /// Retrieves the column number to which @self attaches its left side.
69    ///
70    /// # Returns
71    ///
72    /// the column number
73    #[doc(alias = "gtk_grid_layout_child_get_column")]
74    #[doc(alias = "get_column")]
75    pub fn column(&self) -> i32 {
76        unsafe { ffi::gtk_grid_layout_child_get_column(self.to_glib_none().0) }
77    }
78
79    /// Retrieves the number of columns that @self spans to.
80    ///
81    /// # Returns
82    ///
83    /// the number of columns
84    #[doc(alias = "gtk_grid_layout_child_get_column_span")]
85    #[doc(alias = "get_column_span")]
86    #[doc(alias = "column-span")]
87    pub fn column_span(&self) -> i32 {
88        unsafe { ffi::gtk_grid_layout_child_get_column_span(self.to_glib_none().0) }
89    }
90
91    /// Retrieves the row number to which @self attaches its top side.
92    ///
93    /// # Returns
94    ///
95    /// the row number
96    #[doc(alias = "gtk_grid_layout_child_get_row")]
97    #[doc(alias = "get_row")]
98    pub fn row(&self) -> i32 {
99        unsafe { ffi::gtk_grid_layout_child_get_row(self.to_glib_none().0) }
100    }
101
102    /// Retrieves the number of rows that @self spans to.
103    ///
104    /// # Returns
105    ///
106    /// the number of row
107    #[doc(alias = "gtk_grid_layout_child_get_row_span")]
108    #[doc(alias = "get_row_span")]
109    #[doc(alias = "row-span")]
110    pub fn row_span(&self) -> i32 {
111        unsafe { ffi::gtk_grid_layout_child_get_row_span(self.to_glib_none().0) }
112    }
113
114    /// Sets the column number to attach the left side of @self.
115    /// ## `column`
116    /// the attach point for @self
117    #[doc(alias = "gtk_grid_layout_child_set_column")]
118    #[doc(alias = "column")]
119    pub fn set_column(&self, column: i32) {
120        unsafe {
121            ffi::gtk_grid_layout_child_set_column(self.to_glib_none().0, column);
122        }
123    }
124
125    /// Sets the number of columns @self spans to.
126    /// ## `span`
127    /// the span of @self
128    #[doc(alias = "gtk_grid_layout_child_set_column_span")]
129    #[doc(alias = "column-span")]
130    pub fn set_column_span(&self, span: i32) {
131        unsafe {
132            ffi::gtk_grid_layout_child_set_column_span(self.to_glib_none().0, span);
133        }
134    }
135
136    /// Sets the row to place @self in.
137    /// ## `row`
138    /// the row for @self
139    #[doc(alias = "gtk_grid_layout_child_set_row")]
140    #[doc(alias = "row")]
141    pub fn set_row(&self, row: i32) {
142        unsafe {
143            ffi::gtk_grid_layout_child_set_row(self.to_glib_none().0, row);
144        }
145    }
146
147    /// Sets the number of rows @self spans to.
148    /// ## `span`
149    /// the span of @self
150    #[doc(alias = "gtk_grid_layout_child_set_row_span")]
151    #[doc(alias = "row-span")]
152    pub fn set_row_span(&self, span: i32) {
153        unsafe {
154            ffi::gtk_grid_layout_child_set_row_span(self.to_glib_none().0, span);
155        }
156    }
157
158    #[doc(alias = "column")]
159    pub fn connect_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
160        unsafe extern "C" fn notify_column_trampoline<F: Fn(&GridLayoutChild) + 'static>(
161            this: *mut ffi::GtkGridLayoutChild,
162            _param_spec: glib::ffi::gpointer,
163            f: glib::ffi::gpointer,
164        ) {
165            unsafe {
166                let f: &F = &*(f as *const F);
167                f(&from_glib_borrow(this))
168            }
169        }
170        unsafe {
171            let f: Box_<F> = Box_::new(f);
172            connect_raw(
173                self.as_ptr() as *mut _,
174                c"notify::column".as_ptr() as *const _,
175                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
176                    notify_column_trampoline::<F> as *const (),
177                )),
178                Box_::into_raw(f),
179            )
180        }
181    }
182
183    #[doc(alias = "column-span")]
184    pub fn connect_column_span_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
185        unsafe extern "C" fn notify_column_span_trampoline<F: Fn(&GridLayoutChild) + 'static>(
186            this: *mut ffi::GtkGridLayoutChild,
187            _param_spec: glib::ffi::gpointer,
188            f: glib::ffi::gpointer,
189        ) {
190            unsafe {
191                let f: &F = &*(f as *const F);
192                f(&from_glib_borrow(this))
193            }
194        }
195        unsafe {
196            let f: Box_<F> = Box_::new(f);
197            connect_raw(
198                self.as_ptr() as *mut _,
199                c"notify::column-span".as_ptr() as *const _,
200                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
201                    notify_column_span_trampoline::<F> as *const (),
202                )),
203                Box_::into_raw(f),
204            )
205        }
206    }
207
208    #[doc(alias = "row")]
209    pub fn connect_row_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
210        unsafe extern "C" fn notify_row_trampoline<F: Fn(&GridLayoutChild) + 'static>(
211            this: *mut ffi::GtkGridLayoutChild,
212            _param_spec: glib::ffi::gpointer,
213            f: glib::ffi::gpointer,
214        ) {
215            unsafe {
216                let f: &F = &*(f as *const F);
217                f(&from_glib_borrow(this))
218            }
219        }
220        unsafe {
221            let f: Box_<F> = Box_::new(f);
222            connect_raw(
223                self.as_ptr() as *mut _,
224                c"notify::row".as_ptr() as *const _,
225                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
226                    notify_row_trampoline::<F> as *const (),
227                )),
228                Box_::into_raw(f),
229            )
230        }
231    }
232
233    #[doc(alias = "row-span")]
234    pub fn connect_row_span_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
235        unsafe extern "C" fn notify_row_span_trampoline<F: Fn(&GridLayoutChild) + 'static>(
236            this: *mut ffi::GtkGridLayoutChild,
237            _param_spec: glib::ffi::gpointer,
238            f: glib::ffi::gpointer,
239        ) {
240            unsafe {
241                let f: &F = &*(f as *const F);
242                f(&from_glib_borrow(this))
243            }
244        }
245        unsafe {
246            let f: Box_<F> = Box_::new(f);
247            connect_raw(
248                self.as_ptr() as *mut _,
249                c"notify::row-span".as_ptr() as *const _,
250                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
251                    notify_row_span_trampoline::<F> as *const (),
252                )),
253                Box_::into_raw(f),
254            )
255        }
256    }
257}