This repository was archived by the owner on Jun 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-21
lines changed Expand file tree Collapse file tree 2 files changed +24
-21
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ use std::mem;
1212use std:: ptr;
1313
1414use Value ;
15+ use value:: SetValue ;
1516use Type ;
1617use BoolError ;
1718use Closure ;
@@ -243,6 +244,28 @@ macro_rules! glib_object_wrapper {
243244 }
244245 }
245246
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+
246269 impl :: std:: cmp:: Eq for $name { }
247270 } ;
248271
@@ -373,7 +396,7 @@ fn get_property_type<T: IsA<Object>>(obj: &T, property_name: &str) -> Option<Typ
373396 }
374397}
375398
376- impl < T : IsA < Object > > ObjectExt for T {
399+ impl < T : IsA < Object > + SetValue > ObjectExt for T {
377400 fn get_type ( & self ) -> Type {
378401 unsafe {
379402 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;
7979use std:: ptr;
8080use libc:: c_void;
8181
82- use object:: { Downcast , IsA , Object } ;
8382use translate:: * ;
8483use types:: { StaticType , Type } ;
8584
@@ -518,25 +517,6 @@ impl SetValueOptional for String {
518517 }
519518}
520519
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-
540520impl < ' a > FromValueOptional < ' a > for bool {
541521 unsafe fn from_value_optional ( value : & ' a Value ) -> Option < Self > {
542522 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