libadwaita/auto/
breakpoint.rs1use crate::{ffi, BreakpointCondition};
7use glib::{
8 object::ObjectType as _,
9 prelude::*,
10 signal::{connect_raw, SignalHandlerId},
11 translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16 #[doc(alias = "AdwBreakpoint")]
17 pub struct Breakpoint(Object<ffi::AdwBreakpoint, ffi::AdwBreakpointClass>) @implements gtk::Buildable;
18
19 match fn {
20 type_ => || ffi::adw_breakpoint_get_type(),
21 }
22}
23
24impl Breakpoint {
25 #[doc(alias = "adw_breakpoint_new")]
26 pub fn new(condition: BreakpointCondition) -> Breakpoint {
27 assert_initialized_main_thread!();
28 unsafe { from_glib_full(ffi::adw_breakpoint_new(condition.into_glib_ptr())) }
29 }
30
31 #[doc(alias = "adw_breakpoint_add_setter")]
32 pub fn add_setter(
33 &self,
34 object: &impl IsA<glib::Object>,
35 property: &str,
36 value: Option<&glib::Value>,
37 ) {
38 unsafe {
39 ffi::adw_breakpoint_add_setter(
40 self.to_glib_none().0,
41 object.as_ref().to_glib_none().0,
42 property.to_glib_none().0,
43 value.to_glib_none().0,
44 );
45 }
46 }
47
48 #[doc(alias = "adw_breakpoint_get_condition")]
49 #[doc(alias = "get_condition")]
50 pub fn condition(&self) -> Option<BreakpointCondition> {
51 unsafe { from_glib_none(ffi::adw_breakpoint_get_condition(self.to_glib_none().0)) }
52 }
53
54 #[doc(alias = "adw_breakpoint_set_condition")]
55 #[doc(alias = "condition")]
56 pub fn set_condition(&self, condition: Option<&BreakpointCondition>) {
57 unsafe {
58 ffi::adw_breakpoint_set_condition(
59 self.to_glib_none().0,
60 mut_override(condition.to_glib_none().0),
61 );
62 }
63 }
64
65 #[cfg(feature = "v1_4")]
66 #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
67 #[doc(alias = "apply")]
68 pub fn connect_apply<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
69 unsafe extern "C" fn apply_trampoline<F: Fn(&Breakpoint) + 'static>(
70 this: *mut ffi::AdwBreakpoint,
71 f: glib::ffi::gpointer,
72 ) {
73 let f: &F = &*(f as *const F);
74 f(&from_glib_borrow(this))
75 }
76 unsafe {
77 let f: Box_<F> = Box_::new(f);
78 connect_raw(
79 self.as_ptr() as *mut _,
80 c"apply".as_ptr() as *const _,
81 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
82 apply_trampoline::<F> as *const (),
83 )),
84 Box_::into_raw(f),
85 )
86 }
87 }
88
89 #[cfg(feature = "v1_4")]
90 #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
91 #[doc(alias = "unapply")]
92 pub fn connect_unapply<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
93 unsafe extern "C" fn unapply_trampoline<F: Fn(&Breakpoint) + 'static>(
94 this: *mut ffi::AdwBreakpoint,
95 f: glib::ffi::gpointer,
96 ) {
97 let f: &F = &*(f as *const F);
98 f(&from_glib_borrow(this))
99 }
100 unsafe {
101 let f: Box_<F> = Box_::new(f);
102 connect_raw(
103 self.as_ptr() as *mut _,
104 c"unapply".as_ptr() as *const _,
105 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
106 unapply_trampoline::<F> as *const (),
107 )),
108 Box_::into_raw(f),
109 )
110 }
111 }
112
113 #[cfg(feature = "v1_4")]
114 #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
115 #[doc(alias = "condition")]
116 pub fn connect_condition_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
117 unsafe extern "C" fn notify_condition_trampoline<F: Fn(&Breakpoint) + 'static>(
118 this: *mut ffi::AdwBreakpoint,
119 _param_spec: glib::ffi::gpointer,
120 f: glib::ffi::gpointer,
121 ) {
122 let f: &F = &*(f as *const F);
123 f(&from_glib_borrow(this))
124 }
125 unsafe {
126 let f: Box_<F> = Box_::new(f);
127 connect_raw(
128 self.as_ptr() as *mut _,
129 c"notify::condition".as_ptr() as *const _,
130 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
131 notify_condition_trampoline::<F> as *const (),
132 )),
133 Box_::into_raw(f),
134 )
135 }
136 }
137}