Skip to content

Commit 77d82c5

Browse files
committed
Bind name_lost vfunc
1 parent f40c7d4 commit 77d82c5

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

gio/src/subclass/application.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ pub trait ApplicationImpl:
118118
fn dbus_unregister(&self, connection: &DBusConnection, object_path: &str) {
119119
self.parent_dbus_unregister(connection, object_path)
120120
}
121+
122+
fn name_lost(&self) -> bool {
123+
self.parent_name_lost()
124+
}
121125
}
122126

123127
pub trait ApplicationImplExt: ApplicationImpl {
@@ -316,6 +320,21 @@ pub trait ApplicationImplExt: ApplicationImpl {
316320
);
317321
}
318322
}
323+
324+
fn parent_name_lost(&self) -> bool {
325+
unsafe {
326+
let data = Self::type_data();
327+
let parent_class = data.as_ref().parent_class() as *mut ffi::GApplicationClass;
328+
let f = (*parent_class)
329+
.name_lost
330+
.expect("No parent class implementation for \"name_lost\"");
331+
if f(self.obj().unsafe_cast_ref::<Application>().to_glib_none().0) == glib::ffi::GTRUE {
332+
true
333+
} else {
334+
false
335+
}
336+
}
337+
}
319338
}
320339

321340
impl<T: ApplicationImpl> ApplicationImplExt for T {}
@@ -338,6 +357,7 @@ unsafe impl<T: ApplicationImpl> IsSubclassable<T> for Application {
338357
klass.handle_local_options = Some(application_handle_local_options::<T>);
339358
klass.dbus_register = Some(application_dbus_register::<T>);
340359
klass.dbus_unregister = Some(application_dbus_unregister::<T>);
360+
klass.name_lost = Some(application_name_lost::<T>);
341361
}
342362
}
343363

@@ -478,6 +498,18 @@ unsafe extern "C" fn application_dbus_unregister<T: ApplicationImpl>(
478498
);
479499
}
480500

501+
unsafe extern "C" fn application_name_lost<T: ApplicationImpl>(
502+
ptr: *mut ffi::GApplication,
503+
) -> glib::ffi::gboolean {
504+
let instance = &*(ptr as *mut T::Instance);
505+
let imp = instance.imp();
506+
if imp.name_lost() {
507+
glib::ffi::GTRUE
508+
} else {
509+
glib::ffi::GFALSE
510+
}
511+
}
512+
481513
#[cfg(test)]
482514
mod tests {
483515
use super::*;

0 commit comments

Comments
 (0)