Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
/ Orion Public archive

Feature/105 add tray icon #101

Merged
merged 7 commits into from
May 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function startIPFSDaemon () {
ipfsProcess.stderr.pipe(tmpLogPipe)

ipfsProcess.on('close', (exit) => {
if (exit !== 0) {
if (exit !== 0 && exit !== null) {
let msg = `IPFS Daemon was closed with exit code ${exit}. `
msg += 'The app will be closed. Try again. '
msg += `Log file: ${tmpLog.name}`
Expand Down
17 changes: 7 additions & 10 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { join as pathJoin } from 'path'
import pjson from '../package.json'
import './report'
import rootDir from 'app-root-dir'
import setupTrayIcon from './setup-tray-icon'

import {
startIPFSDaemon,
Expand Down Expand Up @@ -72,6 +73,11 @@ function askWhichNodeToUse (apiVersion) {
}

app.on('ready', () => {
// On MacOS it's expected for the app not to close, and to re-open it from Launchpad
if (process.platform !== 'darwin') {
setupTrayIcon()
}

// Ask github whether there is an update
autoUpdater.checkForUpdates()
autoUpdater.on('update-available', (info) => {
Expand Down Expand Up @@ -234,17 +240,8 @@ app.on('ready', () => {
})
})

// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// Re-create the window in the app when the
// dock icon is clicked and there are no other windows open.
if (app.mainWindow) {
app.mainWindow.once('ready-to-show', () => {
Expand Down
35 changes: 35 additions & 0 deletions app/setup-tray-icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import path from 'path'
import { app, Menu, Tray, nativeImage } from 'electron'

let appTray = null
const iconPath = path.join(__dirname, '../docs/logo.png')
const icon = nativeImage.createFromPath(iconPath)

/**
* This will setup a tray icon for the app,
* which allows the user to:
* - open the main window (StorageWindow)
* - quit the app.
*/
function setupTrayIcon () {
appTray = new Tray(icon)
const contextMenu = Menu.buildFromTemplate([
{
label: 'Open Siderus Orion',
click () {
app.emit('activate')
}
},
{
label: 'Quit',
click () {
app.quit()
}
}
])

// Call this again for Linux because we modified the context menu
appTray.setContextMenu(contextMenu)
}

export default setupTrayIcon
2 changes: 1 addition & 1 deletion docs/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Orion apps requires the following dependencies installed:
Ubuntu Linux Users instead needs specific packages to be installed:

```
# apt-get install libgtkextra-dev libgconf2-dev libnss3 libasound2 libxtst-dev
# apt-get install libgtkextra-dev libgconf2-dev libnss3 libasound2 libxtst-dev gconf2 gconf-service libnotify4 libappindicator1 libxtst6 libnss3 libxss1
```

## Clone the source
Expand Down
2 changes: 1 addition & 1 deletion docs/RUN.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Orion apps requires the following dependencies installed:
Ubuntu Linux Users instead needs specific packages to be installed:

```
apt-get install libgtkextra-dev libgconf2-dev libnss3 libasound2 libxtst-dev
apt-get install libgtkextra-dev libgconf2-dev libnss3 libasound2 libxtst-dev gconf2 gconf-service libnotify4 libappindicator1 libxtst6 libnss3 libxss1
```

Windows users need to install the [windows-build-tools](https://github.com/felixrieseberg/windows-build-tools) package, which comes with
Expand Down