@@ -1366,6 +1366,9 @@ pub fn cstr_bytes(item: TokenStream) -> TokenStream {
1366
1366
/// Optional types also require the `nullable` attribute: without it, the generated setter on the wrapper type
1367
1367
/// will take `T` instead of `Option<T>`, preventing the user from ever calling the setter with a `None` value.
1368
1368
///
1369
+ /// Notice: For enums that derive [`Enum`] or are C-style enums, you must explicitly specify the
1370
+ /// default value of the enum using the `builder` parameter in the `#[property]` attribute.
1371
+ ///
1369
1372
/// ## Adding support for custom types
1370
1373
/// ### Types wrapping an existing <code>T: [ToValue] + [HasParamSpec]</code>
1371
1374
/// If you have declared a newtype as
@@ -1390,7 +1393,7 @@ pub fn cstr_bytes(item: TokenStream) -> TokenStream {
1390
1393
///
1391
1394
/// # Example
1392
1395
/// ```
1393
- /// use std::cell::RefCell;
1396
+ /// use std::cell::{Cell, RefCell} ;
1394
1397
/// use glib::prelude::*;
1395
1398
/// use glib::subclass::prelude::*;
1396
1399
/// use glib_macros::Properties;
@@ -1401,6 +1404,13 @@ pub fn cstr_bytes(item: TokenStream) -> TokenStream {
1401
1404
/// nick: String,
1402
1405
/// }
1403
1406
///
1407
+ /// #[derive(Debug, Copy, Clone, PartialEq, Eq, glib::Enum)]
1408
+ /// #[enum_type(name = "MyEnum")]
1409
+ /// enum MyEnum {
1410
+ /// Val,
1411
+ /// OtherVal
1412
+ /// }
1413
+ ///
1404
1414
/// pub mod imp {
1405
1415
/// use std::rc::Rc;
1406
1416
///
@@ -1426,6 +1436,8 @@ pub fn cstr_bytes(item: TokenStream) -> TokenStream {
1426
1436
/// optional: RefCell<Option<String>>,
1427
1437
/// #[property(get, set)]
1428
1438
/// smart_pointer: Rc<RefCell<String>>,
1439
+ /// #[property(get, set, builder(MyEnum::Val))]
1440
+ /// my_enum: Cell<MyEnum>,
1429
1441
/// /// # Getter
1430
1442
/// ///
1431
1443
/// /// Get the value of the property `extra_comments`
0 commit comments