1
0
mirror of https://github.com/moparisthebest/FireTray synced 2025-01-09 12:38:04 -05:00

Merge branch 'startup' into v0.4.6rc2

This commit is contained in:
foudfou 2013-05-01 15:45:35 +02:00
commit c439efb036
2 changed files with 30 additions and 8 deletions

View File

@ -125,11 +125,16 @@ firetray.Handler = {
firetray.Utils.addObservers(firetray.Handler, firetray.Utils.addObservers(firetray.Handler,
[ "xpcom-will-shutdown", "profile-change-teardown" ]); [ "xpcom-will-shutdown", "profile-change-teardown" ]);
if (this.appId === FIRETRAY_APP_DB['thunderbird']['id']) { if (this.appId === FIRETRAY_APP_DB['firefox']['id'] ||
firetray.Utils.addObservers(firetray.Handler, [ "console-api-log-event" ]); this.appId === FIRETRAY_APP_DB['seamonkey']['id']) {
} else if (this.appId === FIRETRAY_APP_DB['firefox']['id'] ||
this.appId === FIRETRAY_APP_DB['seamonkey']['id']) {
firetray.Utils.addObservers(firetray.Handler, [ "sessionstore-windows-restored" ]); firetray.Utils.addObservers(firetray.Handler, [ "sessionstore-windows-restored" ]);
} else if (this.appId === FIRETRAY_APP_DB['thunderbird']['id']) {
this.restoredWindowsCount = this.readTBRestoreWindowsCount();
log.debug("restoredWindowsCount="+this.restoredWindowsCount);
if (!this.restoredWindowsCount) {
log.error("session file could not be read");
this.restoredWindowsCount = 1; // default
}
} else { } else {
firetray.Utils.addObservers(firetray.Handler, [ "final-ui-startup" ]); firetray.Utils.addObservers(firetray.Handler, [ "final-ui-startup" ]);
} }
@ -188,6 +193,24 @@ firetray.Handler = {
} }
}, },
readTBRestoreWindowsCount: function() {
Cu.import("resource:///modules/IOUtils.js");
let sessionFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
sessionFile.append("session.json");
var initialState = null;
if (sessionFile.exists()) {
let data = IOUtils.loadFileToString(sessionFile);
if (!data) return null;
try {
initialState = JSON.parse(data);
} catch(x) {}
if (!initialState) return null;
return initialState.windows.length;
}
return null;
},
// FIXME: this should definetely be done in Chat, but IM accounts // FIXME: this should definetely be done in Chat, but IM accounts
// seem not be initialized at early stage (Exception... "'TypeError: // seem not be initialized at early stage (Exception... "'TypeError:
// this._items is undefined' when calling method: // this._items is undefined' when calling method:
@ -219,10 +242,6 @@ firetray.Handler = {
case "sessionstore-windows-restored": case "sessionstore-windows-restored":
// sessionstore-windows-restored does not come after the realization of // sessionstore-windows-restored does not come after the realization of
// all windows... so we wait a little // all windows... so we wait a little
case "console-api-log-event": // one of the few events issued at later
// stage, once windows are realized
// second TB window also issues
// "mail-startup-done"/"mail-tabs-session-restored"
case "final-ui-startup": // subject=ChromeWindow case "final-ui-startup": // subject=ChromeWindow
log.debug(topic+": "+subject+","+data); log.debug(topic+": "+subject+","+data);
firetray.Utils.removeObservers(firetray.Handler, [ topic ]); firetray.Utils.removeObservers(firetray.Handler, [ topic ]);

View File

@ -592,6 +592,9 @@ firetray.Window = {
if (!firetray.Handler.appStarted && if (!firetray.Handler.appStarted &&
firetray.Utils.prefService.getBoolPref('start_hidden')) { firetray.Utils.prefService.getBoolPref('start_hidden')) {
log.debug("start_hidden"); log.debug("start_hidden");
if (firetray.Handler.restoredWindowsCount &&
!--firetray.Handler.restoredWindowsCount)
firetray.Handler.startupDone();
firetray.Window.startupHide(xid); firetray.Window.startupHide(xid);
} }
gdk.gdk_window_remove_filter(firetray.Handler.gdkWindows.get(xid), gdk.gdk_window_remove_filter(firetray.Handler.gdkWindows.get(xid),