mirror of
https://github.com/moparisthebest/FireTray
synced 2024-12-22 13:58:48 -05:00
make firetray.Utils.timer() API more readable
This commit is contained in:
parent
29de64e51f
commit
5dce03778d
@ -192,16 +192,16 @@ firetray.Handler = {
|
|||||||
case "before-first-paint":
|
case "before-first-paint":
|
||||||
log.debug("before-first-paint: "+subject.baseURI);
|
log.debug("before-first-paint: "+subject.baseURI);
|
||||||
firetray.Utils.removeObservers(firetray.Handler, [ "before-first-paint" ]);
|
firetray.Utils.removeObservers(firetray.Handler, [ "before-first-paint" ]);
|
||||||
firetray.Utils.timer(function() {
|
firetray.Utils.timer(FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS,
|
||||||
|
Ci.nsITimer.TYPE_ONE_SHOT, function() {
|
||||||
|
if (firetray.Utils.prefService.getBoolPref('start_hidden')) {
|
||||||
|
log.debug("start_hidden");
|
||||||
|
firetray.Handler.hideAllWindows();
|
||||||
|
}
|
||||||
|
|
||||||
if (firetray.Utils.prefService.getBoolPref('start_hidden')) {
|
firetray.Handler.appStarted = true;
|
||||||
log.debug("start_hidden");
|
log.debug("*** appStarted ***");
|
||||||
firetray.Handler.hideAllWindows();
|
});
|
||||||
}
|
|
||||||
|
|
||||||
firetray.Handler.appStarted = true;
|
|
||||||
log.debug("*** appStarted ***");
|
|
||||||
}, FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "xpcom-will-shutdown":
|
case "xpcom-will-shutdown":
|
||||||
@ -327,10 +327,11 @@ firetray.Handler = {
|
|||||||
|
|
||||||
// FIXME: obviously we need to wait to avoid seg fault on jsapi.cpp:827
|
// FIXME: obviously we need to wait to avoid seg fault on jsapi.cpp:827
|
||||||
// 827 if (t->data.requestDepth) {
|
// 827 if (t->data.requestDepth) {
|
||||||
firetray.Utils.timer(function() {
|
firetray.Utils.timer(FIRETRAY_DELAY_NOWAIT_MILLISECONDS,
|
||||||
for(var key in firetray.Handler.windows) break;
|
Ci.nsITimer.TYPE_ONE_SHOT, function() {
|
||||||
firetray.Handler.windows[key].chromeWin.open(home);
|
for(var key in firetray.Handler.windows) break;
|
||||||
}, FIRETRAY_DELAY_NOWAIT_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
firetray.Handler.windows[key].chromeWin.open(home);
|
||||||
|
});
|
||||||
} catch (x) { log.error(x); }
|
} catch (x) { log.error(x); }
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -345,11 +346,12 @@ firetray.Handler = {
|
|||||||
|
|
||||||
quitApplication: function() {
|
quitApplication: function() {
|
||||||
try {
|
try {
|
||||||
firetray.Utils.timer(function() {
|
firetray.Utils.timer(FIRETRAY_DELAY_NOWAIT_MILLISECONDS,
|
||||||
let appStartup = Cc['@mozilla.org/toolkit/app-startup;1']
|
Ci.nsITimer.TYPE_ONE_SHOT, function() {
|
||||||
.getService(Ci.nsIAppStartup);
|
let appStartup = Cc['@mozilla.org/toolkit/app-startup;1']
|
||||||
appStartup.quit(Ci.nsIAppStartup.eAttemptQuit);
|
.getService(Ci.nsIAppStartup);
|
||||||
}, FIRETRAY_DELAY_NOWAIT_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
appStartup.quit(Ci.nsIAppStartup.eAttemptQuit);
|
||||||
|
});
|
||||||
} catch (x) { log.error(x); }
|
} catch (x) { log.error(x); }
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -465,10 +467,11 @@ firetray.VersionChangeHandler = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tabmail) {
|
if (tabmail) {
|
||||||
firetray.Utils.timer(function() {
|
firetray.Utils.timer(FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS,
|
||||||
log.debug("openMailTab");
|
Ci.nsITimer.TYPE_ONE_SHOT, function() {
|
||||||
tabmail.openTab("contentTab", {contentPage: url});
|
log.debug("openMailTab");
|
||||||
}, FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
tabmail.openTab("contentTab", {contentPage: url});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ firetray.Utils = {
|
|||||||
return list;
|
return list;
|
||||||
},
|
},
|
||||||
|
|
||||||
timer: function(callback, delay, timerType) {
|
timer: function(delay, timerType, callback) {
|
||||||
var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||||
timer.initWithCallback({ notify: callback },
|
timer.initWithCallback({ notify: callback },
|
||||||
delay, timerType);
|
delay, timerType);
|
||||||
|
Loading…
Reference in New Issue
Block a user