Attribute Macro glib_macros::gflags[][src]

#[gflags]
Expand description

Attribute macro for defining flags using the bitflags crate. This macro will also define a GFlags::type_ function and the glib::Value traits.

The expected GType name has to be passed as macro attribute. The name and nick of each flag can also be optionally defined. Default name is the flag identifier in CamelCase and default nick is the identifier in kebab-case. Combined flags should not be registered with the GType system and so needs to be tagged with the #[gflags(skip)] attribute.

Example

use glib::prelude::*;
use glib::subclass::prelude::*;

#[glib::gflags("MyFlags")]
enum MyFlags {
    #[gflags(name = "Flag A", nick = "nick-a")]
    A = 0b00000001,
    #[gflags(name = "Flag B")]
    B = 0b00000010,
    #[gflags(skip)]
    AB = Self::A.bits() | Self::B.bits(),
    C = 0b00000100,
}