[Pkg-mozext-commits] [requestpolicy] 51/280: fix a bug with Australis. fixes #532
David Prévot
taffit at moszumanska.debian.org
Sat May 2 20:29:58 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit 278a5381bf769e5f385019e727a60fb5f0fca911
Author: Martin Kimmerle <dev at 256k.de>
Date: Fri Dec 5 08:33:32 2014 +0100
fix a bug with Australis. fixes #532
---
src/content/lib/window-manager-toolbarbutton.js | 53 ++++++++++++++------
src/content/lib/window-manager.jsm | 65 +++++++++++++++++--------
2 files changed, 81 insertions(+), 37 deletions(-)
diff --git a/src/content/lib/window-manager-toolbarbutton.js b/src/content/lib/window-manager-toolbarbutton.js
index 1c7d917..139a731 100644
--- a/src/content/lib/window-manager-toolbarbutton.js
+++ b/src/content/lib/window-manager-toolbarbutton.js
@@ -39,25 +39,24 @@ if (Utils.info.isAustralis) {
let rpWindowManager = (function(self) {
+ let isAustralis = Utils.info.isAustralis;
- self.addToolbarButtonToWindow = function(win) {
- if (Utils.info.isAustralis) {
- addToolbarButtonToAustralis(win);
- } else {
- XULUtils.addTreeElementsToWindow(win, "toolbarbutton");
- addToolbarButtonToNavBar(win);
- }
- };
+ //
+ // Case 1: Australis (Gecko >= 29)
+ //
- self.removeToolbarButtonFromWindow = function(win) {
- if (Utils.info.isAustralis) {
- CustomizableUI.destroyWidget(toolbarButtonId);
- } else {
- XULUtils.removeTreeElementsFromWindow(win, "toolbarbutton");
- }
- };
+ if (isAustralis) {
+ BootstrapManager.registerStartupFunction(function() {
+ addToolbarButtonToAustralis();
+ });
+
+ BootstrapManager.registerShutdownFunction(function() {
+ let tbb = XULUtils.xulTrees.toolbarbutton[0];
+ CustomizableUI.destroyWidget(tbb.id);
+ });
+ }
- function addToolbarButtonToAustralis(win) {
+ function addToolbarButtonToAustralis() {
let tbb = XULUtils.xulTrees.toolbarbutton[0];
CustomizableUI.createWidget({
id: tbb.id,
@@ -65,12 +64,34 @@ let rpWindowManager = (function(self) {
label: tbb.label,
tooltiptext: tbb.tooltiptext,
onCommand : function(aEvent) {
+ // Bad smell
+ let win = aEvent.target.ownerDocument.defaultView;
win.requestpolicy.overlay.openToolbarPopup(aEvent.target);
}
});
}
+ //
+ // Case 2: Gecko < 29
+ //
+
+
+ // this function can be deleted if Gecko < 29 isn't supported anymore
+ self.addToolbarButtonToWindow = function(win) {
+ if (!isAustralis) {
+ XULUtils.addTreeElementsToWindow(win, "toolbarbutton");
+ addToolbarButtonToNavBar(win);
+ }
+ };
+
+ self.removeToolbarButtonFromWindow = function(win) {
+ if (!isAustralis) {
+ XULUtils.removeTreeElementsFromWindow(win, "toolbarbutton");
+ }
+ };
+
+
function addToolbarButtonToNavBar(win) {
// SeaMonkey users have to use a toolbar button now. At the moment I can't
// justify a bunch of special cases to support the statusbar when such a
diff --git a/src/content/lib/window-manager.jsm b/src/content/lib/window-manager.jsm
index 875dd65..da07f4e 100644
--- a/src/content/lib/window-manager.jsm
+++ b/src/content/lib/window-manager.jsm
@@ -88,25 +88,50 @@ let rpWindowManager = (function(self) {
}
function loadIntoWindow(window) {
- XULUtils.addTreeElementsToWindow(window, "mainTree");
-
- // create a scope variable for RP for this window
- window.requestpolicy = {};
- Services.scriptloader.loadSubScript(
- "chrome://requestpolicy/content/ui/overlay.js", window);
- Services.scriptloader.loadSubScript(
- "chrome://requestpolicy/content/ui/menu.js", window);
- Services.scriptloader.loadSubScript(
- "chrome://requestpolicy/content/ui/classicmenu.js", window);
-
- self.addToolbarButtonToWindow(window);
-
- // init and onWindowLoad must be called last, because they assume that
- // everything else is ready
- window.requestpolicy.overlay.init();
- window.requestpolicy.overlay.onWindowLoad();
- window.messageManager.loadFrameScript(
- "chrome://requestpolicy/content/ui/frame.js", true);
+ try {
+ XULUtils.addTreeElementsToWindow(window, "mainTree");
+ } catch (e) {
+ Logger.warning(Logger.TYPE_ERROR,
+ "Couldn't add tree elements to window.");
+ }
+
+ try {
+ // create a scope variable for RP for this window
+ window.requestpolicy = {};
+ Services.scriptloader.loadSubScript(
+ "chrome://requestpolicy/content/ui/overlay.js", window);
+ Services.scriptloader.loadSubScript(
+ "chrome://requestpolicy/content/ui/menu.js", window);
+ Services.scriptloader.loadSubScript(
+ "chrome://requestpolicy/content/ui/classicmenu.js", window);
+ } catch (e) {
+ Logger.warning(Logger.TYPE_ERROR,
+ "Error loading subscripts for window: "+e, e);
+ }
+
+ try {
+ self.addToolbarButtonToWindow(window);
+ } catch (e) {
+ Logger.warning(Logger.TYPE_ERROR, "Error while adding the toolbar " +
+ "button to the window: "+e, e);
+ }
+
+ try {
+ // init and onWindowLoad must be called last, because they assume that
+ // everything else is ready
+ window.requestpolicy.overlay.init();
+ window.requestpolicy.overlay.onWindowLoad();
+ } catch (e) {
+ Logger.warning(Logger.TYPE_ERROR,
+ "An error occurred while initializing the overlay: "+e, e);
+ }
+
+ try {
+ window.messageManager.loadFrameScript(
+ "chrome://requestpolicy/content/ui/frame.js", true);
+ } catch (e) {
+ Logger.warning(Logger.TYPE_ERROR, "Error loading the frame script: "+e,e);
+ }
}
function unloadFromWindow(window) {
@@ -124,8 +149,6 @@ let rpWindowManager = (function(self) {
-
-
BootstrapManager.registerStartupFunction(function(data, reason) {
forEachOpenWindow(loadIntoWindow);
Services.wm.addListener(WindowListener);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list