feat(ui): implement exit method on macOS
This commit is contained in:
parent
4ab040da3c
commit
8c2e02030a
|
@ -55,6 +55,7 @@ extern "C" {
|
||||||
pub fn ui_eventloop(
|
pub fn ui_eventloop(
|
||||||
event_callback: extern "C" fn(_self: *mut MacEventLoop, event: RawUIEvent),
|
event_callback: extern "C" fn(_self: *mut MacEventLoop, event: RawUIEvent),
|
||||||
) -> i32;
|
) -> i32;
|
||||||
|
pub fn ui_exit();
|
||||||
pub fn ui_update_tray_icon(index: i32);
|
pub fn ui_update_tray_icon(index: i32);
|
||||||
pub fn ui_show_notification(message: *const c_char, delay: f64);
|
pub fn ui_show_notification(message: *const c_char, delay: f64);
|
||||||
pub fn ui_show_context_menu(payload: *const c_char);
|
pub fn ui_show_context_menu(payload: *const c_char);
|
||||||
|
@ -217,6 +218,10 @@ impl UIRemote for MacRemote {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn exit(&self) {
|
||||||
|
unsafe { ui_exit() };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::single_match)] // TODO: remove after another match is used
|
#[allow(clippy::single_match)] // TODO: remove after another match is used
|
||||||
|
|
|
@ -58,6 +58,9 @@ extern "C" void ui_initialize(void * self, UIOptions options);
|
||||||
// Run the event loop. Blocking call.
|
// Run the event loop. Blocking call.
|
||||||
extern "C" int32_t ui_eventloop(EventCallback callback);
|
extern "C" int32_t ui_eventloop(EventCallback callback);
|
||||||
|
|
||||||
|
// Stops the application eventloop.
|
||||||
|
extern "C" void ui_exit();
|
||||||
|
|
||||||
// Updates the tray icon to the given one. The method accepts an index that refers to
|
// Updates the tray icon to the given one. The method accepts an index that refers to
|
||||||
// the icon within the UIOptions.icon_paths array.
|
// the icon within the UIOptions.icon_paths array.
|
||||||
extern "C" void ui_update_tray_icon(int32_t index);
|
extern "C" void ui_update_tray_icon(int32_t index);
|
||||||
|
|
|
@ -45,6 +45,11 @@ int32_t ui_eventloop(EventCallback _callback)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ui_exit() {
|
||||||
|
[NSApp stop:nil];
|
||||||
|
[NSApp abortModal];
|
||||||
|
}
|
||||||
|
|
||||||
void ui_update_tray_icon(int32_t index)
|
void ui_update_tray_icon(int32_t index)
|
||||||
{
|
{
|
||||||
dispatch_async(dispatch_get_main_queue(), ^(void) {
|
dispatch_async(dispatch_get_main_queue(), ^(void) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user