2013-09-13 22:57:57 +00:00
|
|
|
require([
|
2013-12-04 17:24:04 +00:00
|
|
|
"command",
|
|
|
|
"settings!user",
|
|
|
|
"ui/dialog",
|
|
|
|
"ui/projectManager",
|
|
|
|
"ui/keys",
|
|
|
|
"fileManager",
|
|
|
|
"ui/menus",
|
|
|
|
"ui/palette",
|
2013-12-04 18:52:56 +00:00
|
|
|
"api",
|
|
|
|
"storage/syncfile"
|
2013-09-16 20:52:54 +00:00
|
|
|
], function(command, Settings, dialog) {
|
2013-08-20 00:53:03 +00:00
|
|
|
|
2013-08-23 23:03:46 +00:00
|
|
|
var frame = chrome.app.window.current();
|
|
|
|
|
2013-09-02 01:26:22 +00:00
|
|
|
command.on("app:exit", function() {
|
|
|
|
frame.close();
|
|
|
|
});
|
|
|
|
|
2013-09-13 22:57:57 +00:00
|
|
|
var setTheme = function() {
|
|
|
|
var user = Settings.get("user");
|
|
|
|
var themes = {
|
|
|
|
"dark": "css/caret-dark.css",
|
|
|
|
"light": "css/caret.css"
|
|
|
|
};
|
|
|
|
var theme = user.uiTheme || "light";
|
|
|
|
var url = themes[theme];
|
|
|
|
document.find("#theme").setAttribute("href", url);
|
|
|
|
}
|
|
|
|
|
2013-09-02 01:28:31 +00:00
|
|
|
//the settings manager may also fire init:restart to re-init components after startup
|
2013-09-02 01:26:22 +00:00
|
|
|
command.fire("init:startup");
|
2013-09-13 22:57:57 +00:00
|
|
|
command.on("init:restart", setTheme);
|
|
|
|
setTheme();
|
2013-09-02 01:26:22 +00:00
|
|
|
|
2013-10-28 21:02:11 +00:00
|
|
|
var updateID = "caret:update";
|
|
|
|
|
2013-11-06 20:18:50 +00:00
|
|
|
var checkUpdates = function(isManual) {
|
|
|
|
chrome.runtime.requestUpdateCheck(function(status, details) {
|
|
|
|
if (status == "update_available") {
|
2013-12-16 18:44:11 +00:00
|
|
|
chrome.runtime.onUpdateAvailable.addListener(function() {
|
|
|
|
chrome.notifications.create(updateID, {
|
|
|
|
type: "basic",
|
|
|
|
iconUrl: "icon-128.png",
|
|
|
|
title: "Caret: Update Available",
|
|
|
|
message: "An update to Caret version " + details.version + " is available. Would you like to update and restart now?",
|
|
|
|
buttons: [ { title: "Yes, update and restart" }, { title: "No thanks" }]
|
|
|
|
}, function(id) { updateID = id });
|
|
|
|
});
|
2013-11-06 20:18:50 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
if (Settings.get("user").promptForUpdates !== false) checkUpdates();
|
|
|
|
command.on("app:check-for-updates", checkUpdates);
|
2013-10-28 21:02:11 +00:00
|
|
|
|
|
|
|
chrome.notifications.onButtonClicked.addListener(function(id, index) {
|
|
|
|
if (id != updateID) return;
|
|
|
|
if (index == 0) {
|
|
|
|
chrome.runtime.reload();
|
2013-09-16 17:22:49 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-08-20 00:53:03 +00:00
|
|
|
});
|