Skip to content

Commit e643e46

Browse files
authored
Merge pull request #120 from gtk-rs/bilelmoussaoui/gtk/application-subclass-fix
gtk: backport application subclass startup override
2 parents c1306e0 + 679cffd commit e643e46

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

gtk4/src/subclass/application.rs

+15
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,24 @@ unsafe impl<T: GtkApplicationImpl> IsSubclassable<T> for Application {
6262
let klass = class.as_mut();
6363
klass.window_added = Some(application_window_added::<T>);
6464
klass.window_removed = Some(application_window_removed::<T>);
65+
66+
// Chain our startup handler in here
67+
let parent_klass = &mut class.as_mut().parent_class;
68+
parent_klass.startup = Some(application_startup::<T>);
6569
}
6670
}
6771

72+
unsafe extern "C" fn application_startup<T: ObjectSubclass>(ptr: *mut gio::ffi::GApplication)
73+
where
74+
T: GtkApplicationImpl,
75+
{
76+
let instance = &*(ptr as *mut T::Instance);
77+
let imp = instance.get_impl();
78+
let wrap: Borrowed<gio::Application> = from_glib_borrow(ptr);
79+
crate::rt::set_initialized();
80+
imp.startup(wrap.unsafe_cast_ref())
81+
}
82+
6883
unsafe extern "C" fn application_window_added<T: GtkApplicationImpl>(
6984
ptr: *mut ffi::GtkApplication,
7085
wptr: *mut ffi::GtkWindow,

0 commit comments

Comments
 (0)