Skip to main content

gtk4/auto/
at_context.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::{Accessible, AccessibleRole, ffi};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GtkATContext")]
16    pub struct ATContext(Object<ffi::GtkATContext, ffi::GtkATContextClass>);
17
18    match fn {
19        type_ => || ffi::gtk_at_context_get_type(),
20    }
21}
22
23impl ATContext {
24    #[doc(alias = "gtk_at_context_create")]
25    pub fn create(
26        accessible_role: AccessibleRole,
27        accessible: &impl IsA<Accessible>,
28        display: &impl IsA<gdk::Display>,
29    ) -> Option<ATContext> {
30        skip_assert_initialized!();
31        unsafe {
32            from_glib_full(ffi::gtk_at_context_create(
33                accessible_role.into_glib(),
34                accessible.as_ref().to_glib_none().0,
35                display.as_ref().to_glib_none().0,
36            ))
37        }
38    }
39
40    #[doc(alias = "gtk_at_context_get_accessible")]
41    #[doc(alias = "get_accessible")]
42    pub fn accessible(&self) -> Accessible {
43        unsafe { from_glib_none(ffi::gtk_at_context_get_accessible(self.to_glib_none().0)) }
44    }
45
46    #[doc(alias = "gtk_at_context_get_accessible_role")]
47    #[doc(alias = "get_accessible_role")]
48    #[doc(alias = "accessible-role")]
49    pub fn accessible_role(&self) -> AccessibleRole {
50        unsafe {
51            from_glib(ffi::gtk_at_context_get_accessible_role(
52                self.to_glib_none().0,
53            ))
54        }
55    }
56
57    #[doc(alias = "accessible-role")]
58    pub fn set_accessible_role(&self, accessible_role: AccessibleRole) {
59        ObjectExt::set_property(self, "accessible-role", accessible_role)
60    }
61
62    pub fn display(&self) -> Option<gdk::Display> {
63        ObjectExt::property(self, "display")
64    }
65
66    pub fn set_display<P: IsA<gdk::Display>>(&self, display: Option<&P>) {
67        ObjectExt::set_property(self, "display", display)
68    }
69
70    #[doc(alias = "state-change")]
71    pub fn connect_state_change<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
72        unsafe extern "C" fn state_change_trampoline<F: Fn(&ATContext) + 'static>(
73            this: *mut ffi::GtkATContext,
74            f: glib::ffi::gpointer,
75        ) {
76            unsafe {
77                let f: &F = &*(f as *const F);
78                f(&from_glib_borrow(this))
79            }
80        }
81        unsafe {
82            let f: Box_<F> = Box_::new(f);
83            connect_raw(
84                self.as_ptr() as *mut _,
85                c"state-change".as_ptr(),
86                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
87                    state_change_trampoline::<F> as *const (),
88                )),
89                Box_::into_raw(f),
90            )
91        }
92    }
93
94    #[doc(alias = "accessible-role")]
95    pub fn connect_accessible_role_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
96        unsafe extern "C" fn notify_accessible_role_trampoline<F: Fn(&ATContext) + 'static>(
97            this: *mut ffi::GtkATContext,
98            _param_spec: glib::ffi::gpointer,
99            f: glib::ffi::gpointer,
100        ) {
101            unsafe {
102                let f: &F = &*(f as *const F);
103                f(&from_glib_borrow(this))
104            }
105        }
106        unsafe {
107            let f: Box_<F> = Box_::new(f);
108            connect_raw(
109                self.as_ptr() as *mut _,
110                c"notify::accessible-role".as_ptr(),
111                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
112                    notify_accessible_role_trampoline::<F> as *const (),
113                )),
114                Box_::into_raw(f),
115            )
116        }
117    }
118
119    #[doc(alias = "display")]
120    pub fn connect_display_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
121        unsafe extern "C" fn notify_display_trampoline<F: Fn(&ATContext) + 'static>(
122            this: *mut ffi::GtkATContext,
123            _param_spec: glib::ffi::gpointer,
124            f: glib::ffi::gpointer,
125        ) {
126            unsafe {
127                let f: &F = &*(f as *const F);
128                f(&from_glib_borrow(this))
129            }
130        }
131        unsafe {
132            let f: Box_<F> = Box_::new(f);
133            connect_raw(
134                self.as_ptr() as *mut _,
135                c"notify::display".as_ptr(),
136                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
137                    notify_display_trampoline::<F> as *const (),
138                )),
139                Box_::into_raw(f),
140            )
141        }
142    }
143}