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
// This file was generated by gir (9e3f4cc) from gir-files (71d73f0)
// DO NOT EDIT

#[cfg(feature = "v3_14")]
use PropagationPhase;
#[cfg(feature = "v3_14")]
use Widget;
use ffi;
#[cfg(feature = "v3_14")]
use gdk;
use glib::object::IsA;
use glib::translate::*;

glib_wrapper! {
    pub struct EventController(Object<ffi::GtkEventController>);

    match fn {
        get_type => || ffi::gtk_event_controller_get_type(),
    }
}

pub trait EventControllerExt {
    #[cfg(feature = "v3_14")]
    fn get_propagation_phase(&self) -> PropagationPhase;

    #[cfg(feature = "v3_14")]
    fn get_widget(&self) -> Option<Widget>;

    #[cfg(feature = "v3_14")]
    fn handle_event(&self, event: &gdk::Event) -> bool;

    #[cfg(feature = "v3_14")]
    fn reset(&self);

    #[cfg(feature = "v3_14")]
    fn set_propagation_phase(&self, phase: PropagationPhase);
}

impl<O: IsA<EventController>> EventControllerExt for O {
    #[cfg(feature = "v3_14")]
    fn get_propagation_phase(&self) -> PropagationPhase {
        unsafe {
            from_glib(ffi::gtk_event_controller_get_propagation_phase(self.to_glib_none().0))
        }
    }

    #[cfg(feature = "v3_14")]
    fn get_widget(&self) -> Option<Widget> {
        unsafe {
            from_glib_none(ffi::gtk_event_controller_get_widget(self.to_glib_none().0))
        }
    }

    #[cfg(feature = "v3_14")]
    fn handle_event(&self, event: &gdk::Event) -> bool {
        unsafe {
            from_glib(ffi::gtk_event_controller_handle_event(self.to_glib_none().0, event.to_glib_none().0))
        }
    }

    #[cfg(feature = "v3_14")]
    fn reset(&self) {
        unsafe {
            ffi::gtk_event_controller_reset(self.to_glib_none().0);
        }
    }

    #[cfg(feature = "v3_14")]
    fn set_propagation_phase(&self, phase: PropagationPhase) {
        unsafe {
            ffi::gtk_event_controller_set_propagation_phase(self.to_glib_none().0, phase.to_glib());
        }
    }
}