-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
185 changed files
with
5,637 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,210 @@ | ||
|
||
const electron = require('electron') | ||
const open = require('open') | ||
// Module to control application life. | ||
const app = electron.app | ||
const Menu = electron.Menu; | ||
|
||
// Module to create native browser window. | ||
const BrowserWindow = electron.BrowserWindow; | ||
// Keep a global reference of the window object, if you don't, the window will | ||
// be closed automatically when the JavaScript object is garbage collected. | ||
let mainWindow | ||
|
||
|
||
//Creating icon for the app. Not sure where used. Differes depending on platform. | ||
const nativeImage = require('electron').nativeImage; | ||
let image = nativeImage.createFromPath('file://${__dirname}/icon.png'); | ||
|
||
|
||
function createWindow () { | ||
// Create the browser window. | ||
mainWindow = new BrowserWindow({width: 800, height: 600, icon: image}) | ||
|
||
//Load main vector file | ||
mainWindow.loadURL(`file://${__dirname}/vector/index.html`) | ||
|
||
//Create app wide menu from template. Needed for shortcuts to work. | ||
const menu = Menu.buildFromTemplate(template); | ||
Menu.setApplicationMenu(menu); | ||
|
||
//Hijack all _blank links to open in browser instead of electron window. | ||
mainWindow.webContents.on('new-window', function(event, url){ | ||
event.preventDefault(); | ||
open(url); | ||
}); | ||
|
||
// Emitted when the window is closed. | ||
mainWindow.on('closed', function () { | ||
mainWindow = null; | ||
}) | ||
|
||
|
||
} | ||
|
||
// This method will be called when Electron has finished | ||
// initialization and is ready to create browser windows. | ||
// Some APIs can only be used after this event occurs. | ||
app.on('ready', createWindow) | ||
|
||
// Quit when all windows are closed. | ||
app.on('window-all-closed', function () { | ||
// 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', function () { | ||
// On OS X it's common to re-create a window in the app when the | ||
// dock icon is clicked and there are no other windows open. | ||
if (mainWindow === null) { | ||
createWindow() | ||
} | ||
}) | ||
|
||
|
||
|
||
// long menu template - could be separated | ||
const template = [ | ||
{ | ||
label: 'Edit', | ||
submenu: [ | ||
{ | ||
role: 'undo' | ||
}, | ||
{ | ||
role: 'redo' | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
role: 'cut' | ||
}, | ||
{ | ||
role: 'copy' | ||
}, | ||
{ | ||
role: 'paste' | ||
}, | ||
{ | ||
role: 'pasteandmatchstyle' | ||
}, | ||
{ | ||
role: 'delete' | ||
}, | ||
{ | ||
role: 'selectall' | ||
}, | ||
] | ||
}, | ||
{ | ||
label: 'View', | ||
submenu: [ | ||
{ | ||
label: 'Reload', | ||
accelerator: 'CmdOrCtrl+R', | ||
click(item, focusedWindow) { | ||
if (focusedWindow) focusedWindow.reload(); | ||
} | ||
}, | ||
{ | ||
role: 'togglefullscreen' | ||
}, | ||
{ | ||
label: 'Toggle Developer Tools', | ||
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I', | ||
click(item, focusedWindow) { | ||
if (focusedWindow) | ||
focusedWindow.webContents.toggleDevTools(); | ||
} | ||
}, | ||
] | ||
}, | ||
{ | ||
role: 'window', | ||
submenu: [ | ||
{ | ||
role: 'minimize' | ||
}, | ||
{ | ||
role: 'close' | ||
}, | ||
] | ||
}, | ||
{ | ||
role: 'help', | ||
submenu: [ | ||
{ | ||
label: 'Learn More', | ||
click() { require('electron').shell.openExternal('http://vector.im'); } | ||
}, | ||
] | ||
}, | ||
]; | ||
|
||
if (process.platform === 'darwin') { | ||
const name = app.getName(); | ||
template.unshift({ | ||
label: name, | ||
submenu: [ | ||
{ | ||
role: 'about' | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
role: 'services', | ||
submenu: [] | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
role: 'hide' | ||
}, | ||
{ | ||
role: 'hideothers' | ||
}, | ||
{ | ||
role: 'unhide' | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
role: 'quit' | ||
}, | ||
] | ||
}); | ||
// Window menu. | ||
template[3].submenu = [ | ||
{ | ||
label: 'Close', | ||
accelerator: 'CmdOrCtrl+W', | ||
role: 'close' | ||
}, | ||
{ | ||
label: 'Minimize', | ||
accelerator: 'CmdOrCtrl+M', | ||
role: 'minimize' | ||
}, | ||
{ | ||
label: 'Zoom', | ||
role: 'zoom' | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
label: 'Bring All to Front', | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "vector-electron-desktop", | ||
"version": "0.0.1", | ||
"description": "Basic electron wrapper for Vector (http://vector.im) a messaging client that uses Matrix protocol (http://matrix.org/).", | ||
"main": "main.js", | ||
"scripts": { | ||
"start": "electron ." | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/electron/electron-quick-start.git" | ||
}, | ||
"author": "KRISIS", | ||
"license": "CC0-1.0", | ||
"bugs": { | ||
"url": "https://github.com/electron/electron-quick-start/issues" | ||
}, | ||
"homepage": "https://github.com/electron/electron-quick-start#readme", | ||
"devDependencies": { | ||
"devtron": "^1.2.1", | ||
"electron-packager": "^7.3.0", | ||
"electron-prebuilt": "^1.2.0" | ||
}, | ||
"dependencies": { | ||
"open": "0.0.5" | ||
} | ||
} |
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,3 @@ | ||
// This file is required by the index.html file and will | ||
// be executed in the renderer process for that window. | ||
// All of the Node.js APIs are available in this process. |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.