Skip to content

Commit a47890a

Browse files
gtk: backport application subclass startup override
add a default impl that properly log rt initalisation details at gtk-rs/gtk3-rs@25ef6ee fixes #118
1 parent c1306e0 commit a47890a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

gtk4/src/subclass/application.rs

+16
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,27 @@ unsafe impl<T: GtkApplicationImpl> IsSubclassable<T> for Application {
6060
<gio::Application as IsSubclassable<T>>::override_vfuncs(class);
6161

6262
let klass = class.as_mut();
63+
6364
klass.window_added = Some(application_window_added::<T>);
6465
klass.window_removed = Some(application_window_removed::<T>);
66+
67+
// Chain our startup handler in here
68+
let parent_klass = &mut class.as_mut().parent_class;
69+
parent_klass.startup = Some(application_startup::<T>);
6570
}
6671
}
6772

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

0 commit comments

Comments
 (0)