diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-06-04 13:17:38 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-06-04 13:17:38 +0200 |
commit | a1be17c1cea81ebb1e8b131a662c698d78f3f7f2 (patch) | |
tree | a92f7de513be600cc07bac458183e9af40e00c06 /application/basilisk/tools/mozscreenshots/mozscreenshots/extension/configurations/LightweightThemes.jsm | |
parent | bf11fdd304898ac675e39b01b280d39550e419d0 (diff) | |
download | UXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.tar UXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.tar.gz UXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.tar.lz UXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.tar.xz UXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.zip |
Issue #303 Part 1: Move basilisk files from /browser to /application/basilisk
Diffstat (limited to 'application/basilisk/tools/mozscreenshots/mozscreenshots/extension/configurations/LightweightThemes.jsm')
-rw-r--r-- | application/basilisk/tools/mozscreenshots/mozscreenshots/extension/configurations/LightweightThemes.jsm | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/application/basilisk/tools/mozscreenshots/mozscreenshots/extension/configurations/LightweightThemes.jsm b/application/basilisk/tools/mozscreenshots/mozscreenshots/extension/configurations/LightweightThemes.jsm new file mode 100644 index 000000000..52d0c2207 --- /dev/null +++ b/application/basilisk/tools/mozscreenshots/mozscreenshots/extension/configurations/LightweightThemes.jsm @@ -0,0 +1,92 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +this.EXPORTED_SYMBOLS = ["LightweightThemes"]; + +const {classes: Cc, interfaces: Ci, utils: Cu} = Components; + +Cu.import("resource://gre/modules/LightweightThemeManager.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/Task.jsm"); +Cu.import("resource://gre/modules/Timer.jsm"); + +this.LightweightThemes = { + init(libDir) { + // convert -size 3000x200 canvas:#333 black_theme.png + let blackImage = libDir.clone(); + blackImage.append("black_theme.png"); + this._blackImageURL = Services.io.newFileURI(blackImage).spec; + + // convert -size 3000x200 canvas:#eee white_theme.png + let whiteImage = libDir.clone(); + whiteImage.append("white_theme.png"); + this._whiteImageURL = Services.io.newFileURI(whiteImage).spec; + }, + + configurations: { + noLWT: { + applyConfig: Task.async(function*() { + LightweightThemeManager.currentTheme = null; + }), + }, + + darkLWT: { + applyConfig() { + LightweightThemeManager.setLocalTheme({ + id: "black", + name: "black", + headerURL: LightweightThemes._blackImageURL, + footerURL: LightweightThemes._blackImageURL, + textcolor: "#eeeeee", + accentcolor: "#111111", + }); + + // Wait for LWT listener + return new Promise(resolve => { + setTimeout(() => { + resolve("darkLWT"); + }, 500); + }); + }, + + verifyConfig: verifyConfigHelper, + }, + + lightLWT: { + applyConfig() { + LightweightThemeManager.setLocalTheme({ + id: "white", + name: "white", + headerURL: LightweightThemes._whiteImageURL, + footerURL: LightweightThemes._whiteImageURL, + textcolor: "#111111", + accentcolor: "#eeeeee", + }); + // Wait for LWT listener + return new Promise(resolve => { + setTimeout(() => { + resolve("lightLWT"); + }, 500); + }); + }, + + verifyConfig: verifyConfigHelper, + }, + + }, +}; + + +function verifyConfigHelper() { + return new Promise((resolve, reject) => { + let browserWindow = Services.wm.getMostRecentWindow("navigator:browser"); + if (browserWindow.document.documentElement.hasAttribute("lwtheme")) { + resolve("verifyConfigHelper"); + } else { + reject("The @lwtheme attribute wasn't present so themes may not be available"); + } + }); +} |