1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
use crate::foundation::id;
#[cfg(target_os = "macos")]
#[derive(Debug)]
pub enum MacSystemIcon {
PreferencesGeneral,
PreferencesAdvanced,
PreferencesUserAccounts,
Add,
Remove,
Folder
}
extern "C" {
static NSImageNamePreferencesGeneral: id;
static NSImageNameAdvanced: id;
static NSImageNameUserAccounts: id;
static NSImageNameAddTemplate: id;
static NSImageNameFolder: id;
static NSImageNameRemoveTemplate: id;
}
#[cfg(target_os = "macos")]
impl MacSystemIcon {
pub fn to_id(&self) -> id {
unsafe {
match self {
MacSystemIcon::PreferencesGeneral => NSImageNamePreferencesGeneral,
MacSystemIcon::PreferencesAdvanced => NSImageNameAdvanced,
MacSystemIcon::PreferencesUserAccounts => NSImageNameUserAccounts,
MacSystemIcon::Add => NSImageNameAddTemplate,
MacSystemIcon::Remove => NSImageNameRemoveTemplate,
MacSystemIcon::Folder => NSImageNameFolder
}
}
}
pub fn to_sfsymbol_str(&self) -> &'static str {
match self {
MacSystemIcon::PreferencesGeneral => SFSymbol::GearShape.to_str(),
MacSystemIcon::PreferencesAdvanced => SFSymbol::SliderVertical3.to_str(),
MacSystemIcon::PreferencesUserAccounts => SFSymbol::AtSymbol.to_str(),
MacSystemIcon::Add => SFSymbol::Plus.to_str(),
MacSystemIcon::Remove => SFSymbol::Minus.to_str(),
MacSystemIcon::Folder => SFSymbol::FolderFilled.to_str()
}
}
}
#[derive(Debug)]
pub enum SFSymbol {
AtSymbol,
GearShape,
FolderFilled,
PaperPlane,
PaperPlaneFilled,
Plus,
Minus,
SliderVertical3,
SquareAndArrowUpOnSquare,
SquareAndArrowUpOnSquareFill,
SquareAndArrowDownOnSquare,
SquareAndArrowDownOnSquareFill,
SquareDashed
}
impl SFSymbol {
pub fn to_str(&self) -> &'static str {
match self {
Self::AtSymbol => "at",
Self::GearShape => "gearshape",
Self::FolderFilled => "folder.fill",
Self::PaperPlane => "paperplane",
Self::PaperPlaneFilled => "paperplane.fill",
Self::Plus => "plus",
Self::Minus => "minus",
Self::SliderVertical3 => "slider.vertical.3",
Self::SquareAndArrowUpOnSquare => "square.and.arrow.up.on.square",
Self::SquareAndArrowUpOnSquareFill => "square.and.arrow.up.on.square.fill",
Self::SquareAndArrowDownOnSquare => "square.and.arrow.down.on.square",
Self::SquareAndArrowDownOnSquareFill => "square.and.arrow.down.on.square.fill",
Self::SquareDashed => "square.dashed"
}
}
}