File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,8 @@ mod foo {
99
99
bar : Mutex < String > ,
100
100
#[ property( get, set) ]
101
101
double : RefCell < f64 > ,
102
+ #[ property( get, set) ]
103
+ string_vec : RefCell < Vec < String > > ,
102
104
#[ property( get = |_| 42.0 , set) ]
103
105
infer_inline_type : RefCell < f64 > ,
104
106
// The following property doesn't store any data. The value of the property is calculated
@@ -197,14 +199,22 @@ mod foo {
197
199
fn props ( ) {
198
200
let myfoo: foo:: Foo = glib:: object:: Object :: new ( ) ;
199
201
200
- // Read bar
202
+ // Read values
201
203
let bar: String = myfoo. property ( "bar" ) ;
202
204
assert_eq ! ( bar, "" . to_string( ) ) ;
205
+ let string_vec: Vec < String > = myfoo. property ( "string-vec" ) ;
206
+ assert ! ( string_vec. is_empty( ) ) ;
203
207
204
- // Set bar
208
+ // Set values
205
209
myfoo. set_property ( "bar" , "epic" . to_value ( ) ) ;
206
210
let bar: String = myfoo. property ( "bar" ) ;
207
211
assert_eq ! ( bar, "epic" . to_string( ) ) ;
212
+ myfoo. set_property ( "string-vec" , [ "epic" , "more epic" ] . to_value ( ) ) ;
213
+ let string_vec: Vec < String > = myfoo. property ( "string-vec" ) ;
214
+ assert_eq ! (
215
+ string_vec,
216
+ vec![ "epic" . to_string( ) , "more epic" . to_string( ) ]
217
+ ) ;
208
218
209
219
// Custom getter
210
220
let buzz: String = myfoo. property ( "buzz" ) ;
Original file line number Diff line number Diff line change @@ -2115,6 +2115,24 @@ impl HasParamSpec for String {
2115
2115
Self :: ParamSpec :: builder
2116
2116
}
2117
2117
}
2118
+ impl HasParamSpec for crate :: StrV {
2119
+ type ParamSpec = ParamSpecBoxed ;
2120
+ type SetValue = Self ;
2121
+ type BuilderFn = fn ( & str ) -> ParamSpecBoxedBuilder < Self > ;
2122
+
2123
+ fn param_spec_builder ( ) -> Self :: BuilderFn {
2124
+ Self :: ParamSpec :: builder
2125
+ }
2126
+ }
2127
+ impl HasParamSpec for Vec < String > {
2128
+ type ParamSpec = ParamSpecBoxed ;
2129
+ type SetValue = Self ;
2130
+ type BuilderFn = fn ( & str ) -> ParamSpecBoxedBuilder < Self > ;
2131
+
2132
+ fn param_spec_builder ( ) -> Self :: BuilderFn {
2133
+ Self :: ParamSpec :: builder
2134
+ }
2135
+ }
2118
2136
impl HasParamSpec for char {
2119
2137
type ParamSpec = ParamSpecUnichar ;
2120
2138
type SetValue = Self ;
You can’t perform that action at this time.
0 commit comments