@@ -404,7 +404,7 @@ mod test {
404
404
. param_types( [ String :: static_type( ) ] )
405
405
. return_type:: <String >( )
406
406
. action( )
407
- . class_handler( |_ , args| {
407
+ . class_handler( |args| {
408
408
let obj = args[ 0 ]
409
409
. get:: <super :: SimpleObject >( )
410
410
. expect( "Failed to get Object from args[0]" ) ;
@@ -426,6 +426,16 @@ mod test {
426
426
super :: Signal :: builder( "create-child-object" )
427
427
. return_type:: <super :: ChildObject >( )
428
428
. build( ) ,
429
+ super :: Signal :: builder( "return-string" )
430
+ . return_type:: <String >( )
431
+ . action( )
432
+ . class_handler( |args| {
433
+ let _obj = args[ 0 ]
434
+ . get:: <super :: SimpleObject >( )
435
+ . expect( "Failed to get Object from args[0]" ) ;
436
+ Some ( "base" . to_value( ) )
437
+ } )
438
+ . build( ) ,
429
439
]
430
440
} )
431
441
}
@@ -487,6 +497,33 @@ mod test {
487
497
}
488
498
}
489
499
500
+ #[ derive( Default ) ]
501
+ pub struct SimpleSubObject ;
502
+
503
+ #[ glib:: object_subclass]
504
+ impl ObjectSubclass for SimpleSubObject {
505
+ const NAME : & ' static str = "SimpleSubObject" ;
506
+ type Type = super :: SimpleSubObject ;
507
+ type ParentType = super :: SimpleObject ;
508
+
509
+ fn class_init ( class : & mut Self :: Class ) {
510
+ class. override_signal_class_handler ( "return-string" , |token, args| {
511
+ let obj = args[ 0 ]
512
+ . get :: < super :: SimpleSubObject > ( )
513
+ . expect ( "Failed to get Object from args[0]" ) ;
514
+
515
+ let res = obj. imp ( ) . signal_chain_from_overridden ( token, args) ;
516
+ assert_eq ! ( res. unwrap( ) . get:: <& str >( ) . unwrap( ) , "base" ) ;
517
+
518
+ Some ( "sub" . to_value ( ) )
519
+ } ) ;
520
+ }
521
+ }
522
+
523
+ impl ObjectImpl for SimpleSubObject { }
524
+
525
+ impl SimpleObjectImpl for SimpleSubObject { }
526
+
490
527
#[ derive( Clone , Copy ) ]
491
528
#[ repr( C ) ]
492
529
pub struct DummyInterface {
@@ -514,6 +551,14 @@ mod test {
514
551
pub struct SimpleObject ( ObjectSubclass <imp:: SimpleObject >) ;
515
552
}
516
553
554
+ pub trait SimpleObjectImpl : ObjectImpl { }
555
+
556
+ unsafe impl < Obj : SimpleObjectImpl > IsSubclassable < Obj > for SimpleObject { }
557
+
558
+ wrapper ! {
559
+ pub struct SimpleSubObject ( ObjectSubclass <imp:: SimpleSubObject >) @extends SimpleObject ;
560
+ }
561
+
517
562
wrapper ! {
518
563
pub struct Dummy ( ObjectInterface <imp:: Dummy >) ;
519
564
}
@@ -543,6 +588,14 @@ mod test {
543
588
assert ! ( weak. upgrade( ) . is_none( ) ) ;
544
589
}
545
590
591
+ #[ test]
592
+ fn test_sub_create ( ) {
593
+ let obj = Object :: builder :: < SimpleSubObject > ( ) . build ( ) ;
594
+ assert ! ( obj. type_( ) . is_a( SimpleObject :: static_type( ) ) ) ;
595
+ assert_eq ! ( obj. type_( ) , SimpleSubObject :: static_type( ) ) ;
596
+ assert ! ( obj. property:: <bool >( "constructed" ) ) ;
597
+ }
598
+
546
599
#[ test]
547
600
fn test_properties ( ) {
548
601
let type_ = SimpleObject :: static_type ( ) ;
@@ -829,6 +882,8 @@ mod test {
829
882
"old-name"
830
883
) ;
831
884
assert ! ( name_changed_triggered. load( Ordering :: Relaxed ) ) ;
885
+
886
+ assert_eq ! ( obj. emit_by_name:: <String >( "return-string" , & [ ] ) , "base" ) ;
832
887
}
833
888
834
889
#[ test]
@@ -845,6 +900,13 @@ mod test {
845
900
assert_eq ! ( value, "return value" ) ;
846
901
}
847
902
903
+ #[ test]
904
+ fn test_signal_override ( ) {
905
+ let obj = Object :: builder :: < SimpleSubObject > ( ) . build ( ) ;
906
+
907
+ assert_eq ! ( obj. emit_by_name:: <String >( "return-string" , & [ ] ) , "sub" ) ;
908
+ }
909
+
848
910
#[ test]
849
911
fn test_callback_validity ( ) {
850
912
use std:: sync:: {
0 commit comments