This repository has been archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #332 from paritytech/luke-312-taskbar-app
feat: Relates to #312. Taskbar app
- Loading branch information
Showing
80 changed files
with
1,854 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
plugins: [['@babel/plugin-proposal-class-properties', { loose: false }]], | ||
presets: ['@babel/preset-env'] | ||
}; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// Copyright 2015-2018 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
import EventEmitter from 'events'; | ||
|
||
import { | ||
calculateWinPosition, | ||
createPositioner, | ||
createTray, | ||
createWindow, | ||
fixWinPosition, | ||
getScreenResolution, | ||
hideWindow, | ||
loadTray, | ||
moveWindowUp, | ||
onTrayClick, | ||
onWindowClose, | ||
processSaveWinPosition, | ||
setupAppListeners, | ||
setupDebug, | ||
setupGlobals, | ||
setupLogger, | ||
setupMenu, | ||
setupParityEthereum, | ||
setupRequestListeners, | ||
setupSecurity, | ||
setupWinListeners, | ||
setupWin32Listeners, | ||
showTrayBalloon, | ||
showWindow, | ||
updateProgress, | ||
windowClear | ||
} from './methods'; | ||
|
||
let hasCalledInitFetherApp = false; | ||
|
||
class FetherApp extends EventEmitter { | ||
constructor (electronApp, options) { | ||
super(); | ||
|
||
if (hasCalledInitFetherApp) { | ||
this.emit( | ||
'error', | ||
new Error('Unable to initialise Fether app more than once') | ||
); | ||
} | ||
|
||
/** | ||
* After the Fether instance and fetherApp.win has been created. | ||
* If the user then chooses from the Fether Menu "Window > Close" | ||
* it runs windowClear, which deletes fetherApp.win and associated | ||
* listeners since the 'close' event also occurs when the user exits. | ||
* If the user then clicks the tray icon to re-open the Fether window, | ||
* it will run the onTrayClick method, which calls fetherApp.showWindow | ||
* and if fetherApp.win does not exist, it runs showWindow and createWindow | ||
* to restore create fetherApp.win again and associated listeners. However we | ||
* do not need to run all the fetherApp methods again like we did on the | ||
* when fetherApp.win was first created (i.e. createTray, loadTray, | ||
* setupDebug, setupSecurity, setupLogger, setupParityEthereum, setupGlobals) | ||
*/ | ||
this.app = electronApp; | ||
this.options = options; | ||
|
||
this.createWindow(); | ||
this.updateProgress(0.4, undefined); | ||
|
||
// These methods are called only once when Fether instance is created | ||
// (i.e. not called again when the Fether window closed and re-opened) | ||
this.createTray(); | ||
this.loadTray(); | ||
this.setupDebug(); | ||
this.setupSecurity(); | ||
this.setupLogger(); | ||
this.setupParityEthereum(); | ||
this.setupGlobals(); | ||
|
||
this.updateProgress(0.8, undefined); | ||
this.showWindow(undefined); | ||
this.updateProgress(1.0, undefined); | ||
this.updateProgress(-1, 'after-create-app'); | ||
} | ||
|
||
calculateWinPosition = () => calculateWinPosition(this); | ||
createPositioner = () => createPositioner(this); | ||
createTray = () => createTray(this); | ||
createWindow = () => createWindow(this); | ||
fixWinPosition = positionStruct => fixWinPosition(this, positionStruct); | ||
getScreenResolution = () => getScreenResolution(); | ||
hideWindow = () => hideWindow(this); | ||
loadTray = () => loadTray(this); | ||
moveWindowUp = () => moveWindowUp(this); | ||
onTrayClick = (e, bounds) => onTrayClick(this, e, bounds); | ||
onWindowClose = () => onWindowClose(this); | ||
processSaveWinPosition = () => processSaveWinPosition(this); | ||
setupAppListeners = () => setupAppListeners(this); | ||
setupDebug = () => setupDebug(this); | ||
setupGlobals = () => setupGlobals(); | ||
setupLogger = () => setupLogger(); | ||
setupMenu = () => setupMenu(this); | ||
setupParityEthereum = () => setupParityEthereum(this); | ||
setupRequestListeners = () => setupRequestListeners(this); | ||
setupSecurity = () => setupSecurity(this); | ||
setupWinListeners = () => setupWinListeners(this); | ||
setupWin32Listeners = () => setupWin32Listeners(this); | ||
showTrayBalloon = () => showTrayBalloon(this); | ||
showWindow = trayPos => showWindow(this, trayPos); | ||
updateProgress = (percentage, eventListenerName) => | ||
updateProgress(this, percentage, eventListenerName); | ||
windowClear = () => windowClear(this); | ||
} | ||
|
||
export default FetherApp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2015-2018 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
import electron from 'electron'; | ||
import { template } from './template'; | ||
|
||
const { Menu } = electron; | ||
|
||
const menu = Menu.buildFromTemplate(template); | ||
|
||
const getMenu = () => { | ||
return Menu.getApplicationMenu(); | ||
}; | ||
|
||
const addMenu = () => { | ||
Menu.setApplicationMenu(menu); | ||
}; | ||
|
||
export { addMenu, getMenu }; |
87 changes: 87 additions & 0 deletions
87
packages/fether-electron/src/main/app/menu/template/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright 2015-2018 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
import electron from 'electron'; | ||
|
||
const { app, shell } = electron; | ||
|
||
// Create the Application's main menu | ||
// https://github.com/electron/electron/blob/master/docs/api/menu.md#examples | ||
export const template = [ | ||
{ | ||
label: 'Edit', | ||
submenu: [ | ||
{ role: 'cut' }, | ||
{ role: 'copy' }, | ||
{ role: 'paste' }, | ||
{ 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 () { | ||
shell.openExternal('https://parity.io'); | ||
} | ||
} | ||
] | ||
} | ||
]; | ||
|
||
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' } | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.