glib/gobject/flags.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::{gobject_ffi, translate::*};
4
5bitflags::bitflags! {
6 /// Through the [`ParamFlags`][crate::ParamFlags] flag values, certain aspects of parameters
7 /// can be configured.
8 ///
9 /// See also: `G_PARAM_STATIC_STRINGS`
10 // rustdoc-stripper-ignore-next-stop
11 /// Through the [`ParamFlags`][crate::ParamFlags] flag values, certain aspects of parameters
12 /// can be configured.
13 ///
14 /// See also: `G_PARAM_STATIC_STRINGS`
15 #[doc(alias = "GParamFlags")]
16 #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
17 pub struct ParamFlags: u32 {
18 /// the parameter is readable
19 // rustdoc-stripper-ignore-next-stop
20 /// the parameter is readable
21 #[doc(alias = "G_PARAM_READABLE")]
22 const READABLE = gobject_ffi::G_PARAM_READABLE as _;
23 /// the parameter is writable
24 // rustdoc-stripper-ignore-next-stop
25 /// the parameter is writable
26 #[doc(alias = "G_PARAM_WRITABLE")]
27 const WRITABLE = gobject_ffi::G_PARAM_WRITABLE as _;
28 /// alias for [`READABLE`][Self::READABLE] | [`WRITABLE`][Self::WRITABLE]
29 // rustdoc-stripper-ignore-next-stop
30 /// alias for [`READABLE`][Self::READABLE] | [`WRITABLE`][Self::WRITABLE]
31 #[doc(alias = "G_PARAM_READWRITE")]
32 const READWRITE = gobject_ffi::G_PARAM_READWRITE as _;
33 /// the parameter will be set upon object construction.
34 /// See [vfunc`Object`] for more details
35 // rustdoc-stripper-ignore-next-stop
36 /// the parameter will be set upon object construction.
37 /// See [vfunc`Object`] for more details
38 #[doc(alias = "G_PARAM_CONSTRUCT")]
39 const CONSTRUCT = gobject_ffi::G_PARAM_CONSTRUCT as _;
40 /// the parameter can only be set upon object construction.
41 /// See [vfunc`Object`] for more details
42 // rustdoc-stripper-ignore-next-stop
43 /// the parameter can only be set upon object construction.
44 /// See [vfunc`Object`] for more details
45 #[doc(alias = "G_PARAM_CONSTRUCT_ONLY")]
46 const CONSTRUCT_ONLY = gobject_ffi::G_PARAM_CONSTRUCT_ONLY as _;
47 /// upon parameter conversion (see `g_param_value_convert()`)
48 /// strict validation is not required
49 // rustdoc-stripper-ignore-next-stop
50 /// upon parameter conversion (see `g_param_value_convert()`)
51 /// strict validation is not required
52 #[doc(alias = "G_PARAM_LAX_VALIDATION")]
53 const LAX_VALIDATION = gobject_ffi::G_PARAM_LAX_VALIDATION as _;
54 const USER_0 = 256;
55 const USER_1 = 512;
56 const USER_2 = 1024;
57 const USER_3 = 2048;
58 const USER_4 = 4096;
59 const USER_5 = 8192;
60 const USER_6 = 16384;
61 const USER_7 = 32768;
62 const USER_8 = 65536;
63 /// calls to [`ObjectExt::set_property()`][crate::prelude::ObjectExt::set_property()] for this
64 /// property will not automatically result in a "notify" signal being
65 /// emitted: the implementation must call [`ObjectExt::notify()`][crate::prelude::ObjectExt::notify()] themselves
66 /// in case the property actually changes. Since: 2.42.
67 // rustdoc-stripper-ignore-next-stop
68 /// calls to [`ObjectExt::set_property()`][crate::prelude::ObjectExt::set_property()] for this
69 /// property will not automatically result in a "notify" signal being
70 /// emitted: the implementation must call [`ObjectExt::notify()`][crate::prelude::ObjectExt::notify()] themselves
71 /// in case the property actually changes. Since: 2.42.
72 #[doc(alias = "G_PARAM_EXPLICIT_NOTIFY")]
73 const EXPLICIT_NOTIFY = gobject_ffi::G_PARAM_EXPLICIT_NOTIFY as _;
74 /// the parameter is deprecated and will be removed
75 /// in a future version. A warning will be generated if it is used
76 /// while running with G_ENABLE_DIAGNOSTIC=1.
77 /// Since 2.26
78 // rustdoc-stripper-ignore-next-stop
79 /// the parameter is deprecated and will be removed
80 /// in a future version. A warning will be generated if it is used
81 /// while running with G_ENABLE_DIAGNOSTIC=1.
82 /// Since 2.26
83 #[doc(alias = "G_PARAM_DEPRECATED")]
84 const DEPRECATED = gobject_ffi::G_PARAM_DEPRECATED as _;
85 }
86}
87
88impl Default for ParamFlags {
89 fn default() -> Self {
90 ParamFlags::READWRITE
91 }
92}
93
94#[doc(hidden)]
95impl IntoGlib for ParamFlags {
96 type GlibType = gobject_ffi::GParamFlags;
97
98 #[inline]
99 fn into_glib(self) -> gobject_ffi::GParamFlags {
100 self.bits()
101 }
102}
103
104#[doc(hidden)]
105impl FromGlib<gobject_ffi::GParamFlags> for ParamFlags {
106 #[inline]
107 unsafe fn from_glib(value: gobject_ffi::GParamFlags) -> Self {
108 Self::from_bits_truncate(value)
109 }
110}