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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::{ffi, FuseCategory};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    ///
    ///
    /// This is an Abstract Base Class, you cannot instantiate it.
    ///
    /// ## Properties
    ///
    ///
    /// #### `category`
    ///  <para>The category under which the Fuse will be stored.</para>
    /// <para>Possible <type>FuseboxFuseCategory</type> values are PERSONAL, NETWORK or SYSTEM.</para>
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `index`
    ///  <para>The placement index of the fuse; starts at 0.</para>
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `code-name`
    ///  <para>The unique name representing the Fuse.</para>
    /// <para>It is also used to recognise it with the open-fuse command.</para>
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `display-name`
    ///  <para>The localised name of the Fuse.</para>
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `description`
    ///  <para>A short description of the Fuse.</para>
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `icon`
    ///  <para>The icon representing the Fuse.</para>
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `supported-settings`
    ///  <para>A map of settings:\/\/ endpoints and location to pass to the <function>fusebox_fuse_search_callback</function> method if the value is not
    /// &percnt;NULL. For example {&quot;input/keyboard&quot;, &quot;keyboard&quot;}.</para>
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `can-show`
    ///  <para>Inform if the Fuse should be shown or not</para>
    ///
    /// Readable | Writeable
    ///
    /// # Implements
    ///
    /// [`FuseExt`][trait@crate::prelude::FuseExt]
    #[doc(alias = "FuseboxFuse")]
    pub struct Fuse(Object<ffi::FuseboxFuse, ffi::FuseboxFuseClass>);

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

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

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

/// Trait containing all [`struct@Fuse`] methods.
///
/// # Implementors
///
/// [`Fuse`][struct@crate::Fuse]
pub trait FuseExt: IsA<Fuse> + sealed::Sealed + 'static {
    /// <para>Returns the widget that contain the whole interface.</para>
    ///
    /// # Returns
    ///
    /// <para>a <type>GtkWidget</type> containing the interface. </para>
    #[doc(alias = "fusebox_fuse_get_widget")]
    #[doc(alias = "get_widget")]
    fn widget(&self) -> gtk::Widget {
        unsafe { from_glib_full(ffi::fusebox_fuse_get_widget(self.as_ref().to_glib_none().0)) }
    }

    /// <para>Called when the Fuse appears to the user.</para>
    #[doc(alias = "fusebox_fuse_shown")]
    fn shown(&self) {
        unsafe {
            ffi::fusebox_fuse_shown(self.as_ref().to_glib_none().0);
        }
    }

    /// <para>Called when the Fuse disappear to the user.</para>
    /// <para>This is not called when the Fuse got destroyed or the window is closed, use ~Fuse &lpar;&rpar; instead.</para>
    #[doc(alias = "fusebox_fuse_hidden")]
    fn hidden(&self) {
        unsafe {
            ffi::fusebox_fuse_hidden(self.as_ref().to_glib_none().0);
        }
    }

    //#[doc(alias = "fusebox_fuse_search")]
    //fn search(&self, search: &str, _callback_: AsyncReadyCallback) {
    //    unsafe { TODO: call ffi:fusebox_fuse_search() }
    //}

    /// <para>This function is used when the user click on a search result, it should show the selected setting &lpar;right tab…&rpar;.</para>
    /// ## `location`
    /// <para>a <type>gchar</type> that represents the setting to show. </para>
    #[doc(alias = "fusebox_fuse_search_callback")]
    fn search_callback(&self, location: &str) {
        unsafe {
            ffi::fusebox_fuse_search_callback(
                self.as_ref().to_glib_none().0,
                location.to_glib_none().0,
            );
        }
    }

    #[doc(alias = "fusebox_fuse_get_category")]
    #[doc(alias = "get_category")]
    fn category(&self) -> FuseCategory {
        unsafe {
            from_glib(ffi::fusebox_fuse_get_category(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "fusebox_fuse_get_index")]
    #[doc(alias = "get_index")]
    fn index(&self) -> i32 {
        unsafe { ffi::fusebox_fuse_get_index(self.as_ref().to_glib_none().0) }
    }

    #[doc(alias = "fusebox_fuse_get_code_name")]
    #[doc(alias = "get_code_name")]
    fn code_name(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::fusebox_fuse_get_code_name(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "fusebox_fuse_get_display_name")]
    #[doc(alias = "get_display_name")]
    fn display_name(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::fusebox_fuse_get_display_name(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "fusebox_fuse_get_description")]
    #[doc(alias = "get_description")]
    fn description(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::fusebox_fuse_get_description(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "fusebox_fuse_get_icon")]
    #[doc(alias = "get_icon")]
    fn icon(&self) -> glib::GString {
        unsafe { from_glib_none(ffi::fusebox_fuse_get_icon(self.as_ref().to_glib_none().0)) }
    }

    //#[doc(alias = "fusebox_fuse_get_supported_settings")]
    //#[doc(alias = "get_supported_settings")]
    //fn supported_settings(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 } {
    //    unsafe { TODO: call ffi:fusebox_fuse_get_supported_settings() }
    //}

    #[doc(alias = "fusebox_fuse_get_can_show")]
    #[doc(alias = "get_can_show")]
    fn can_show(&self) -> bool {
        unsafe {
            from_glib(ffi::fusebox_fuse_get_can_show(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "fusebox_fuse_set_can_show")]
    fn set_can_show(&self, value: bool) {
        unsafe {
            ffi::fusebox_fuse_set_can_show(self.as_ref().to_glib_none().0, value.into_glib());
        }
    }

    #[doc(alias = "can-show")]
    fn connect_can_show_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_can_show_trampoline<P: IsA<Fuse>, F: Fn(&P) + 'static>(
            this: *mut ffi::FuseboxFuse,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Fuse::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::can-show\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_can_show_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<Fuse>> FuseExt for O {}