macos: add version info to system name
This commit is contained in:
3 files changed
+27
-1
No files matched your search
Generated
+1
@@ -6290,6 +6290,7 @@ dependencies = [
|
||||
"metrics",
|
||||
"mio",
|
||||
"objc",
|
||||
"plist",
|
||||
"promise",
|
||||
"raw-window-handle",
|
||||
"resize",
|
||||
|
||||
@@ -90,3 +90,4 @@ clipboard_macos = "0.1"
|
||||
core-foundation = "0.7"
|
||||
core-graphics = "0.19"
|
||||
cgl = "0.3"
|
||||
plist = "1.3"
|
||||
@@ -13,6 +13,7 @@ use cocoa::base::{id, nil};
|
||||
use cocoa::foundation::{NSArray, NSInteger, NSRect};
|
||||
use objc::runtime::{Object, BOOL, YES};
|
||||
use objc::*;
|
||||
use serde::Deserialize;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
@@ -81,9 +82,32 @@ impl Connection {
|
||||
}
|
||||
}
|
||||
|
||||
/// `/System/Library/CoreServices/SystemVersion.plist`
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
struct SoftwareVersion {
|
||||
product_build_version: String,
|
||||
product_user_visible_version: String,
|
||||
product_name: String,
|
||||
}
|
||||
|
||||
impl SoftwareVersion {
|
||||
fn load() -> anyhow::Result<Self> {
|
||||
let vers: Self = plist::from_file("/System/Library/CoreServices/SystemVersion.plist")?;
|
||||
Ok(vers)
|
||||
}
|
||||
}
|
||||
|
||||
impl ConnectionOps for Connection {
|
||||
fn name(&self) -> String {
|
||||
"macOS".to_string()
|
||||
if let Ok(vers) = SoftwareVersion::load() {
|
||||
format!(
|
||||
"{} {} ({})",
|
||||
vers.product_name, vers.product_user_visible_version, vers.product_build_version
|
||||
)
|
||||
} else {
|
||||
"macOS".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
fn terminate_message_loop(&self) {
|
||||
|
||||
Reference in new issue
Block a user