Skip to content

Commit 29ea6f5

Browse files
swsnrsdroege
authored andcommitted
Bind name_lost vfunc
1 parent 759c959 commit 29ea6f5

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

gio/src/subclass/application.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
use std::{ffi::OsString, fmt, ops::Deref, ptr};
44

5-
use glib::{prelude::*, subclass::prelude::*, translate::*, Error, ExitCode, VariantDict};
5+
use glib::{
6+
prelude::*, subclass::prelude::*, translate::*, Error, ExitCode, Propagation, VariantDict,
7+
};
68
use libc::{c_char, c_int, c_void};
79

810
use crate::{ffi, Application, DBusConnection};
@@ -116,6 +118,10 @@ pub trait ApplicationImpl: ObjectImpl + ApplicationImplExt {
116118
fn dbus_unregister(&self, connection: &DBusConnection, object_path: &str) {
117119
self.parent_dbus_unregister(connection, object_path)
118120
}
121+
122+
fn name_lost(&self) -> Propagation {
123+
self.parent_name_lost()
124+
}
119125
}
120126

121127
mod sealed {
@@ -319,6 +325,21 @@ pub trait ApplicationImplExt: sealed::Sealed + ObjectSubclass {
319325
);
320326
}
321327
}
328+
329+
fn parent_name_lost(&self) -> Propagation {
330+
unsafe {
331+
let data = Self::type_data();
332+
let parent_class = data.as_ref().parent_class() as *mut ffi::GApplicationClass;
333+
let f = (*parent_class)
334+
.name_lost
335+
.expect("No parent class implementation for \"name_lost\"");
336+
Propagation::from_glib(f(self
337+
.obj()
338+
.unsafe_cast_ref::<Application>()
339+
.to_glib_none()
340+
.0))
341+
}
342+
}
322343
}
323344

324345
impl<T: ApplicationImpl> ApplicationImplExt for T {}
@@ -341,6 +362,7 @@ unsafe impl<T: ApplicationImpl> IsSubclassable<T> for Application {
341362
klass.handle_local_options = Some(application_handle_local_options::<T>);
342363
klass.dbus_register = Some(application_dbus_register::<T>);
343364
klass.dbus_unregister = Some(application_dbus_unregister::<T>);
365+
klass.name_lost = Some(application_name_lost::<T>);
344366
}
345367
}
346368

@@ -481,6 +503,14 @@ unsafe extern "C" fn application_dbus_unregister<T: ApplicationImpl>(
481503
);
482504
}
483505

506+
unsafe extern "C" fn application_name_lost<T: ApplicationImpl>(
507+
ptr: *mut ffi::GApplication,
508+
) -> glib::ffi::gboolean {
509+
let instance = &*(ptr as *mut T::Instance);
510+
let imp = instance.imp();
511+
imp.name_lost().into_glib()
512+
}
513+
484514
#[cfg(test)]
485515
mod tests {
486516
use super::*;

0 commit comments

Comments
 (0)