Skip to content

Commit

Permalink
Use msg_send_! macro to infer ObjcId types
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Murphy committed Jun 29, 2024
1 parent e2bc99b commit 74f1890
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/native/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,31 +907,31 @@ unsafe fn initialize_menu_bar(ns_app: ObjcId) {
// Adapted from Winit `menu::initialize`

// System menu bar
let menu_bar: ObjcId = msg_send![class!(NSMenu), new];
let menu_bar = msg_send_![class!(NSMenu), new];
// Entry for the app menu dropdown in the menu bar
let app_menu_item: ObjcId = msg_send![class!(NSMenuItem), new];
let app_menu: ObjcId = msg_send![class!(NSMenu), new];
let app_menu_item = msg_send_![class!(NSMenuItem), new];
let app_menu = msg_send_![class!(NSMenu), new];

// Hook up the menu components to the application
let () = msg_send![app_menu_item, setSubmenu: app_menu];
let () = msg_send![menu_bar, addItem: app_menu_item];
let () = msg_send![ns_app, setMainMenu: menu_bar];
msg_send_![app_menu_item, setSubmenu: app_menu];
msg_send_![menu_bar, addItem: app_menu_item];
msg_send_![ns_app, setMainMenu: menu_bar];

// Add quit menu entry with shortcut command-q
// It uses NSRunningApplication.localizedName, which will try to use the localized name,
// and will go through a chain of fallbacks based on what name strings are set in
// the Application bundle files, ending with the executable name.
let running_application: ObjcId = msg_send![class!(NSRunningApplication), currentApplication];
let application_name: ObjcId = msg_send![running_application, localizedName];
let running_application = msg_send_![class!(NSRunningApplication), currentApplication];
let application_name = msg_send_![running_application, localizedName];
let quit_item_title = str_to_nsstring(&format!("Quit {}", nsstring_to_string(application_name)));
let quit_item: ObjcId = msg_send![class!(NSMenuItem), alloc];
let quit_item: ObjcId = msg_send![
let quit_item = msg_send_![class!(NSMenuItem), alloc];
let quit_item = msg_send_![
quit_item,
initWithTitle: quit_item_title
action: sel!(terminate:)
keyEquivalent: str_to_nsstring("q")
];
() = msg_send![app_menu, addItem: quit_item];
msg_send_![app_menu, addItem: quit_item];
}

pub unsafe fn run<F>(conf: crate::conf::Conf, f: F)
Expand Down

0 comments on commit 74f1890

Please sign in to comment.