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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
// Generated by gir (https://github.com/gtk-rs/gir @ d7c0763cacbc)
// from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)
// DO NOT EDIT
#![allow(deprecated)]

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

glib::wrapper! {
    ///
    ///
    /// ## Properties
    ///
    ///
    /// #### `flush-on-destroy`
    ///  Readable | Writeable
    ///
    ///
    /// #### `format`
    ///  Readable | Writeable | Construct Only
    ///
    ///
    /// #### `px-size`
    ///  Readable
    ///
    ///
    /// #### `tile-height`
    ///  Readable | Writeable | Construct Only
    ///
    ///
    /// #### `tile-size`
    ///  Readable
    ///
    ///
    /// #### `tile-width`
    ///  Readable | Writeable | Construct Only
    ///
    /// # Implements
    ///
    /// [`TileBackendExt`][trait@crate::prelude::TileBackendExt], [`TileSourceExt`][trait@crate::prelude::TileSourceExt]
    #[doc(alias = "GeglTileBackend")]
    pub struct TileBackend(Object<ffi::GeglTileBackend, ffi::GeglTileBackendClass>) @extends TileSource;

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

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

    // rustdoc-stripper-ignore-next
    /// Creates a new builder-pattern struct instance to construct [`TileBackend`] objects.
    ///
    /// This method returns an instance of [`TileBackendBuilder`](crate::builders::TileBackendBuilder) which can be used to create [`TileBackend`] objects.
    pub fn builder() -> TileBackendBuilder {
        TileBackendBuilder::new()
    }

    /// Delete a swap file from disk. This must be used by tile backends which may
    /// swap to disk under certain circonstances.
    ///
    /// For safety, this function will check that the swap file is in the swap
    /// directory before deletion but it won't perform any other check.
    ///
    /// # Deprecated since 0.4.14
    ///
    /// This function is not compatible with a dynamically-
    /// changing swap path. Use [`Buffer::swap_remove_file()`][crate::Buffer::swap_remove_file()] instead.
    /// ## `path`
    /// the path where the gegl tile backend has swapped.
    #[cfg_attr(feature = "v0_4_14", deprecated = "Since 0.4.14")]
    #[allow(deprecated)]
    #[doc(alias = "gegl_tile_backend_unlink_swap")]
    pub fn unlink_swap(path: &str) {
        unsafe {
            ffi::gegl_tile_backend_unlink_swap(path.to_glib_none().0);
        }
    }
}

// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`TileBackend`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct TileBackendBuilder {
    builder: glib::object::ObjectBuilder<'static, TileBackend>,
}

impl TileBackendBuilder {
    fn new() -> Self {
        Self {
            builder: glib::object::Object::builder(),
        }
    }

    pub fn flush_on_destroy(self, flush_on_destroy: bool) -> Self {
        Self {
            builder: self.builder.property("flush-on-destroy", flush_on_destroy),
        }
    }

    //pub fn format(self, format: /*Unimplemented*/Basic: Pointer) -> Self {
    //    Self { builder: self.builder.property("format", format), }
    //}

    pub fn tile_height(self, tile_height: i32) -> Self {
        Self {
            builder: self.builder.property("tile-height", tile_height),
        }
    }

    pub fn tile_width(self, tile_width: i32) -> Self {
        Self {
            builder: self.builder.property("tile-width", tile_width),
        }
    }

    // rustdoc-stripper-ignore-next
    /// Build the [`TileBackend`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> TileBackend {
        self.builder.build()
    }
}

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

/// Trait containing all [`struct@TileBackend`] methods.
///
/// # Implementors
///
/// [`TileBackend`][struct@crate::TileBackend]
pub trait TileBackendExt: IsA<TileBackend> + sealed::Sealed + 'static {
    //#[doc(alias = "gegl_tile_backend_command")]
    //fn command(&self, command: TileCommand, x: i32, y: i32, z: i32, data: /*Unimplemented*/Option<Basic: Pointer>) -> /*Unimplemented*/Option<Basic: Pointer> {
    //    unsafe { TODO: call ffi:gegl_tile_backend_command() }
    //}

    #[doc(alias = "gegl_tile_backend_get_flush_on_destroy")]
    #[doc(alias = "get_flush_on_destroy")]
    #[doc(alias = "flush-on-destroy")]
    fn is_flush_on_destroy(&self) -> bool {
        unsafe {
            from_glib(ffi::gegl_tile_backend_get_flush_on_destroy(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// the height of tile from this backend
    #[doc(alias = "gegl_tile_backend_get_tile_height")]
    #[doc(alias = "get_tile_height")]
    #[doc(alias = "tile-height")]
    fn tile_height(&self) -> i32 {
        unsafe { ffi::gegl_tile_backend_get_tile_height(self.as_ref().to_glib_none().0) }
    }

    ///
    /// # Returns
    ///
    /// the size in bytes for a tile from this backend
    #[doc(alias = "gegl_tile_backend_get_tile_size")]
    #[doc(alias = "get_tile_size")]
    #[doc(alias = "tile-size")]
    fn tile_size(&self) -> i32 {
        unsafe { ffi::gegl_tile_backend_get_tile_size(self.as_ref().to_glib_none().0) }
    }

    ///
    /// # Returns
    ///
    /// the width of tile from this backend
    #[doc(alias = "gegl_tile_backend_get_tile_width")]
    #[doc(alias = "get_tile_width")]
    #[doc(alias = "tile-width")]
    fn tile_width(&self) -> i32 {
        unsafe { ffi::gegl_tile_backend_get_tile_width(self.as_ref().to_glib_none().0) }
    }

    /// Gets a pointer to the GeglTileStorage that uses the backend
    ///
    /// # Returns
    ///
    /// the `GeglTileStorage`
    #[doc(alias = "gegl_tile_backend_peek_storage")]
    fn peek_storage(&self) -> Option<TileSource> {
        unsafe {
            from_glib_none(ffi::gegl_tile_backend_peek_storage(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Specify the extent of the backend, can be used to pre-prime the
    /// backend with the width/height information when constructing proxy
    /// GeglBuffers to interact with other systems
    /// ## `rectangle`
    /// the new extent
    #[doc(alias = "gegl_tile_backend_set_extent")]
    fn set_extent(&self, rectangle: &Rectangle) {
        unsafe {
            ffi::gegl_tile_backend_set_extent(
                self.as_ref().to_glib_none().0,
                rectangle.to_glib_none().0,
            );
        }
    }

    #[doc(alias = "gegl_tile_backend_set_flush_on_destroy")]
    #[doc(alias = "flush-on-destroy")]
    fn set_flush_on_destroy(&self, flush_on_destroy: bool) {
        unsafe {
            ffi::gegl_tile_backend_set_flush_on_destroy(
                self.as_ref().to_glib_none().0,
                flush_on_destroy.into_glib(),
            );
        }
    }

    //fn format(&self) -> /*Unimplemented*/Basic: Pointer {
    //    ObjectExt::property(self.as_ref(), "format")
    //}

    #[doc(alias = "px-size")]
    fn px_size(&self) -> i32 {
        ObjectExt::property(self.as_ref(), "px-size")
    }

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

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

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

impl<O: IsA<TileBackend>> TileBackendExt for O {}