This repository was archived by the owner on Jun 8, 2021. It is now read-only.
File tree 2 files changed +24
-21
lines changed 2 files changed +24
-21
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ use std::mem;
12
12
use std:: ptr;
13
13
14
14
use Value ;
15
+ use value:: SetValue ;
15
16
use Type ;
16
17
use BoolError ;
17
18
use Closure ;
@@ -243,6 +244,28 @@ macro_rules! glib_object_wrapper {
243
244
}
244
245
}
245
246
247
+ #[ doc( hidden) ]
248
+ impl <' a> $crate:: value:: FromValueOptional <' a> for $name {
249
+ unsafe fn from_value_optional( value: & $crate:: Value ) -> Option <Self > {
250
+ Option :: <$name>:: from_glib_full( gobject_ffi:: g_value_dup_object( value. to_glib_none( ) . 0 ) as * mut $ffi_name)
251
+ . map( |o| $crate:: object:: Downcast :: downcast_unchecked( o) )
252
+ }
253
+ }
254
+
255
+ #[ doc( hidden) ]
256
+ impl $crate:: value:: SetValue for $name {
257
+ unsafe fn set_value( value: & mut $crate:: Value , this: & Self ) {
258
+ gobject_ffi:: g_value_set_object( value. to_glib_none_mut( ) . 0 , $crate:: translate:: ToGlibPtr :: <* mut $ffi_name>:: to_glib_none( this) . 0 as * mut gobject_ffi:: GObject )
259
+ }
260
+ }
261
+
262
+ #[ doc( hidden) ]
263
+ impl $crate:: value:: SetValueOptional for $name {
264
+ unsafe fn set_value_optional( value: & mut $crate:: Value , this: Option <& Self >) {
265
+ gobject_ffi:: g_value_set_object( value. to_glib_none_mut( ) . 0 , $crate:: translate:: ToGlibPtr :: <* mut $ffi_name>:: to_glib_none( & this) . 0 as * mut gobject_ffi:: GObject )
266
+ }
267
+ }
268
+
246
269
impl :: std:: cmp:: Eq for $name { }
247
270
} ;
248
271
@@ -373,7 +396,7 @@ fn get_property_type<T: IsA<Object>>(obj: &T, property_name: &str) -> Option<Typ
373
396
}
374
397
}
375
398
376
- impl < T : IsA < Object > > ObjectExt for T {
399
+ impl < T : IsA < Object > + SetValue > ObjectExt for T {
377
400
fn get_type ( & self ) -> Type {
378
401
unsafe {
379
402
let obj = self . to_glib_none ( ) . 0 ;
Original file line number Diff line number Diff line change @@ -79,7 +79,6 @@ use std::ffi::CStr;
79
79
use std:: ptr;
80
80
use libc:: c_void;
81
81
82
- use object:: { Downcast , IsA , Object } ;
83
82
use translate:: * ;
84
83
use types:: { StaticType , Type } ;
85
84
@@ -518,25 +517,6 @@ impl SetValueOptional for String {
518
517
}
519
518
}
520
519
521
- impl < ' a , T : IsA < Object > > FromValueOptional < ' a > for T {
522
- unsafe fn from_value_optional ( value : & Value ) -> Option < Self > {
523
- Option :: < Object > :: from_glib_full ( gobject_ffi:: g_value_dup_object ( value. to_glib_none ( ) . 0 ) )
524
- . map ( |o| o. downcast_unchecked ( ) )
525
- }
526
- }
527
-
528
- impl < T : IsA < Object > > SetValue for T {
529
- unsafe fn set_value ( value : & mut Value , this : & Self ) {
530
- gobject_ffi:: g_value_set_object ( value. to_glib_none_mut ( ) . 0 , this. to_glib_none ( ) . 0 )
531
- }
532
- }
533
-
534
- impl < T : IsA < Object > > SetValueOptional for T {
535
- unsafe fn set_value_optional ( value : & mut Value , this : Option < & Self > ) {
536
- gobject_ffi:: g_value_set_object ( value. to_glib_none_mut ( ) . 0 , this. to_glib_none ( ) . 0 )
537
- }
538
- }
539
-
540
520
impl < ' a > FromValueOptional < ' a > for bool {
541
521
unsafe fn from_value_optional ( value : & ' a Value ) -> Option < Self > {
542
522
Some ( from_glib ( gobject_ffi:: g_value_get_boolean ( value. to_glib_none ( ) . 0 ) ) )
You can’t perform that action at this time.
0 commit comments