5
5
6
6
use std:: { boxed:: Box as Box_ , collections:: HashMap , fmt, future:: Future } ;
7
7
8
- use glib:: { clone:: Downgrade , subclass:: SignalId , translate:: * , GString , Variant } ;
8
+ use glib:: {
9
+ clone:: Downgrade ,
10
+ property:: { Property , PropertyGet } ,
11
+ subclass:: SignalId ,
12
+ translate:: * ,
13
+ GString , Variant ,
14
+ } ;
9
15
10
16
use crate :: {
11
17
ffi, prelude:: * , subclass:: prelude:: * , Accessible , AccessibleRole , Buildable , BuilderRustScope ,
@@ -1214,13 +1220,19 @@ pub unsafe trait WidgetClassExt: ClassStruct {
1214
1220
unsafe impl < T : ClassStruct > WidgetClassExt for T where T :: Type : WidgetImpl { }
1215
1221
1216
1222
#[ derive( Debug , PartialEq , Eq ) ]
1217
- #[ repr( C ) ]
1223
+ #[ repr( transparent ) ]
1218
1224
pub struct TemplateChild < T >
1219
1225
where
1220
1226
T : ObjectType + FromGlibPtrNone < * mut <T as ObjectType >:: GlibType > ,
1221
1227
{
1222
1228
ptr : * mut <T as ObjectType >:: GlibType ,
1223
- should_drop : bool ,
1229
+ }
1230
+
1231
+ impl < T : Property > Property for TemplateChild < T >
1232
+ where
1233
+ T : ObjectType + FromGlibPtrNone < * mut <T as ObjectType >:: GlibType > ,
1234
+ {
1235
+ type Value = T :: Value ;
1224
1236
}
1225
1237
1226
1238
impl < T > Default for TemplateChild < T >
@@ -1232,59 +1244,18 @@ where
1232
1244
1233
1245
Self {
1234
1246
ptr : std:: ptr:: null_mut ( ) ,
1235
- should_drop : false ,
1236
1247
}
1237
1248
}
1238
1249
}
1239
1250
1240
- impl < T > glib:: HasParamSpec for TemplateChild < T >
1241
- where
1242
- T : ObjectType + IsA < glib:: Object > + FromGlibPtrNone < * mut <T as ObjectType >:: GlibType > ,
1243
- {
1244
- type ParamSpec = glib:: ParamSpecObject ;
1245
- type SetValue = T ;
1246
- type BuilderFn = fn ( & str ) -> glib:: ParamSpecObjectBuilder < T > ;
1247
-
1248
- fn param_spec_builder ( ) -> Self :: BuilderFn {
1249
- Self :: ParamSpec :: builder
1250
- }
1251
- }
1252
-
1253
- impl < T > ToValue for TemplateChild < T >
1254
- where
1255
- T : ToValue + ObjectType + FromGlibPtrNone < * mut <T as ObjectType >:: GlibType > ,
1256
- {
1257
- #[ inline]
1258
- fn to_value ( & self ) -> glib:: Value {
1259
- T :: to_value ( & self . get ( ) )
1260
- }
1261
-
1262
- #[ inline]
1263
- fn value_type ( & self ) -> glib:: Type {
1264
- T :: static_type ( )
1265
- }
1266
- }
1267
-
1268
- impl < T > glib:: value:: ValueType for TemplateChild < T >
1251
+ impl < T > PropertyGet for TemplateChild < T >
1269
1252
where
1270
- T : glib :: value :: ValueType + ObjectType + FromGlibPtrNone < * mut <T as ObjectType >:: GlibType > ,
1253
+ T : Property + ObjectType + FromGlibPtrNone < * mut <T as ObjectType >:: GlibType > ,
1271
1254
{
1272
- type Type = <T as glib:: value:: ValueType >:: Type ;
1273
- }
1255
+ type Value = T ;
1274
1256
1275
- unsafe impl < ' a , T > glib:: value:: FromValue < ' a > for TemplateChild < T >
1276
- where
1277
- T : ObjectType + FromGlibPtrNone < * mut <T as ObjectType >:: GlibType > ,
1278
- {
1279
- type Checker = glib:: value:: GenericValueTypeChecker < T > ;
1280
-
1281
- #[ inline]
1282
- unsafe fn from_value ( value : & ' a glib:: Value ) -> Self {
1283
- skip_assert_initialized ! ( ) ;
1284
- TemplateChild {
1285
- ptr : T :: from_value ( value) . into_glib_ptr ( ) ,
1286
- should_drop : true ,
1287
- }
1257
+ fn get < R , F : Fn ( & Self :: Value ) -> R > ( & self , f : F ) -> R {
1258
+ f ( & self . get ( ) )
1288
1259
}
1289
1260
}
1290
1261
@@ -1317,19 +1288,6 @@ where
1317
1288
}
1318
1289
}
1319
1290
1320
- impl < T > Drop for TemplateChild < T >
1321
- where
1322
- T : ObjectType + FromGlibPtrNone < * mut <T as ObjectType >:: GlibType > ,
1323
- {
1324
- fn drop ( & mut self ) {
1325
- if self . should_drop {
1326
- unsafe {
1327
- crate :: glib:: gobject_ffi:: g_object_unref ( self . ptr as * mut _ ) ;
1328
- }
1329
- }
1330
- }
1331
- }
1332
-
1333
1291
impl < T > TemplateChild < T >
1334
1292
where
1335
1293
T : ObjectType + FromGlibPtrNone < * mut <T as ObjectType >:: GlibType > ,
0 commit comments