@@ -106,6 +106,16 @@ let template = [{
106
106
label : 'Close' ,
107
107
accelerator : 'CmdOrCtrl+W' ,
108
108
role : 'close'
109
+ } , {
110
+ type : 'separator'
111
+ } , {
112
+ label : 'Reopen Window' ,
113
+ accelerator : 'CmdOrCtrl+Shift+T' ,
114
+ enabled : false ,
115
+ key : 'reopenMenuItem' ,
116
+ click : function ( ) {
117
+ app . emit ( 'activate' )
118
+ }
109
119
} ]
110
120
} , {
111
121
label : 'Help' ,
@@ -149,6 +159,23 @@ function addUpdateMenuItems (items, position) {
149
159
items . splice . apply ( items , [ position , 0 ] . concat ( updateItems ) )
150
160
}
151
161
162
+ function findReopenMenuItem ( ) {
163
+ const menu = Menu . getApplicationMenu ( )
164
+ if ( ! menu ) return
165
+
166
+ let reopenMenuItem
167
+ menu . items . forEach ( function ( item ) {
168
+ if ( item . submenu ) {
169
+ item . submenu . items . forEach ( function ( item ) {
170
+ if ( item . key === 'reopenMenuItem' ) {
171
+ reopenMenuItem = item
172
+ }
173
+ } )
174
+ }
175
+ } )
176
+ return reopenMenuItem
177
+ }
178
+
152
179
if ( process . platform === 'darwin' ) {
153
180
const name = electron . app . getName ( )
154
181
template . unshift ( {
@@ -185,6 +212,7 @@ if (process.platform === 'darwin') {
185
212
}
186
213
} ]
187
214
} )
215
+
188
216
// Window menu.
189
217
template [ 3 ] . submenu . push ( {
190
218
type : 'separator'
@@ -205,3 +233,13 @@ app.on('ready', function () {
205
233
const menu = Menu . buildFromTemplate ( template )
206
234
Menu . setApplicationMenu ( menu )
207
235
} )
236
+
237
+ app . on ( 'browser-window-created' , function ( ) {
238
+ let reopenMenuItem = findReopenMenuItem ( )
239
+ if ( reopenMenuItem ) reopenMenuItem . enabled = false
240
+ } )
241
+
242
+ app . on ( 'window-all-closed' , function ( ) {
243
+ let reopenMenuItem = findReopenMenuItem ( )
244
+ if ( reopenMenuItem ) reopenMenuItem . enabled = true
245
+ } )
0 commit comments