@@ -525,6 +525,10 @@ pub fn closure_local(item: TokenStream) -> TokenStream {
525
525
/// }
526
526
/// ```
527
527
///
528
+ /// When using the [`Properties`] macro with enums that derive [`Enum`], the default value must be
529
+ /// explicitly set via the `builder` parameter of the `#[property]` attribute. See
530
+ /// [here](Properties#supported-types) for details.
531
+ ///
528
532
/// An enum can be registered as a dynamic type by setting the derive macro
529
533
/// helper attribute `enum_dynamic`:
530
534
///
@@ -1366,6 +1370,9 @@ pub fn cstr_bytes(item: TokenStream) -> TokenStream {
1366
1370
/// Optional types also require the `nullable` attribute: without it, the generated setter on the wrapper type
1367
1371
/// will take `T` instead of `Option<T>`, preventing the user from ever calling the setter with a `None` value.
1368
1372
///
1373
+ /// Notice: For enums that derive [`Enum`] or are C-style enums, you must explicitly specify the
1374
+ /// default value of the enum using the `builder` parameter in the `#[property]` attribute.
1375
+ ///
1369
1376
/// ## Adding support for custom types
1370
1377
/// ### Types wrapping an existing <code>T: [ToValue] + [HasParamSpec]</code>
1371
1378
/// If you have declared a newtype as
@@ -1390,7 +1397,7 @@ pub fn cstr_bytes(item: TokenStream) -> TokenStream {
1390
1397
///
1391
1398
/// # Example
1392
1399
/// ```
1393
- /// use std::cell::RefCell;
1400
+ /// use std::cell::{Cell, RefCell} ;
1394
1401
/// use glib::prelude::*;
1395
1402
/// use glib::subclass::prelude::*;
1396
1403
/// use glib_macros::Properties;
@@ -1401,6 +1408,14 @@ pub fn cstr_bytes(item: TokenStream) -> TokenStream {
1401
1408
/// nick: String,
1402
1409
/// }
1403
1410
///
1411
+ /// #[derive(Debug, Copy, Clone, PartialEq, Eq, glib::Enum, Default)]
1412
+ /// #[enum_type(name = "MyEnum")]
1413
+ /// enum MyEnum {
1414
+ /// #[default]
1415
+ /// Val,
1416
+ /// OtherVal
1417
+ /// }
1418
+ ///
1404
1419
/// pub mod imp {
1405
1420
/// use std::rc::Rc;
1406
1421
///
@@ -1426,6 +1441,8 @@ pub fn cstr_bytes(item: TokenStream) -> TokenStream {
1426
1441
/// optional: RefCell<Option<String>>,
1427
1442
/// #[property(get, set)]
1428
1443
/// smart_pointer: Rc<RefCell<String>>,
1444
+ /// #[property(get, set, builder(MyEnum::Val))]
1445
+ /// my_enum: Cell<MyEnum>,
1429
1446
/// /// # Getter
1430
1447
/// ///
1431
1448
/// /// Get the value of the property `extra_comments`
0 commit comments