Desktop: Add app menu for Mac (#3428)

* add mac app menu

* review fixup

* Remove "About Graphite" ellipsis, add "Show All", make it say "Quit Graphite"

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Timon
2025-11-28 23:42:14 +00:00
committed by GitHub
co-authored by Keavon Chambers
parent 406f3d93f3
commit bb4516e377
15 changed files with 230 additions and 93 deletions
@@ -50,12 +50,65 @@ impl LayoutHolder for MenuBarMessageHandler {
let reset_node_definitions_on_open = self.reset_node_definitions_on_open;
let make_path_editable_is_allowed = self.make_path_editable_is_allowed;
let about = MenuBarEntry {
#[cfg(not(target_os = "macos"))]
label: "About Graphite…".into(),
#[cfg(target_os = "macos")]
label: "About Graphite".into(),
icon: Some("GraphiteLogo".into()),
action: MenuBarEntry::create_action(|_| DialogMessage::RequestAboutGraphiteDialog.into()),
..MenuBarEntry::default()
};
let preferences = MenuBarEntry {
label: "Preferences…".into(),
icon: Some("Settings".into()),
shortcut: action_keys!(DialogMessageDiscriminant::RequestPreferencesDialog),
action: MenuBarEntry::create_action(|_| DialogMessage::RequestPreferencesDialog.into()),
..MenuBarEntry::default()
};
let menu_bar_entries = vec![
#[cfg(not(target_os = "macos"))]
MenuBarEntry {
icon: Some("GraphiteLogo".into()),
action: MenuBarEntry::create_action(|_| FrontendMessage::TriggerVisitLink { url: "https://graphite.rs".into() }.into()),
..Default::default()
},
#[cfg(target_os = "macos")]
MenuBarEntry::new_root(
"".into(),
false,
MenuBarEntryChildren(vec![
vec![about],
vec![preferences],
vec![
MenuBarEntry {
label: "Hide Graphite".into(),
shortcut: action_keys!(AppWindowMessageDiscriminant::Hide),
action: MenuBarEntry::create_action(|_| AppWindowMessage::Hide.into()),
..MenuBarEntry::default()
},
MenuBarEntry {
label: "Hide Others".into(),
shortcut: action_keys!(AppWindowMessageDiscriminant::HideOthers),
action: MenuBarEntry::create_action(|_| AppWindowMessage::HideOthers.into()),
..MenuBarEntry::default()
},
MenuBarEntry {
label: "Show All".into(),
shortcut: action_keys!(AppWindowMessageDiscriminant::ShowAll),
action: MenuBarEntry::create_action(|_| AppWindowMessage::ShowAll.into()),
..MenuBarEntry::default()
},
],
vec![MenuBarEntry {
label: "Quit Graphite".into(),
shortcut: action_keys!(AppWindowMessageDiscriminant::Close),
action: MenuBarEntry::create_action(|_| AppWindowMessage::Close.into()),
..MenuBarEntry::default()
}],
]),
),
MenuBarEntry::new_root(
"File".into(),
false,
@@ -137,13 +190,8 @@ impl LayoutHolder for MenuBarMessageHandler {
..MenuBarEntry::default()
},
],
vec![MenuBarEntry {
label: "Preferences…".into(),
icon: Some("Settings".into()),
shortcut: action_keys!(DialogMessageDiscriminant::RequestPreferencesDialog),
action: MenuBarEntry::create_action(|_| DialogMessage::RequestPreferencesDialog.into()),
..MenuBarEntry::default()
}],
#[cfg(not(target_os = "macos"))]
vec![preferences],
]),
),
MenuBarEntry::new_root(
@@ -633,12 +681,8 @@ impl LayoutHolder for MenuBarMessageHandler {
"Help".into(),
false,
MenuBarEntryChildren(vec![
vec![MenuBarEntry {
label: "About Graphite…".into(),
icon: Some("GraphiteLogo".into()),
action: MenuBarEntry::create_action(|_| DialogMessage::RequestAboutGraphiteDialog.into()),
..MenuBarEntry::default()
}],
#[cfg(not(target_os = "macos"))]
vec![about],
vec![
MenuBarEntry {
label: "Donate to Graphite".into(),