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
131
132
133
134
135
136
137
138
139
140
141
142
// 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, FeatureStatus};
use glib::translate::*;

glib::wrapper! {
    /// Describes a web engine feature that may be toggled at runtime.
    ///
    /// The WebKit web engine includes a set of features which may be toggled
    /// programmatically, each one represented by a #WebKitFeature that provides
    /// information about it:
    ///
    /// - A unique “identifier”: [`identifier()`][Self::identifier()].
    /// - A “default value”, which indicates whether the option is enabled
    ///   automatically: [`is_default_value()`][Self::is_default_value()].
    /// - Its “status”, which determines whether it should be considered
    ///   user-settable and its development stage (see [`FeatureStatus`][crate::FeatureStatus]
    ///   for details): [`status()`][Self::status()].
    /// - A category, which may be used to group features together:
    ///   [`category()`][Self::category()].
    /// - An optional short “name” which can be presented to an user:
    ///   [`name()`][Self::name()].
    /// - An optional longer “detailed” description:
    ///   [`details()`][Self::details()].
    ///
    /// The lists of available features can be obtained with
    /// `get_all_features()`, `get_experimental_features()`,
    /// and `get_development_features()`). As a rule of thumb,
    /// applications which may want to allow users (i.e. web developers) to test
    /// WebKit features should use the list of experimental features. Additionally,
    /// applications might want to expose development features *when targeting
    /// technically inclined users* for early testing of in-development features
    /// (i.e. in “technology preview” or “canary” builds).
    ///
    /// Applications **must not** expose the list of all features to end users
    /// because they often lack descriptions and control parts of the web engine
    /// which are either intended to be used during development of WebKit itself,
    /// or in specific scenarios to tweak how WebKit integrates with the
    /// application.
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct Feature(Shared<ffi::WebKitFeature>);

    match fn {
        ref => |ptr| ffi::webkit_feature_ref(ptr),
        unref => |ptr| ffi::webkit_feature_unref(ptr),
        type_ => || ffi::webkit_feature_get_type(),
    }
}

impl Feature {
    /// Gets the category of the feature.
    ///
    /// Applications which include user interface to toggle features may want
    /// to use the category to group related features together.
    ///
    /// # Returns
    ///
    /// Feature category.
    #[doc(alias = "webkit_feature_get_category")]
    #[doc(alias = "get_category")]
    pub fn category(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::webkit_feature_get_category(self.to_glib_none().0)) }
    }

    /// Gets whether the feature is enabled by default.
    ///
    /// The default value may be used by applications which include user interface
    /// to toggle features to restore its settings to their defaults. Note that
    /// whether a feature is actually enabled must be checked with
    /// [`Settings::is_feature_enabled()`][crate::Settings::is_feature_enabled()].
    ///
    /// # Returns
    ///
    /// Whether the feature is enabled by default.
    #[doc(alias = "webkit_feature_get_default_value")]
    #[doc(alias = "get_default_value")]
    pub fn is_default_value(&self) -> bool {
        unsafe { from_glib(ffi::webkit_feature_get_default_value(self.to_glib_none().0)) }
    }

    /// Gets a description for the @self.
    ///
    /// The detailed description should be considered an additional clarification
    /// on the purpose of the feature, to be used as complementary aid to be
    /// displayed along the feature name returned by [`name()`][Self::name()].
    /// The returned string is suitable to be displayed to end users, but it
    /// should not be relied upon being localized.
    ///
    /// Note that some *features may not* have a detailed description, and @NULL
    /// is returned in this case.
    ///
    /// # Returns
    ///
    /// Feature description.
    #[doc(alias = "webkit_feature_get_details")]
    #[doc(alias = "get_details")]
    pub fn details(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::webkit_feature_get_details(self.to_glib_none().0)) }
    }

    /// Gets a string that uniquely identifies the @self.
    ///
    /// # Returns
    ///
    /// The identifier string for the feature.
    #[doc(alias = "webkit_feature_get_identifier")]
    #[doc(alias = "get_identifier")]
    pub fn identifier(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::webkit_feature_get_identifier(self.to_glib_none().0)) }
    }

    /// Gets a short name for the @self.
    ///
    /// The returned string is suitable to be displayed to end users, but it
    /// should not be relied upon being localized.
    ///
    /// Note that some *features may not* have a short name, and @NULL
    /// is returned in this case.
    ///
    /// # Returns
    ///
    /// Short feature name.
    #[doc(alias = "webkit_feature_get_name")]
    #[doc(alias = "get_name")]
    pub fn name(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::webkit_feature_get_name(self.to_glib_none().0)) }
    }

    /// Gets the status of the feature.
    ///
    /// # Returns
    ///
    /// Feature status.
    #[doc(alias = "webkit_feature_get_status")]
    #[doc(alias = "get_status")]
    pub fn status(&self) -> FeatureStatus {
        unsafe { from_glib(ffi::webkit_feature_get_status(self.to_glib_none().0)) }
    }
}