2
2
3
3
use std:: { ffi:: OsString , fmt, ops:: Deref , ptr} ;
4
4
5
- use glib:: { prelude:: * , subclass:: prelude:: * , translate:: * , Error , ExitCode , VariantDict } ;
5
+ use glib:: {
6
+ prelude:: * , subclass:: prelude:: * , translate:: * , Error , ExitCode , Propagation , VariantDict ,
7
+ } ;
6
8
use libc:: { c_char, c_int, c_void} ;
7
9
8
10
use crate :: { ffi, ActionGroup , ActionMap , Application , DBusConnection } ;
@@ -118,6 +120,10 @@ pub trait ApplicationImpl:
118
120
fn dbus_unregister ( & self , connection : & DBusConnection , object_path : & str ) {
119
121
self . parent_dbus_unregister ( connection, object_path)
120
122
}
123
+
124
+ fn name_lost ( & self ) -> Propagation {
125
+ self . parent_name_lost ( )
126
+ }
121
127
}
122
128
123
129
pub trait ApplicationImplExt : ApplicationImpl {
@@ -316,6 +322,21 @@ pub trait ApplicationImplExt: ApplicationImpl {
316
322
) ;
317
323
}
318
324
}
325
+
326
+ fn parent_name_lost ( & self ) -> Propagation {
327
+ unsafe {
328
+ let data = Self :: type_data ( ) ;
329
+ let parent_class = data. as_ref ( ) . parent_class ( ) as * mut ffi:: GApplicationClass ;
330
+ let f = ( * parent_class)
331
+ . name_lost
332
+ . expect ( "No parent class implementation for \" name_lost\" " ) ;
333
+ Propagation :: from_glib ( f ( self
334
+ . obj ( )
335
+ . unsafe_cast_ref :: < Application > ( )
336
+ . to_glib_none ( )
337
+ . 0 ) )
338
+ }
339
+ }
319
340
}
320
341
321
342
impl < T : ApplicationImpl > ApplicationImplExt for T { }
@@ -338,6 +359,7 @@ unsafe impl<T: ApplicationImpl> IsSubclassable<T> for Application {
338
359
klass. handle_local_options = Some ( application_handle_local_options :: < T > ) ;
339
360
klass. dbus_register = Some ( application_dbus_register :: < T > ) ;
340
361
klass. dbus_unregister = Some ( application_dbus_unregister :: < T > ) ;
362
+ klass. name_lost = Some ( application_name_lost :: < T > ) ;
341
363
}
342
364
}
343
365
@@ -478,6 +500,14 @@ unsafe extern "C" fn application_dbus_unregister<T: ApplicationImpl>(
478
500
) ;
479
501
}
480
502
503
+ unsafe extern "C" fn application_name_lost < T : ApplicationImpl > (
504
+ ptr : * mut ffi:: GApplication ,
505
+ ) -> glib:: ffi:: gboolean {
506
+ let instance = & * ( ptr as * mut T :: Instance ) ;
507
+ let imp = instance. imp ( ) ;
508
+ imp. name_lost ( ) . into_glib ( )
509
+ }
510
+
481
511
#[ cfg( test) ]
482
512
mod tests {
483
513
use super :: * ;
0 commit comments