-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
136 lines (127 loc) · 3.2 KB
/
app.js
File metadata and controls
136 lines (127 loc) · 3.2 KB
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
/**
* app.js - Detective
* Licensed under GPLv2.
* Copyright (C) 2015 VVBKA.
**/
'use strict';
var app = require('app'),
BrowserWindow = require('browser-window'),
Menu = require('menu');
// report crashes for electron
require('crash-reporter').start();
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var DetectiveWindow = null;
// apparently everything other than OSX needs to be
// manually quitted
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit();
}
});
var MenuTemplate = [{
label: 'Electron',
submenu: [{
label: 'About Electron',
selector: 'orderFrontStandardAboutPanel:'
}, {
type: 'separator'
}, {
label: 'Services',
submenu: []
}, {
type: 'separator'
}, {
label: 'Hide Electron',
accelerator: 'Command+H',
selector: 'hide:'
}, {
label: 'Hide Others',
accelerator: 'Command+Shift+H',
selector: 'hideOtherApplications:'
}, {
label: 'Show All',
selector: 'unhideAllApplications:'
}, {
type: 'separator'
}, {
label: 'Quit',
accelerator: 'Command+Q',
click: function () {
app.quit();
}
}, ]
}, {
label: 'Edit',
submenu: [{
label: 'Undo',
accelerator: 'Command+Z',
selector: 'undo:'
}, {
label: 'Redo',
accelerator: 'Shift+Command+Z',
selector: 'redo:'
}, {
type: 'separator'
}, {
label: 'Cut',
accelerator: 'Command+X',
selector: 'cut:'
}, {
label: 'Copy',
accelerator: 'Command+C',
selector: 'copy:'
}, {
label: 'Paste',
accelerator: 'Command+V',
selector: 'paste:'
}, {
label: 'Select All',
accelerator: 'Command+A',
selector: 'selectAll:'
}, ]
}, {
label: 'View',
submenu: [{
label: 'Reload',
accelerator: 'Command+R',
click: function () {
BrowserWindow.getFocusedWindow().reloadIgnoringCache();
}
}, {
label: 'Toggle DevTools',
accelerator: 'Alt+Command+I',
click: function () {
BrowserWindow.getFocusedWindow().toggleDevTools();
}
}, ]
}, {
label: 'Window',
submenu: [{
label: 'Minimize',
accelerator: 'Command+M',
selector: 'performMiniaturize:'
}, {
label: 'Close',
accelerator: 'Command+W',
selector: 'performClose:'
}, {
type: 'separator'
}, {
label: 'Bring All to Front',
selector: 'arrangeInFront:'
}, ]
}, ];
// prepare for full init from electron, then do
// our stuff
app.on('ready', function () {
DetectiveWindow = new BrowserWindow({
width: 1200,
height: 710,
icon: __dirname + '/img/icon-128x128.png'
});
Menu.setApplicationMenu(Menu.buildFromTemplate(MenuTemplate));
DetectiveWindow.loadUrl('file://' + __dirname + '/index.html');
if (process.env.NODE_ENV === 'development') DetectiveWindow.openDevTools();
DetectiveWindow.maximize();
});