Skip to main content

webkit_web_process_extension6/auto/
web_editor.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// from webkit-gir-files
4// DO NOT EDIT
5
6use crate::{WebPage, ffi};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "WebKitWebEditor")]
17    pub struct WebEditor(Object<ffi::WebKitWebEditor, ffi::WebKitWebEditorClass>);
18
19    match fn {
20        type_ => || ffi::webkit_web_editor_get_type(),
21    }
22}
23
24impl WebEditor {
25    #[doc(alias = "webkit_web_editor_get_page")]
26    #[doc(alias = "get_page")]
27    pub fn page(&self) -> Option<WebPage> {
28        unsafe { from_glib_none(ffi::webkit_web_editor_get_page(self.to_glib_none().0)) }
29    }
30
31    #[doc(alias = "selection-changed")]
32    pub fn connect_selection_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
33        unsafe extern "C" fn selection_changed_trampoline<F: Fn(&WebEditor) + 'static>(
34            this: *mut ffi::WebKitWebEditor,
35            f: glib::ffi::gpointer,
36        ) {
37            unsafe {
38                let f: &F = &*(f as *const F);
39                f(&from_glib_borrow(this))
40            }
41        }
42        unsafe {
43            let f: Box_<F> = Box_::new(f);
44            connect_raw(
45                self.as_ptr() as *mut _,
46                c"selection-changed".as_ptr(),
47                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
48                    selection_changed_trampoline::<F> as *const (),
49                )),
50                Box_::into_raw(f),
51            )
52        }
53    }
54}