1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::{BreakpointConditionLengthType, BreakpointConditionRatioType, LengthUnit};
use glib::translate::*;

glib::wrapper! {
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct BreakpointCondition(Boxed<ffi::AdwBreakpointCondition>);

    match fn {
        copy => |ptr| ffi::adw_breakpoint_condition_copy(mut_override(ptr)),
        free => |ptr| ffi::adw_breakpoint_condition_free(ptr),
        type_ => || ffi::adw_breakpoint_condition_get_type(),
    }
}

impl BreakpointCondition {
    #[doc(alias = "adw_breakpoint_condition_new_and")]
    pub fn new_and(
        condition_1: BreakpointCondition,
        condition_2: BreakpointCondition,
    ) -> BreakpointCondition {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::adw_breakpoint_condition_new_and(
                condition_1.into_glib_ptr(),
                condition_2.into_glib_ptr(),
            ))
        }
    }

    #[doc(alias = "adw_breakpoint_condition_new_length")]
    pub fn new_length(
        type_: BreakpointConditionLengthType,
        value: f64,
        unit: LengthUnit,
    ) -> BreakpointCondition {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::adw_breakpoint_condition_new_length(
                type_.into_glib(),
                value,
                unit.into_glib(),
            ))
        }
    }

    #[doc(alias = "adw_breakpoint_condition_new_or")]
    pub fn new_or(
        condition_1: BreakpointCondition,
        condition_2: BreakpointCondition,
    ) -> BreakpointCondition {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::adw_breakpoint_condition_new_or(
                condition_1.into_glib_ptr(),
                condition_2.into_glib_ptr(),
            ))
        }
    }

    #[doc(alias = "adw_breakpoint_condition_new_ratio")]
    pub fn new_ratio(
        type_: BreakpointConditionRatioType,
        width: i32,
        height: i32,
    ) -> BreakpointCondition {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::adw_breakpoint_condition_new_ratio(
                type_.into_glib(),
                width,
                height,
            ))
        }
    }

    #[doc(alias = "adw_breakpoint_condition_to_string")]
    #[doc(alias = "to_string")]
    pub fn to_str(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::adw_breakpoint_condition_to_string(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    #[doc(alias = "adw_breakpoint_condition_parse")]
    pub fn parse(str: &str) -> Result<BreakpointCondition, glib::BoolError> {
        assert_initialized_main_thread!();
        unsafe {
            Option::<_>::from_glib_full(ffi::adw_breakpoint_condition_parse(str.to_glib_none().0))
                .ok_or_else(|| glib::bool_error!("Invalid condition"))
        }
    }
}

impl std::fmt::Display for BreakpointCondition {
    #[inline]
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(&self.to_str())
    }
}