mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
refactor: make applicationMenu a property on app (#17361)
This commit is contained in:
@@ -19,9 +19,11 @@ Object.setPrototypeOf(App.prototype, EventEmitter.prototype)
|
||||
EventEmitter.call(app as any)
|
||||
|
||||
Object.assign(app, {
|
||||
// TODO(codebytere): remove in 7.0
|
||||
setApplicationMenu (menu: Electron.Menu | null) {
|
||||
return Menu.setApplicationMenu(menu)
|
||||
},
|
||||
// TODO(codebytere): remove in 7.0
|
||||
getApplicationMenu () {
|
||||
return Menu.getApplicationMenu()
|
||||
},
|
||||
@@ -38,6 +40,17 @@ Object.assign(app, {
|
||||
|
||||
app.getFileIcon = deprecate.promisify(app.getFileIcon)
|
||||
|
||||
// we define this here because it'd be overly complicated to
|
||||
// do in native land
|
||||
Object.defineProperty(app, 'applicationMenu', {
|
||||
get () {
|
||||
return Menu.getApplicationMenu()
|
||||
},
|
||||
set (menu: Electron.Menu | null) {
|
||||
return Menu.setApplicationMenu(menu)
|
||||
}
|
||||
})
|
||||
|
||||
app.isPackaged = (() => {
|
||||
const execFile = path.basename(process.execPath).toLowerCase()
|
||||
if (process.platform === 'win32') {
|
||||
|
||||
@@ -12,7 +12,7 @@ TopLevelWindow.prototype._init = function () {
|
||||
|
||||
// Simulate the application menu on platforms other than macOS.
|
||||
if (process.platform !== 'darwin') {
|
||||
const menu = app.getApplicationMenu()
|
||||
const menu = app.applicationMenu
|
||||
if (menu) this.setMenu(menu)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user