Skip to content
This repository was archived by the owner on Feb 5, 2020. It is now read-only.
Open
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The Gitter Desktop client is written using [NW.js](http://nwjs.io/), but the onl

1. clone this repo: `git clone git@github.com:gitterHQ/desktop.git && cd desktop`
2. install all dependencies: `npm install`
3. generate your own [app oAuth credentials](https://developer.gitter.im/apps) where the redirect url is `app://gitter/oauth.html`
3. generate your own [app oAuth credentials](https://developer.gitter.im/apps) where the redirect url is `chrome-extension://gitter/oauth.html`
4. start the app with your credentials:
* linux/osx: `OAUTH_KEY=yourkey OAUTH_SECRET=yoursecret npm start`
* windows cmd: `set OAUTH_KEY=yourkey && set OAUTH_SECRET=yoursecret && npm start`
Expand Down
1 change: 1 addition & 0 deletions linux/gitter.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Icon=/opt/Gitter/{{arch}}/logo.png
Terminal=false
Type=Application
Categories=Utility;
StartupWMClass=gitter-desktop
10 changes: 4 additions & 6 deletions nwapp/components/context-menu.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
'use strict';

var gui = window.require('nw.gui');
var menu = new gui.Menu();
var menu = new nw.Menu();

function Menu(cutLabel, copyLabel, pasteLabel) {
var cut = new gui.MenuItem({
var cut = new nw.MenuItem({
label: cutLabel || "Cut",
click: function() {
document.execCommand("cut");
}
});

var copy = new gui.MenuItem({
var copy = new nw.MenuItem({
label: copyLabel || "Copy",
click: function() {
document.execCommand("copy");
}
});

var paste = new gui.MenuItem({
var paste = new nw.MenuItem({
label: pasteLabel || "Paste",
click: function() {
document.execCommand("paste");
Expand All @@ -35,4 +34,3 @@ function Menu(cutLabel, copyLabel, pasteLabel) {


module.exports = new Menu();

1 change: 0 additions & 1 deletion nwapp/components/menu-items.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

var gui = window.require('nw.gui');
var pkg = require('../package.json');
var settings = require('../utils/settings');
var events = require('../utils/custom-events');
Expand Down
15 changes: 7 additions & 8 deletions nwapp/components/menu.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
'use strict';

var events = require('../utils/custom-events');
var gui = window.require('nw.gui');
var CLIENT = require('../utils/client-type');

// recursively assembles menus and sub-menus
function assembleMenu(items, parent) {
var fold;

parent = parent ? parent : new gui.Menu();
parent = parent ? parent : new nw.Menu();

items.forEach(function (item) {
// means that we have a submenu
if (item.content && item.content.length > 0) {
var submenu = new gui.Menu();
var submenu = new nw.Menu();
fold = assembleMenu(item.content, submenu);
} else {
fold = new gui.MenuItem(item);
fold = new nw.MenuItem(item);
}

if (fold.type === 'contextmenu') {
item.submenu = fold;
fold = new gui.MenuItem(item);
fold = new nw.MenuItem(item);
}

if (item.index && CLIENT === 'osx') {
Expand All @@ -36,7 +35,7 @@ function assembleMenu(items, parent) {

function CustomMenu(spec) {

this.menu = new gui.Menu({ type: 'menubar' });
this.menu = new nw.Menu({ type: 'menubar' });
this.items = spec.items || [];
this.filter = spec.filter;
this.label = spec.label;
Expand Down Expand Up @@ -72,9 +71,9 @@ CustomMenu.prototype.build = function () {
assembleMenu(filteredItems, this.menu.items[0].submenu);
break;
default:
var sub = new gui.Menu();
var sub = new nw.Menu();
assembleMenu(filteredItems, sub);
this.menu.append(new gui.MenuItem({
this.menu.append(new nw.MenuItem({
label: this.label,
submenu: sub
}));
Expand Down
13 changes: 6 additions & 7 deletions nwapp/components/tray-menu.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
'use strict';

var gui = window.require('nw.gui');
var log = require('loglevel');
var Gitter = require('gitter-realtime-client');
var settings = require('../utils/settings');
var events = require('../utils/custom-events');
var quitApp = require('../utils/quit-app');

function TrayMenu() {
this.menu = new gui.Menu();
this.menu = new nw.Menu();
this.unsetRooms();

events.on('user:signedOut', function () {
Expand Down Expand Up @@ -58,9 +57,9 @@ TrayMenu.prototype.clear = function () {

TrayMenu.prototype.addDefaults = function () {
if (settings.token) {
this.menu.append(new gui.MenuItem({ label: 'Sign Out', click: events.emit.bind(events, 'traymenu:signout') }));
this.menu.append(new nw.MenuItem({ label: 'Sign Out', click: events.emit.bind(events, 'traymenu:signout') }));
}
this.menu.append(new gui.MenuItem({ label: 'Exit Gitter', click: quitApp }));
this.menu.append(new nw.MenuItem({ label: 'Exit Gitter', click: quitApp }));
};

TrayMenu.prototype.build = function () {
Expand Down Expand Up @@ -91,11 +90,11 @@ TrayMenu.prototype.addSection = function (spec) {

this.menu.append(this.toLabel(spec.label));
spec.collection.slice(0, 5).forEach(appendRoom);
this.menu.append(new gui.MenuItem({ type: 'separator' }));
this.menu.append(new nw.MenuItem({ type: 'separator' }));
};

TrayMenu.prototype.toMenuItem = function (room) {
return new gui.MenuItem({
return new nw.MenuItem({
label: room.get('name'),
click: function () {
events.emit('traymenu:clicked', room.get('url'));
Expand All @@ -104,7 +103,7 @@ TrayMenu.prototype.toMenuItem = function (room) {
};

TrayMenu.prototype.toLabel = function (name) {
return new gui.MenuItem({
return new nw.MenuItem({
label: name.toUpperCase(),
enabled: false
});
Expand Down
3 changes: 1 addition & 2 deletions nwapp/components/tray.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
'use strict';

var gui = window.require('nw.gui');
var settings = require('../utils/settings');
var events = require('../utils/custom-events');

var CLIENT_TYPE = require('../utils/client-type');
var icon = require('../icons.json')[CLIENT_TYPE];

function CustomTray() {
this.tray = new gui.Tray({
this.tray = new nw.Tray({
icon: icon.disconnected,
alticon: icon.selected,
iconsAreTemplates: false
Expand Down
24 changes: 11 additions & 13 deletions nwapp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ log.setLevel('debug');
var CLIENT = require('./utils/client-type');

var manifest = require('./package.json');
var gui = require('nw.gui');
var pkg = require('./package.json');
var Gitter = require('gitter-realtime-client');
var os = require('os');
var path = require('path');

var argv = require('yargs')(gui.App.argv).argv;
var argv = require('yargs')(nw.App.argv).argv;
var Promise = require('bluebird');
var semver = require('semver');
var autoUpdate = require('./utils/auto-update');
Expand Down Expand Up @@ -176,7 +175,7 @@ function setupTray(win) {
// initialises and adds listeners to the top level components of the UI
function initGUI() {
log.trace('initGUI()');
win = gui.Window.get();
win = nw.Window.get();

// Set up tray(OSX)/menu bar(Windows)
if(settings.showInMacMenuBar) {
Expand All @@ -192,7 +191,7 @@ function initGUI() {
}
});

gui.App.on('reopen', reopen); // When someone clicks on the dock icon, show window again.
nw.App.on('reopen', reopen); // When someone clicks on the dock icon, show window again.

win.on('close', function (evt) {
log.trace('win:close');
Expand Down Expand Up @@ -286,10 +285,10 @@ function initApp() {
function showAuth() {
if (loginView) return;

// whitelists app:// protocol used for the oAuth callback
gui.App.addOriginAccessWhitelistEntry('https://gitter.im/', 'app', 'gitter', true);
// whitelists chrome-extension:// protocol used for the oAuth callback
nw.App.addOriginAccessWhitelistEntry('https://gitter.im/', 'app', 'gitter', true);

loginView = new LoginView(gui.Window);
loginView = new LoginView(nw.Window);

loginView.on('accessTokenReceived', function(accessToken) {
log.trace('authWindow:loaded');
Expand Down Expand Up @@ -330,11 +329,10 @@ function signout() {
function showLoggedInWindow(exec) {
log.trace('showLoggedInWindow()');

mainWindow = gui.Window.get(
window.open('loggedin.html', {
focus: true
})
);
var win = nw.Window.get();
win.get('loggedin.html', {
focus: true
});

mainWindow.setMinimumSize(400, 200);

Expand Down Expand Up @@ -402,7 +400,7 @@ function showLoggedInWindow(exec) {
});

mainWindow.on('new-win-policy', function (frame, url, policy) {
gui.Shell.openExternal(url);
nw.Shell.openExternal(url);
policy.ignore();
});
}
Expand Down
6 changes: 3 additions & 3 deletions nwapp/lib/login-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var clientSecret = process.env.OAUTH_SECRET || oauthJson[os].secret || '';
var baseSite = 'https://gitter.im/';
var authorizePath = 'login/oauth/authorize';
var accessTokenPath = 'login/oauth/token';
var redirectUri = 'app://gitter/oauth.html';
var redirectUri = 'chrome-extension://gitter/oauth.html';


var LoginView = function(rootWindow) {
Expand All @@ -42,15 +42,15 @@ var LoginView = function(rootWindow) {
width: 1024,
height: 640
});
var mb = new gui.Menu({
var mb = new nw.Menu({
type: 'menubar'
});
if(os === 'osx') {
mb.createMacBuiltin('Gitter', {
hideEdit: false
});
}
gui.Window.get().menu = mb;
nw.Window.get().menu = mb;

this.oauthWindow.on('document-end', function() {
// gitter login page finished loading visible bits
Expand Down
3 changes: 1 addition & 2 deletions nwapp/loggedin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var gui = require('nw.gui');
var win = gui.Window.get();
var win = nw.Window.get();
var frame = win.window.document.getElementById('mainframe');
var settings = require('./utils/settings');
var version = require('./package.json').version;
Expand Down
3 changes: 1 addition & 2 deletions nwapp/oauth.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<head>
<title>Gitter Login</title>
<script type="text/javascript">
var gui = window.require('nw.gui');
var oauthWindow = gui.Window.get();
var oauthWindow = nw.Window.get();
var code = window.location.search.match(/code=(\w+)$/);
var error = window.location.search.match(/error=(\w+)$/);

Expand Down
2 changes: 1 addition & 1 deletion nwapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Gitter",
"description": "Where developers come to talk.",
"version": "3.1.0",
"main": "app://gitter/index.html",
"main": "chrome-extension://gitter/index.html",
"engineStrict": true,
"engines": {
"npm": "^3.0.0"
Expand Down
3 changes: 1 addition & 2 deletions nwapp/utils/auto-update.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
'use strict';

var gui = window.require('nw.gui');
var manifest = require('../package.json');
var log = require('loglevel');
var argv = require('yargs')(gui.App.argv).argv;
var argv = require('yargs')(nw.App.argv).argv;
var os = require('./client-type');

var Promise = require('bluebird');
Expand Down
3 changes: 1 addition & 2 deletions nwapp/utils/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ var objectAssign = require('object-assign');
var settings = require('./settings');
var events = require('./custom-events');

var gui = window.require('nw.gui');
var win = gui.Window.get();
var win = nw.Window.get();

var CLIENT = require('./client-type');
var SOUNDS_ITEMS = require('../components/sound-items');
Expand Down
3 changes: 1 addition & 2 deletions nwapp/utils/quit-app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var log = require('loglevel');
var gui = window.require('nw.gui');
var events = require('./custom-events');

// We wrap their quit method as it doesn't emit a `quit` or `close` event that
Expand All @@ -8,5 +7,5 @@ module.exports = function() {
log.info('Quitting app, app:quit');
events.emit('app:quit');

gui.App.quit();
nw.App.quit();
};
3 changes: 1 addition & 2 deletions nwapp/utils/settings.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

var Store = require('jfs');
var gui = window.require('nw.gui');
var events = require('./custom-events');
var log = require('loglevel');
var SOUNDS = require('./sounds');
Expand Down Expand Up @@ -44,7 +43,7 @@ var DEFAULT_SETTINGS = {
}
};

var db = new Store(gui.App.dataPath + '/gitter_preferences.json', { pretty: true }); // FIXME: pretty Boolean - should be environment dependent
var db = new Store(nw.App.dataPath + '/gitter_preferences.json', { pretty: true }); // FIXME: pretty Boolean - should be environment dependent

// initial load is done synchronously
var settings = db.getSync('settings');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"devDependencies": {
"bluebird": "^3.2.2",
"npm": "^3.7.3",
"nw": "^0.12.3",
"nw": "^0.18.5",
"rimraf": "^2.2.8",
"s3": "^4.3.1",
"stream-exhaust": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion windows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Usage: `signtool.exe sign /f troupe-cert.pfx binary.exe`

### kSign

Has a GUI. Very easy to use. Just use the cert provided: `troupe-cert.pfx`
Has a nw. Very easy to use. Just use the cert provided: `troupe-cert.pfx`

## Inno Setup

Expand Down