animate/legacy/
stage.rs

1// Scriptable
2use crate::{Actor, Animatable, Container, Event, Group, Perspective, PickMode};
3use glib::{
4    object as gobject,
5    object::{Cast, IsA},
6    signal::{connect_raw, SignalHandlerId},
7    translate::*,
8    GString, StaticType, Value,
9};
10use std::boxed::Box as Box_;
11use std::{fmt, mem, mem::transmute};
12
13// TODO: implements atk::ImplementorIface, Scriptable
14glib_wrapper! {
15    pub struct Stage(Object<ffi::ClutterStage, ffi::ClutterStageClass, StageClass>) @extends Group, Actor, gobject::InitiallyUnowned, @implements Animatable, Container;
16
17    match fn {
18        get_type => || ffi::clutter_stage_get_type(),
19    }
20}
21
22impl Stage {
23    /// Creates a new, non-default stage. A non-default stage is a new
24    /// top-level actor which can be used as another container. It works
25    /// exactly like the default stage, but while `Stage::get_default`
26    /// will always return the same instance, you will have to keep a pointer
27    /// to any `Stage` returned by `Stage::new`.
28    ///
29    /// The ability to support multiple stages depends on the current
30    /// backend. Use `feature_available` and
31    /// `FeatureFlags::StageMultiple` to check at runtime whether a
32    /// backend supports multiple stages.
33    ///
34    /// # Returns
35    ///
36    /// a new stage, or `None` if the default backend does
37    ///  not support multiple stages. Use `ActorExt::destroy` to
38    ///  programmatically close the returned stage.
39    pub fn new() -> Stage {
40        unsafe { Actor::from_glib_none(ffi::clutter_stage_new()).unsafe_cast() }
41    }
42}
43
44impl Default for Stage {
45    fn default() -> Self {
46        Self::new()
47    }
48}
49
50/// Trait containing all `Stage` methods.
51///
52/// # Implementors
53///
54/// [`Stage`](struct.Stage.html)
55pub trait StageExt: 'static {
56    /// This function essentially makes sure the right GL context is
57    /// current for the passed stage. It is not intended to
58    /// be used by applications.
59    fn ensure_current(&self);
60
61    /// Ensures that `self` is redrawn
62    ///
63    /// This function should not be called by applications: it is
64    /// used when embedding a `Stage` into a toolkit with
65    /// another windowing system, like GTK+.
66    fn ensure_redraw(&self);
67
68    /// Ensures that the GL viewport is updated with the current
69    /// stage window size.
70    ///
71    /// This function will queue a redraw of `self`.
72    ///
73    /// This function should not be called by applications; it is used
74    /// when embedding a `Stage` into a toolkit with another
75    /// windowing system, like GTK+.
76    fn ensure_viewport(&self);
77
78    /// This function is used to emit an event on the main stage.
79    ///
80    /// You should rarely need to use this function, except for
81    /// synthetised events.
82    /// ## `event`
83    /// a `Event`
84    ///
85    /// # Returns
86    ///
87    /// the return value from the signal emission
88    fn event(&self, event: &mut Event) -> bool;
89
90    /// Retrieves the value set with `StageExt::set_accept_focus`.
91    ///
92    /// # Returns
93    ///
94    /// `true` if the `Stage` should accept focus, and `false`
95    ///  otherwise
96    fn get_accept_focus(&self) -> bool;
97
98    /// Checks the scene at the coordinates `x` and `y` and returns a pointer
99    /// to the `Actor` at those coordinates.
100    ///
101    /// By using `pick_mode` it is possible to control which actors will be
102    /// painted and thus available.
103    /// ## `pick_mode`
104    /// how the scene graph should be painted
105    /// ## `x`
106    /// X coordinate to check
107    /// ## `y`
108    /// Y coordinate to check
109    ///
110    /// # Returns
111    ///
112    /// the actor at the specified coordinates,
113    ///  if any
114    fn get_actor_at_pos(&self, pick_mode: PickMode, x: i32, y: i32) -> Option<Actor>;
115
116    /// Retrieves whether the stage is full screen or not
117    ///
118    /// # Returns
119    ///
120    /// `true` if the stage is full screen
121    fn get_fullscreen(&self) -> bool;
122
123    /// Retrieves the actor that is currently under key focus.
124    ///
125    /// # Returns
126    ///
127    /// the actor with key focus, or the stage
128    fn get_key_focus(&self) -> Option<Actor>;
129
130    /// Retrieves the minimum size for a stage window as set using
131    /// `StageExt::set_minimum_size`.
132    ///
133    /// The returned size may not correspond to the actual minimum size and
134    /// it is specific to the `Stage` implementation inside the
135    /// backend
136    /// ## `width`
137    /// return location for the minimum width, in pixels,
138    ///  or `None`
139    /// ## `height`
140    /// return location for the minimum height, in pixels,
141    ///  or `None`
142    fn get_minimum_size(&self) -> (u32, u32);
143
144    /// Retrieves the value set using `StageExt::set_motion_events_enabled`.
145    ///
146    /// # Returns
147    ///
148    /// `true` if the per-actor motion event delivery is enabled
149    ///  and `false` otherwise
150    fn get_motion_events_enabled(&self) -> bool;
151
152    /// Retrieves the hint set with `StageExt::set_no_clear_hint`
153    ///
154    /// # Returns
155    ///
156    /// `true` if the stage should not clear itself on every paint
157    ///  cycle, and `false` otherwise
158    fn get_no_clear_hint(&self) -> bool;
159
160    /// Retrieves the stage perspective.
161    /// ## `perspective`
162    /// return location for a
163    ///  `Perspective`
164    fn get_perspective(&self) -> Perspective;
165
166    /// Gets the bounds of the current redraw for `self` in stage pixel
167    /// coordinates. E.g., if only a single actor has queued a redraw then
168    /// it may redraw the stage with a clip so that it doesn't have to
169    /// paint every pixel in the stage. This function would then return the
170    /// bounds of that clip. An application can use this information to
171    /// avoid some extra work if it knows that some regions of the stage
172    /// aren't going to be painted. This should only be called while the
173    /// stage is being painted. If there is no current redraw clip then
174    /// this function will set `clip` to the full extents of the stage.
175    /// ## `clip`
176    /// Return location for the clip bounds
177    fn get_redraw_clip_bounds(&self) -> cairo::RectangleInt;
178
179    /// Retrieves the value set with `StageExt::set_throttle_motion_events`
180    ///
181    /// # Returns
182    ///
183    /// `true` if the motion events are being throttled,
184    ///  and `false` otherwise
185    fn get_throttle_motion_events(&self) -> bool;
186
187    /// Gets the stage title.
188    ///
189    /// # Returns
190    ///
191    /// pointer to the title string for the stage. The
192    /// returned string is owned by the actor and should not
193    /// be modified or freed.
194    fn get_title(&self) -> Option<GString>;
195
196    /// Retrieves the value set using `StageExt::set_use_alpha`
197    ///
198    /// # Returns
199    ///
200    /// `true` if the stage should honour the opacity and the
201    ///  alpha channel of the stage color
202    fn get_use_alpha(&self) -> bool;
203
204    /// Retrieves the value set with `StageExt::set_user_resizable`.
205    ///
206    /// # Returns
207    ///
208    /// `true` if the stage is resizable by the user.
209    fn get_user_resizable(&self) -> bool;
210
211    /// Makes the cursor invisible on the stage window
212    fn hide_cursor(&self);
213
214    // /// Makes a screenshot of the stage in RGBA 8bit data, returns a
215    // /// linear buffer with `width` * 4 as rowstride.
216    // ///
217    // /// The alpha data contained in the returned buffer is driver-dependent,
218    // /// and not guaranteed to hold any sensible value.
219    // /// ## `x`
220    // /// x coordinate of the first pixel that is read from stage
221    // /// ## `y`
222    // /// y coordinate of the first pixel that is read from stage
223    // /// ## `width`
224    // /// Width dimention of pixels to be read, or -1 for the
225    // ///  entire stage width
226    // /// ## `height`
227    // /// Height dimention of pixels to be read, or -1 for the
228    // ///  entire stage height
229    // ///
230    // /// # Returns
231    // ///
232    // /// a pointer to newly allocated memory with the buffer
233    // ///  or `None` if the read failed. Use `g_free` on the returned data
234    // ///  to release the resources it has allocated.
235    // fn read_pixels(&self, x: i32, y: i32, width: i32, height: i32) -> Vec<u8>;
236
237    /// Sets whether the `self` should accept the key focus when shown.
238    ///
239    /// This function should be called before showing `self` using
240    /// `ActorExt::show`.
241    /// ## `accept_focus`
242    /// `true` to accept focus on show
243    fn set_accept_focus(&self, accept_focus: bool);
244
245    /// Asks to place the stage window in the fullscreen or unfullscreen
246    /// states.
247    ///
248    ///  ( Note that you shouldn't assume the window is definitely full screen
249    /// afterward, because other entities (e.g. the user or window manager)
250    /// could unfullscreen it again, and not all window managers honor
251    /// requests to fullscreen windows.
252    ///
253    /// If you want to receive notification of the fullscreen state you
254    /// should either use the `Stage::fullscreen` and
255    /// `Stage::unfullscreen` signals, or use the notify signal
256    /// for the `Stage:fullscreen-set` property
257    /// ## `fullscreen`
258    /// `true` to to set the stage fullscreen
259    fn set_fullscreen(&self, fullscreen: bool);
260
261    /// Sets the key focus on `actor`. An actor with key focus will receive
262    /// all the key events. If `actor` is `None`, the stage will receive
263    /// focus.
264    /// ## `actor`
265    /// the actor to set key focus to, or `None`
266    fn set_key_focus<P: IsA<Actor>>(&self, actor: Option<&P>);
267
268    /// Sets the minimum size for a stage window, if the default backend
269    /// uses `Stage` inside a window
270    ///
271    /// This is a convenience function, and it is equivalent to setting the
272    /// `Actor:min-width` and `Actor:min-height` on `self`
273    ///
274    /// If the current size of `self` is smaller than the minimum size, the
275    /// `self` will be resized to the new `width` and `height`
276    ///
277    /// This function has no effect if `self` is fullscreen
278    /// ## `width`
279    /// width, in pixels
280    /// ## `height`
281    /// height, in pixels
282    fn set_minimum_size(&self, width: u32, height: u32);
283
284    /// Sets whether per-actor motion events (and relative crossing
285    /// events) should be disabled or not.
286    ///
287    /// The default is `true`.
288    ///
289    /// If `enable` is `false` the following signals will not be emitted
290    /// by the actors children of `self`:
291    ///
292    ///  - `Actor::motion-event`
293    ///  - `Actor::enter-event`
294    ///  - `Actor::leave-event`
295    ///
296    /// The events will still be delivered to the `Stage`.
297    ///
298    /// The main side effect of this function is that disabling the motion
299    /// events will disable picking to detect the `Actor` underneath
300    /// the pointer for each motion event. This is useful, for instance,
301    /// when dragging a `Actor` across the `self`: the actor underneath
302    /// the pointer is not going to change, so it's meaningless to perform
303    /// a pick.
304    /// ## `enabled`
305    /// `true` to enable the motion events delivery, and `false`
306    ///  otherwise
307    fn set_motion_events_enabled(&self, enabled: bool);
308
309    /// Sets whether the `self` should clear itself at the beginning
310    /// of each paint cycle or not.
311    ///
312    /// Clearing the `Stage` can be a costly operation, especially
313    /// if the stage is always covered - for instance, in a full-screen
314    /// video player or in a game with a background texture.
315    ///
316    /// This setting is a hint; it might discard this hint
317    /// depending on its internal state.
318    ///
319    /// If parts of the stage are visible and you disable clearing you
320    /// might end up with visual artifacts while painting the contents of
321    /// the stage.
322    /// ## `no_clear`
323    /// `true` if the `self` should not clear itself on every
324    ///  repaint cycle
325    fn set_no_clear_hint(&self, no_clear: bool);
326
327    /// Sets the stage perspective. Using this function is not recommended
328    /// because it will disable it's attempts to generate an
329    /// appropriate perspective based on the size of the stage.
330    /// ## `perspective`
331    /// A `Perspective`
332    fn set_perspective(&self, perspective: &mut Perspective);
333
334    /// Sets whether motion events received between redraws should
335    /// be throttled or not. If motion events are throttled, those
336    /// events received by the windowing system between redraws will
337    /// be compressed so that only the last event will be propagated
338    /// to the `self` and its actors.
339    ///
340    /// This function should only be used if you want to have all
341    /// the motion events delivered to your application code.
342    /// ## `throttle`
343    /// `true` to throttle motion events
344    fn set_throttle_motion_events(&self, throttle: bool);
345
346    /// Sets the stage title.
347    /// ## `title`
348    /// A utf8 string for the stage windows title.
349    fn set_title(&self, title: &str);
350
351    /// Sets whether the `self` should honour the `Actor:opacity` and
352    /// the alpha channel of the `Stage:color`
353    /// ## `use_alpha`
354    /// whether the stage should honour the opacity or the
355    ///  alpha channel of the stage color
356    fn set_use_alpha(&self, use_alpha: bool);
357
358    /// Sets if the stage is resizable by user interaction (e.g. via
359    /// window manager controls)
360    /// ## `resizable`
361    /// whether the stage should be user resizable.
362    fn set_user_resizable(&self, resizable: bool);
363
364    /// Shows the cursor on the stage window
365    fn show_cursor(&self);
366
367    /// Whether the mouse pointer should be visible
368    fn get_property_cursor_visible(&self) -> bool;
369
370    /// Whether the mouse pointer should be visible
371    fn set_property_cursor_visible(&self, cursor_visible: bool);
372
373    fn get_property_fullscreen_set(&self) -> bool;
374
375    /// The ::activate signal is emitted when the stage receives key focus
376    /// from the underlying window system.
377    fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
378
379    /// The ::after-paint signal is emitted after the stage is painted,
380    /// but before the results are displayed on the screen.
381    fn connect_after_paint<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
382
383    /// The ::deactivate signal is emitted when the stage loses key focus
384    /// from the underlying window system.
385    fn connect_deactivate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
386
387    /// The ::delete-event signal is emitted when the user closes a
388    /// `Stage` window using the window controls.
389    ///
390    /// by default will call `main_quit` if `stage` is
391    /// the default stage, and `ActorExt::destroy` for any other
392    /// stage.
393    ///
394    /// It is possible to override the default behaviour by connecting
395    /// a new handler and returning `true` there.
396    ///
397    /// This signal is emitted only on backends that
398    /// embed `Stage` in native windows. It is not emitted for
399    /// backends that use a static frame buffer.
400    /// ## `event`
401    /// a `Event` of type `EventType::Delete`
402    fn connect_delete_event<F: Fn(&Self, &Event) -> bool + 'static>(&self, f: F)
403        -> SignalHandlerId;
404
405    /// The ::fullscreen signal is emitted when the stage is made fullscreen.
406    fn connect_fullscreen<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
407
408    /// The ::unfullscreen signal is emitted when the stage leaves a fullscreen
409    /// state.
410    fn connect_unfullscreen<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
411
412    fn connect_property_accept_focus_notify<F: Fn(&Self) + 'static>(&self, f: F)
413        -> SignalHandlerId;
414
415    fn connect_property_cursor_visible_notify<F: Fn(&Self) + 'static>(
416        &self,
417        f: F,
418    ) -> SignalHandlerId;
419
420    fn connect_property_fullscreen_set_notify<F: Fn(&Self) + 'static>(
421        &self,
422        f: F,
423    ) -> SignalHandlerId;
424
425    fn connect_property_key_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
426
427    fn connect_property_no_clear_hint_notify<F: Fn(&Self) + 'static>(
428        &self,
429        f: F,
430    ) -> SignalHandlerId;
431
432    fn connect_property_perspective_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
433
434    fn connect_property_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
435
436    fn connect_property_use_alpha_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
437
438    fn connect_property_user_resizable_notify<F: Fn(&Self) + 'static>(
439        &self,
440        f: F,
441    ) -> SignalHandlerId;
442}
443
444impl<O: IsA<Stage>> StageExt for O {
445    fn ensure_current(&self) {
446        unsafe {
447            ffi::clutter_stage_ensure_current(self.as_ref().to_glib_none().0);
448        }
449    }
450
451    fn ensure_redraw(&self) {
452        unsafe {
453            ffi::clutter_stage_ensure_redraw(self.as_ref().to_glib_none().0);
454        }
455    }
456
457    fn ensure_viewport(&self) {
458        unsafe {
459            ffi::clutter_stage_ensure_viewport(self.as_ref().to_glib_none().0);
460        }
461    }
462
463    fn event(&self, event: &mut Event) -> bool {
464        unsafe {
465            from_glib(ffi::clutter_stage_event(
466                self.as_ref().to_glib_none().0,
467                event.to_glib_none_mut().0,
468            ))
469        }
470    }
471
472    fn get_accept_focus(&self) -> bool {
473        unsafe {
474            from_glib(ffi::clutter_stage_get_accept_focus(
475                self.as_ref().to_glib_none().0,
476            ))
477        }
478    }
479
480    fn get_actor_at_pos(&self, pick_mode: PickMode, x: i32, y: i32) -> Option<Actor> {
481        unsafe {
482            from_glib_none(ffi::clutter_stage_get_actor_at_pos(
483                self.as_ref().to_glib_none().0,
484                pick_mode.to_glib(),
485                x,
486                y,
487            ))
488        }
489    }
490
491    fn get_fullscreen(&self) -> bool {
492        unsafe {
493            from_glib(ffi::clutter_stage_get_fullscreen(
494                self.as_ref().to_glib_none().0,
495            ))
496        }
497    }
498
499    fn get_key_focus(&self) -> Option<Actor> {
500        unsafe {
501            from_glib_none(ffi::clutter_stage_get_key_focus(
502                self.as_ref().to_glib_none().0,
503            ))
504        }
505    }
506
507    fn get_minimum_size(&self) -> (u32, u32) {
508        unsafe {
509            let mut width = mem::MaybeUninit::uninit();
510            let mut height = mem::MaybeUninit::uninit();
511            ffi::clutter_stage_get_minimum_size(
512                self.as_ref().to_glib_none().0,
513                width.as_mut_ptr(),
514                height.as_mut_ptr(),
515            );
516            let width = width.assume_init();
517            let height = height.assume_init();
518            (width, height)
519        }
520    }
521
522    fn get_motion_events_enabled(&self) -> bool {
523        unsafe {
524            from_glib(ffi::clutter_stage_get_motion_events_enabled(
525                self.as_ref().to_glib_none().0,
526            ))
527        }
528    }
529
530    fn get_no_clear_hint(&self) -> bool {
531        unsafe {
532            from_glib(ffi::clutter_stage_get_no_clear_hint(
533                self.as_ref().to_glib_none().0,
534            ))
535        }
536    }
537
538    fn get_perspective(&self) -> Perspective {
539        unsafe {
540            let mut perspective = Perspective::uninitialized();
541            ffi::clutter_stage_get_perspective(
542                self.as_ref().to_glib_none().0,
543                perspective.to_glib_none_mut().0,
544            );
545            perspective
546        }
547    }
548
549    fn get_redraw_clip_bounds(&self) -> cairo::RectangleInt {
550        unsafe {
551            let mut clip = cairo::RectangleInt::uninitialized();
552            ffi::clutter_stage_get_redraw_clip_bounds(
553                self.as_ref().to_glib_none().0,
554                clip.to_glib_none_mut().0,
555            );
556            clip
557        }
558    }
559
560    fn get_throttle_motion_events(&self) -> bool {
561        unsafe {
562            from_glib(ffi::clutter_stage_get_throttle_motion_events(
563                self.as_ref().to_glib_none().0,
564            ))
565        }
566    }
567
568    fn get_title(&self) -> Option<GString> {
569        unsafe { from_glib_none(ffi::clutter_stage_get_title(self.as_ref().to_glib_none().0)) }
570    }
571
572    fn get_use_alpha(&self) -> bool {
573        unsafe {
574            from_glib(ffi::clutter_stage_get_use_alpha(
575                self.as_ref().to_glib_none().0,
576            ))
577        }
578    }
579
580    fn get_user_resizable(&self) -> bool {
581        unsafe {
582            from_glib(ffi::clutter_stage_get_user_resizable(
583                self.as_ref().to_glib_none().0,
584            ))
585        }
586    }
587
588    fn hide_cursor(&self) {
589        unsafe {
590            ffi::clutter_stage_hide_cursor(self.as_ref().to_glib_none().0);
591        }
592    }
593
594    // fn read_pixels(&self, x: i32, y: i32, width: i32, height: i32) -> Vec<u8> {
595    //     unsafe {
596    //         FromGlibPtrContainer::from_glib_full(ffi::clutter_stage_read_pixels(
597    //             self.as_ref().to_glib_none().0,
598    //             x,
599    //             y,
600    //             width,
601    //             height,
602    //         ))
603    //     }
604    // }
605
606    fn set_accept_focus(&self, accept_focus: bool) {
607        unsafe {
608            ffi::clutter_stage_set_accept_focus(
609                self.as_ref().to_glib_none().0,
610                accept_focus.to_glib(),
611            );
612        }
613    }
614
615    fn set_fullscreen(&self, fullscreen: bool) {
616        unsafe {
617            ffi::clutter_stage_set_fullscreen(self.as_ref().to_glib_none().0, fullscreen.to_glib());
618        }
619    }
620
621    fn set_key_focus<P: IsA<Actor>>(&self, actor: Option<&P>) {
622        unsafe {
623            ffi::clutter_stage_set_key_focus(
624                self.as_ref().to_glib_none().0,
625                actor.map(|p| p.as_ref()).to_glib_none().0,
626            );
627        }
628    }
629
630    fn set_minimum_size(&self, width: u32, height: u32) {
631        unsafe {
632            ffi::clutter_stage_set_minimum_size(self.as_ref().to_glib_none().0, width, height);
633        }
634    }
635
636    fn set_motion_events_enabled(&self, enabled: bool) {
637        unsafe {
638            ffi::clutter_stage_set_motion_events_enabled(
639                self.as_ref().to_glib_none().0,
640                enabled.to_glib(),
641            );
642        }
643    }
644
645    fn set_no_clear_hint(&self, no_clear: bool) {
646        unsafe {
647            ffi::clutter_stage_set_no_clear_hint(
648                self.as_ref().to_glib_none().0,
649                no_clear.to_glib(),
650            );
651        }
652    }
653
654    fn set_perspective(&self, perspective: &mut Perspective) {
655        unsafe {
656            ffi::clutter_stage_set_perspective(
657                self.as_ref().to_glib_none().0,
658                perspective.to_glib_none_mut().0,
659            );
660        }
661    }
662
663    fn set_throttle_motion_events(&self, throttle: bool) {
664        unsafe {
665            ffi::clutter_stage_set_throttle_motion_events(
666                self.as_ref().to_glib_none().0,
667                throttle.to_glib(),
668            );
669        }
670    }
671
672    fn set_title(&self, title: &str) {
673        unsafe {
674            ffi::clutter_stage_set_title(self.as_ref().to_glib_none().0, title.to_glib_none().0);
675        }
676    }
677
678    fn set_use_alpha(&self, use_alpha: bool) {
679        unsafe {
680            ffi::clutter_stage_set_use_alpha(self.as_ref().to_glib_none().0, use_alpha.to_glib());
681        }
682    }
683
684    fn set_user_resizable(&self, resizable: bool) {
685        unsafe {
686            ffi::clutter_stage_set_user_resizable(
687                self.as_ref().to_glib_none().0,
688                resizable.to_glib(),
689            );
690        }
691    }
692
693    fn show_cursor(&self) {
694        unsafe {
695            ffi::clutter_stage_show_cursor(self.as_ref().to_glib_none().0);
696        }
697    }
698
699    fn get_property_cursor_visible(&self) -> bool {
700        unsafe {
701            let mut value = Value::from_type(<bool as StaticType>::static_type());
702            gobject_sys::g_object_get_property(
703                self.to_glib_none().0 as *mut gobject_sys::GObject,
704                b"cursor-visible\0".as_ptr() as *const _,
705                value.to_glib_none_mut().0,
706            );
707            value
708                .get()
709                .expect("Return Value for property `cursor-visible` getter")
710                .unwrap()
711        }
712    }
713
714    fn set_property_cursor_visible(&self, cursor_visible: bool) {
715        unsafe {
716            gobject_sys::g_object_set_property(
717                self.to_glib_none().0 as *mut gobject_sys::GObject,
718                b"cursor-visible\0".as_ptr() as *const _,
719                Value::from(&cursor_visible).to_glib_none().0,
720            );
721        }
722    }
723
724    fn get_property_fullscreen_set(&self) -> bool {
725        unsafe {
726            let mut value = Value::from_type(<bool as StaticType>::static_type());
727            gobject_sys::g_object_get_property(
728                self.to_glib_none().0 as *mut gobject_sys::GObject,
729                b"fullscreen-set\0".as_ptr() as *const _,
730                value.to_glib_none_mut().0,
731            );
732            value
733                .get()
734                .expect("Return Value for property `fullscreen-set` getter")
735                .unwrap()
736        }
737    }
738
739    fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
740        unsafe extern "C" fn activate_trampoline<P, F: Fn(&P) + 'static>(
741            this: *mut ffi::ClutterStage,
742            f: glib_sys::gpointer,
743        ) where
744            P: IsA<Stage>,
745        {
746            let f: &F = &*(f as *const F);
747            f(&Stage::from_glib_borrow(this).unsafe_cast_ref())
748        }
749        unsafe {
750            let f: Box_<F> = Box_::new(f);
751            connect_raw(
752                self.as_ptr() as *mut _,
753                b"activate\0".as_ptr() as *const _,
754                Some(transmute::<_, unsafe extern "C" fn()>(
755                    activate_trampoline::<Self, F> as *const (),
756                )),
757                Box_::into_raw(f),
758            )
759        }
760    }
761
762    fn connect_after_paint<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
763        unsafe extern "C" fn after_paint_trampoline<P, F: Fn(&P) + 'static>(
764            this: *mut ffi::ClutterStage,
765            f: glib_sys::gpointer,
766        ) where
767            P: IsA<Stage>,
768        {
769            let f: &F = &*(f as *const F);
770            f(&Stage::from_glib_borrow(this).unsafe_cast_ref())
771        }
772        unsafe {
773            let f: Box_<F> = Box_::new(f);
774            connect_raw(
775                self.as_ptr() as *mut _,
776                b"after-paint\0".as_ptr() as *const _,
777                Some(transmute::<_, unsafe extern "C" fn()>(
778                    after_paint_trampoline::<Self, F> as *const (),
779                )),
780                Box_::into_raw(f),
781            )
782        }
783    }
784
785    fn connect_deactivate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
786        unsafe extern "C" fn deactivate_trampoline<P, F: Fn(&P) + 'static>(
787            this: *mut ffi::ClutterStage,
788            f: glib_sys::gpointer,
789        ) where
790            P: IsA<Stage>,
791        {
792            let f: &F = &*(f as *const F);
793            f(&Stage::from_glib_borrow(this).unsafe_cast_ref())
794        }
795        unsafe {
796            let f: Box_<F> = Box_::new(f);
797            connect_raw(
798                self.as_ptr() as *mut _,
799                b"deactivate\0".as_ptr() as *const _,
800                Some(transmute::<_, unsafe extern "C" fn()>(
801                    deactivate_trampoline::<Self, F> as *const (),
802                )),
803                Box_::into_raw(f),
804            )
805        }
806    }
807
808    fn connect_delete_event<F: Fn(&Self, &Event) -> bool + 'static>(
809        &self,
810        f: F,
811    ) -> SignalHandlerId {
812        unsafe extern "C" fn delete_event_trampoline<P, F: Fn(&P, &Event) -> bool + 'static>(
813            this: *mut ffi::ClutterStage,
814            event: *mut ffi::ClutterEvent,
815            f: glib_sys::gpointer,
816        ) -> glib_sys::gboolean
817        where
818            P: IsA<Stage>,
819        {
820            let f: &F = &*(f as *const F);
821            f(
822                &Stage::from_glib_borrow(this).unsafe_cast_ref(),
823                &from_glib_none(event),
824            )
825            .to_glib()
826        }
827        unsafe {
828            let f: Box_<F> = Box_::new(f);
829            connect_raw(
830                self.as_ptr() as *mut _,
831                b"delete-event\0".as_ptr() as *const _,
832                Some(transmute::<_, unsafe extern "C" fn()>(
833                    delete_event_trampoline::<Self, F> as *const (),
834                )),
835                Box_::into_raw(f),
836            )
837        }
838    }
839
840    fn connect_fullscreen<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
841        unsafe extern "C" fn fullscreen_trampoline<P, F: Fn(&P) + 'static>(
842            this: *mut ffi::ClutterStage,
843            f: glib_sys::gpointer,
844        ) where
845            P: IsA<Stage>,
846        {
847            let f: &F = &*(f as *const F);
848            f(&Stage::from_glib_borrow(this).unsafe_cast_ref())
849        }
850        unsafe {
851            let f: Box_<F> = Box_::new(f);
852            connect_raw(
853                self.as_ptr() as *mut _,
854                b"fullscreen\0".as_ptr() as *const _,
855                Some(transmute::<_, unsafe extern "C" fn()>(
856                    fullscreen_trampoline::<Self, F> as *const (),
857                )),
858                Box_::into_raw(f),
859            )
860        }
861    }
862
863    fn connect_unfullscreen<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
864        unsafe extern "C" fn unfullscreen_trampoline<P, F: Fn(&P) + 'static>(
865            this: *mut ffi::ClutterStage,
866            f: glib_sys::gpointer,
867        ) where
868            P: IsA<Stage>,
869        {
870            let f: &F = &*(f as *const F);
871            f(&Stage::from_glib_borrow(this).unsafe_cast_ref())
872        }
873        unsafe {
874            let f: Box_<F> = Box_::new(f);
875            connect_raw(
876                self.as_ptr() as *mut _,
877                b"unfullscreen\0".as_ptr() as *const _,
878                Some(transmute::<_, unsafe extern "C" fn()>(
879                    unfullscreen_trampoline::<Self, F> as *const (),
880                )),
881                Box_::into_raw(f),
882            )
883        }
884    }
885
886    fn connect_property_accept_focus_notify<F: Fn(&Self) + 'static>(
887        &self,
888        f: F,
889    ) -> SignalHandlerId {
890        unsafe extern "C" fn notify_accept_focus_trampoline<P, F: Fn(&P) + 'static>(
891            this: *mut ffi::ClutterStage,
892            _param_spec: glib_sys::gpointer,
893            f: glib_sys::gpointer,
894        ) where
895            P: IsA<Stage>,
896        {
897            let f: &F = &*(f as *const F);
898            f(&Stage::from_glib_borrow(this).unsafe_cast_ref())
899        }
900        unsafe {
901            let f: Box_<F> = Box_::new(f);
902            connect_raw(
903                self.as_ptr() as *mut _,
904                b"notify::accept-focus\0".as_ptr() as *const _,
905                Some(transmute::<_, unsafe extern "C" fn()>(
906                    notify_accept_focus_trampoline::<Self, F> as *const (),
907                )),
908                Box_::into_raw(f),
909            )
910        }
911    }
912
913    fn connect_property_cursor_visible_notify<F: Fn(&Self) + 'static>(
914        &self,
915        f: F,
916    ) -> SignalHandlerId {
917        unsafe extern "C" fn notify_cursor_visible_trampoline<P, F: Fn(&P) + 'static>(
918            this: *mut ffi::ClutterStage,
919            _param_spec: glib_sys::gpointer,
920            f: glib_sys::gpointer,
921        ) where
922            P: IsA<Stage>,
923        {
924            let f: &F = &*(f as *const F);
925            f(&Stage::from_glib_borrow(this).unsafe_cast_ref())
926        }
927        unsafe {
928            let f: Box_<F> = Box_::new(f);
929            connect_raw(
930                self.as_ptr() as *mut _,
931                b"notify::cursor-visible\0".as_ptr() as *const _,
932                Some(transmute::<_, unsafe extern "C" fn()>(
933                    notify_cursor_visible_trampoline::<Self, F> as *const (),
934                )),
935                Box_::into_raw(f),
936            )
937        }
938    }
939
940    fn connect_property_fullscreen_set_notify<F: Fn(&Self) + 'static>(
941        &self,
942        f: F,
943    ) -> SignalHandlerId {
944        unsafe extern "C" fn notify_fullscreen_set_trampoline<P, F: Fn(&P) + 'static>(
945            this: *mut ffi::ClutterStage,
946            _param_spec: glib_sys::gpointer,
947            f: glib_sys::gpointer,
948        ) where
949            P: IsA<Stage>,
950        {
951            let f: &F = &*(f as *const F);
952            f(&Stage::from_glib_borrow(this).unsafe_cast_ref())
953        }
954        unsafe {
955            let f: Box_<F> = Box_::new(f);
956            connect_raw(
957                self.as_ptr() as *mut _,
958                b"notify::fullscreen-set\0".as_ptr() as *const _,
959                Some(transmute::<_, unsafe extern "C" fn()>(
960                    notify_fullscreen_set_trampoline::<Self, F> as *const (),
961                )),
962                Box_::into_raw(f),
963            )
964        }
965    }
966
967    fn connect_property_key_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
968        unsafe extern "C" fn notify_key_focus_trampoline<P, F: Fn(&P) + 'static>(
969            this: *mut ffi::ClutterStage,
970            _param_spec: glib_sys::gpointer,
971            f: glib_sys::gpointer,
972        ) where
973            P: IsA<Stage>,
974        {
975            let f: &F = &*(f as *const F);
976            f(&Stage::from_glib_borrow(this).unsafe_cast_ref())
977        }
978        unsafe {
979            let f: Box_<F> = Box_::new(f);
980            connect_raw(
981                self.as_ptr() as *mut _,
982                b"notify::key-focus\0".as_ptr() as *const _,
983                Some(transmute::<_, unsafe extern "C" fn()>(
984                    notify_key_focus_trampoline::<Self, F> as *const (),
985                )),
986                Box_::into_raw(f),
987            )
988        }
989    }
990
991    fn connect_property_no_clear_hint_notify<F: Fn(&Self) + 'static>(
992        &self,
993        f: F,
994    ) -> SignalHandlerId {
995        unsafe extern "C" fn notify_no_clear_hint_trampoline<P, F: Fn(&P) + 'static>(
996            this: *mut ffi::ClutterStage,
997            _param_spec: glib_sys::gpointer,
998            f: glib_sys::gpointer,
999        ) where
1000            P: IsA<Stage>,
1001        {
1002            let f: &F = &*(f as *const F);
1003            f(&Stage::from_glib_borrow(this).unsafe_cast_ref())
1004        }
1005        unsafe {
1006            let f: Box_<F> = Box_::new(f);
1007            connect_raw(
1008                self.as_ptr() as *mut _,
1009                b"notify::no-clear-hint\0".as_ptr() as *const _,
1010                Some(transmute::<_, unsafe extern "C" fn()>(
1011                    notify_no_clear_hint_trampoline::<Self, F> as *const (),
1012                )),
1013                Box_::into_raw(f),
1014            )
1015        }
1016    }
1017
1018    fn connect_property_perspective_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1019        unsafe extern "C" fn notify_perspective_trampoline<P, F: Fn(&P) + 'static>(
1020            this: *mut ffi::ClutterStage,
1021            _param_spec: glib_sys::gpointer,
1022            f: glib_sys::gpointer,
1023        ) where
1024            P: IsA<Stage>,
1025        {
1026            let f: &F = &*(f as *const F);
1027            f(&Stage::from_glib_borrow(this).unsafe_cast_ref())
1028        }
1029        unsafe {
1030            let f: Box_<F> = Box_::new(f);
1031            connect_raw(
1032                self.as_ptr() as *mut _,
1033                b"notify::perspective\0".as_ptr() as *const _,
1034                Some(transmute::<_, unsafe extern "C" fn()>(
1035                    notify_perspective_trampoline::<Self, F> as *const (),
1036                )),
1037                Box_::into_raw(f),
1038            )
1039        }
1040    }
1041
1042    fn connect_property_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1043        unsafe extern "C" fn notify_title_trampoline<P, F: Fn(&P) + 'static>(
1044            this: *mut ffi::ClutterStage,
1045            _param_spec: glib_sys::gpointer,
1046            f: glib_sys::gpointer,
1047        ) where
1048            P: IsA<Stage>,
1049        {
1050            let f: &F = &*(f as *const F);
1051            f(&Stage::from_glib_borrow(this).unsafe_cast_ref())
1052        }
1053        unsafe {
1054            let f: Box_<F> = Box_::new(f);
1055            connect_raw(
1056                self.as_ptr() as *mut _,
1057                b"notify::title\0".as_ptr() as *const _,
1058                Some(transmute::<_, unsafe extern "C" fn()>(
1059                    notify_title_trampoline::<Self, F> as *const (),
1060                )),
1061                Box_::into_raw(f),
1062            )
1063        }
1064    }
1065
1066    fn connect_property_use_alpha_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1067        unsafe extern "C" fn notify_use_alpha_trampoline<P, F: Fn(&P) + 'static>(
1068            this: *mut ffi::ClutterStage,
1069            _param_spec: glib_sys::gpointer,
1070            f: glib_sys::gpointer,
1071        ) where
1072            P: IsA<Stage>,
1073        {
1074            let f: &F = &*(f as *const F);
1075            f(&Stage::from_glib_borrow(this).unsafe_cast_ref())
1076        }
1077        unsafe {
1078            let f: Box_<F> = Box_::new(f);
1079            connect_raw(
1080                self.as_ptr() as *mut _,
1081                b"notify::use-alpha\0".as_ptr() as *const _,
1082                Some(transmute::<_, unsafe extern "C" fn()>(
1083                    notify_use_alpha_trampoline::<Self, F> as *const (),
1084                )),
1085                Box_::into_raw(f),
1086            )
1087        }
1088    }
1089
1090    fn connect_property_user_resizable_notify<F: Fn(&Self) + 'static>(
1091        &self,
1092        f: F,
1093    ) -> SignalHandlerId {
1094        unsafe extern "C" fn notify_user_resizable_trampoline<P, F: Fn(&P) + 'static>(
1095            this: *mut ffi::ClutterStage,
1096            _param_spec: glib_sys::gpointer,
1097            f: glib_sys::gpointer,
1098        ) where
1099            P: IsA<Stage>,
1100        {
1101            let f: &F = &*(f as *const F);
1102            f(&Stage::from_glib_borrow(this).unsafe_cast_ref())
1103        }
1104        unsafe {
1105            let f: Box_<F> = Box_::new(f);
1106            connect_raw(
1107                self.as_ptr() as *mut _,
1108                b"notify::user-resizable\0".as_ptr() as *const _,
1109                Some(transmute::<_, unsafe extern "C" fn()>(
1110                    notify_user_resizable_trampoline::<Self, F> as *const (),
1111                )),
1112                Box_::into_raw(f),
1113            )
1114        }
1115    }
1116}
1117
1118impl fmt::Display for Stage {
1119    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1120        write!(f, "Stage")
1121    }
1122}