1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// This file was generated by gir (https://github.com/gtk-rs/gir)
// DO NOT EDIT

use crate::{GlobalProxy,Iterator,Object,Proxy};
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};

glib::wrapper! {
    #[doc(alias = "WpMetadata")]
    pub struct Metadata(Object<ffi::WpMetadata, ffi::WpMetadataClass>) @extends GlobalProxy, Proxy, Object;

    match fn {
        type_ => || ffi::wp_metadata_get_type(),
    }
}

impl Metadata {
        pub const NONE: Option<&'static Metadata> = None;
    

    #[doc(alias = "wp_metadata_iterator_item_extract")]
    pub fn iterator_item_extract(item: &glib::Value) -> (u32, glib::GString, glib::GString, glib::GString) {
        unsafe {
            let mut subject = std::mem::MaybeUninit::uninit();
            let mut key = std::ptr::null();
            let mut type_ = std::ptr::null();
            let mut value = std::ptr::null();
            ffi::wp_metadata_iterator_item_extract(item.to_glib_none().0, subject.as_mut_ptr(), &mut key, &mut type_, &mut value);
            (subject.assume_init(), from_glib_none(key), from_glib_none(type_), from_glib_none(value))
        }
    }
}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::Metadata>> Sealed for T {}
}

pub trait MetadataExt: IsA<Metadata> + sealed::Sealed + 'static {
    #[doc(alias = "wp_metadata_clear")]
    fn clear(&self) {
        unsafe {
            ffi::wp_metadata_clear(self.as_ref().to_glib_none().0);
        }
    }

    #[doc(alias = "wp_metadata_find")]
    fn find(&self, subject: u32, key: &str) -> (Option<glib::GString>, Option<glib::GString>) {
        unsafe {
            let mut type_ = std::ptr::null();
            let ret = from_glib_none(ffi::wp_metadata_find(self.as_ref().to_glib_none().0, subject, key.to_glib_none().0, &mut type_));
            (ret, from_glib_full(type_))
        }
    }

    #[doc(alias = "wp_metadata_new_iterator")]
    fn new_iterator(&self, subject: u32) -> Option<Iterator> {
        unsafe {
            from_glib_full(ffi::wp_metadata_new_iterator(self.as_ref().to_glib_none().0, subject))
        }
    }

    #[doc(alias = "wp_metadata_set")]
    fn set(&self, subject: u32, key: Option<&str>, type_: Option<&str>, value: Option<&str>) {
        unsafe {
            ffi::wp_metadata_set(self.as_ref().to_glib_none().0, subject, key.to_glib_none().0, type_.to_glib_none().0, value.to_glib_none().0);
        }
    }

    #[doc(alias = "changed")]
    fn connect_changed<F: Fn(&Self, u32, Option<&str>, Option<&str>, Option<&str>) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn changed_trampoline<P: IsA<Metadata>, F: Fn(&P, u32, Option<&str>, Option<&str>, Option<&str>) + 'static>(this: *mut ffi::WpMetadata, object: libc::c_uint, p0: *mut libc::c_char, p1: *mut libc::c_char, p2: *mut libc::c_char, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(Metadata::from_glib_borrow(this).unsafe_cast_ref(), object, Option::<glib::GString>::from_glib_borrow(p0).as_ref().as_ref().map(|s| s.as_str()), Option::<glib::GString>::from_glib_borrow(p1).as_ref().as_ref().map(|s| s.as_str()), Option::<glib::GString>::from_glib_borrow(p2).as_ref().as_ref().map(|s| s.as_str()))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(changed_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
        }
    }
}

impl<O: IsA<Metadata>> MetadataExt for O {}