Skip to content

Commit

Permalink
Merge pull request #890 from renative-org/fix/electron_linux_windows_fix
Browse files Browse the repository at this point in the history
fix: electron for windows and linux
  • Loading branch information
mihaiblaga89 committed Jul 7, 2022
2 parents 61effc0 + 6db8653 commit efb3206
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
// This file is generated by ReNative.
// To override it simply copy/create ./appConfigs/base/builds/linux/contextMenu.js file
// To override it simply copy/create ./appConfigs/base/builds/macos/contextMenu.js file

const { Menu } = require('electron');
const { app, Menu } = require('electron');

let createWindow;

const template = [
// { role: 'appMenu' }
...[],
...[{
label: app.name,
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideothers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' }
]
}],
// { role: 'fileMenu' }
{
label: 'File',
submenu: [
isMac ? { role: 'close' } : { role: 'quit' }
{ role: 'close' }
]
},
// { role: 'editMenu' }
Expand All @@ -26,9 +39,17 @@ const template = [
{ role: 'copy' },
{ role: 'paste' },
...[
{ role: 'pasteAndMatchStyle' },
{ role: 'delete' },
{ role: 'selectAll' },
{ type: 'separator' },
{ role: 'selectAll' }
{
label: 'Speech',
submenu: [
{ role: 'startspeaking' },
{ role: 'stopspeaking' }
]
}
]
]
},
Expand All @@ -54,7 +75,15 @@ const template = [
{ role: 'minimize' },
{ role: 'zoom' },
...[
{ role: 'close' }
{ type: 'separator' },
{ role: 'front' },
{ type: 'separator' },
{
label: app.name,
click: async () => {
if (!mainWindow) createWindow();
}
}
]
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Modules to control application life and create native browser window
const { app, BrowserWindow } = require('electron');
const { app, BrowserWindow, nativeImage } = require('electron');
const { initContextMenu } = require('./contextMenu')
if(initContextMenu) initContextMenu(createWindow)

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
Expand Down Expand Up @@ -57,5 +59,4 @@ app.on('activate', () => {
}
});

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
{{PLUGIN_INJECT_MAIN_PROCESS}}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Modules to control application life and create native browser window
const { app, BrowserWindow } = require('electron');
const { app, BrowserWindow, nativeImage } = require('electron');
const { initContextMenu } = require('./contextMenu')
if(initContextMenu) initContextMenu(createWindow)


// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
Expand Down Expand Up @@ -46,5 +49,4 @@ app.on('activate', () => {
}
});

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
{{PLUGIN_INJECT_MAIN_PROCESS}}
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,11 @@ app.on('activate', () => {
}
});

const isMacos = process.platform === 'darwin';

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

// This applies logo to the application when it is displayed in the dock on macOS
if (isMacos) {
const image = nativeImage.createFromPath("{{PLUGIN_INJECT_ICON_LOCATION}}");
app.dock.setIcon(image);
}
const image = nativeImage.createFromPath("{{PLUGIN_INJECT_ICON_LOCATION}}");
app.dock.setIcon(image);

{{PLUGIN_INJECT_MAIN_PROCESS}}
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,11 @@ app.on('activate', () => {
}
});

const isMacos = process.platform === 'darwin';

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

// This applies logo to the application when it is displayed in the dock on macOS
if (isMacos) {
const image = nativeImage.createFromPath("{{PLUGIN_INJECT_ICON_LOCATION}}");
app.dock.setIcon(image);
}
const image = nativeImage.createFromPath("{{PLUGIN_INJECT_ICON_LOCATION}}");
app.dock.setIcon(image);

{{PLUGIN_INJECT_MAIN_PROCESS}}
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
// This file is generated by ReNative.
// To override it simply copy/create ./appConfigs/base/builds/windows/contextMenu.js file
// To override it simply copy/create ./appConfigs/base/builds/macos/contextMenu.js file

const { Menu } = require('electron');
const { app, Menu } = require('electron');

let createWindow;

const template = [
// { role: 'appMenu' }
...[],
...[{
label: app.name,
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideothers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' }
]
}],
// { role: 'fileMenu' }
{
label: 'File',
submenu: [
isMac ? { role: 'close' } : { role: 'quit' }
{ role: 'close' }
]
},
// { role: 'editMenu' }
Expand All @@ -26,9 +39,17 @@ const template = [
{ role: 'copy' },
{ role: 'paste' },
...[
{ role: 'pasteAndMatchStyle' },
{ role: 'delete' },
{ role: 'selectAll' },
{ type: 'separator' },
{ role: 'selectAll' }
{
label: 'Speech',
submenu: [
{ role: 'startspeaking' },
{ role: 'stopspeaking' }
]
}
]
]
},
Expand All @@ -54,7 +75,15 @@ const template = [
{ role: 'minimize' },
{ role: 'zoom' },
...[
{ role: 'close' }
{ type: 'separator' },
{ role: 'front' },
{ type: 'separator' },
{
label: app.name,
click: async () => {
if (!mainWindow) createWindow();
}
}
]
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Modules to control application life and create native browser window
const { app, BrowserWindow } = require('electron');
const { app, BrowserWindow, nativeImage } = require('electron');
const { initContextMenu } = require('./contextMenu')
if(initContextMenu) initContextMenu(createWindow)

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
Expand Down Expand Up @@ -57,5 +59,4 @@ app.on('activate', () => {
}
});

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
{{PLUGIN_INJECT_MAIN_PROCESS}}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Modules to control application life and create native browser window
const { app, BrowserWindow } = require('electron');
const { app, BrowserWindow, nativeImage } = require('electron');
const { initContextMenu } = require('./contextMenu')
if(initContextMenu) initContextMenu(createWindow)


// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
Expand Down Expand Up @@ -46,5 +49,4 @@ app.on('activate', () => {
}
});

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
{{PLUGIN_INJECT_MAIN_PROCESS}}

0 comments on commit efb3206

Please sign in to comment.