libpanel/auto/
position.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{ffi, Area};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "PanelPosition")]
16    pub struct Position(Object<ffi::PanelPosition, ffi::PanelPositionClass>);
17
18    match fn {
19        type_ => || ffi::panel_position_get_type(),
20    }
21}
22
23impl Position {
24    #[doc(alias = "panel_position_new")]
25    pub fn new() -> Position {
26        assert_initialized_main_thread!();
27        unsafe { from_glib_full(ffi::panel_position_new()) }
28    }
29
30    #[doc(alias = "panel_position_new_from_variant")]
31    #[doc(alias = "new_from_variant")]
32    pub fn from_variant(variant: &glib::Variant) -> Option<Position> {
33        assert_initialized_main_thread!();
34        unsafe {
35            from_glib_full(ffi::panel_position_new_from_variant(
36                variant.to_glib_none().0,
37            ))
38        }
39    }
40
41    // rustdoc-stripper-ignore-next
42    /// Creates a new builder-pattern struct instance to construct [`Position`] objects.
43    ///
44    /// This method returns an instance of [`PositionBuilder`](crate::builders::PositionBuilder) which can be used to create [`Position`] objects.
45    pub fn builder() -> PositionBuilder {
46        PositionBuilder::new()
47    }
48
49    #[doc(alias = "panel_position_equal")]
50    pub fn equal(&self, b: &Position) -> bool {
51        unsafe {
52            from_glib(ffi::panel_position_equal(
53                self.to_glib_none().0,
54                b.to_glib_none().0,
55            ))
56        }
57    }
58
59    #[doc(alias = "panel_position_get_area")]
60    #[doc(alias = "get_area")]
61    pub fn area(&self) -> Area {
62        unsafe { from_glib(ffi::panel_position_get_area(self.to_glib_none().0)) }
63    }
64
65    #[doc(alias = "panel_position_get_area_set")]
66    #[doc(alias = "get_area_set")]
67    #[doc(alias = "area-set")]
68    pub fn is_area_set(&self) -> bool {
69        unsafe { from_glib(ffi::panel_position_get_area_set(self.to_glib_none().0)) }
70    }
71
72    #[doc(alias = "panel_position_get_column")]
73    #[doc(alias = "get_column")]
74    pub fn column(&self) -> u32 {
75        unsafe { ffi::panel_position_get_column(self.to_glib_none().0) }
76    }
77
78    #[doc(alias = "panel_position_get_column_set")]
79    #[doc(alias = "get_column_set")]
80    #[doc(alias = "column-set")]
81    pub fn is_column_set(&self) -> bool {
82        unsafe { from_glib(ffi::panel_position_get_column_set(self.to_glib_none().0)) }
83    }
84
85    #[doc(alias = "panel_position_get_depth")]
86    #[doc(alias = "get_depth")]
87    pub fn depth(&self) -> u32 {
88        unsafe { ffi::panel_position_get_depth(self.to_glib_none().0) }
89    }
90
91    #[doc(alias = "panel_position_get_depth_set")]
92    #[doc(alias = "get_depth_set")]
93    #[doc(alias = "depth-set")]
94    pub fn is_depth_set(&self) -> bool {
95        unsafe { from_glib(ffi::panel_position_get_depth_set(self.to_glib_none().0)) }
96    }
97
98    #[doc(alias = "panel_position_get_row")]
99    #[doc(alias = "get_row")]
100    pub fn row(&self) -> u32 {
101        unsafe { ffi::panel_position_get_row(self.to_glib_none().0) }
102    }
103
104    #[doc(alias = "panel_position_get_row_set")]
105    #[doc(alias = "get_row_set")]
106    #[doc(alias = "row-set")]
107    pub fn is_row_set(&self) -> bool {
108        unsafe { from_glib(ffi::panel_position_get_row_set(self.to_glib_none().0)) }
109    }
110
111    #[doc(alias = "panel_position_is_indeterminate")]
112    pub fn is_indeterminate(&self) -> bool {
113        unsafe { from_glib(ffi::panel_position_is_indeterminate(self.to_glib_none().0)) }
114    }
115
116    #[doc(alias = "panel_position_set_area")]
117    #[doc(alias = "area")]
118    pub fn set_area(&self, area: Area) {
119        unsafe {
120            ffi::panel_position_set_area(self.to_glib_none().0, area.into_glib());
121        }
122    }
123
124    #[doc(alias = "panel_position_set_area_set")]
125    #[doc(alias = "area-set")]
126    pub fn set_area_set(&self, area_set: bool) {
127        unsafe {
128            ffi::panel_position_set_area_set(self.to_glib_none().0, area_set.into_glib());
129        }
130    }
131
132    #[doc(alias = "panel_position_set_column")]
133    #[doc(alias = "column")]
134    pub fn set_column(&self, column: u32) {
135        unsafe {
136            ffi::panel_position_set_column(self.to_glib_none().0, column);
137        }
138    }
139
140    #[doc(alias = "panel_position_set_column_set")]
141    #[doc(alias = "column-set")]
142    pub fn set_column_set(&self, column_set: bool) {
143        unsafe {
144            ffi::panel_position_set_column_set(self.to_glib_none().0, column_set.into_glib());
145        }
146    }
147
148    #[doc(alias = "panel_position_set_depth")]
149    #[doc(alias = "depth")]
150    pub fn set_depth(&self, depth: u32) {
151        unsafe {
152            ffi::panel_position_set_depth(self.to_glib_none().0, depth);
153        }
154    }
155
156    #[doc(alias = "panel_position_set_depth_set")]
157    #[doc(alias = "depth-set")]
158    pub fn set_depth_set(&self, depth_set: bool) {
159        unsafe {
160            ffi::panel_position_set_depth_set(self.to_glib_none().0, depth_set.into_glib());
161        }
162    }
163
164    #[doc(alias = "panel_position_set_row")]
165    #[doc(alias = "row")]
166    pub fn set_row(&self, row: u32) {
167        unsafe {
168            ffi::panel_position_set_row(self.to_glib_none().0, row);
169        }
170    }
171
172    #[doc(alias = "panel_position_set_row_set")]
173    #[doc(alias = "row-set")]
174    pub fn set_row_set(&self, row_set: bool) {
175        unsafe {
176            ffi::panel_position_set_row_set(self.to_glib_none().0, row_set.into_glib());
177        }
178    }
179
180    #[doc(alias = "panel_position_to_variant")]
181    pub fn to_variant(&self) -> Option<glib::Variant> {
182        unsafe { from_glib_full(ffi::panel_position_to_variant(self.to_glib_none().0)) }
183    }
184
185    #[doc(alias = "area")]
186    pub fn connect_area_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
187        unsafe extern "C" fn notify_area_trampoline<F: Fn(&Position) + 'static>(
188            this: *mut ffi::PanelPosition,
189            _param_spec: glib::ffi::gpointer,
190            f: glib::ffi::gpointer,
191        ) {
192            let f: &F = &*(f as *const F);
193            f(&from_glib_borrow(this))
194        }
195        unsafe {
196            let f: Box_<F> = Box_::new(f);
197            connect_raw(
198                self.as_ptr() as *mut _,
199                c"notify::area".as_ptr() as *const _,
200                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
201                    notify_area_trampoline::<F> as *const (),
202                )),
203                Box_::into_raw(f),
204            )
205        }
206    }
207
208    #[doc(alias = "area-set")]
209    pub fn connect_area_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
210        unsafe extern "C" fn notify_area_set_trampoline<F: Fn(&Position) + 'static>(
211            this: *mut ffi::PanelPosition,
212            _param_spec: glib::ffi::gpointer,
213            f: glib::ffi::gpointer,
214        ) {
215            let f: &F = &*(f as *const F);
216            f(&from_glib_borrow(this))
217        }
218        unsafe {
219            let f: Box_<F> = Box_::new(f);
220            connect_raw(
221                self.as_ptr() as *mut _,
222                c"notify::area-set".as_ptr() as *const _,
223                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
224                    notify_area_set_trampoline::<F> as *const (),
225                )),
226                Box_::into_raw(f),
227            )
228        }
229    }
230
231    #[doc(alias = "column")]
232    pub fn connect_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
233        unsafe extern "C" fn notify_column_trampoline<F: Fn(&Position) + 'static>(
234            this: *mut ffi::PanelPosition,
235            _param_spec: glib::ffi::gpointer,
236            f: glib::ffi::gpointer,
237        ) {
238            let f: &F = &*(f as *const F);
239            f(&from_glib_borrow(this))
240        }
241        unsafe {
242            let f: Box_<F> = Box_::new(f);
243            connect_raw(
244                self.as_ptr() as *mut _,
245                c"notify::column".as_ptr() as *const _,
246                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
247                    notify_column_trampoline::<F> as *const (),
248                )),
249                Box_::into_raw(f),
250            )
251        }
252    }
253
254    #[doc(alias = "column-set")]
255    pub fn connect_column_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
256        unsafe extern "C" fn notify_column_set_trampoline<F: Fn(&Position) + 'static>(
257            this: *mut ffi::PanelPosition,
258            _param_spec: glib::ffi::gpointer,
259            f: glib::ffi::gpointer,
260        ) {
261            let f: &F = &*(f as *const F);
262            f(&from_glib_borrow(this))
263        }
264        unsafe {
265            let f: Box_<F> = Box_::new(f);
266            connect_raw(
267                self.as_ptr() as *mut _,
268                c"notify::column-set".as_ptr() as *const _,
269                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
270                    notify_column_set_trampoline::<F> as *const (),
271                )),
272                Box_::into_raw(f),
273            )
274        }
275    }
276
277    #[doc(alias = "depth")]
278    pub fn connect_depth_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
279        unsafe extern "C" fn notify_depth_trampoline<F: Fn(&Position) + 'static>(
280            this: *mut ffi::PanelPosition,
281            _param_spec: glib::ffi::gpointer,
282            f: glib::ffi::gpointer,
283        ) {
284            let f: &F = &*(f as *const F);
285            f(&from_glib_borrow(this))
286        }
287        unsafe {
288            let f: Box_<F> = Box_::new(f);
289            connect_raw(
290                self.as_ptr() as *mut _,
291                c"notify::depth".as_ptr() as *const _,
292                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
293                    notify_depth_trampoline::<F> as *const (),
294                )),
295                Box_::into_raw(f),
296            )
297        }
298    }
299
300    #[doc(alias = "depth-set")]
301    pub fn connect_depth_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
302        unsafe extern "C" fn notify_depth_set_trampoline<F: Fn(&Position) + 'static>(
303            this: *mut ffi::PanelPosition,
304            _param_spec: glib::ffi::gpointer,
305            f: glib::ffi::gpointer,
306        ) {
307            let f: &F = &*(f as *const F);
308            f(&from_glib_borrow(this))
309        }
310        unsafe {
311            let f: Box_<F> = Box_::new(f);
312            connect_raw(
313                self.as_ptr() as *mut _,
314                c"notify::depth-set".as_ptr() as *const _,
315                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
316                    notify_depth_set_trampoline::<F> as *const (),
317                )),
318                Box_::into_raw(f),
319            )
320        }
321    }
322
323    #[doc(alias = "row")]
324    pub fn connect_row_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
325        unsafe extern "C" fn notify_row_trampoline<F: Fn(&Position) + 'static>(
326            this: *mut ffi::PanelPosition,
327            _param_spec: glib::ffi::gpointer,
328            f: glib::ffi::gpointer,
329        ) {
330            let f: &F = &*(f as *const F);
331            f(&from_glib_borrow(this))
332        }
333        unsafe {
334            let f: Box_<F> = Box_::new(f);
335            connect_raw(
336                self.as_ptr() as *mut _,
337                c"notify::row".as_ptr() as *const _,
338                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
339                    notify_row_trampoline::<F> as *const (),
340                )),
341                Box_::into_raw(f),
342            )
343        }
344    }
345
346    #[doc(alias = "row-set")]
347    pub fn connect_row_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
348        unsafe extern "C" fn notify_row_set_trampoline<F: Fn(&Position) + 'static>(
349            this: *mut ffi::PanelPosition,
350            _param_spec: glib::ffi::gpointer,
351            f: glib::ffi::gpointer,
352        ) {
353            let f: &F = &*(f as *const F);
354            f(&from_glib_borrow(this))
355        }
356        unsafe {
357            let f: Box_<F> = Box_::new(f);
358            connect_raw(
359                self.as_ptr() as *mut _,
360                c"notify::row-set".as_ptr() as *const _,
361                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
362                    notify_row_set_trampoline::<F> as *const (),
363                )),
364                Box_::into_raw(f),
365            )
366        }
367    }
368}
369
370impl Default for Position {
371    fn default() -> Self {
372        Self::new()
373    }
374}
375
376// rustdoc-stripper-ignore-next
377/// A [builder-pattern] type to construct [`Position`] objects.
378///
379/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
380#[must_use = "The builder must be built to be used"]
381pub struct PositionBuilder {
382    builder: glib::object::ObjectBuilder<'static, Position>,
383}
384
385impl PositionBuilder {
386    fn new() -> Self {
387        Self {
388            builder: glib::object::Object::builder(),
389        }
390    }
391
392    pub fn area(self, area: Area) -> Self {
393        Self {
394            builder: self.builder.property("area", area),
395        }
396    }
397
398    pub fn area_set(self, area_set: bool) -> Self {
399        Self {
400            builder: self.builder.property("area-set", area_set),
401        }
402    }
403
404    pub fn column(self, column: u32) -> Self {
405        Self {
406            builder: self.builder.property("column", column),
407        }
408    }
409
410    pub fn column_set(self, column_set: bool) -> Self {
411        Self {
412            builder: self.builder.property("column-set", column_set),
413        }
414    }
415
416    pub fn depth(self, depth: u32) -> Self {
417        Self {
418            builder: self.builder.property("depth", depth),
419        }
420    }
421
422    pub fn depth_set(self, depth_set: bool) -> Self {
423        Self {
424            builder: self.builder.property("depth-set", depth_set),
425        }
426    }
427
428    pub fn row(self, row: u32) -> Self {
429        Self {
430            builder: self.builder.property("row", row),
431        }
432    }
433
434    pub fn row_set(self, row_set: bool) -> Self {
435        Self {
436            builder: self.builder.property("row-set", row_set),
437        }
438    }
439
440    // rustdoc-stripper-ignore-next
441    /// Build the [`Position`].
442    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
443    pub fn build(self) -> Position {
444        assert_initialized_main_thread!();
445        self.builder.build()
446    }
447}