libadwaita/auto/
breakpoint_condition.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, BreakpointConditionLengthType, BreakpointConditionRatioType, LengthUnit};
7use glib::translate::*;
8
9glib::wrapper! {
10    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
11    pub struct BreakpointCondition(Boxed<ffi::AdwBreakpointCondition>);
12
13    match fn {
14        copy => |ptr| ffi::adw_breakpoint_condition_copy(mut_override(ptr)),
15        free => |ptr| ffi::adw_breakpoint_condition_free(ptr),
16        type_ => || ffi::adw_breakpoint_condition_get_type(),
17    }
18}
19
20impl BreakpointCondition {
21    #[doc(alias = "adw_breakpoint_condition_new_and")]
22    pub fn new_and(
23        condition_1: BreakpointCondition,
24        condition_2: BreakpointCondition,
25    ) -> BreakpointCondition {
26        assert_initialized_main_thread!();
27        unsafe {
28            from_glib_full(ffi::adw_breakpoint_condition_new_and(
29                condition_1.into_glib_ptr(),
30                condition_2.into_glib_ptr(),
31            ))
32        }
33    }
34
35    #[doc(alias = "adw_breakpoint_condition_new_length")]
36    pub fn new_length(
37        type_: BreakpointConditionLengthType,
38        value: f64,
39        unit: LengthUnit,
40    ) -> BreakpointCondition {
41        assert_initialized_main_thread!();
42        unsafe {
43            from_glib_full(ffi::adw_breakpoint_condition_new_length(
44                type_.into_glib(),
45                value,
46                unit.into_glib(),
47            ))
48        }
49    }
50
51    #[doc(alias = "adw_breakpoint_condition_new_or")]
52    pub fn new_or(
53        condition_1: BreakpointCondition,
54        condition_2: BreakpointCondition,
55    ) -> BreakpointCondition {
56        assert_initialized_main_thread!();
57        unsafe {
58            from_glib_full(ffi::adw_breakpoint_condition_new_or(
59                condition_1.into_glib_ptr(),
60                condition_2.into_glib_ptr(),
61            ))
62        }
63    }
64
65    #[doc(alias = "adw_breakpoint_condition_new_ratio")]
66    pub fn new_ratio(
67        type_: BreakpointConditionRatioType,
68        width: i32,
69        height: i32,
70    ) -> BreakpointCondition {
71        assert_initialized_main_thread!();
72        unsafe {
73            from_glib_full(ffi::adw_breakpoint_condition_new_ratio(
74                type_.into_glib(),
75                width,
76                height,
77            ))
78        }
79    }
80
81    #[doc(alias = "adw_breakpoint_condition_to_string")]
82    #[doc(alias = "to_string")]
83    pub fn to_str(&self) -> glib::GString {
84        unsafe {
85            from_glib_full(ffi::adw_breakpoint_condition_to_string(mut_override(
86                self.to_glib_none().0,
87            )))
88        }
89    }
90
91    #[doc(alias = "adw_breakpoint_condition_parse")]
92    pub fn parse(str: &str) -> Result<BreakpointCondition, glib::BoolError> {
93        assert_initialized_main_thread!();
94        unsafe {
95            Option::<_>::from_glib_full(ffi::adw_breakpoint_condition_parse(str.to_glib_none().0))
96                .ok_or_else(|| glib::bool_error!("Invalid condition"))
97        }
98    }
99}
100
101impl std::fmt::Display for BreakpointCondition {
102    #[inline]
103    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
104        f.write_str(&self.to_str())
105    }
106}