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::{ffi, Accessible, AccessibleRole};
6use glib::{
7 object::ObjectType as _,
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 /// [`ATContext`][crate::ATContext] is an abstract class provided by GTK to communicate to
16 /// platform-specific assistive technologies API.
17 ///
18 /// Each platform supported by GTK implements a [`ATContext`][crate::ATContext] subclass, and
19 /// is responsible for updating the accessible state in response to state
20 /// changes in [`Accessible`][crate::Accessible].
21 ///
22 /// This is an Abstract Base Class, you cannot instantiate it.
23 ///
24 /// ## Properties
25 ///
26 ///
27 /// #### `accessible`
28 /// The [`Accessible`][crate::Accessible] that created the [`ATContext`][crate::ATContext] instance.
29 ///
30 /// Readable | Writeable | Construct Only
31 ///
32 ///
33 /// #### `accessible-role`
34 /// The accessible role used by the AT context.
35 ///
36 /// Depending on the given role, different states and properties can be
37 /// set or retrieved.
38 ///
39 /// Readable | Writeable | Construct
40 ///
41 ///
42 /// #### `display`
43 /// The [`gdk::Display`][crate::gdk::Display] for the [`ATContext`][crate::ATContext].
44 ///
45 /// Readable | Writeable
46 ///
47 /// ## Signals
48 ///
49 ///
50 /// #### `state-change`
51 /// Emitted when the attributes of the accessible for the
52 /// [`ATContext`][crate::ATContext] instance change.
53 ///
54 ///
55 ///
56 /// # Implements
57 ///
58 /// [`trait@glib::ObjectExt`]
59 #[doc(alias = "GtkATContext")]
60 pub struct ATContext(Object<ffi::GtkATContext, ffi::GtkATContextClass>);
61
62 match fn {
63 type_ => || ffi::gtk_at_context_get_type(),
64 }
65}
66
67impl ATContext {
68 /// Creates a new [`ATContext`][crate::ATContext] instance for the given accessible role,
69 /// accessible instance, and display connection.
70 ///
71 /// The [`ATContext`][crate::ATContext] implementation being instantiated will depend on the
72 /// platform.
73 /// ## `accessible_role`
74 /// the accessible role used by the [`ATContext`][crate::ATContext]
75 /// ## `accessible`
76 /// the [`Accessible`][crate::Accessible] implementation using the [`ATContext`][crate::ATContext]
77 /// ## `display`
78 /// the [`gdk::Display`][crate::gdk::Display] used by the [`ATContext`][crate::ATContext]
79 ///
80 /// # Returns
81 ///
82 /// the [`ATContext`][crate::ATContext]
83 #[doc(alias = "gtk_at_context_create")]
84 pub fn create(
85 accessible_role: AccessibleRole,
86 accessible: &impl IsA<Accessible>,
87 display: &impl IsA<gdk::Display>,
88 ) -> Option<ATContext> {
89 skip_assert_initialized!();
90 unsafe {
91 from_glib_full(ffi::gtk_at_context_create(
92 accessible_role.into_glib(),
93 accessible.as_ref().to_glib_none().0,
94 display.as_ref().to_glib_none().0,
95 ))
96 }
97 }
98
99 /// Retrieves the [`Accessible`][crate::Accessible] using this context.
100 ///
101 /// # Returns
102 ///
103 /// a [`Accessible`][crate::Accessible]
104 #[doc(alias = "gtk_at_context_get_accessible")]
105 #[doc(alias = "get_accessible")]
106 pub fn accessible(&self) -> Accessible {
107 unsafe { from_glib_none(ffi::gtk_at_context_get_accessible(self.to_glib_none().0)) }
108 }
109
110 /// Retrieves the accessible role of this context.
111 ///
112 /// # Returns
113 ///
114 /// a [`AccessibleRole`][crate::AccessibleRole]
115 #[doc(alias = "gtk_at_context_get_accessible_role")]
116 #[doc(alias = "get_accessible_role")]
117 #[doc(alias = "accessible-role")]
118 pub fn accessible_role(&self) -> AccessibleRole {
119 unsafe {
120 from_glib(ffi::gtk_at_context_get_accessible_role(
121 self.to_glib_none().0,
122 ))
123 }
124 }
125
126 /// The accessible role used by the AT context.
127 ///
128 /// Depending on the given role, different states and properties can be
129 /// set or retrieved.
130 #[doc(alias = "accessible-role")]
131 pub fn set_accessible_role(&self, accessible_role: AccessibleRole) {
132 ObjectExt::set_property(self, "accessible-role", accessible_role)
133 }
134
135 /// The [`gdk::Display`][crate::gdk::Display] for the [`ATContext`][crate::ATContext].
136 pub fn display(&self) -> Option<gdk::Display> {
137 ObjectExt::property(self, "display")
138 }
139
140 /// The [`gdk::Display`][crate::gdk::Display] for the [`ATContext`][crate::ATContext].
141 pub fn set_display<P: IsA<gdk::Display>>(&self, display: Option<&P>) {
142 ObjectExt::set_property(self, "display", display)
143 }
144
145 /// Emitted when the attributes of the accessible for the
146 /// [`ATContext`][crate::ATContext] instance change.
147 #[doc(alias = "state-change")]
148 pub fn connect_state_change<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
149 unsafe extern "C" fn state_change_trampoline<F: Fn(&ATContext) + 'static>(
150 this: *mut ffi::GtkATContext,
151 f: glib::ffi::gpointer,
152 ) {
153 let f: &F = &*(f as *const F);
154 f(&from_glib_borrow(this))
155 }
156 unsafe {
157 let f: Box_<F> = Box_::new(f);
158 connect_raw(
159 self.as_ptr() as *mut _,
160 b"state-change\0".as_ptr() as *const _,
161 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
162 state_change_trampoline::<F> as *const (),
163 )),
164 Box_::into_raw(f),
165 )
166 }
167 }
168
169 #[doc(alias = "accessible-role")]
170 pub fn connect_accessible_role_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
171 unsafe extern "C" fn notify_accessible_role_trampoline<F: Fn(&ATContext) + 'static>(
172 this: *mut ffi::GtkATContext,
173 _param_spec: glib::ffi::gpointer,
174 f: glib::ffi::gpointer,
175 ) {
176 let f: &F = &*(f as *const F);
177 f(&from_glib_borrow(this))
178 }
179 unsafe {
180 let f: Box_<F> = Box_::new(f);
181 connect_raw(
182 self.as_ptr() as *mut _,
183 b"notify::accessible-role\0".as_ptr() as *const _,
184 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
185 notify_accessible_role_trampoline::<F> as *const (),
186 )),
187 Box_::into_raw(f),
188 )
189 }
190 }
191
192 #[doc(alias = "display")]
193 pub fn connect_display_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
194 unsafe extern "C" fn notify_display_trampoline<F: Fn(&ATContext) + 'static>(
195 this: *mut ffi::GtkATContext,
196 _param_spec: glib::ffi::gpointer,
197 f: glib::ffi::gpointer,
198 ) {
199 let f: &F = &*(f as *const F);
200 f(&from_glib_borrow(this))
201 }
202 unsafe {
203 let f: Box_<F> = Box_::new(f);
204 connect_raw(
205 self.as_ptr() as *mut _,
206 b"notify::display\0".as_ptr() as *const _,
207 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
208 notify_display_trampoline::<F> as *const (),
209 )),
210 Box_::into_raw(f),
211 )
212 }
213 }
214}