Skip to content

Commit

Permalink
feat(wip): show filled image
Browse files Browse the repository at this point in the history
  • Loading branch information
asantos00 authored and fsschmitt committed Mar 9, 2020
1 parent 3ea975b commit b211384
Show file tree
Hide file tree
Showing 4 changed files with 260 additions and 50 deletions.
109 changes: 62 additions & 47 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,92 @@
const { app, BrowserWindow, Menu, ipcMain } = require('electron')
const path = require('path')
const appSettings = require('./electron/appSettings');
const { app, BrowserWindow, Menu, ipcMain } = require("electron");
const path = require("path");
const appSettings = require("./electron/appSettings");
let win;
let isDev = !app.isPackaged
let isDev = !app.isPackaged;

require('./electron/eventBus');
!isDev && require('./shared/sentry');
require("./electron/eventBus");
!isDev && require("./shared/sentry");

const getBrowserWindowInstance = () => {
return new BrowserWindow({
show: false,
width: 560,
height: 690,
center: true,
resizable: isDev,
webPreferences: {
nodeIntegration: true,
scrollBounce: true,
devTools: isDev,
preload: path.join(__dirname, 'shared', 'sentry.js'),
nativeWindowOpen: true
},
icon: path.join(__dirname, 'assets/icons/icon.png')
})
}

function createWindow() {
// Create the browser window.
win = new BrowserWindow({
show: false,
width: 560,
height: 690,
center: true,
resizable: isDev,
webPreferences: {
nodeIntegration: true,
scrollBounce: true,
devTools: isDev,
preload: path.join(__dirname, 'shared', 'sentry.js')
},
icon: path.join(__dirname, 'assets/icons/icon.png')
})

win = getBrowserWindowInstance();
isDev && win.webContents.openDevTools();

const menu = Menu.buildFromTemplate([
{ role: 'fileMenu' },
{ role: 'editMenu'},
{ role: "fileMenu" },
{ role: "editMenu" },
{
label: 'Debug',
submenu: [
{
label: 'Show browser',
click() {
appSettings.toggle('showBrowser');
},
type: 'checkbox',
checked: appSettings.get('showBrowser'),
accelerator: 'CmdOrCtrl+Shift+B'
label: "Debug",
submenu: [
{
label: "Show browser",
click() {
appSettings.toggle("showBrowser");
},
]
type: "checkbox",
checked: appSettings.get("showBrowser"),
accelerator: "CmdOrCtrl+Shift+B"
}
]
}
])
]);
Menu.setApplicationMenu(menu);

win.once('ready-to-show', () => {
win.show()
})
win.once("ready-to-show", () => {
win.show();
});

// and load the index.html of the app.
win.loadURL(
isDev
? 'http://localhost:1234/'
? "http://localhost:1234/"
: `file://${path.join(__dirname, "./dist/index.html")}`
)
);

win.webContents.on("new-window", function(event, url) {
win.webContents.on("new-window", function(event, url, frameName, disposition, options) {
event.preventDefault();
if (frameName === "modal") {
// open window as modal
event.preventDefault();
Object.assign(options, {
modal: true,
parent: win,
width: 500,
height: 500
});
event.newGuest = new BrowserWindow(options);
}
});

win.on("closed", () => (win = null));
}

app.whenReady().then(createWindow)
app.whenReady().then(createWindow);

ipcMain.on('anteater.error', () => {
console.log('Error triggered in main processes');
throw new Error('Error triggered in main processes');
ipcMain.on("anteater.error", () => {
console.log("Error triggered in main processes");
throw new Error("Error triggered in main processes");
});

ipcMain.on('anteater.crash', () => {
console.log('process.crash()');
ipcMain.on("anteater.crash", () => {
console.log("process.crash()");
process.crash();
});
Loading

0 comments on commit b211384

Please sign in to comment.