You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// | `set [= expr]` | Specify that the property is writable and use `PropertySet::set` [or optionally set a custom internal setter] | | `#[property(set)]`, `#[property(set = set_prop)]`, or `[property(set = \|_, val\| {})]` |
874
874
/// | `override_class = expr` | The type of class of which to override the property from | | `#[property(override_class = SomeClass)]` |
875
875
/// | `override_interface = expr` | The type of interface of which to override the property from | | `#[property(override_interface = SomeInterface)]` |
876
-
/// | `nullable` | Whether to use `Option<T>` in the wrapper's generated setter | | `#[property(nullable)]` |
876
+
/// | `nullable` | Whether to use `Option<T>` in the generated setter method | | `#[property(nullable)]` |
877
877
/// | `member = ident` | Field of the nested type where property is retrieved and set | | `#[property(member = author)]` |
878
878
/// | `construct_only` | Specify that the property is construct only. This will not generate a public setter and only allow the property to be set during object construction. The use of a custom internal setter is supported. | | `#[property(get, construct_only)]` or `#[property(get, set = set_prop, construct_only)]` |
879
879
/// | `builder(<required-params>)[.ident]*` | Used to input required params or add optional Param Spec builder fields | | `#[property(builder(SomeEnum::default()))]`, `#[builder().default_value(1).minimum(0).maximum(5)]`, etc. |
/// You might hit a roadblock when declaring properties with this macro because you want to use a name that happens to be a Rust keyword. This may happen with names like `loop`, which is a pretty common name when creating things like animation handlers.
886
886
/// To use those names, you can make use of the raw identifier feature of Rust. Simply prefix the identifier name with `r#` in the struct declaration. Internally, those `r#`s are stripped so you can use its expected name in [`ObjectExt::property`] or within GtkBuilder template files.
887
887
///
888
-
/// # Generated wrapper methods
888
+
/// # Generated methods
889
889
/// The following methods are generated on the wrapper type specified on `#[properties(wrapper_type = ...)]`:
890
890
/// * `$property()`, when the property is readable
891
891
/// * `set_$property()`, when the property is writable and not construct-only
892
892
/// * `connect_$property_notify()`
893
893
/// * `notify_$property()`
894
894
///
895
-
/// Notice: You can't reimplement the generated methods on the wrapper type,
896
-
/// but you can change their behavior using a custom internal getter/setter.
895
+
/// ## Extension trait
896
+
/// You can choose to move the method definitions to a trait by using `#[properties(wrapper_type = super::MyType, ext_trait = MyTypePropertiesExt)]`.
897
+
/// The trait name is optional, and defaults to `MyTypePropertiesExt`, where `MyType` is extracted from the wrapper type.
898
+
/// Note: The trait is defined in the same module where the `#[derive(Properties)]` call happens, and is implemented on the wrapper type.
899
+
///
900
+
/// Notice: You can't reimplement the generated methods on the wrapper type, unless you move them to a trait.
901
+
/// You can change the behavior of the generated getter/setter methods by using a custom internal getter/setter.
897
902
///
898
903
/// # Internal getters and setters
899
904
/// By default, they are generated for you. However, you can use a custom getter/setter
0 commit comments