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 #[doc(alias = "GParamFlags")]
11 #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
12 pub struct ParamFlags: u32 {
13 /// the parameter is readable
14 #[doc(alias = "G_PARAM_READABLE")]
15 const READABLE = gobject_ffi::G_PARAM_READABLE as _;
16 /// the parameter is writable
17 #[doc(alias = "G_PARAM_WRITABLE")]
18 const WRITABLE = gobject_ffi::G_PARAM_WRITABLE as _;
19 /// alias for [`READABLE`][Self::READABLE] | [`WRITABLE`][Self::WRITABLE]
20 #[doc(alias = "G_PARAM_READWRITE")]
21 const READWRITE = gobject_ffi::G_PARAM_READWRITE as _;
22 /// the parameter will be set upon object construction.
23 /// See [vfunc`Object`] for more details
24 #[doc(alias = "G_PARAM_CONSTRUCT")]
25 const CONSTRUCT = gobject_ffi::G_PARAM_CONSTRUCT as _;
26 /// the parameter can only be set upon object construction.
27 /// See [vfunc`Object`] for more details
28 #[doc(alias = "G_PARAM_CONSTRUCT_ONLY")]
29 const CONSTRUCT_ONLY = gobject_ffi::G_PARAM_CONSTRUCT_ONLY as _;
30 /// upon parameter conversion (see `g_param_value_convert()`)
31 /// strict validation is not required
32 #[doc(alias = "G_PARAM_LAX_VALIDATION")]
33 const LAX_VALIDATION = gobject_ffi::G_PARAM_LAX_VALIDATION as _;
34 const USER_0 = 256;
35 const USER_1 = 512;
36 const USER_2 = 1024;
37 const USER_3 = 2048;
38 const USER_4 = 4096;
39 const USER_5 = 8192;
40 const USER_6 = 16384;
41 const USER_7 = 32768;
42 const USER_8 = 65536;
43 /// calls to [`ObjectExt::set_property()`][crate::prelude::ObjectExt::set_property()] for this
44 /// property will not automatically result in a "notify" signal being
45 /// emitted: the implementation must call [`ObjectExt::notify()`][crate::prelude::ObjectExt::notify()] themselves
46 /// in case the property actually changes. Since: 2.42.
47 #[doc(alias = "G_PARAM_EXPLICIT_NOTIFY")]
48 const EXPLICIT_NOTIFY = gobject_ffi::G_PARAM_EXPLICIT_NOTIFY as _;
49 /// the parameter is deprecated and will be removed
50 /// in a future version. A warning will be generated if it is used
51 /// while running with G_ENABLE_DIAGNOSTIC=1.
52 /// Since 2.26
53 #[doc(alias = "G_PARAM_DEPRECATED")]
54 const DEPRECATED = gobject_ffi::G_PARAM_DEPRECATED as _;
55 }
56}
57
58impl Default for ParamFlags {
59 fn default() -> Self {
60 ParamFlags::READWRITE
61 }
62}
63
64#[doc(hidden)]
65impl IntoGlib for ParamFlags {
66 type GlibType = gobject_ffi::GParamFlags;
67
68 #[inline]
69 fn into_glib(self) -> gobject_ffi::GParamFlags {
70 self.bits()
71 }
72}
73
74#[doc(hidden)]
75impl FromGlib<gobject_ffi::GParamFlags> for ParamFlags {
76 #[inline]
77 unsafe fn from_glib(value: gobject_ffi::GParamFlags) -> Self {
78 Self::from_bits_truncate(value)
79 }
80}