This commit is contained in:
Ryan McGrath 2023-05-01 03:47:35 -07:00
parent a1f2711ceb
commit 589ff8c789
No known key found for this signature in database
GPG key ID: DA6CBD9233593DEA
2 changed files with 8 additions and 4 deletions

View file

@ -69,7 +69,7 @@ pub(crate) static APP_PTR: &str = "rstAppPtr";
/// A handler to make some boilerplate less annoying. /// A handler to make some boilerplate less annoying.
#[inline] #[inline]
fn shared_application<T, F: Fn(id) -> T>(handler: F) -> T { pub(crate) fn shared_application<T, F: Fn(id) -> T>(handler: F) -> T {
let app: id = unsafe { msg_send![register_app_class(), sharedApplication] }; let app: id = unsafe { msg_send![register_app_class(), sharedApplication] };
handler(app) handler(app)
} }
@ -123,7 +123,7 @@ impl<T> App<T> {
pub fn run(&self) { pub fn run(&self) {
unsafe { unsafe {
//let current_app: id = msg_send![class!(NSRunningApplication), currentApplication]; //let current_app: id = msg_send![class!(NSRunningApplication), currentApplication];
let shared_app: id = msg_send![class!(RSTApplication), sharedApplication]; let shared_app: id = msg_send![register_app_class(), sharedApplication];
let _: () = msg_send![shared_app, run]; let _: () = msg_send![shared_app, run];
self.pool.drain(); self.pool.drain();
} }

View file

@ -165,8 +165,12 @@ impl MenuItem {
// supported by MenuItem yet. // supported by MenuItem yet.
Self::Services => { Self::Services => {
let item = make_menu_item("Services", None, None, None); let item = make_menu_item("Services", None, None, None);
let app: id = msg_send![class!(RSTApplication), sharedApplication];
let services: id = msg_send![app, servicesMenu]; let services = crate::appkit::app::shared_application(|app| {
let services: id = msg_send![app, servicesMenu];
services
});
let _: () = msg_send![&*item, setSubmenu: services]; let _: () = msg_send![&*item, setSubmenu: services];
item item
}, },