summaryrefslogtreecommitdiff
path: root/electron_js
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2018-05-07 11:36:44 -0400
committerPliable Pixels <pliablepixels@gmail.com>2018-05-07 11:36:44 -0400
commite5bcf3ba79dfa170d34bf85afafc8cbfed0f3c34 (patch)
treeeeda8e51c0c585f7a3613b4e96abc921d021e495 /electron_js
parent5497a287a3279cf7c0999c40b87f95c6d82cef3e (diff)
#623 copy/paste enabled
Diffstat (limited to 'electron_js')
-rw-r--r--electron_js/main.js101
1 files changed, 98 insertions, 3 deletions
diff --git a/electron_js/main.js b/electron_js/main.js
index a4fe235b..2d2f4ec4 100644
--- a/electron_js/main.js
+++ b/electron_js/main.js
@@ -1,6 +1,6 @@
const electron = require('electron');
const windowStateKeeper = require('electron-window-state');
-const {app, globalShortcut} = electron;
+const {app, globalShortcut, Menu} = electron;
const {dialog} = require('electron')
// Module to create native browser window.
@@ -9,6 +9,8 @@ var isFs = false;
var isProxy = false;
var argv = require('minimist')(process.argv.slice(1));
+
+
console.log ("ARGV="+JSON.stringify(argv));
if (argv.path) {
@@ -73,7 +75,7 @@ const mx = globalShortcut.register('CommandOrControl+Alt+F', () => {
- win.webContents.session.webRequest.onHeadersReceived({}, (d, c) => {
+ win.webContents.session.webRequest.onHeadersReceived({}, (d, c) => {
if(d.responseHeaders['x-frame-options'] || d.responseHeaders['X-Frame-Options']){
delete d.responseHeaders['x-frame-options'];
delete d.responseHeaders['X-Frame-Options'];
@@ -98,9 +100,102 @@ const mx = globalShortcut.register('CommandOrControl+Alt+F', () => {
// and load the index.html of the app.
win.loadURL(`file://${__dirname}/index.html`);
+ // Create the Application's main menu
+
+ // const menu = Menu.buildFromTemplate(template)
+ // Menu.setApplicationMenu(menu)
+
+
+ const template = [
+ {
+ label: 'Edit',
+ submenu: [
+ {role: 'undo'},
+ {role: 'redo'},
+ {type: 'separator'},
+ {role: 'cut'},
+ {role: 'copy'},
+ {role: 'paste'},
+ {role: 'pasteandmatchstyle'},
+ {role: 'delete'},
+ {role: 'selectall'}
+ ]
+ },
+ {
+ label: 'View',
+ submenu: [
+ {role: 'reload'},
+ {role: 'forcereload'},
+ {role: 'toggledevtools'},
+ {type: 'separator'},
+ {role: 'resetzoom'},
+ {role: 'zoomin'},
+ {role: 'zoomout'},
+ {type: 'separator'},
+ {role: 'togglefullscreen'}
+ ]
+ },
+ {
+ role: 'window',
+ submenu: [
+ {role: 'minimize'},
+ {role: 'close'}
+ ]
+ },
+ {
+ role: 'help',
+ submenu: [
+ {
+ label: 'Learn More',
+ click () { require('electron').shell.openExternal('https://electronjs.org') }
+ }
+ ]
+ }
+ ]
+
+ if (process.platform === 'darwin') {
+ template.unshift({
+ label: app.getName(),
+ submenu: [
+ {role: 'about'},
+ {type: 'separator'},
+ {role: 'services', submenu: []},
+ {type: 'separator'},
+ {role: 'hide'},
+ {role: 'hideothers'},
+ {role: 'unhide'},
+ {type: 'separator'},
+ {role: 'quit'}
+ ]
+ })
+
+ // Edit menu
+ template[1].submenu.push(
+ {type: 'separator'},
+ {
+ label: 'Speech',
+ submenu: [
+ {role: 'startspeaking'},
+ {role: 'stopspeaking'}
+ ]
+ }
+ )
+
+ // Window menu
+ template[3].submenu = [
+ {role: 'close'},
+ {role: 'minimize'},
+ {role: 'zoom'},
+ {type: 'separator'},
+ {role: 'front'}
+ ]
+ }
+
+ const menu = Menu.buildFromTemplate(template);
+ Menu.setApplicationMenu(menu);
+
// Open the DevTools.
//win.webContents.openDevTools();
-
// Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store windows