Skip to content

Commit

Permalink
v2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sidneys committed Feb 27, 2017
1 parent 87cda63 commit 1dae354
Show file tree
Hide file tree
Showing 28 changed files with 739 additions and 438 deletions.
17 changes: 9 additions & 8 deletions .travis.yml
Expand Up @@ -26,6 +26,7 @@ cache:
addons:
apt:
packages:
- bsdtar
- icnsutils
- gcc-multilib
- g++-multilib
Expand All @@ -34,28 +35,28 @@ addons:
- xz-utils

before_install:
- echo "Installing nvm"
- curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | NVM_DIR=$HOME/.nvm sh
- source $HOME/.nvm/nvm.sh
- nvm install 7.2.1
- nvm use 7.2.1
- nvm install 7.6.0
- nvm use 7.6.0

install:
- echo "Installing dependencies"
- npm install

before_script:
- echo "Deploying artifacts from $ARTIFACTS_DIRECTORY"

script:
- echo "Building artifacts"
- npm run-script build

after_success:
- echo "Deploying artifacts"
- npm run-script deploy:github

notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/a1a9de50af1c703bfe6c
- https://updates-desktop-dimmer.herokuapp.com/webhook
on_success: always
on_failure: never
on_success: change
on_failure: always
on_start: never
3 changes: 2 additions & 1 deletion app/html/controller.html
@@ -1,9 +1,10 @@
<!DOCTYPE html>
<html class="controller">
<head>
<title>Controller</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../vendor/material-icons.css">
<link rel="stylesheet" type="text/css" href="../vendor/roboto.css">
<link rel="stylesheet" type="text/css" href="../vendor/color-picker.css">
<link rel="stylesheet" type="text/css" href="../styles/styles.css">
</head>
<body>
Expand Down
3 changes: 2 additions & 1 deletion app/html/overlay.html
@@ -1,8 +1,9 @@
<!DOCTYPE html>
<html class="overlay">
<head>
<title>Overlay</title>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="../styles/styles.css">
</head>
<body>
<script src="../scripts/renderer/overlay.js"></script>
Expand Down
9 changes: 7 additions & 2 deletions app/html/preferences.html
@@ -1,8 +1,10 @@
<!DOCTYPE html>
<html class="settings">
<html class="preferences">
<head>
<title></title>
<title>Preferences</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../vendor/photon.css">
<link rel="stylesheet" type="text/css" href="../styles/styles.css">
</head>
<body>
<div class="window padded">
Expand All @@ -17,6 +19,9 @@
</div>
</div>
</form>

<div class="name"></div>
<div class="version"></div>
</div>

<script src="../scripts/renderer/preferences.js"></script>
Expand Down
156 changes: 79 additions & 77 deletions app/scripts/components/application.js
Expand Up @@ -17,24 +17,16 @@ const util = require('util');
* @global
* @constant
*/
const electron = require('electron');
const { app, ipcMain } = electron;
//const electron = require('electron');
const Menubar = require('menubar');

/**
* Chrome Commandline Switches
*/
if ((os.platform() === 'linux')) {
app.commandLine.appendSwitch('enable-transparent-visuals');
app.commandLine.appendSwitch('disable-gpu');
}

/**
* Modules
* External
* @global
* @constant
*/
const menubar = require('menubar');
const appRootPath = require('app-root-path').path;
const electronSettings = require('electron-settings');
const electronConnect = require('electron-connect');
Expand All @@ -48,16 +40,10 @@ const electronConnect = require('electron-connect');

const packageJson = require(path.join(appRootPath, 'package.json'));
const platformHelper = require(path.join(appRootPath, 'lib', 'platform-helper'));
const overlayManager = require(path.join(appRootPath, 'app', 'scripts', 'components', 'overlay-manager'));
const trayMenu = require(path.join(appRootPath, 'app', 'scripts', 'menus', 'tray-menu'));
const logger = require(path.join(appRootPath, 'lib', 'logger'))({ writeToFile: true });
const isDebug = require(path.join(appRootPath, 'lib', 'is-debug'));
const isLivereload = require(path.join(appRootPath, 'lib', 'is-livereload'));
/* jshint ignore:start */
const screenManager = require(path.join(appRootPath, 'app', 'scripts', 'components', 'screen-manager'));
const preferencesWindow = require(path.join(appRootPath, 'app', 'scripts', 'windows', 'preferences-window'));
const updaterService = require(path.join(appRootPath, 'app', 'scripts', 'services', 'updater-service'));
/* jshint ignore:end */


/**
* URLS
Expand All @@ -71,57 +57,78 @@ const controllerUrl = url.format({
* App
* @global
*/
const appName = packageJson.name;
const appVersion = packageJson.version;

/**
* Paths
* @global
*/
const appTrayIconEnabled = path.join(appRootPath, 'icons', platformHelper.type, 'icon-tray-enabled' + platformHelper.templateImageExtension(platformHelper.name));
const appTrayIconEnabled = path.join(appRootPath, 'icons', platformHelper.type, `icon-tray-default${platformHelper.templateImageExtension(platformHelper.name)}`);

/**
* Create reference for App Menubar Controller (Menubar)
* Menubar Controller (Menubar)
* @global
* @constant
*/
const appMenubar = menubar({
width: 256,
minWidth: 256,
maxWidth: 256,
const menubar = Menubar({
alwaysOnTop: isDebug,
backgroundColor: platformHelper.isMacOS ? null : '#404040',
hasShadow: false,
height: 48,
minHeight: 48,
preloadWindow: true,
icon: appTrayIconEnabled,
index: controllerUrl,
alwaysOnTop: isDebug === true,
backgroundColor: platformHelper.isMacOS ? null : '#404040',
maxWidth: 256,
minHeight: 48,
minWidth: 256,
preloadWindow: true,
showDockIcon: isDebug,
vibrancy: 'dark',
hasShadow: false
width: 256,
});
global.menubar = menubar;

/**
* Modules
* Internal
* @global
* @constant
*/
const trayMenu = require(path.join(appRootPath, 'app', 'scripts', 'menus', 'tray-menu'));
const overlayManager = require(path.join(appRootPath, 'app', 'scripts', 'components', 'overlay-manager')); // jshint ignore:line
const screenManager = require(path.join(appRootPath, 'app', 'scripts', 'components', 'screen-manager')); // jshint ignore:line
const updaterService = require(path.join(appRootPath, 'app', 'scripts', 'services', 'updater-service')); // jshint ignore:line
const preferencesWindow = require(path.join(appRootPath, 'app', 'scripts', 'windows', 'preferences-window')); // jshint ignore:line


/**
* GPU Settings
* @global
*/
menubar.app.disableHardwareAcceleration();
if ((os.platform() === 'linux')) {
menubar.app.commandLine.appendSwitch('enable-transparent-visuals');
}


/**
* Settings Defaults
* @property {String} internal.currentVersion - Application Version
* @property {Boolean} internal.updatePending - Hashmap
* @property {Object} internal.overlays - Hashmap
* @property {Number} display.id- Play Notification Sound
* @property {Number} display.alpha - Autostart
* @property {String} display.color - Show recent pushes
* @property {String} currentVersion - Application Version
* @property {Object} overlays - Hashmap
* @property {Boolean} launchOnStartup - Auto launch
*/
let settingsDefaults = {
internal: {
currentVersion: appVersion,
overlays: {}
},
user: {
launchOnStartup: false
}
currentVersion: appVersion,
overlays: {},
launchOnStartup: false
};

/**
* Init Settings
*/
let initializeSettings = () => {
logger.debug('application', 'initializeSettings()');

// Settings Defaults
electronSettings.defaults(settingsDefaults);
electronSettings.applyDefaultsSync();
Expand All @@ -131,64 +138,59 @@ let initializeSettings = () => {
prettify: true,
atomicSaving: true
});

logger.log('settings', `settingsFilePath: '${electronSettings.getSettingsFilePath()}'`);
logger.debug('settings', util.inspect(electronSettings.getSync()));
};


/**
* @listens app#quit
* @listens menubar#quit
*/
app.on('quit', () => {
logger.log('settings', `settingsFilePath: '${electronSettings.getSettingsFilePath()}'`);
logger.debug('settings', util.inspect(electronSettings.getSync()));
menubar.app.on('before-quit', () => {
logger.debug('application', electronSettings.getSettingsFilePath());
logger.debug('application', util.inspect(electronSettings.getSync()));
});

/**
* @listens app#ready
* @listens menubar#after-create-window
*/
app.on('ready', () => {
global.appMenubar = appMenubar;
menubar.on('after-create-window', () => {
logger.debug('application', 'menubar:after-create-window');

initializeSettings();
overlayManager.create();

if (platformHelper.isLinux) {
trayMenu.add(appMenubar.tray);
trayMenu.add(menubar.tray);
}

// DEBUG
logger.log('application', 'ready');

// DEBUG
if (isDebug) {
appMenubar.window.webContents.openDevTools({ mode: 'detach' });
}
if (isLivereload) {
appMenubar.window.webContents.openDevTools({ mode: 'detach' });
const electronConnectClient = electronConnect.client;
electronConnectClient.create();
}
/**
* @listens Electron#WebContents:dom-ready
*/
menubar.window.webContents.on('dom-ready', () => {
logger.debug('application', 'menubar:dom-ready');

// DEBUG
if (isDebug) {
menubar.window.webContents.openDevTools({ mode: 'detach' });
}
if (isLivereload) {
electronConnect.client.create();
}
});
});

/**
* @listens appMenubar#hide
* @listens menubar#hide
*/
appMenubar.on('hide', () => {
appMenubar.window.webContents.send('controller-hide');
});
menubar.on('hide', () => {
logger.debug('application', 'menubar:hide');

/**
* @listens appMenubar#show
*/
appMenubar.on('show', () => {
appMenubar.window.webContents.send('controller-show');
menubar.window.webContents.send('controller-hide');
});

/**
* @listens ipcMain#log
* @listens menubar#show
*/
ipcMain.on('log', (event, message) => {
logger.log('renderer', message);
menubar.on('show', () => {
logger.debug('application', 'menubar:show');

menubar.window.webContents.send('controller-show');
});

0 comments on commit 1dae354

Please sign in to comment.