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
119
120
121
122
123
124
125
126
127
128
129
130
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from webkit-gir-files
// DO NOT EDIT

use crate::{ffi, NavigationType, 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 {
    /// Gets the @self target frame name. For example if navigation was triggered by clicking a
    /// link with a target attribute equal to "_blank", this will return the value of that attribute.
    /// In all other cases this function will return [`None`].
    ///
    /// # Returns
    ///
    /// The name of the new frame this navigation action targets or [`None`]
    #[doc(alias = "webkit_navigation_action_get_frame_name")]
    #[doc(alias = "get_frame_name")]
    pub fn frame_name(&mut self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::webkit_navigation_action_get_frame_name(
                self.to_glib_none_mut().0,
            ))
        }
    }

    /// 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(&mut self) -> u32 {
        unsafe { ffi::webkit_navigation_action_get_modifiers(self.to_glib_none_mut().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(&mut self) -> u32 {
        unsafe { ffi::webkit_navigation_action_get_mouse_button(self.to_glib_none_mut().0) }
    }

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

    /// Return the #WebKitURIRequest 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 #WebKitURIRequest
    #[doc(alias = "webkit_navigation_action_get_request")]
    #[doc(alias = "get_request")]
    pub fn request(&mut self) -> Option<URIRequest> {
        unsafe {
            from_glib_none(ffi::webkit_navigation_action_get_request(
                self.to_glib_none_mut().0,
            ))
        }
    }

    /// Returns whether the @self was redirected.
    ///
    /// # Returns
    ///
    /// [`true`] if the original navigation was redirected, [`false`] otherwise.
    #[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(&mut self) -> bool {
        unsafe {
            from_glib(ffi::webkit_navigation_action_is_user_gesture(
                self.to_glib_none_mut().0,
            ))
        }
    }
}