Add minimize on startup

This commit is contained in:
Ximi1970
2020-02-29 20:36:08 +01:00
parent eb2623b8c3
commit 25d59fec38
4 changed files with 45 additions and 11 deletions

View File

@@ -22,5 +22,10 @@
"tabMail": { "tabMail": {
"message": "Mail", "message": "Mail",
"description": "Tab for Mail options" "description": "Tab for Mail options"
},
"tabDebug": {
"message": "Debug",
"description": "Tab for Debug options"
} }
} }

View File

@@ -349,10 +349,14 @@ SysTrayX.Window = {
}; };
async function start() { async function start() {
// Always start minimized // Get the prefered start state
// browser.windows.update(browser.windows.WINDOW_ID_CURRENT, { const state = await getStartupState();
// state: "minimized"
// }); if (state == "minimized") {
browser.windows.update(browser.windows.WINDOW_ID_CURRENT, {
state: "minimized"
});
}
// Init defaults before everything // Init defaults before everything
await getDefaultIcon(); await getDefaultIcon();
@@ -364,6 +368,9 @@ async function start() {
// Setup the link first // Setup the link first
SysTrayX.Link.init(); SysTrayX.Link.init();
// Send current state
SysTrayX.Link.postSysTrayXMessage({ window: state });
// Main start // Main start
SysTrayX.Messaging.init(); SysTrayX.Messaging.init();
} }

View File

@@ -54,3 +54,19 @@ async function getDefaultIcon() {
console.debug("Default: " + iconBase64); console.debug("Default: " + iconBase64);
} }
} }
//
// Get window startup state
//
async function getStartupState() {
function getStartupState(result) {
return result.startMinimized == "true" ? "minimized" : "normal";
}
function onStartupStateError() {
return "normal";
}
const getState = browser.storage.sync.get("startMinimized");
return await getState.then(getStartupState, onStartupStateError);
}

View File

@@ -9,17 +9,11 @@
<script src="js/i18n.js"></script> <script src="js/i18n.js"></script>
<script src="js/options_accounts.js"></script> <script src="js/options_accounts.js"></script>
<br />
<div id="debugselect">
<input type="checkbox" name="debug" value="Debug" /> Display debug
window<br />
</div>
<br />
<div class="tab"> <div class="tab">
<button class="tablinks active" id="Windows">__MSG_tabWindows__</button> <button class="tablinks active" id="Windows">__MSG_tabWindows__</button>
<button class="tablinks" id="Icon">__MSG_tabIcon__</button> <button class="tablinks" id="Icon">__MSG_tabIcon__</button>
<button class="tablinks" id="Mail">__MSG_tabMail__</button> <button class="tablinks" id="Mail">__MSG_tabMail__</button>
<button class="tablinks" id="Debug">__MSG_tabDebug__</button>
</div> </div>
<div id="WindowsContent" class="tabcontent" style="display:block"> <div id="WindowsContent" class="tabcontent" style="display:block">
@@ -89,6 +83,18 @@
</form> </form>
</div> </div>
<div id="DebugContent" class="tabcontent">
<form name="debugform">
<h3>Debug options</h3>
<br />
<div id="debugselect">
<input type="checkbox" name="debug" value="Debug" /> Display debug
window<br />
</div>
<br />
</form>
</div>
<br /> <br />
<form name="saveform"> <form name="saveform">
<label>Save preferences</label> <label>Save preferences</label>