| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
use std::boxed::Box as Box_; |
| 7 |
|
| 8 |
use glib::prelude::*; |
| 9 |
use glib::signal::{SignalHandlerId, connect_raw}; |
| 10 |
use glib::translate::*; |
| 11 |
|
| 12 |
use crate::ffi; |
| 13 |
|
| 14 |
glib::wrapper! { |
| 15 |
#[doc(alias = "GlyFrameRequest")] |
| 16 |
pub struct FrameRequest(Object<ffi::GlyFrameRequest, ffi::GlyFrameRequestClass>); |
| 17 |
|
| 18 |
match fn { |
| 19 |
type_ => || ffi::gly_frame_request_get_type(), |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
impl FrameRequest { |
| 24 |
#[doc(alias = "gly_frame_request_new")] |
| 25 |
pub fn new() -> FrameRequest { |
| 26 |
assert_initialized_main_thread!(); |
| 27 |
unsafe { from_glib_full(ffi::gly_frame_request_new()) } |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
pub fn builder() -> FrameRequestBuilder { |
| 38 |
FrameRequestBuilder::new() |
| 39 |
} |
| 40 |
|
| 41 |
#[doc(alias = "gly_frame_request_set_loop_animation")] |
| 42 |
#[doc(alias = "loop-animation")] |
| 43 |
pub fn set_loop_animation(&self, loop_animation: bool) { |
| 44 |
unsafe { |
| 45 |
ffi::gly_frame_request_set_loop_animation( |
| 46 |
self.to_glib_none().0, |
| 47 |
loop_animation.into_glib(), |
| 48 |
); |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
#[doc(alias = "gly_frame_request_set_scale")] |
| 53 |
pub fn set_scale(&self, width: u32, height: u32) { |
| 54 |
unsafe { |
| 55 |
ffi::gly_frame_request_set_scale(self.to_glib_none().0, width, height); |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
#[doc(alias = "loop-animation")] |
| 60 |
pub fn is_loop_animation(&self) -> bool { |
| 61 |
ObjectExt::property(self, "loop-animation") |
| 62 |
} |
| 63 |
|
| 64 |
#[doc(alias = "scale-height")] |
| 65 |
pub fn scale_height(&self) -> u32 { |
| 66 |
ObjectExt::property(self, "scale-height") |
| 67 |
} |
| 68 |
|
| 69 |
#[doc(alias = "scale-width")] |
| 70 |
pub fn scale_width(&self) -> u32 { |
| 71 |
ObjectExt::property(self, "scale-width") |
| 72 |
} |
| 73 |
|
| 74 |
#[doc(alias = "loop-animation")] |
| 75 |
pub fn connect_loop_animation_notify<F: Fn(&Self) + Send + Sync + 'static>( |
| 76 |
&self, |
| 77 |
f: F, |
| 78 |
) -> SignalHandlerId { |
| 79 |
unsafe extern "C" fn notify_loop_animation_trampoline< |
| 80 |
F: Fn(&FrameRequest) + Send + Sync + 'static, |
| 81 |
>( |
| 82 |
this: *mut ffi::GlyFrameRequest, |
| 83 |
_param_spec: glib::ffi::gpointer, |
| 84 |
f: glib::ffi::gpointer, |
| 85 |
) { |
| 86 |
unsafe { |
| 87 |
let f: &F = &*(f as *const F); |
| 88 |
f(&from_glib_borrow(this)) |
| 89 |
} |
| 90 |
} |
| 91 |
unsafe { |
| 92 |
let f: Box_<F> = Box_::new(f); |
| 93 |
connect_raw( |
| 94 |
self.as_ptr() as *mut _, |
| 95 |
c"notify::loop-animation".as_ptr() as *const _, |
| 96 |
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( |
| 97 |
notify_loop_animation_trampoline::<F> as *const (), |
| 98 |
)), |
| 99 |
Box_::into_raw(f), |
| 100 |
) |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
#[doc(alias = "scale-height")] |
| 105 |
pub fn connect_scale_height_notify<F: Fn(&Self) + Send + Sync + 'static>( |
| 106 |
&self, |
| 107 |
f: F, |
| 108 |
) -> SignalHandlerId { |
| 109 |
unsafe extern "C" fn notify_scale_height_trampoline< |
| 110 |
F: Fn(&FrameRequest) + Send + Sync + 'static, |
| 111 |
>( |
| 112 |
this: *mut ffi::GlyFrameRequest, |
| 113 |
_param_spec: glib::ffi::gpointer, |
| 114 |
f: glib::ffi::gpointer, |
| 115 |
) { |
| 116 |
unsafe { |
| 117 |
let f: &F = &*(f as *const F); |
| 118 |
f(&from_glib_borrow(this)) |
| 119 |
} |
| 120 |
} |
| 121 |
unsafe { |
| 122 |
let f: Box_<F> = Box_::new(f); |
| 123 |
connect_raw( |
| 124 |
self.as_ptr() as *mut _, |
| 125 |
c"notify::scale-height".as_ptr() as *const _, |
| 126 |
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( |
| 127 |
notify_scale_height_trampoline::<F> as *const (), |
| 128 |
)), |
| 129 |
Box_::into_raw(f), |
| 130 |
) |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
#[doc(alias = "scale-width")] |
| 135 |
pub fn connect_scale_width_notify<F: Fn(&Self) + Send + Sync + 'static>( |
| 136 |
&self, |
| 137 |
f: F, |
| 138 |
) -> SignalHandlerId { |
| 139 |
unsafe extern "C" fn notify_scale_width_trampoline< |
| 140 |
F: Fn(&FrameRequest) + Send + Sync + 'static, |
| 141 |
>( |
| 142 |
this: *mut ffi::GlyFrameRequest, |
| 143 |
_param_spec: glib::ffi::gpointer, |
| 144 |
f: glib::ffi::gpointer, |
| 145 |
) { |
| 146 |
unsafe { |
| 147 |
let f: &F = &*(f as *const F); |
| 148 |
f(&from_glib_borrow(this)) |
| 149 |
} |
| 150 |
} |
| 151 |
unsafe { |
| 152 |
let f: Box_<F> = Box_::new(f); |
| 153 |
connect_raw( |
| 154 |
self.as_ptr() as *mut _, |
| 155 |
c"notify::scale-width".as_ptr() as *const _, |
| 156 |
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( |
| 157 |
notify_scale_width_trampoline::<F> as *const (), |
| 158 |
)), |
| 159 |
Box_::into_raw(f), |
| 160 |
) |
| 161 |
} |
| 162 |
} |
| 163 |
} |
| 164 |
|
| 165 |
impl Default for FrameRequest { |
| 166 |
fn default() -> Self { |
| 167 |
Self::new() |
| 168 |
} |
| 169 |
} |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
#[must_use = "The builder must be built to be used"] |
| 176 |
pub struct FrameRequestBuilder { |
| 177 |
builder: glib::object::ObjectBuilder<'static, FrameRequest>, |
| 178 |
} |
| 179 |
|
| 180 |
impl FrameRequestBuilder { |
| 181 |
fn new() -> Self { |
| 182 |
Self { |
| 183 |
builder: glib::object::Object::builder(), |
| 184 |
} |
| 185 |
} |
| 186 |
|
| 187 |
pub fn loop_animation(self, loop_animation: bool) -> Self { |
| 188 |
Self { |
| 189 |
builder: self.builder.property("loop-animation", loop_animation), |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] |
| 196 |
pub fn build(self) -> FrameRequest { |
| 197 |
assert_initialized_main_thread!(); |
| 198 |
self.builder.build() |
| 199 |
} |
| 200 |
} |
| 201 |
|
| 202 |
unsafe impl Send for FrameRequest {} |
| 203 |
unsafe impl Sync for FrameRequest {} |