mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-26 00:57:30 +09:00
[Pale-Moon] Issue MoonchildProductions/UXP#65 - Remove AppConstants Pale Moon.. again.
This commit is contained in:
parent
0dae8965e5
commit
5e0560d895
5 changed files with 131 additions and 124 deletions
|
|
@ -449,12 +449,14 @@
|
||||||
|
|
||||||
var cancel = false;
|
var cancel = false;
|
||||||
|
|
||||||
let { AppConstants } =
|
|
||||||
Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
|
|
||||||
// Catch any keys that could potentially move the caret. Ctrl can be
|
// Catch any keys that could potentially move the caret. Ctrl can be
|
||||||
// used in combination with these keys on Windows and Linux; and Alt
|
// used in combination with these keys on Windows and Linux; and Alt
|
||||||
// can be used on OS X, so make sure the unused one isn't used.
|
// can be used on OS X, so make sure the unused one isn't used.
|
||||||
let metaKey = AppConstants.platform == "macosx" ? aEvent.ctrlKey : aEvent.altKey;
|
#ifdef XP_MACOSX
|
||||||
|
let metaKey = aEvent.ctrlKey;
|
||||||
|
#else
|
||||||
|
let metaKey = aEvent.altKey;
|
||||||
|
#endif
|
||||||
if (!this.disableKeyNavigation && !metaKey) {
|
if (!this.disableKeyNavigation && !metaKey) {
|
||||||
switch (aEvent.keyCode) {
|
switch (aEvent.keyCode) {
|
||||||
case KeyEvent.DOM_VK_LEFT:
|
case KeyEvent.DOM_VK_LEFT:
|
||||||
|
|
@ -492,11 +494,11 @@
|
||||||
cancel = this.mController.handleEscape();
|
cancel = this.mController.handleEscape();
|
||||||
break;
|
break;
|
||||||
case KeyEvent.DOM_VK_RETURN:
|
case KeyEvent.DOM_VK_RETURN:
|
||||||
if (AppConstants.platform == "macosx") {
|
#ifdef XP_MACOSX
|
||||||
// Prevent the default action, since it will beep on Mac
|
// Prevent the default action, since it will beep on Mac
|
||||||
if (aEvent.metaKey)
|
if (aEvent.metaKey)
|
||||||
aEvent.preventDefault();
|
aEvent.preventDefault();
|
||||||
}
|
#endif
|
||||||
this.mEnterEvent = aEvent;
|
this.mEnterEvent = aEvent;
|
||||||
if (this.mController.selection) {
|
if (this.mController.selection) {
|
||||||
this._selectionDetails = {
|
this._selectionDetails = {
|
||||||
|
|
@ -507,15 +509,19 @@
|
||||||
cancel = this.handleEnter();
|
cancel = this.handleEnter();
|
||||||
break;
|
break;
|
||||||
case KeyEvent.DOM_VK_DELETE:
|
case KeyEvent.DOM_VK_DELETE:
|
||||||
if (AppConstants.platform == "macosx" && !aEvent.shiftKey) {
|
#ifdef XP_MACOSX
|
||||||
|
if (!aEvent.shiftKey) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
cancel = this.handleDelete();
|
cancel = this.handleDelete();
|
||||||
break;
|
break;
|
||||||
case KeyEvent.DOM_VK_BACK_SPACE:
|
case KeyEvent.DOM_VK_BACK_SPACE:
|
||||||
if (AppConstants.platform == "macosx" && aEvent.shiftKey) {
|
#ifdef XP_MACOSX
|
||||||
|
if (aEvent.shiftKey) {
|
||||||
cancel = this.handleDelete();
|
cancel = this.handleDelete();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case KeyEvent.DOM_VK_DOWN:
|
case KeyEvent.DOM_VK_DOWN:
|
||||||
case KeyEvent.DOM_VK_UP:
|
case KeyEvent.DOM_VK_UP:
|
||||||
|
|
@ -523,9 +529,9 @@
|
||||||
this.toggleHistoryPopup();
|
this.toggleHistoryPopup();
|
||||||
break;
|
break;
|
||||||
case KeyEvent.DOM_VK_F4:
|
case KeyEvent.DOM_VK_F4:
|
||||||
if (AppConstants.platform != "macosx") {
|
#ifndef XP_MACOSX
|
||||||
this.toggleHistoryPopup();
|
this.toggleHistoryPopup();
|
||||||
}
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ this.EXPORTED_SYMBOLS = ["ShellService"];
|
||||||
|
|
||||||
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "WindowsRegistry",
|
XPCOMUtils.defineLazyModuleGetter(this, "WindowsRegistry",
|
||||||
|
|
@ -26,20 +25,17 @@ var ShellServiceInternal = {
|
||||||
* environments.
|
* environments.
|
||||||
*/
|
*/
|
||||||
get canSetDesktopBackground() {
|
get canSetDesktopBackground() {
|
||||||
if (AppConstants.platform == "win" ||
|
#ifdef XP_LINUX
|
||||||
AppConstants.platform == "macosx") {
|
if (this.shellService) {
|
||||||
return true;
|
let linuxShellService = this.shellService
|
||||||
|
.QueryInterface(Ci.nsIGNOMEShellService);
|
||||||
|
return linuxShellService.canSetDesktopBackground;
|
||||||
}
|
}
|
||||||
|
#elif defined(XP_WIN) || defined(XP_MACOSX)
|
||||||
if (AppConstants.platform == "linux") {
|
return true;
|
||||||
if (this.shellService) {
|
#else
|
||||||
let linuxShellService = this.shellService
|
|
||||||
.QueryInterface(Ci.nsIGNOMEShellService);
|
|
||||||
return linuxShellService.canSetDesktopBackground;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
#endif
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -60,18 +56,18 @@ var ShellServiceInternal = {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AppConstants.platform == "win") {
|
#ifdef XP_WIN
|
||||||
let optOutValue = WindowsRegistry.readRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
let optOutValue = WindowsRegistry.readRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
||||||
"Software\\Mozilla\\PaleMoon",
|
"Software\\Mozilla\\PaleMoon",
|
||||||
"DefaultBrowserOptOut");
|
"DefaultBrowserOptOut");
|
||||||
WindowsRegistry.removeRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
WindowsRegistry.removeRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
||||||
"Software\\Mozilla\\PaleMoon",
|
"Software\\Mozilla\\PaleMoon",
|
||||||
"DefaultBrowserOptOut");
|
"DefaultBrowserOptOut");
|
||||||
if (optOutValue == "True") {
|
if (optOutValue == "True") {
|
||||||
Services.prefs.setBoolPref("browser.shell.checkDefaultBrowser", false);
|
Services.prefs.setBoolPref("browser.shell.checkDefaultBrowser", false);
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,13 @@ Components.utils.import("resource://gre/modules/AppConstants.jsm");
|
||||||
var Ci = Components.interfaces;
|
var Ci = Components.interfaces;
|
||||||
|
|
||||||
var gSetBackground = {
|
var gSetBackground = {
|
||||||
_position : AppConstants.platform == "macosx" ? "STRETCH" : "",
|
#ifdef XP_MACOSX
|
||||||
_backgroundColor : AppConstants.platform != "macosx" ? 0 : undefined,
|
_position : "STRETCH",
|
||||||
|
_backgroundColor : undefined,
|
||||||
|
#else
|
||||||
|
_position : "",
|
||||||
|
_backgroundColor : 0,
|
||||||
|
#endif
|
||||||
_screenWidth : 0,
|
_screenWidth : 0,
|
||||||
_screenHeight : 0,
|
_screenHeight : 0,
|
||||||
_image : null,
|
_image : null,
|
||||||
|
|
@ -25,23 +30,23 @@ var gSetBackground = {
|
||||||
this._canvas = document.getElementById("screen");
|
this._canvas = document.getElementById("screen");
|
||||||
this._screenWidth = screen.width;
|
this._screenWidth = screen.width;
|
||||||
this._screenHeight = screen.height;
|
this._screenHeight = screen.height;
|
||||||
if (AppConstants.platform == "macosx") {
|
#ifdef XP_MACOSX
|
||||||
document.documentElement.getButton("accept").hidden = true;
|
document.documentElement.getButton("accept").hidden = true;
|
||||||
}
|
#endif
|
||||||
if (this._screenWidth / this._screenHeight >= 1.6)
|
if (this._screenWidth / this._screenHeight >= 1.6)
|
||||||
document.getElementById("monitor").setAttribute("aspectratio", "16:10");
|
document.getElementById("monitor").setAttribute("aspectratio", "16:10");
|
||||||
|
|
||||||
if (AppConstants.platform == "win") {
|
#ifdef XP_WIN
|
||||||
// Hide fill + fit options if < Win7 since they don't work.
|
// Hide fill + fit options if < Win7 since they don't work.
|
||||||
var version = Components.classes["@mozilla.org/system-info;1"]
|
var version = Components.classes["@mozilla.org/system-info;1"]
|
||||||
.getService(Ci.nsIPropertyBag2)
|
.getService(Ci.nsIPropertyBag2)
|
||||||
.getProperty("version");
|
.getProperty("version");
|
||||||
var isWindows7OrHigher = (parseFloat(version) >= 6.1);
|
var isWindows7OrHigher = (parseFloat(version) >= 6.1);
|
||||||
if (!isWindows7OrHigher) {
|
if (!isWindows7OrHigher) {
|
||||||
document.getElementById("fillPosition").hidden = true;
|
document.getElementById("fillPosition").hidden = true;
|
||||||
document.getElementById("fitPosition").hidden = true;
|
document.getElementById("fitPosition").hidden = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// make sure that the correct dimensions will be used
|
// make sure that the correct dimensions will be used
|
||||||
setTimeout(function(self) {
|
setTimeout(function(self) {
|
||||||
|
|
@ -60,28 +65,25 @@ var gSetBackground = {
|
||||||
var ctx = this._canvas.getContext("2d");
|
var ctx = this._canvas.getContext("2d");
|
||||||
ctx.scale(this._canvas.clientWidth / this._screenWidth, this._canvas.clientHeight / this._screenHeight);
|
ctx.scale(this._canvas.clientWidth / this._screenWidth, this._canvas.clientHeight / this._screenHeight);
|
||||||
|
|
||||||
if (AppConstants.platform != "macosx") {
|
#ifdef XP_MACOSX
|
||||||
this._initColor();
|
// Make sure to reset the button state in case the user has already
|
||||||
} else {
|
// set an image as their desktop background.
|
||||||
// Make sure to reset the button state in case the user has already
|
var setDesktopBackground = document.getElementById("setDesktopBackground");
|
||||||
// set an image as their desktop background.
|
setDesktopBackground.hidden = false;
|
||||||
var setDesktopBackground = document.getElementById("setDesktopBackground");
|
var bundle = document.getElementById("backgroundBundle");
|
||||||
setDesktopBackground.hidden = false;
|
setDesktopBackground.label = bundle.getString("DesktopBackgroundSet");
|
||||||
var bundle = document.getElementById("backgroundBundle");
|
setDesktopBackground.disabled = false;
|
||||||
setDesktopBackground.label = bundle.getString("DesktopBackgroundSet");
|
|
||||||
setDesktopBackground.disabled = false;
|
|
||||||
|
|
||||||
document.getElementById("showDesktopPreferences").hidden = true;
|
document.getElementById("showDesktopPreferences").hidden = true;
|
||||||
}
|
#else
|
||||||
|
this._initColor();
|
||||||
|
#endif
|
||||||
this.updatePosition();
|
this.updatePosition();
|
||||||
},
|
},
|
||||||
|
|
||||||
setDesktopBackground: function ()
|
setDesktopBackground: function ()
|
||||||
{
|
{
|
||||||
if (AppConstants.platform != "macosx") {
|
#ifdef XP_MACOSX
|
||||||
document.persist("menuPosition", "value");
|
|
||||||
this._shell.desktopBackgroundColor = this._hexStringToLong(this._backgroundColor);
|
|
||||||
} else {
|
|
||||||
Components.classes["@mozilla.org/observer-service;1"]
|
Components.classes["@mozilla.org/observer-service;1"]
|
||||||
.getService(Ci.nsIObserverService)
|
.getService(Ci.nsIObserverService)
|
||||||
.addObserver(this, "shell:desktop-background-changed", false);
|
.addObserver(this, "shell:desktop-background-changed", false);
|
||||||
|
|
@ -90,7 +92,10 @@ var gSetBackground = {
|
||||||
var setDesktopBackground = document.getElementById("setDesktopBackground");
|
var setDesktopBackground = document.getElementById("setDesktopBackground");
|
||||||
setDesktopBackground.disabled = true;
|
setDesktopBackground.disabled = true;
|
||||||
setDesktopBackground.label = bundle.getString("DesktopBackgroundDownloading");
|
setDesktopBackground.label = bundle.getString("DesktopBackgroundDownloading");
|
||||||
}
|
#else
|
||||||
|
document.persist("menuPosition", "value");
|
||||||
|
this._shell.desktopBackgroundColor = this._hexStringToLong(this._backgroundColor);
|
||||||
|
#endif
|
||||||
this._shell.setDesktopBackground(this._image,
|
this._shell.setDesktopBackground(this._image,
|
||||||
Ci.nsIShellService["BACKGROUND_" + this._position]);
|
Ci.nsIShellService["BACKGROUND_" + this._position]);
|
||||||
},
|
},
|
||||||
|
|
@ -100,9 +105,9 @@ var gSetBackground = {
|
||||||
var ctx = this._canvas.getContext("2d");
|
var ctx = this._canvas.getContext("2d");
|
||||||
ctx.clearRect(0, 0, this._screenWidth, this._screenHeight);
|
ctx.clearRect(0, 0, this._screenWidth, this._screenHeight);
|
||||||
|
|
||||||
if (AppConstants.platform != "macosx") {
|
#ifndef XP_MACOSX
|
||||||
this._position = document.getElementById("menuPosition").value;
|
this._position = document.getElementById("menuPosition").value;
|
||||||
}
|
#endif
|
||||||
|
|
||||||
switch (this._position) {
|
switch (this._position) {
|
||||||
case "TILE":
|
case "TILE":
|
||||||
|
|
@ -158,57 +163,57 @@ var gSetBackground = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (AppConstants.platform != "macosx") {
|
#ifdef XP_MACOSX
|
||||||
gSetBackground["_initColor"] = function ()
|
gSetBackground["observe"] = function (aSubject, aTopic, aData)
|
||||||
{
|
{
|
||||||
var color = this._shell.desktopBackgroundColor;
|
if (aTopic == "shell:desktop-background-changed") {
|
||||||
|
document.getElementById("setDesktopBackground").hidden = true;
|
||||||
|
document.getElementById("showDesktopPreferences").hidden = false;
|
||||||
|
|
||||||
const rMask = 4294901760;
|
Components.classes["@mozilla.org/observer-service;1"]
|
||||||
const gMask = 65280;
|
.getService(Ci.nsIObserverService)
|
||||||
const bMask = 255;
|
.removeObserver(this, "shell:desktop-background-changed");
|
||||||
var r = (color & rMask) >> 16;
|
}
|
||||||
var g = (color & gMask) >> 8;
|
};
|
||||||
var b = (color & bMask);
|
|
||||||
this.updateColor(this._rgbToHex(r, g, b));
|
|
||||||
|
|
||||||
var colorpicker = document.getElementById("desktopColor");
|
gSetBackground["showDesktopPrefs"] = function()
|
||||||
colorpicker.color = this._backgroundColor;
|
{
|
||||||
};
|
this._shell.openApplication(Ci.nsIMacShellService.APPLICATION_DESKTOP);
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
gSetBackground["_initColor"] = function ()
|
||||||
|
{
|
||||||
|
var color = this._shell.desktopBackgroundColor;
|
||||||
|
|
||||||
gSetBackground["updateColor"] = function (aColor)
|
const rMask = 4294901760;
|
||||||
{
|
const gMask = 65280;
|
||||||
this._backgroundColor = aColor;
|
const bMask = 255;
|
||||||
this._canvas.style.backgroundColor = aColor;
|
var r = (color & rMask) >> 16;
|
||||||
};
|
var g = (color & gMask) >> 8;
|
||||||
|
var b = (color & bMask);
|
||||||
|
this.updateColor(this._rgbToHex(r, g, b));
|
||||||
|
|
||||||
// Converts a color string in the format "#RRGGBB" to an integer.
|
var colorpicker = document.getElementById("desktopColor");
|
||||||
gSetBackground["_hexStringToLong"] = function (aString)
|
colorpicker.color = this._backgroundColor;
|
||||||
{
|
};
|
||||||
return parseInt(aString.substring(1, 3), 16) << 16 |
|
|
||||||
parseInt(aString.substring(3, 5), 16) << 8 |
|
|
||||||
parseInt(aString.substring(5, 7), 16);
|
|
||||||
};
|
|
||||||
|
|
||||||
gSetBackground["_rgbToHex"] = function (aR, aG, aB)
|
gSetBackground["updateColor"] = function (aColor)
|
||||||
{
|
{
|
||||||
return "#" + [aR, aG, aB].map(aInt => aInt.toString(16).replace(/^(.)$/, "0$1"))
|
this._backgroundColor = aColor;
|
||||||
.join("").toUpperCase();
|
this._canvas.style.backgroundColor = aColor;
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
gSetBackground["observe"] = function (aSubject, aTopic, aData)
|
|
||||||
{
|
|
||||||
if (aTopic == "shell:desktop-background-changed") {
|
|
||||||
document.getElementById("setDesktopBackground").hidden = true;
|
|
||||||
document.getElementById("showDesktopPreferences").hidden = false;
|
|
||||||
|
|
||||||
Components.classes["@mozilla.org/observer-service;1"]
|
// Converts a color string in the format "#RRGGBB" to an integer.
|
||||||
.getService(Ci.nsIObserverService)
|
gSetBackground["_hexStringToLong"] = function (aString)
|
||||||
.removeObserver(this, "shell:desktop-background-changed");
|
{
|
||||||
}
|
return parseInt(aString.substring(1, 3), 16) << 16 |
|
||||||
};
|
parseInt(aString.substring(3, 5), 16) << 8 |
|
||||||
|
parseInt(aString.substring(5, 7), 16);
|
||||||
|
};
|
||||||
|
|
||||||
gSetBackground["showDesktopPrefs"] = function()
|
gSetBackground["_rgbToHex"] = function (aR, aG, aB)
|
||||||
{
|
{
|
||||||
this._shell.openApplication(Ci.nsIMacShellService.APPLICATION_DESKTOP);
|
return "#" + [aR, aG, aB].map(aInt => aInt.toString(16).replace(/^(.)$/, "0$1"))
|
||||||
};
|
.join("").toUpperCase();
|
||||||
}
|
};
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,4 @@
|
||||||
|
|
||||||
browser.jar:
|
browser.jar:
|
||||||
* content/browser/setDesktopBackground.xul (content/setDesktopBackground.xul)
|
* content/browser/setDesktopBackground.xul (content/setDesktopBackground.xul)
|
||||||
content/browser/setDesktopBackground.js (content/setDesktopBackground.js)
|
* content/browser/setDesktopBackground.js (content/setDesktopBackground.js)
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ EXTRA_COMPONENTS += [
|
||||||
'nsSetDefaultBrowser.manifest',
|
'nsSetDefaultBrowser.manifest',
|
||||||
]
|
]
|
||||||
|
|
||||||
EXTRA_JS_MODULES += ['ShellService.jsm']
|
EXTRA_PP_JS_MODULES += ['ShellService.jsm']
|
||||||
|
|
||||||
for var in ('MOZ_APP_NAME', 'MOZ_APP_VERSION'):
|
for var in ('MOZ_APP_NAME', 'MOZ_APP_VERSION'):
|
||||||
DEFINES[var] = '"%s"' % CONFIG[var]
|
DEFINES[var] = '"%s"' % CONFIG[var]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue