webkit6/auto/feature.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from webkit-gir-files
4// DO NOT EDIT
5
6use crate::{FeatureStatus, ffi};
7use glib::translate::*;
8
9glib::wrapper! {
10 /// Describes a web engine feature that may be toggled at runtime.
11 ///
12 /// The WebKit web engine includes a set of features which may be toggled
13 /// programmatically, each one represented by a [`Feature`][crate::Feature] that provides
14 /// information about it:
15 ///
16 /// - A unique “identifier”: [method`Feature`].
17 /// - A “default value”, which indicates whether the option is enabled
18 /// automatically: [method`Feature`].
19 /// - Its “status”, which determines whether it should be considered
20 /// user-settable and its development stage (see [enum`FeatureStatus`]
21 /// for details): [method`Feature`].
22 /// - A category, which may be used to group features together:
23 /// [method`Feature`].
24 /// - An optional short “name” which can be presented to an user:
25 /// [method`Feature`].
26 /// - An optional longer “detailed” description:
27 /// [method`Feature`].
28 ///
29 /// The lists of available features can be obtained with
30 /// [func`Settings`], [func`Settings`],
31 /// and [func`Settings`]). As a rule of thumb,
32 /// applications which may want to allow users (i.e. web developers) to test
33 /// WebKit features should use the list of experimental features. Additionally,
34 /// applications might want to expose development features *when targeting
35 /// technically inclined users* for early testing of in-development features
36 /// (i.e. in “technology preview” or “canary” builds).
37 ///
38 /// Applications **must not** expose the list of all features to end users
39 /// because they often lack descriptions and control parts of the web engine
40 /// which are either intended to be used during development of WebKit itself,
41 /// or in specific scenarios to tweak how WebKit integrates with the
42 /// application.
43 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
44 pub struct Feature(Shared<ffi::WebKitFeature>);
45
46 match fn {
47 ref => |ptr| ffi::webkit_feature_ref(ptr),
48 unref => |ptr| ffi::webkit_feature_unref(ptr),
49 type_ => || ffi::webkit_feature_get_type(),
50 }
51}
52
53impl Feature {
54 /// Gets the category of the feature.
55 ///
56 /// Applications which include user interface to toggle features may want
57 /// to use the category to group related features together.
58 ///
59 /// # Returns
60 ///
61 /// Feature category.
62 #[doc(alias = "webkit_feature_get_category")]
63 #[doc(alias = "get_category")]
64 pub fn category(&self) -> Option<glib::GString> {
65 unsafe { from_glib_none(ffi::webkit_feature_get_category(self.to_glib_none().0)) }
66 }
67
68 /// Gets whether the feature is enabled by default.
69 ///
70 /// The default value may be used by applications which include user interface
71 /// to toggle features to restore its settings to their defaults. Note that
72 /// whether a feature is actually enabled must be checked with
73 /// [method`Settings`].
74 ///
75 /// # Returns
76 ///
77 /// Whether the feature is enabled by default.
78 #[doc(alias = "webkit_feature_get_default_value")]
79 #[doc(alias = "get_default_value")]
80 pub fn is_default_value(&self) -> bool {
81 unsafe { from_glib(ffi::webkit_feature_get_default_value(self.to_glib_none().0)) }
82 }
83
84 /// Gets a description for the `self`.
85 ///
86 /// The detailed description should be considered an additional clarification
87 /// on the purpose of the feature, to be used as complementary aid to be
88 /// displayed along the feature name returned by [method`Feature`].
89 /// The returned string is suitable to be displayed to end users, but it
90 /// should not be relied upon being localized.
91 ///
92 /// Note that some *features may not* have a detailed description, and [`None`]
93 /// is returned in this case.
94 ///
95 /// # Returns
96 ///
97 /// Feature description.
98 #[doc(alias = "webkit_feature_get_details")]
99 #[doc(alias = "get_details")]
100 pub fn details(&self) -> Option<glib::GString> {
101 unsafe { from_glib_none(ffi::webkit_feature_get_details(self.to_glib_none().0)) }
102 }
103
104 /// Gets a string that uniquely identifies the `self`.
105 ///
106 /// # Returns
107 ///
108 /// The identifier string for the feature.
109 #[doc(alias = "webkit_feature_get_identifier")]
110 #[doc(alias = "get_identifier")]
111 pub fn identifier(&self) -> Option<glib::GString> {
112 unsafe { from_glib_none(ffi::webkit_feature_get_identifier(self.to_glib_none().0)) }
113 }
114
115 /// Gets a short name for the `self`.
116 ///
117 /// The returned string is suitable to be displayed to end users, but it
118 /// should not be relied upon being localized.
119 ///
120 /// Note that some *features may not* have a short name, and [`None`]
121 /// is returned in this case.
122 ///
123 /// # Returns
124 ///
125 /// Short feature name.
126 #[doc(alias = "webkit_feature_get_name")]
127 #[doc(alias = "get_name")]
128 pub fn name(&self) -> Option<glib::GString> {
129 unsafe { from_glib_none(ffi::webkit_feature_get_name(self.to_glib_none().0)) }
130 }
131
132 /// Gets the status of the feature.
133 ///
134 /// # Returns
135 ///
136 /// Feature status.
137 #[doc(alias = "webkit_feature_get_status")]
138 #[doc(alias = "get_status")]
139 pub fn status(&self) -> FeatureStatus {
140 unsafe { from_glib(ffi::webkit_feature_get_status(self.to_glib_none().0)) }
141 }
142}