Skip to content

Commit 00fe956

Browse files
committed
Bind name_lost vfunc
1 parent 7e0bed4 commit 00fe956

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, ActionGroup, ActionMap, Application, DBusConnection};
@@ -118,6 +120,10 @@ pub trait ApplicationImpl:
118120
fn dbus_unregister(&self, connection: &DBusConnection, object_path: &str) {
119121
self.parent_dbus_unregister(connection, object_path)
120122
}
123+
124+
fn name_lost(&self) -> Propagation {
125+
self.parent_name_lost()
126+
}
121127
}
122128

123129
pub trait ApplicationImplExt: ApplicationImpl {
@@ -316,6 +322,21 @@ pub trait ApplicationImplExt: ApplicationImpl {
316322
);
317323
}
318324
}
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+
}
319340
}
320341

321342
impl<T: ApplicationImpl> ApplicationImplExt for T {}
@@ -338,6 +359,7 @@ unsafe impl<T: ApplicationImpl> IsSubclassable<T> for Application {
338359
klass.handle_local_options = Some(application_handle_local_options::<T>);
339360
klass.dbus_register = Some(application_dbus_register::<T>);
340361
klass.dbus_unregister = Some(application_dbus_unregister::<T>);
362+
klass.name_lost = Some(application_name_lost::<T>);
341363
}
342364
}
343365

@@ -478,6 +500,14 @@ unsafe extern "C" fn application_dbus_unregister<T: ApplicationImpl>(
478500
);
479501
}
480502

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+
481511
#[cfg(test)]
482512
mod tests {
483513
use super::*;

0 commit comments

Comments
 (0)