refactor: make applicationMenu a property on app (#17361)

This commit is contained in:
Shelley Vohr 2019-04-02 13:36:57 -07:00 committed by GitHub
parent d412582f72
commit 0431997c8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 1 deletions

View file

@ -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') {