[go: up one dir, main page]

gtk4/auto/
graphics_offload.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::{
6    ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, GraphicsOffloadEnabled,
7    LayoutManager, Overflow, Widget,
8};
9use glib::{
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    #[doc(alias = "GtkGraphicsOffload")]
18    pub struct GraphicsOffload(Object<ffi::GtkGraphicsOffload, ffi::GtkGraphicsOffloadClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
19
20    match fn {
21        type_ => || ffi::gtk_graphics_offload_get_type(),
22    }
23}
24
25impl GraphicsOffload {
26    #[doc(alias = "gtk_graphics_offload_new")]
27    pub fn new(child: Option<&impl IsA<Widget>>) -> GraphicsOffload {
28        assert_initialized_main_thread!();
29        unsafe {
30            Widget::from_glib_none(ffi::gtk_graphics_offload_new(
31                child.map(|p| p.as_ref()).to_glib_none().0,
32            ))
33            .unsafe_cast()
34        }
35    }
36
37    // rustdoc-stripper-ignore-next
38    /// Creates a new builder-pattern struct instance to construct [`GraphicsOffload`] objects.
39    ///
40    /// This method returns an instance of [`GraphicsOffloadBuilder`](crate::builders::GraphicsOffloadBuilder) which can be used to create [`GraphicsOffload`] objects.
41    pub fn builder() -> GraphicsOffloadBuilder {
42        GraphicsOffloadBuilder::new()
43    }
44
45    #[cfg(feature = "v4_16")]
46    #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
47    #[doc(alias = "gtk_graphics_offload_get_black_background")]
48    #[doc(alias = "get_black_background")]
49    #[doc(alias = "black-background")]
50    pub fn is_black_background(&self) -> bool {
51        unsafe {
52            from_glib(ffi::gtk_graphics_offload_get_black_background(
53                self.to_glib_none().0,
54            ))
55        }
56    }
57
58    #[doc(alias = "gtk_graphics_offload_get_child")]
59    #[doc(alias = "get_child")]
60    pub fn child(&self) -> Option<Widget> {
61        unsafe { from_glib_none(ffi::gtk_graphics_offload_get_child(self.to_glib_none().0)) }
62    }
63
64    #[doc(alias = "gtk_graphics_offload_get_enabled")]
65    #[doc(alias = "get_enabled")]
66    pub fn enabled(&self) -> GraphicsOffloadEnabled {
67        unsafe { from_glib(ffi::gtk_graphics_offload_get_enabled(self.to_glib_none().0)) }
68    }
69
70    #[cfg(feature = "v4_16")]
71    #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
72    #[doc(alias = "gtk_graphics_offload_set_black_background")]
73    #[doc(alias = "black-background")]
74    pub fn set_black_background(&self, value: bool) {
75        unsafe {
76            ffi::gtk_graphics_offload_set_black_background(
77                self.to_glib_none().0,
78                value.into_glib(),
79            );
80        }
81    }
82
83    #[doc(alias = "gtk_graphics_offload_set_child")]
84    #[doc(alias = "child")]
85    pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
86        unsafe {
87            ffi::gtk_graphics_offload_set_child(
88                self.to_glib_none().0,
89                child.map(|p| p.as_ref()).to_glib_none().0,
90            );
91        }
92    }
93
94    #[doc(alias = "gtk_graphics_offload_set_enabled")]
95    #[doc(alias = "enabled")]
96    pub fn set_enabled(&self, enabled: GraphicsOffloadEnabled) {
97        unsafe {
98            ffi::gtk_graphics_offload_set_enabled(self.to_glib_none().0, enabled.into_glib());
99        }
100    }
101
102    #[cfg(feature = "v4_16")]
103    #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
104    #[doc(alias = "black-background")]
105    pub fn connect_black_background_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
106        unsafe extern "C" fn notify_black_background_trampoline<
107            F: Fn(&GraphicsOffload) + 'static,
108        >(
109            this: *mut ffi::GtkGraphicsOffload,
110            _param_spec: glib::ffi::gpointer,
111            f: glib::ffi::gpointer,
112        ) {
113            let f: &F = &*(f as *const F);
114            f(&from_glib_borrow(this))
115        }
116        unsafe {
117            let f: Box_<F> = Box_::new(f);
118            connect_raw(
119                self.as_ptr() as *mut _,
120                c"notify::black-background".as_ptr() as *const _,
121                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
122                    notify_black_background_trampoline::<F> as *const (),
123                )),
124                Box_::into_raw(f),
125            )
126        }
127    }
128
129    #[cfg(feature = "v4_14")]
130    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
131    #[doc(alias = "child")]
132    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
133        unsafe extern "C" fn notify_child_trampoline<F: Fn(&GraphicsOffload) + 'static>(
134            this: *mut ffi::GtkGraphicsOffload,
135            _param_spec: glib::ffi::gpointer,
136            f: glib::ffi::gpointer,
137        ) {
138            let f: &F = &*(f as *const F);
139            f(&from_glib_borrow(this))
140        }
141        unsafe {
142            let f: Box_<F> = Box_::new(f);
143            connect_raw(
144                self.as_ptr() as *mut _,
145                c"notify::child".as_ptr() as *const _,
146                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
147                    notify_child_trampoline::<F> as *const (),
148                )),
149                Box_::into_raw(f),
150            )
151        }
152    }
153
154    #[cfg(feature = "v4_14")]
155    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
156    #[doc(alias = "enabled")]
157    pub fn connect_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
158        unsafe extern "C" fn notify_enabled_trampoline<F: Fn(&GraphicsOffload) + 'static>(
159            this: *mut ffi::GtkGraphicsOffload,
160            _param_spec: glib::ffi::gpointer,
161            f: glib::ffi::gpointer,
162        ) {
163            let f: &F = &*(f as *const F);
164            f(&from_glib_borrow(this))
165        }
166        unsafe {
167            let f: Box_<F> = Box_::new(f);
168            connect_raw(
169                self.as_ptr() as *mut _,
170                c"notify::enabled".as_ptr() as *const _,
171                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
172                    notify_enabled_trampoline::<F> as *const (),
173                )),
174                Box_::into_raw(f),
175            )
176        }
177    }
178}
179
180#[cfg(feature = "v4_14")]
181#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
182impl Default for GraphicsOffload {
183    fn default() -> Self {
184        glib::object::Object::new::<Self>()
185    }
186}
187
188// rustdoc-stripper-ignore-next
189/// A [builder-pattern] type to construct [`GraphicsOffload`] objects.
190///
191/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
192#[must_use = "The builder must be built to be used"]
193pub struct GraphicsOffloadBuilder {
194    builder: glib::object::ObjectBuilder<'static, GraphicsOffload>,
195}
196
197impl GraphicsOffloadBuilder {
198    fn new() -> Self {
199        Self {
200            builder: glib::object::Object::builder(),
201        }
202    }
203
204    #[cfg(feature = "v4_16")]
205    #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
206    pub fn black_background(self, black_background: bool) -> Self {
207        Self {
208            builder: self.builder.property("black-background", black_background),
209        }
210    }
211
212    #[cfg(feature = "v4_14")]
213    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
214    pub fn child(self, child: &impl IsA<Widget>) -> Self {
215        Self {
216            builder: self.builder.property("child", child.clone().upcast()),
217        }
218    }
219
220    #[cfg(feature = "v4_14")]
221    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
222    pub fn enabled(self, enabled: GraphicsOffloadEnabled) -> Self {
223        Self {
224            builder: self.builder.property("enabled", enabled),
225        }
226    }
227
228    pub fn can_focus(self, can_focus: bool) -> Self {
229        Self {
230            builder: self.builder.property("can-focus", can_focus),
231        }
232    }
233
234    pub fn can_target(self, can_target: bool) -> Self {
235        Self {
236            builder: self.builder.property("can-target", can_target),
237        }
238    }
239
240    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
241        Self {
242            builder: self.builder.property("css-classes", css_classes.into()),
243        }
244    }
245
246    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
247        Self {
248            builder: self.builder.property("css-name", css_name.into()),
249        }
250    }
251
252    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
253        Self {
254            builder: self.builder.property("cursor", cursor.clone()),
255        }
256    }
257
258    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
259        Self {
260            builder: self.builder.property("focus-on-click", focus_on_click),
261        }
262    }
263
264    pub fn focusable(self, focusable: bool) -> Self {
265        Self {
266            builder: self.builder.property("focusable", focusable),
267        }
268    }
269
270    pub fn halign(self, halign: Align) -> Self {
271        Self {
272            builder: self.builder.property("halign", halign),
273        }
274    }
275
276    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
277        Self {
278            builder: self.builder.property("has-tooltip", has_tooltip),
279        }
280    }
281
282    pub fn height_request(self, height_request: i32) -> Self {
283        Self {
284            builder: self.builder.property("height-request", height_request),
285        }
286    }
287
288    pub fn hexpand(self, hexpand: bool) -> Self {
289        Self {
290            builder: self.builder.property("hexpand", hexpand),
291        }
292    }
293
294    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
295        Self {
296            builder: self.builder.property("hexpand-set", hexpand_set),
297        }
298    }
299
300    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
301        Self {
302            builder: self
303                .builder
304                .property("layout-manager", layout_manager.clone().upcast()),
305        }
306    }
307
308    #[cfg(feature = "v4_18")]
309    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
310    pub fn limit_events(self, limit_events: bool) -> Self {
311        Self {
312            builder: self.builder.property("limit-events", limit_events),
313        }
314    }
315
316    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
317        Self {
318            builder: self.builder.property("margin-bottom", margin_bottom),
319        }
320    }
321
322    pub fn margin_end(self, margin_end: i32) -> Self {
323        Self {
324            builder: self.builder.property("margin-end", margin_end),
325        }
326    }
327
328    pub fn margin_start(self, margin_start: i32) -> Self {
329        Self {
330            builder: self.builder.property("margin-start", margin_start),
331        }
332    }
333
334    pub fn margin_top(self, margin_top: i32) -> Self {
335        Self {
336            builder: self.builder.property("margin-top", margin_top),
337        }
338    }
339
340    pub fn name(self, name: impl Into<glib::GString>) -> Self {
341        Self {
342            builder: self.builder.property("name", name.into()),
343        }
344    }
345
346    pub fn opacity(self, opacity: f64) -> Self {
347        Self {
348            builder: self.builder.property("opacity", opacity),
349        }
350    }
351
352    pub fn overflow(self, overflow: Overflow) -> Self {
353        Self {
354            builder: self.builder.property("overflow", overflow),
355        }
356    }
357
358    pub fn receives_default(self, receives_default: bool) -> Self {
359        Self {
360            builder: self.builder.property("receives-default", receives_default),
361        }
362    }
363
364    pub fn sensitive(self, sensitive: bool) -> Self {
365        Self {
366            builder: self.builder.property("sensitive", sensitive),
367        }
368    }
369
370    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
371        Self {
372            builder: self
373                .builder
374                .property("tooltip-markup", tooltip_markup.into()),
375        }
376    }
377
378    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
379        Self {
380            builder: self.builder.property("tooltip-text", tooltip_text.into()),
381        }
382    }
383
384    pub fn valign(self, valign: Align) -> Self {
385        Self {
386            builder: self.builder.property("valign", valign),
387        }
388    }
389
390    pub fn vexpand(self, vexpand: bool) -> Self {
391        Self {
392            builder: self.builder.property("vexpand", vexpand),
393        }
394    }
395
396    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
397        Self {
398            builder: self.builder.property("vexpand-set", vexpand_set),
399        }
400    }
401
402    pub fn visible(self, visible: bool) -> Self {
403        Self {
404            builder: self.builder.property("visible", visible),
405        }
406    }
407
408    pub fn width_request(self, width_request: i32) -> Self {
409        Self {
410            builder: self.builder.property("width-request", width_request),
411        }
412    }
413
414    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
415        Self {
416            builder: self.builder.property("accessible-role", accessible_role),
417        }
418    }
419
420    // rustdoc-stripper-ignore-next
421    /// Build the [`GraphicsOffload`].
422    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
423    pub fn build(self) -> GraphicsOffload {
424        assert_initialized_main_thread!();
425        self.builder.build()
426    }
427}