@ -0,0 +1,203 @@ |
|||||||
|
'use strict'; |
||||||
|
const os = require('os'); |
||||||
|
const electron = require('electron'); |
||||||
|
const app = electron.app; |
||||||
|
const BrowserWindow = electron.BrowserWindow; |
||||||
|
const shell = electron.shell; |
||||||
|
const appName = app.getName(); |
||||||
|
|
||||||
|
function sendAction(action) { |
||||||
|
const win = BrowserWindow.getAllWindows()[0]; |
||||||
|
|
||||||
|
if (process.platform === 'darwin') { |
||||||
|
win.restore(); |
||||||
|
} |
||||||
|
|
||||||
|
win.webContents.send(action); |
||||||
|
} |
||||||
|
|
||||||
|
const helpSubmenu = [ |
||||||
|
{ |
||||||
|
label: `Visit ${appName} Website`, |
||||||
|
click() { |
||||||
|
shell.openExternal('http://saenzramiro.github.io/rambox/'); |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Report an Issue...', |
||||||
|
click() { |
||||||
|
const body = ` |
||||||
|
<!-- Please describe here your issue and steps to reproduce it. --> |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- DON'T REMOVE THE FOLLOWING LINES --> |
||||||
|
- |
||||||
|
> ${app.getName()} ${app.getVersion()} |
||||||
|
> Electron ${process.versions.electron} |
||||||
|
> ${process.platform} ${process.arch} ${os.release()}`;
|
||||||
|
|
||||||
|
shell.openExternal(`https://github.com/saenzramiro/rambox/issues/new?body=${encodeURIComponent(body)}`); |
||||||
|
} |
||||||
|
} |
||||||
|
]; |
||||||
|
|
||||||
|
let tpl = [ |
||||||
|
{ |
||||||
|
label: 'Edit', |
||||||
|
submenu: [ |
||||||
|
{ |
||||||
|
label: 'Undo', |
||||||
|
accelerator: 'CmdOrCtrl+Z', |
||||||
|
role: 'undo' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Redo', |
||||||
|
accelerator: 'Shift+CmdOrCtrl+Z', |
||||||
|
role: 'redo' |
||||||
|
}, |
||||||
|
{ |
||||||
|
type: 'separator' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Cut', |
||||||
|
accelerator: 'CmdOrCtrl+X', |
||||||
|
role: 'cut' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Copy', |
||||||
|
accelerator: 'CmdOrCtrl+C', |
||||||
|
role: 'copy' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Paste', |
||||||
|
accelerator: 'CmdOrCtrl+V', |
||||||
|
role: 'paste' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Select All', |
||||||
|
accelerator: 'CmdOrCtrl+A', |
||||||
|
role: 'selectall' |
||||||
|
}, |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'View', |
||||||
|
submenu: [ |
||||||
|
{ |
||||||
|
label: 'Reload', |
||||||
|
accelerator: 'CmdOrCtrl+R', |
||||||
|
click(item, focusedWindow) { |
||||||
|
if (focusedWindow) focusedWindow.reload(); |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Toggle Full Screen', |
||||||
|
accelerator: process.platform === 'darwin' ? 'Ctrl+Command+F' : 'F11', |
||||||
|
click(item, focusedWindow) { |
||||||
|
if (focusedWindow) |
||||||
|
focusedWindow.setFullScreen(!focusedWindow.isFullScreen()); |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Toggle Developer Tools', |
||||||
|
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I', |
||||||
|
click(item, focusedWindow) { |
||||||
|
if (focusedWindow) |
||||||
|
focusedWindow.webContents.toggleDevTools(); |
||||||
|
} |
||||||
|
}, |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Window', |
||||||
|
role: 'window', |
||||||
|
submenu: [ |
||||||
|
{ |
||||||
|
label: 'Minimize', |
||||||
|
accelerator: 'CmdOrCtrl+M', |
||||||
|
role: 'minimize' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Close', |
||||||
|
accelerator: 'CmdOrCtrl+W', |
||||||
|
role: 'close' |
||||||
|
}, |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Help', |
||||||
|
role: 'help' |
||||||
|
} |
||||||
|
]; |
||||||
|
|
||||||
|
if (process.platform === 'darwin') { |
||||||
|
tpl.unshift({ |
||||||
|
label: appName, |
||||||
|
submenu: [ |
||||||
|
{ |
||||||
|
label: `About ${appName}`, |
||||||
|
role: 'about' |
||||||
|
}, |
||||||
|
{ |
||||||
|
type: 'separator' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Services', |
||||||
|
role: 'services', |
||||||
|
submenu: [] |
||||||
|
}, |
||||||
|
{ |
||||||
|
type: 'separator' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: `Hide ${appName}`, |
||||||
|
accelerator: 'Command+H', |
||||||
|
role: 'hide' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Hide Others', |
||||||
|
accelerator: 'Command+Alt+H', |
||||||
|
role: 'hideothers' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Show All', |
||||||
|
role: 'unhide' |
||||||
|
}, |
||||||
|
{ |
||||||
|
type: 'separator' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: `Quit ${appName}`, |
||||||
|
accelerator: 'Cmd+Q', |
||||||
|
click() { |
||||||
|
app.quit(); |
||||||
|
} |
||||||
|
} |
||||||
|
] |
||||||
|
}); |
||||||
|
} else { |
||||||
|
tpl.unshift({ |
||||||
|
label: 'File', |
||||||
|
submenu: [ |
||||||
|
{ |
||||||
|
label: `Quit ${appName}`, |
||||||
|
accelerator: 'Cmd+Q', |
||||||
|
click() { |
||||||
|
app.quit(); |
||||||
|
} |
||||||
|
} |
||||||
|
] |
||||||
|
}); |
||||||
|
helpSubmenu.push({ |
||||||
|
type: 'separator' |
||||||
|
}); |
||||||
|
helpSubmenu.push({ |
||||||
|
label: `About ${appName}`, |
||||||
|
role: 'about' |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
tpl[tpl.length - 1].submenu = helpSubmenu; |
||||||
|
|
||||||
|
module.exports = electron.Menu.buildFromTemplate(tpl); |
@ -0,0 +1,88 @@ |
|||||||
|
const path = require('path'); |
||||||
|
const electron = require('electron'); |
||||||
|
const app = electron.app; |
||||||
|
const MenuItem = electron.MenuItem; |
||||||
|
let tray = null; |
||||||
|
|
||||||
|
exports.create = win => { |
||||||
|
if (process.platform === 'darwin' || tray) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
const icon = process.platform === 'linux' ? 'IconTray.png' : 'Icon.ico'; |
||||||
|
const iconPath = path.join(__dirname, `../resources/${icon}`); |
||||||
|
|
||||||
|
let showMB = new MenuItem({ |
||||||
|
label: 'Show Rambox' |
||||||
|
,position: '1' |
||||||
|
,visible: false |
||||||
|
,click(btn) { |
||||||
|
win.show(); |
||||||
|
contextMenu.items[0].visible = false; |
||||||
|
contextMenu.items[1].visible = true; |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
let hideMB = new MenuItem({ |
||||||
|
label: 'Minimize Rambox' |
||||||
|
,position: '2' |
||||||
|
,click(btn) { |
||||||
|
win.hide(); |
||||||
|
contextMenu.items[1].visible = false; |
||||||
|
contextMenu.items[0].visible = true; |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
const contextMenu = electron.Menu.buildFromTemplate([ |
||||||
|
showMB, |
||||||
|
hideMB, |
||||||
|
{ |
||||||
|
label: 'Preferences' |
||||||
|
}, |
||||||
|
{ |
||||||
|
type: 'separator' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Quit' |
||||||
|
,click() { |
||||||
|
app.quit(); |
||||||
|
} |
||||||
|
} |
||||||
|
]); |
||||||
|
|
||||||
|
tray = new electron.Tray(iconPath); |
||||||
|
tray.setToolTip('Rambox'); |
||||||
|
tray.setContextMenu(contextMenu); |
||||||
|
tray.on('click', function() { |
||||||
|
if ( win.isVisible() ) { |
||||||
|
win.hide(); |
||||||
|
contextMenu.items[1].visible = false; |
||||||
|
contextMenu.items[0].visible = true; |
||||||
|
} else { |
||||||
|
win.show(); |
||||||
|
contextMenu.items[0].visible = false; |
||||||
|
contextMenu.items[1].visible = true; |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
win.on('hide', function() { |
||||||
|
contextMenu.items[1].visible = false; |
||||||
|
contextMenu.items[0].visible = true; |
||||||
|
}); |
||||||
|
}; |
||||||
|
|
||||||
|
exports.setBadge = shouldDisplayUnread => { |
||||||
|
if (process.platform === 'darwin' || !tray) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
let icon; |
||||||
|
if (process.platform === 'linux') { |
||||||
|
icon = shouldDisplayUnread ? 'IconTrayUnread.png' : 'IconTray.png'; |
||||||
|
} else { |
||||||
|
icon = shouldDisplayUnread ? 'IconTrayUnread.ico' : 'Icon.ico'; |
||||||
|
} |
||||||
|
|
||||||
|
const iconPath = path.join(__dirname, `../resources/${icon}`); |
||||||
|
tray.setImage(iconPath); |
||||||
|
}; |
After Width: | Height: | Size: 361 KiB |
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 72 KiB |
After Width: | Height: | Size: 361 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 58 KiB |
After Width: | Height: | Size: 75 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 823 B |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 4.8 KiB |