Skip to content

Commit

Permalink
Add "New session" item to launcher menu.
Browse files Browse the repository at this point in the history
Also close the New Sessions window on connect, instead of minimize. It is no
longer necessary to keep it open, as the user can start a new session either by
launching the app again, or in the case of Chrome OS, right-clicking the app
icon in the "shelf" and choosing "New session".
  • Loading branch information
rpwoodbu committed Feb 16, 2014
1 parent be6162d commit 6e6ffec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/app/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ window.state = {};
// This is a map of all open session windows.
window.state.windows = {};

chrome.app.runtime.onLaunched.addListener(function() {
function NewSession() {
chrome.app.window.create(
'mosh_client.html',
{
Expand All @@ -30,4 +30,15 @@ chrome.app.runtime.onLaunched.addListener(function() {
},
'id': 'mosh_client',
});
};

chrome.app.runtime.onLaunched.addListener(NewSession);

chrome.contextMenus.create({
'type': 'normal',
'id': 'new_session',
'title': 'New session',
'contexts': ['launcher'],
});

chrome.contextMenus.onClicked.addListener(function() { NewSession(); });
1 change: 1 addition & 0 deletions src/app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
]},
"clipboardRead",
"clipboardWrite",
"contextMenus",
"storage"
],
"icons": {
Expand Down
2 changes: 1 addition & 1 deletion src/app/mosh_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function onConnectClick(e) {
bg.state.windows[id] = createdWindow;
createdWindow.contentWindow.args = args;
createdWindow.contentWindow.state = bg.state;
chrome.app.window.current().minimize();
chrome.app.window.current().close();
});
});
};
Expand Down

0 comments on commit 6e6ffec

Please sign in to comment.