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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// from webkit2gtk-gir-files
// DO NOT EDIT

use crate::NavigationType;
use crate::URIRequest;
use glib::translate::*;

glib::wrapper! {
    /// Provides details about interaction resulting in a resource load.
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct NavigationAction(Boxed<ffi::WebKitNavigationAction>);

    match fn {
        copy => |ptr| ffi::webkit_navigation_action_copy(mut_override(ptr)),
        free => |ptr| ffi::webkit_navigation_action_free(ptr),
        type_ => || ffi::webkit_navigation_action_get_type(),
    }
}

impl NavigationAction {
    /// Return the modifier keys.
    ///
    /// Return a bitmask of `GdkModifierType` values describing the modifier keys that were in effect
    /// when the navigation was requested
    ///
    /// # Returns
    ///
    /// the modifier keys
    #[doc(alias = "webkit_navigation_action_get_modifiers")]
    #[doc(alias = "get_modifiers")]
    pub fn modifiers(&self) -> u32 {
        unsafe { ffi::webkit_navigation_action_get_modifiers(mut_override(self.to_glib_none().0)) }
    }

    /// Return the number of the mouse button that triggered the navigation.
    ///
    /// Return the number of the mouse button that triggered the navigation, or 0 if
    /// the navigation was not started by a mouse event.
    ///
    /// # Returns
    ///
    /// the mouse button number or 0
    #[doc(alias = "webkit_navigation_action_get_mouse_button")]
    #[doc(alias = "get_mouse_button")]
    pub fn mouse_button(&self) -> u32 {
        unsafe {
            ffi::webkit_navigation_action_get_mouse_button(mut_override(self.to_glib_none().0))
        }
    }

    /// Return the type of action that triggered the navigation.
    ///
    /// # Returns
    ///
    /// a [`NavigationType`][crate::NavigationType]
    #[doc(alias = "webkit_navigation_action_get_navigation_type")]
    #[doc(alias = "get_navigation_type")]
    pub fn navigation_type(&self) -> NavigationType {
        unsafe {
            from_glib(ffi::webkit_navigation_action_get_navigation_type(
                mut_override(self.to_glib_none().0),
            ))
        }
    }

    /// Return the [`URIRequest`][crate::URIRequest] associated with the navigation action.
    ///
    /// Modifications to the returned object are `<emphasis>`not`</emphasis>` taken
    /// into account when the request is sent over the network, and is intended
    /// only to aid in evaluating whether a navigation action should be taken or
    /// not. To modify requests before they are sent over the network the
    /// `WebKitPage::send-request` signal can be used instead.
    ///
    /// # Returns
    ///
    /// a [`URIRequest`][crate::URIRequest]
    #[doc(alias = "webkit_navigation_action_get_request")]
    #[doc(alias = "get_request")]
    pub fn request(&self) -> Option<URIRequest> {
        unsafe {
            from_glib_none(ffi::webkit_navigation_action_get_request(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    /// Returns whether the `self` was redirected.
    ///
    /// # Returns
    ///
    /// [`true`] if the original navigation was redirected, [`false`] otherwise.
    #[cfg(any(feature = "v2_20", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_20")))]
    #[doc(alias = "webkit_navigation_action_is_redirect")]
    pub fn is_redirect(&mut self) -> bool {
        unsafe {
            from_glib(ffi::webkit_navigation_action_is_redirect(
                self.to_glib_none_mut().0,
            ))
        }
    }

    /// Return whether the navigation was triggered by a user gesture like a mouse click.
    ///
    /// # Returns
    ///
    /// whether navigation action is a user gesture
    #[doc(alias = "webkit_navigation_action_is_user_gesture")]
    pub fn is_user_gesture(&self) -> bool {
        unsafe {
            from_glib(ffi::webkit_navigation_action_is_user_gesture(mut_override(
                self.to_glib_none().0,
            )))
        }
    }
}