[go: up one dir, main page]

gtk4/auto/
string_object.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;
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GtkStringObject")]
15    pub struct StringObject(Object<ffi::GtkStringObject, ffi::GtkStringObjectClass>);
16
17    match fn {
18        type_ => || ffi::gtk_string_object_get_type(),
19    }
20}
21
22impl StringObject {
23    #[doc(alias = "gtk_string_object_new")]
24    pub fn new(string: &str) -> StringObject {
25        assert_initialized_main_thread!();
26        unsafe { from_glib_full(ffi::gtk_string_object_new(string.to_glib_none().0)) }
27    }
28
29    #[doc(alias = "gtk_string_object_get_string")]
30    #[doc(alias = "get_string")]
31    pub fn string(&self) -> glib::GString {
32        unsafe { from_glib_none(ffi::gtk_string_object_get_string(self.to_glib_none().0)) }
33    }
34
35    #[doc(alias = "string")]
36    pub fn connect_string_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
37        unsafe extern "C" fn notify_string_trampoline<F: Fn(&StringObject) + 'static>(
38            this: *mut ffi::GtkStringObject,
39            _param_spec: glib::ffi::gpointer,
40            f: glib::ffi::gpointer,
41        ) {
42            let f: &F = &*(f as *const F);
43            f(&from_glib_borrow(this))
44        }
45        unsafe {
46            let f: Box_<F> = Box_::new(f);
47            connect_raw(
48                self.as_ptr() as *mut _,
49                c"notify::string".as_ptr() as *const _,
50                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
51                    notify_string_trampoline::<F> as *const (),
52                )),
53                Box_::into_raw(f),
54            )
55        }
56    }
57}