1use crate::WindowAppearance;
2use cocoa::{
3 appkit::{NSAppearanceNameVibrantDark, NSAppearanceNameVibrantLight},
4 base::id,
5 foundation::NSString,
6};
7use objc::{msg_send, sel, sel_impl};
8use std::ffi::CStr;
9
10impl WindowAppearance {
11 pub(crate) unsafe fn from_native(appearance: id) -> Self {
12 let name: id = msg_send![appearance, name];
13 if name == NSAppearanceNameVibrantLight {
14 Self::VibrantLight
15 } else if name == NSAppearanceNameVibrantDark {
16 Self::VibrantDark
17 } else if name == NSAppearanceNameAqua {
18 Self::Light
19 } else if name == NSAppearanceNameDarkAqua {
20 Self::Dark
21 } else {
22 println!(
23 "unknown appearance: {:?}",
24 CStr::from_ptr(name.UTF8String())
25 );
26 Self::Light
27 }
28 }
29}
30
31#[link(name = "AppKit", kind = "framework")]
32extern "C" {
33 pub static NSAppearanceNameAqua: id;
34 pub static NSAppearanceNameDarkAqua: id;
35}