From 4eb58f6ea71ed9ee6454707d605cd0713c1baa4c Mon Sep 17 00:00:00 2001 From: der richter Date: Mon, 4 Mar 2024 00:29:07 +0100 Subject: [PATCH] mac/menu: move conditional Bundle menu items into config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit only add the "Show log File…" menu item config when invoked from the bundle, instead of testing on menu item creation. this is similar to the touch bar menu items now. --- osdep/mac/menu_bar.swift | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/osdep/mac/menu_bar.swift b/osdep/mac/menu_bar.swift index 6fa64b43ca..75b1f35aba 100644 --- a/osdep/mac/menu_bar.swift +++ b/osdep/mac/menu_bar.swift @@ -210,7 +210,7 @@ class MenuBar: NSObject { Config(name: "Zoom", commandSpecial: .zoom), ] - let helpMenuConfigs = [ + var helpMenuConfigs = [ Config(name: "mpv Website…", action: #selector(url(_:)), target: self, url: "https://mpv.io"), Config(name: "mpv on GitHub…", action: #selector(url(_:)), target: self, url: "https://github.com/mpv-player/mpv"), Config(name: "separator"), @@ -220,13 +220,12 @@ class MenuBar: NSObject { Config(name: "Keyboard Shortcuts…", action: #selector(url(_:)), target: self, url: "https://github.com/mpv-player/mpv/blob/master/etc/input.conf"), Config(name: "separator"), Config(name: "Report Issue…", action: #selector(url(_:)), target: self, url: "https://github.com/mpv-player/mpv/issues/new/choose"), - Config( - name: "Show log File…", - action: #selector(showFile(_:)), - target: self, - url: NSHomeDirectory() + "/Library/Logs/mpv.log" - ), ] + if ProcessInfo.processInfo.environment["MPVBUNDLE"] == "true" { + helpMenuConfigs += [ + Config(name: "Show log File…", action: #selector(showFile(_:)), target: self, url: NSHomeDirectory() + "/Library/Logs/mpv.log") + ] + } menuConfigs = [ Config(name: "Apple", configs: appMenuConfigs), @@ -256,10 +255,6 @@ class MenuBar: NSObject { mainMenu.setSubmenu(menu, for: item) for subConfig in menuConfig.configs ?? [] { - if subConfig.name == "Show log File…" && ProcessInfo.processInfo.environment["MPVBUNDLE"] != "true" { - continue - } - if subConfig.name == "separator" { menu.addItem(MenuItem.separator()) } else {