webkit6/auto/
editor_state.rs1use crate::ffi;
7#[cfg(feature = "v2_44")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v2_44")))]
9use glib::object::ObjectType as _;
10use glib::{
11 prelude::*,
12 signal::{connect_raw, SignalHandlerId},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18 #[doc(alias = "WebKitEditorState")]
41 pub struct EditorState(Object<ffi::WebKitEditorState, ffi::WebKitEditorStateClass>);
42
43 match fn {
44 type_ => || ffi::webkit_editor_state_get_type(),
45 }
46}
47
48impl EditorState {
49 #[doc(alias = "webkit_editor_state_get_typing_attributes")]
60 #[doc(alias = "get_typing_attributes")]
61 #[doc(alias = "typing-attributes")]
62 pub fn typing_attributes(&self) -> u32 {
63 unsafe { ffi::webkit_editor_state_get_typing_attributes(self.to_glib_none().0) }
64 }
65
66 #[doc(alias = "webkit_editor_state_is_copy_available")]
72 pub fn is_copy_available(&self) -> bool {
73 unsafe {
74 from_glib(ffi::webkit_editor_state_is_copy_available(
75 self.to_glib_none().0,
76 ))
77 }
78 }
79
80 #[doc(alias = "webkit_editor_state_is_cut_available")]
86 pub fn is_cut_available(&self) -> bool {
87 unsafe {
88 from_glib(ffi::webkit_editor_state_is_cut_available(
89 self.to_glib_none().0,
90 ))
91 }
92 }
93
94 #[doc(alias = "webkit_editor_state_is_paste_available")]
100 pub fn is_paste_available(&self) -> bool {
101 unsafe {
102 from_glib(ffi::webkit_editor_state_is_paste_available(
103 self.to_glib_none().0,
104 ))
105 }
106 }
107
108 #[doc(alias = "webkit_editor_state_is_redo_available")]
114 pub fn is_redo_available(&self) -> bool {
115 unsafe {
116 from_glib(ffi::webkit_editor_state_is_redo_available(
117 self.to_glib_none().0,
118 ))
119 }
120 }
121
122 #[doc(alias = "webkit_editor_state_is_undo_available")]
128 pub fn is_undo_available(&self) -> bool {
129 unsafe {
130 from_glib(ffi::webkit_editor_state_is_undo_available(
131 self.to_glib_none().0,
132 ))
133 }
134 }
135
136 #[cfg(feature = "v2_44")]
138 #[cfg_attr(docsrs, doc(cfg(feature = "v2_44")))]
139 #[doc(alias = "changed")]
140 pub fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
141 unsafe extern "C" fn changed_trampoline<F: Fn(&EditorState) + 'static>(
142 this: *mut ffi::WebKitEditorState,
143 f: glib::ffi::gpointer,
144 ) {
145 let f: &F = &*(f as *const F);
146 f(&from_glib_borrow(this))
147 }
148 unsafe {
149 let f: Box_<F> = Box_::new(f);
150 connect_raw(
151 self.as_ptr() as *mut _,
152 c"changed".as_ptr() as *const _,
153 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
154 changed_trampoline::<F> as *const (),
155 )),
156 Box_::into_raw(f),
157 )
158 }
159 }
160
161 #[doc(alias = "typing-attributes")]
162 pub fn connect_typing_attributes_notify<F: Fn(&Self) + 'static>(
163 &self,
164 f: F,
165 ) -> SignalHandlerId {
166 unsafe extern "C" fn notify_typing_attributes_trampoline<F: Fn(&EditorState) + 'static>(
167 this: *mut ffi::WebKitEditorState,
168 _param_spec: glib::ffi::gpointer,
169 f: glib::ffi::gpointer,
170 ) {
171 let f: &F = &*(f as *const F);
172 f(&from_glib_borrow(this))
173 }
174 unsafe {
175 let f: Box_<F> = Box_::new(f);
176 connect_raw(
177 self.as_ptr() as *mut _,
178 c"notify::typing-attributes".as_ptr() as *const _,
179 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
180 notify_typing_attributes_trampoline::<F> as *const (),
181 )),
182 Box_::into_raw(f),
183 )
184 }
185 }
186}