forked from ethereum/mist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
menuItems.js
177 lines (162 loc) · 5.25 KB
/
menuItems.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
const BrowserWindow = require('browser-window');
const MenuItem = require('menu-item');
const Menu = require('menu');
const config = require('./config');
const ipc = require('ipc');
// create menu
// null -> null
var createMenu = function(mainWindow, webviews) {
const menu = Menu.buildFromTemplate(menuTempl(mainWindow, webviews));
Menu.setApplicationMenu(menu);
};
// create a menu template
// null -> obj
var menuTempl = function(mainWindow, webviews) {
const menu = []
// APP
menu.push({
label: i18n.t('mist.applicationMenu.app.label', {app: config.name}),
submenu: [
{
label: i18n.t('mist.applicationMenu.app.about', {app: config.name}),
selector: 'orderFrontStandardAboutPanel:'
},
{
label: i18n.t('mist.applicationMenu.app.quit', {app: config.name}),
accelerator: 'Command+Q',
selector: 'terminate:'
}
]
})
// EDIT
menu.push({
label: i18n.t('mist.applicationMenu.edit.label'),
submenu: [
{
label: i18n.t('mist.applicationMenu.edit.undo'),
accelerator: 'Command+Z',
selector: 'undo:'
},
{
label: i18n.t('mist.applicationMenu.edit.redo'),
accelerator: 'Shift+Command+Z',
selector: 'redo:'
},
{
type: 'separator'
},
{
label: i18n.t('mist.applicationMenu.edit.cut'),
accelerator: 'Command+X',
selector: 'cut:'
},
{
label: i18n.t('mist.applicationMenu.edit.copy'),
accelerator: 'Command+C',
selector: 'copy:'
},
{
label: i18n.t('mist.applicationMenu.edit.paste'),
accelerator: 'Command+V',
selector: 'paste:'
},
{
label: i18n.t('mist.applicationMenu.edit.selectAll'),
accelerator: 'Command+A',
selector: 'selectAll:'
},
]
})
// VIEW
menu.push({
label: i18n.t('mist.applicationMenu.view.label'),
submenu: [
{
label: i18n.t('mist.applicationMenu.view.fullscreen'),
accelerator: 'Command+F',
click: function(){
mainWindow.setFullScreen(!mainWindow.isFullScreen());
}
}
]
})
// DEVELOP
var devtToolsMenu = [{
label: i18n.t('mist.applicationMenu.develop.devToolsMistUI'),
accelerator: 'Alt+Command+I',
click: function() {
if(curWindow = BrowserWindow.getFocusedWindow())
curWindow.toggleDevTools();
}
},{
type: 'separator'
}];
// add webviews
webviews.forEach(function(webview){
devtToolsMenu.push({
label: i18n.t('mist.applicationMenu.develop.devToolsWebview', {webview: webview.name}),
click: function() {
mainWindow.webContents.send('toogleWebviewDevTool', webview._id);
}
});
});
menu.push({
label: i18n.t('mist.applicationMenu.develop.label'),
submenu: _.union(devtToolsMenu, [
{
type: 'separator'
},
{
label: i18n.t('mist.applicationMenu.develop.runTests'),
click: function(){
// var testWindow = new BrowserWindow({
// width: 800,
// height: 600,
// icon: './icons/icon_128x128.png',
// preload: __dirname +'/modules/preloader/mistAPI.js',
// 'node-integration': true,
// 'web-preferences': {
// // 'web-security': false
// }
// });
// testWindow.loadUrl('file://'+ __dirname + '/tests/mocha-in-browser/runner.html');
mainWindow.webContents.send('runTests', 'webview');
}
}
])
})
// WINDOW
menu.push({
label: i18n.t('mist.applicationMenu.window.label'),
submenu: [
{
label: i18n.t('mist.applicationMenu.window.minimize'),
accelerator: 'Command+M',
selector: 'performMiniaturize:'
},
{
label: i18n.t('mist.applicationMenu.window.close'),
accelerator: 'Command+W',
// click: function() {
// if(curWindow = BrowserWindow.getFocusedWindow())
// curWindow.hide();
// }
selector: 'performClose:'
},
{
type: 'separator'
},
{
label: i18n.t('mist.applicationMenu.window.toFront'),
selector: 'arrangeInFront:'
},
]
})
// HELP
menu.push({
label: i18n.t('mist.applicationMenu.help.label'),
submenu: []
});
return menu;
};
module.exports = createMenu;