Skip to content

Commit

Permalink
v3.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sidneys committed Jan 28, 2017
1 parent 7c941bc commit b1757a4
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 85 deletions.
107 changes: 39 additions & 68 deletions app/scripts/configuration/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,6 @@ let setShowOnlyInTray = function(setShowOnlyInTray) {
};


/**
* Show App in Dock / Taskbar
* @param {Boolean} isVisible - True: show dock icon, false: hide icon
*/
let setIsVisible = function(isVisible) {
logger.debug('settings', 'setIsVisible()', isVisible);

if (isVisible) {
getPrimaryWindow().show();
} else { getPrimaryWindow().hide(); }
};


/**
* Items
Expand All @@ -148,7 +136,7 @@ let configurationItems = {
set(currentVersion) {
logger.debug('settings', this.keypath, 'set()');

electronSettings.setSync(this.keypath, currentVersion);
electronSettings.set(this.keypath, currentVersion).then(() => {});
}
},
/** Show Window */
Expand All @@ -162,12 +150,13 @@ let configurationItems = {
logger.debug('settings', this.keypath, 'init()');

// Apply
this.apply(this.get());
this.implement(this.get());

/** @listens Electron.BrowserWindow#on */
getPrimaryWindow().on('show', () => { this.set(true); });
getPrimaryWindow().on('hide', () => { this.set(false); });
getPrimaryWindow().webContents.on('dom-ready', () => { this.apply(this.get()); });
/** @listens Electron~WebContents#on */
getPrimaryWindow().webContents.on('dom-ready', () => { this.implement(this.get()); });
},
get(){
logger.debug('settings', this.keypath, 'get()');
Expand All @@ -177,14 +166,18 @@ let configurationItems = {
set(isVisible){
logger.debug('settings', this.keypath, 'set()', isVisible);

this.apply(isVisible);
electronSettings.setSync(this.keypath, isVisible);
},
apply(isVisible){
logger.debug('settings', this.keypath, 'apply()', isVisible);

setIsVisible(isVisible);
electronSettings.set(this.keypath, isVisible).then(() => {});
},
implement(isVisible){
logger.debug('settings', this.keypath, 'implement()', isVisible);

if (isVisible) {
getPrimaryWindow().show();
}
else {
getPrimaryWindow().hide();
}
}
},
/** Last Push Timestamp */
lastNotification: {
Expand All @@ -204,7 +197,7 @@ let configurationItems = {
set(lastNotification) {
logger.debug('settings', this.keypath, 'set()');

electronSettings.setSync(this.keypath, lastNotification);
electronSettings.set(this.keypath, lastNotification).then(() => {});
}
},
/** Autostart */
Expand All @@ -225,11 +218,11 @@ let configurationItems = {
set(launchOnStartup){
logger.debug('settings', this.keypath, 'set()', launchOnStartup);

this.apply(launchOnStartup);
electronSettings.setSync(this.keypath, launchOnStartup);
this.implement(launchOnStartup);
electronSettings.set(this.keypath, launchOnStartup).then(() => {});
},
apply(launchOnStartup){
logger.debug('settings', this.keypath, 'apply()', launchOnStartup);
implement(launchOnStartup){
logger.debug('settings', this.keypath, 'implement()', launchOnStartup);

if (launchOnStartup) { autoLauncher.enable(); }
else { autoLauncher.disable(); }
Expand All @@ -253,7 +246,7 @@ let configurationItems = {
set(logFile) {
logger.debug('settings', this.keypath, 'set()');

electronSettings.setSync(this.keypath, logFile);
electronSettings.set(this.keypath, logFile).then(() => {});
}
},
/** Play Sounds */
Expand All @@ -274,7 +267,7 @@ let configurationItems = {
set(soundVolume) {
logger.debug('settings', this.keypath, 'set()');

electronSettings.setSync(this.keypath, soundVolume);
electronSettings.set(this.keypath, soundVolume).then(() => {});
}
},
/** Show recent pushes */
Expand All @@ -295,7 +288,7 @@ let configurationItems = {
set(soundVolume) {
logger.debug('settings', this.keypath, 'set()');

electronSettings.setSync(this.keypath, soundVolume);
electronSettings.set(this.keypath, soundVolume).then(() => {});
}
},
/** Show Main Window */
Expand All @@ -309,12 +302,12 @@ let configurationItems = {
logger.debug('settings', this.keypath, 'init()');

// Apply
this.apply(this.get());
this.implement(this.get());

/** @listens Electron.BrowserWindow#on */
getPrimaryWindow().on('show-only-in-tray', (showOnlyInTray) => {
logger.debug('settings', this.keypath, 'BrowserWindow:show-only-in-tray');
this.apply(showOnlyInTray);
this.implement(showOnlyInTray);
this.set(showOnlyInTray);
});
},
Expand All @@ -326,11 +319,11 @@ let configurationItems = {
set(showOnlyInTray) {
logger.debug('settings', this.keypath, 'set()');

this.apply(showOnlyInTray);
electronSettings.setSync(this.keypath, showOnlyInTray);
this.implement(showOnlyInTray);
electronSettings.set(this.keypath, showOnlyInTray).then(() => {});
},
apply(showOnlyInTray) {
logger.debug('settings', this.keypath, 'apply()', showOnlyInTray);
implement(showOnlyInTray) {
logger.debug('settings', this.keypath, 'implement()', showOnlyInTray);

setShowOnlyInTray(showOnlyInTray);
}
Expand Down Expand Up @@ -360,11 +353,11 @@ let configurationItems = {
},
set(soundFile) {
logger.debug('settings', this.keypath, 'set()');
electronSettings.setSync(this.keypath, soundFile);
electronSettings.set(this.keypath, soundFile).then(() => {});
},
apply(){
implement(){
messengerService.openFile('Change Sound', 'audio', appSoundDirectory, (error, soundFile) => {
logger.debug('settings', this.keypath, 'apply()', soundFile);
logger.debug('settings', this.keypath, 'implement()', soundFile);

if (error) {
logger.error('settings', error.message);
Expand Down Expand Up @@ -393,7 +386,7 @@ let configurationItems = {
set(soundVolume) {
logger.debug('settings', this.keypath, 'set()');

electronSettings.setSync(this.keypath, soundVolume);
electronSettings.set(this.keypath, soundVolume).then(() => {});
}
},
/** Window position and size */
Expand All @@ -407,12 +400,11 @@ let configurationItems = {
logger.debug('settings', this.keypath, 'init()');

// Apply
this.apply(this.get());

this.implement(this.get());

/** @listens Electron.BrowserWindow#on */
getPrimaryWindow().on('move', () => { this.set(getPrimaryWindow().getBounds()); });
getPrimaryWindow().on('resize', () => { this.set(getPrimaryWindow().getBounds()); });
getPrimaryWindow().webContents.on('dom-ready', () => { this.apply(this.get()); });
},
get(){
logger.debug('settings', this.keypath, 'get()');
Expand All @@ -422,11 +414,10 @@ let configurationItems = {
set(windowBounds){
logger.debug('settings', this.keypath, 'set()', JSON.stringify(windowBounds));

this.apply(this.get());
electronSettings.setSync(this.keypath, windowBounds);
electronSettings.set(this.keypath, windowBounds).then(() => {});
},
apply(windowBounds){
logger.debug('settings', this.keypath, 'apply()', JSON.stringify(windowBounds));
implement(windowBounds){
logger.debug('settings', this.keypath, 'implement()', JSON.stringify(windowBounds));

getPrimaryWindow().setBounds(windowBounds);
}
Expand Down Expand Up @@ -478,25 +469,6 @@ let initConfigurationItems = () => {
}, defaultInterval);
};

/**
* Handle App Settings Click
* @param {Electron.MenuItem} menuItem - Menu item
* @param {Object} settingsInstance - electron-settings instance
* @param {String=} settingKeypath - Nested Keypath to registrable settings, e.g. 'options.app'
* @param {Object=} eventObject - Optionally attach behaviour to options
*/
let toggleSettingsProperty = function(menuItem, settingsInstance, settingKeypath, eventObject) {
let itemKeypath = settingKeypath;

settingsInstance.setSync(itemKeypath, menuItem.checked);

let handler = keypath(itemKeypath, eventObject);

if (_.isFunction(handler)) {
handler(menuItem);
}
};


app.on('ready', () => {
// Settings Defaults
Expand All @@ -523,6 +495,5 @@ module.exports = {
electronSettings: electronSettings,
getConfigurationItem: getConfigurationItem,
setShowAppWindow: setShowOnlyInTray,
settingsDefaults: getConfigurationDefaults(),
toggleSettingsProperty: toggleSettingsProperty
settingsDefaults: getConfigurationDefaults()
};
18 changes: 9 additions & 9 deletions app/scripts/menus/tray-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ const appVersion = packageJson.version;
* @global
* @constant
*/
const appTrayIconDefault = path.join(appRootPath, 'icons', platformHelper.type, `icon-tray-default-${platformHelper.templateImageExtension(platformHelper.type)}`);
const appTrayIconTransparent = path.join(appRootPath, 'icons', platformHelper.type, `icon-tray-transparent-${platformHelper.templateImageExtension(platformHelper.type)}`);
const appTrayIconPaused = path.join(appRootPath, 'icons', platformHelper.type, `icon-tray-paused-${platformHelper.templateImageExtension(platformHelper.type)}`);
const appTrayIconDefault = path.join(appRootPath, 'icons', platformHelper.type, `icon-tray-default${platformHelper.templateImageExtension(platformHelper.type)}`);
const appTrayIconTransparent = path.join(appRootPath, 'icons', platformHelper.type, `icon-tray-transparent${platformHelper.templateImageExtension(platformHelper.type)}`);
const appTrayIconPaused = path.join(appRootPath, 'icons', platformHelper.type, `icon-tray-paused${platformHelper.templateImageExtension(platformHelper.type)}`);


/**
Expand Down Expand Up @@ -88,7 +88,7 @@ let getTrayMenuTemplate = () => {
{
id: 'showOnlyInTray',
label: platformHelper.isMacOS ? 'Hide Dock Icon' : 'Minimize to Tray',
icon: path.join(appRootPath, 'app', 'images', `icon-show-app-window-${platformHelper.menuItemImageExtension}`),
icon: path.join(appRootPath, 'app', 'images', `icon-show-app-window${platformHelper.menuItemImageExtension}`),
type: 'checkbox',
checked: settings.getConfigurationItem('showOnlyInTray').get(),
click(menuItem) {
Expand All @@ -98,7 +98,7 @@ let getTrayMenuTemplate = () => {
{
id: 'launchOnStartup',
label: 'Launch on Startup',
icon: path.join(appRootPath, 'app', 'images', `icon-launch-on-startup-${platformHelper.menuItemImageExtension}`),
icon: path.join(appRootPath, 'app', 'images', `icon-launch-on-startup${platformHelper.menuItemImageExtension}`),
type: 'checkbox',
checked: settings.getConfigurationItem('launchOnStartup').get(),
click(menuItem) {
Expand All @@ -108,7 +108,7 @@ let getTrayMenuTemplate = () => {
{
id: 'replayOnLaunch',
label: 'Replay Pushes on Start',
icon: path.join(appRootPath, 'app', 'images', `icon-replay-on-launch-${platformHelper.menuItemImageExtension}`),
icon: path.join(appRootPath, 'app', 'images', `icon-replay-on-launch${platformHelper.menuItemImageExtension}`),
type: 'checkbox',
checked: settings.getConfigurationItem('replayOnLaunch').get(),
click(menuItem) {
Expand All @@ -121,7 +121,7 @@ let getTrayMenuTemplate = () => {
{
id: 'Snooze',
label: 'Snooze',
icon: path.join(appRootPath, 'app', 'images', `icon-snooze-${platformHelper.menuItemImageExtension}`),
icon: path.join(appRootPath, 'app', 'images', `icon-snooze${platformHelper.menuItemImageExtension}`),
submenu: [
{
label: 'Snooze for 1 Hour',
Expand Down Expand Up @@ -155,7 +155,7 @@ let getTrayMenuTemplate = () => {
{
id: 'soundEnabled',
label: 'Play Sound Effects',
icon: path.join(appRootPath, 'app', 'images', `icon-play-sound-effects-${platformHelper.menuItemImageExtension}`),
icon: path.join(appRootPath, 'app', 'images', `icon-play-sound-effects${platformHelper.menuItemImageExtension}`),
type: 'checkbox',
checked: settings.getConfigurationItem('soundEnabled').get(),
click(menuItem) {
Expand All @@ -167,7 +167,7 @@ let getTrayMenuTemplate = () => {
label: 'Open Sound File...',
type: 'normal',
click() {
settings.getConfigurationItem('soundFile').apply();
settings.getConfigurationItem('soundFile').implement();
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/windows/main-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MainWindow extends BrowserWindow {
constructor() {
super({
acceptFirstMouse: true,
autoHideMenuBar: false,
autoHideMenuBar: !isDebug,
backgroundColor: platformHelper.isMacOS ? '#0095A5A6' : '#95A5A6',
frame: true,
fullscreenable: true,
Expand Down
4 changes: 2 additions & 2 deletions lib/platform-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let getIconImageExtension = function(platformName) {
* @returns {string}
*/
let getTemplateImageExtension = function(platformName) {
return platformName.indexOf('darwin') === 0 ? 'Template.png' : '.png';
return platformName.indexOf('darwin') === 0 ? '-Template.png' : '.png';
};


Expand All @@ -46,7 +46,7 @@ module.exports = {
type: process.platform,
arch: getArch,
trayImageExtension: '.png',
menuItemImageExtension: 'Template.png',
menuItemImageExtension: '-Template.png',
iconImageExtension: getIconImageExtension,
templateImageExtension: getTemplateImageExtension
};
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pb-for-desktop",
"productName": "PB for Desktop",
"version": "3.5.0",
"version": "3.5.3",
"description": "PushBullet desktop application for macOS, Windows and Linux",
"license": "MIT",
"homepage": "https://sidneys.github.io/pb-for-desktop",
Expand Down Expand Up @@ -51,12 +51,12 @@
"babel-preset-electron": "^0.37.8",
"chalk": "^1.1.3",
"electron-compile": "^5.1.3",
"electron-compilers": "^5.3.2",
"electron-compilers": "^5.4.0",
"electron-connect": "^0.6.1",
"electron-editor-context-menu": "^1.1.1",
"electron-settings": "^2.2.2",
"electron-squirrel-startup": "^1.0.0",
"electron-updater": "^1.1.1",
"electron-updater": "^1.2.0",
"file-type": "^4.1.0",
"file-url": "^2.0.1",
"fs-extra": "^2.0.0",
Expand All @@ -70,8 +70,8 @@
},
"devDependencies": {
"electron": "^1.4.15",
"electron-builder": "^11.5.1",
"electron-builder-squirrel-windows": "^11.5.0",
"electron-builder": "11.5.1",
"electron-builder-squirrel-windows": "11.5.0",
"fkill": "^4.1.0",
"glob": "^7.1.1",
"gulp": "^3.9.1",
Expand Down

0 comments on commit b1757a4

Please sign in to comment.