From a17391bdbaebfe219a6eba9a93e3b9aeb41f91e0 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 6 Nov 2010 00:43:47 -0700 Subject: [PATCH 001/112] adding a access key (R) --- bootstrap.js | 1 + 1 file changed, 1 insertion(+) diff --git a/bootstrap.js b/bootstrap.js index 83b946f..8fe8706 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -15,6 +15,7 @@ function main(win) { let quitMI = doc.getElementById("menu_FileQuitItem"); restartMI.setAttribute("id", "menu_FileRestartItem"); restartMI.setAttribute("label", "Restart"); + restartMI.setAttribute("accesskey", "R"); restartMI.addEventListener("command", restart, true); fileMenu.insertBefore(restartMI, quitMI); From 1ee6d81857da73d3b11ab06dc0a2f5d5a89b88a9 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 6 Nov 2010 00:46:19 -0700 Subject: [PATCH 002/112] since startup is only calling findWindowsAndRun atm startup now does what findWindowsAndRun used to do. --- bootstrap.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 8fe8706..2efa637 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -29,9 +29,9 @@ function main(win) { win.addEventListener("unload", winUnloader, false); } -function findWindowsAndRun(aFunc) { +function startup() { let browserWins = Services.wm.getEnumerator("navigator:browser"); - while (browserWins.hasMoreElements()) aFunc(browserWins.getNext()); + while (browserWins.hasMoreElements()) main(browserWins.getNext()); function winObs(aSubject, aTopic) { if ("domwindowopened" != aTopic) return; @@ -39,15 +39,13 @@ function findWindowsAndRun(aFunc) { aSubject.removeEventListener("load", winLoad, false); if ("navigator:browser" == aSubject.document.documentElement.getAttribute("windowtype")) - aFunc(aSubject); + main(aSubject); } aSubject.addEventListener("load", winLoad, false); } Services.ww.registerNotification(winObs); cleanupAry.push(function() Services.ww.unregisterNotification(winObs)); } - -function startup() findWindowsAndRun(main); function shutdown() { for (let [, cleaner] in Iterator(cleanupAry)) cleaner && cleaner(); } From 0009b73753956865c70696122152f16fb546b29c Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 6 Nov 2010 00:50:46 -0700 Subject: [PATCH 003/112] minor style change --- bootstrap.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 2efa637..ae79005 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -3,10 +3,9 @@ Cu.import("resource://gre/modules/Services.jsm"); let cleanupAry = []; -function restart() { - Cc['@mozilla.org/toolkit/app-startup;1'].getService(Ci.nsIAppStartup) - .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart); -} +function restart() ( + Cc['@mozilla.org/toolkit/app-startup;1'].getService(Ci.nsIAppStartup) + .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart)); function main(win) { let doc = win.document; From c815bd37ffa1e5454ae3d5afb1ba593400303dfb Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 6 Nov 2010 01:19:01 -0700 Subject: [PATCH 004/112] Closes #1 adding a accel + alt + R hotkey --- bootstrap.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index ae79005..74a0138 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -9,16 +9,32 @@ function restart() ( function main(win) { let doc = win.document; + + // add hotkey + let restartKey = doc.createElement("key"); + restartKey.setAttribute("id", "RR:Restart"); + restartKey.setAttribute("key", "R"); + restartKey.setAttribute("modifiers", "accel,alt"); + restartKey.setAttribute("oncommand", "void(0);"); + restartKey.addEventListener("command", restart, true); + let mainKS = doc.getElementById("mainKeyset"); + mainKS.appendChild(restartKey); + + // add menu item let restartMI = doc.createElement("menuitem"); - let fileMenu = doc.getElementById("menu_FilePopup"); - let quitMI = doc.getElementById("menu_FileQuitItem"); restartMI.setAttribute("id", "menu_FileRestartItem"); restartMI.setAttribute("label", "Restart"); restartMI.setAttribute("accesskey", "R"); + restartMI.setAttribute("key", "RR:Restart"); restartMI.addEventListener("command", restart, true); + let fileMenu = doc.getElementById("menu_FilePopup"); + let quitMI = doc.getElementById("menu_FileQuitItem"); fileMenu.insertBefore(restartMI, quitMI); - let idx1 = cleanupAry.push(function() fileMenu.removeChild(restartMI)) - 1; + let idx1 = cleanupAry.push(function() { + mainKS.removeChild(restartKey); + fileMenu.removeChild(restartMI); + }) - 1; let idx2 = cleanupAry.push(function() ( win.removeEventListener("unload", winUnloader, false))) - 1; function winUnloader() { From 97f0f5e4ec53f6061dc351ee456422be203d937e Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 6 Nov 2010 01:23:56 -0700 Subject: [PATCH 005/112] removing useless var --- bootstrap.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 74a0138..903a64a 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -28,8 +28,7 @@ function main(win) { restartMI.setAttribute("key", "RR:Restart"); restartMI.addEventListener("command", restart, true); let fileMenu = doc.getElementById("menu_FilePopup"); - let quitMI = doc.getElementById("menu_FileQuitItem"); - fileMenu.insertBefore(restartMI, quitMI); + fileMenu.insertBefore(restartMI, doc.getElementById("menu_FileQuitItem")); let idx1 = cleanupAry.push(function() { mainKS.removeChild(restartKey); From dbabf5de44fee127df47037e3023e2c842827805 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 6 Nov 2010 01:45:09 -0700 Subject: [PATCH 006/112] Closes #2 Supporting Seamonkey --- install.rdf | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/install.rdf b/install.rdf index 320c8ce..ddab913 100644 --- a/install.rdf +++ b/install.rdf @@ -11,11 +11,20 @@ http://github.com/erikvold/restartless-restart-ffext http://picol.org/images/icons/files/png/32/refresh_32.png + {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 4.0b4 - 4.0b8pre + 4.0.* + + + + + + {92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} + 2.1a3 + 2.1.* From 5e10c83e20893924f5fe3027f49c6b5e932f9e4e Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 6 Nov 2010 11:13:00 -0700 Subject: [PATCH 007/112] 2 --- install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.rdf b/install.rdf index ddab913..4753544 100644 --- a/install.rdf +++ b/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 1 + 2 true 2 http://github.com/erikvold/restartless-restart-ffext From 89c876d1687d1caa16777b81afa131f402316c30 Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sat, 6 Nov 2010 16:52:46 -0500 Subject: [PATCH 008/112] add app (Firefox button) menu item --- bootstrap.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bootstrap.js b/bootstrap.js index 903a64a..d425a3b 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -20,7 +20,7 @@ function main(win) { let mainKS = doc.getElementById("mainKeyset"); mainKS.appendChild(restartKey); - // add menu item + // add menu bar item let restartMI = doc.createElement("menuitem"); restartMI.setAttribute("id", "menu_FileRestartItem"); restartMI.setAttribute("label", "Restart"); @@ -29,10 +29,21 @@ function main(win) { restartMI.addEventListener("command", restart, true); let fileMenu = doc.getElementById("menu_FilePopup"); fileMenu.insertBefore(restartMI, doc.getElementById("menu_FileQuitItem")); + + // add app (Firefox button) menu item + let restartAMI = doc.createElement("menuitem"); + restartAMI.setAttribute("id", "appmenu_RestartItem"); + restartAMI.setAttribute("label", "Restart"); + restartAMI.setAttribute("accesskey", "R"); + restartAMI.setAttribute("key", "RR:Restart"); + restartAMI.addEventListener("command", restart, true); + let appMenu = doc.getElementById("appmenuPrimaryPane"); + appMenu.insertBefore(restartAMI, doc.getElementById("appmenu-quit")); let idx1 = cleanupAry.push(function() { mainKS.removeChild(restartKey); fileMenu.removeChild(restartMI); + appMenu.removeChild(restartAMI); }) - 1; let idx2 = cleanupAry.push(function() ( win.removeEventListener("unload", winUnloader, false))) - 1; From ad31fa1c2e4756c7c234baaa4229bb2f5b25bae2 Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sat, 6 Nov 2010 17:19:13 -0500 Subject: [PATCH 009/112] add an icon to the app menu item --- bootstrap.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bootstrap.js b/bootstrap.js index d425a3b..1a819fa 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -36,6 +36,10 @@ function main(win) { restartAMI.setAttribute("label", "Restart"); restartAMI.setAttribute("accesskey", "R"); restartAMI.setAttribute("key", "RR:Restart"); + restartAMI.setAttribute("class", "menuitem-iconic menuitem-iconic-tooltip"); + restartAMI.style.MozImageRegion = "rect(0, 28px, 14px, 14px)"; + restartAMI.style.listStyleImage = + "url('chrome://browser/skin/reload-stop-go.png')"; restartAMI.addEventListener("command", restart, true); let appMenu = doc.getElementById("appmenuPrimaryPane"); appMenu.insertBefore(restartAMI, doc.getElementById("appmenu-quit")); From 830e6e2f7146f74dc2a28c814b9bcdbe8417e9e3 Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sat, 6 Nov 2010 17:29:52 -0500 Subject: [PATCH 010/112] mentioning myself --- install.rdf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install.rdf b/install.rdf index 4753544..30110dc 100644 --- a/install.rdf +++ b/install.rdf @@ -11,6 +11,8 @@ http://github.com/erikvold/restartless-restart-ffext http://picol.org/images/icons/files/png/32/refresh_32.png + Greg Parris; http://phob.net/ + From 5e85ad76ae29da26cc90bef61c92d0069409a1fc Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sat, 6 Nov 2010 17:38:33 -0500 Subject: [PATCH 011/112] changing icon to match source in install.rdf --- bootstrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.js b/bootstrap.js index 1a819fa..d5270dc 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -39,7 +39,7 @@ function main(win) { restartAMI.setAttribute("class", "menuitem-iconic menuitem-iconic-tooltip"); restartAMI.style.MozImageRegion = "rect(0, 28px, 14px, 14px)"; restartAMI.style.listStyleImage = - "url('chrome://browser/skin/reload-stop-go.png')"; + "url('http://picol.org/images/icons/files/png/16/refresh_16.png')"; restartAMI.addEventListener("command", restart, true); let appMenu = doc.getElementById("appmenuPrimaryPane"); appMenu.insertBefore(restartAMI, doc.getElementById("appmenu-quit")); From 1c281acfd525e04d07b5c0287a80b16ab04af78a Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sat, 6 Nov 2010 17:41:34 -0500 Subject: [PATCH 012/112] removing image region, not needed with the refresh_16 icon --- bootstrap.js | 1 - 1 file changed, 1 deletion(-) diff --git a/bootstrap.js b/bootstrap.js index d5270dc..3fd713d 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -37,7 +37,6 @@ function main(win) { restartAMI.setAttribute("accesskey", "R"); restartAMI.setAttribute("key", "RR:Restart"); restartAMI.setAttribute("class", "menuitem-iconic menuitem-iconic-tooltip"); - restartAMI.style.MozImageRegion = "rect(0, 28px, 14px, 14px)"; restartAMI.style.listStyleImage = "url('http://picol.org/images/icons/files/png/16/refresh_16.png')"; restartAMI.addEventListener("command", restart, true); From b4c142e5ec6b0a040c0c745a48627b542534c59f Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sat, 6 Nov 2010 18:01:50 -0500 Subject: [PATCH 013/112] SeaMonkey does not have the app menu (yet) --- bootstrap.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 3fd713d..5944e61 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -31,22 +31,24 @@ function main(win) { fileMenu.insertBefore(restartMI, doc.getElementById("menu_FileQuitItem")); // add app (Firefox button) menu item - let restartAMI = doc.createElement("menuitem"); - restartAMI.setAttribute("id", "appmenu_RestartItem"); - restartAMI.setAttribute("label", "Restart"); - restartAMI.setAttribute("accesskey", "R"); - restartAMI.setAttribute("key", "RR:Restart"); - restartAMI.setAttribute("class", "menuitem-iconic menuitem-iconic-tooltip"); - restartAMI.style.listStyleImage = - "url('http://picol.org/images/icons/files/png/16/refresh_16.png')"; - restartAMI.addEventListener("command", restart, true); - let appMenu = doc.getElementById("appmenuPrimaryPane"); - appMenu.insertBefore(restartAMI, doc.getElementById("appmenu-quit")); + let appMenu = doc.getElementById("appmenuPrimaryPane"), restartAMI; + if (appMenu) { + restartAMI = doc.createElement("menuitem"); + restartAMI.setAttribute("id", "appmenu_RestartItem"); + restartAMI.setAttribute("label", "Restart"); + restartAMI.setAttribute("accesskey", "R"); + restartAMI.setAttribute("key", "RR:Restart"); + restartAMI.setAttribute("class", "menuitem-iconic menuitem-iconic-tooltip"); + restartAMI.style.listStyleImage = + "url('http://picol.org/images/icons/files/png/16/refresh_16.png')"; + restartAMI.addEventListener("command", restart, true); + appMenu.insertBefore(restartAMI, doc.getElementById("appmenu-quit")); + } let idx1 = cleanupAry.push(function() { mainKS.removeChild(restartKey); fileMenu.removeChild(restartMI); - appMenu.removeChild(restartAMI); + appMenu && appMenu.removeChild(restartAMI); }) - 1; let idx2 = cleanupAry.push(function() ( win.removeEventListener("unload", winUnloader, false))) - 1; From cfd3c619df8aecafc6f108a8f3373fd9052b01f6 Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sat, 6 Nov 2010 18:49:03 -0500 Subject: [PATCH 014/112] use .cloneNode to create the app menu item --- bootstrap.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 5944e61..80d22f5 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -33,11 +33,8 @@ function main(win) { // add app (Firefox button) menu item let appMenu = doc.getElementById("appmenuPrimaryPane"), restartAMI; if (appMenu) { - restartAMI = doc.createElement("menuitem"); + restartAMI = restartMI.cloneNode(false); restartAMI.setAttribute("id", "appmenu_RestartItem"); - restartAMI.setAttribute("label", "Restart"); - restartAMI.setAttribute("accesskey", "R"); - restartAMI.setAttribute("key", "RR:Restart"); restartAMI.setAttribute("class", "menuitem-iconic menuitem-iconic-tooltip"); restartAMI.style.listStyleImage = "url('http://picol.org/images/icons/files/png/16/refresh_16.png')"; From 59e0642e4e8ea2f2fd2a9727cf2ba3fa8df7bfd8 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 6 Nov 2010 19:01:50 -0700 Subject: [PATCH 015/112] saw a warning that the install() method was not defined, so I'm adding this and uninstall(). --- bootstrap.js | 1 + 1 file changed, 1 insertion(+) diff --git a/bootstrap.js b/bootstrap.js index 80d22f5..738bc0e 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -56,6 +56,7 @@ function main(win) { win.addEventListener("unload", winUnloader, false); } +let install = uninstall = function install(){}; function startup() { let browserWins = Services.wm.getEnumerator("navigator:browser"); while (browserWins.hasMoreElements()) main(browserWins.getNext()); From 2e5c5a235f3e7c1f9186396f2f94e1507d54195c Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 6 Nov 2010 19:10:00 -0700 Subject: [PATCH 016/112] adding a shortcut for doc.getElementById(id); --- bootstrap.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 738bc0e..9826561 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -9,6 +9,7 @@ function restart() ( function main(win) { let doc = win.document; + function $(id) doc.getElementById(id); // add hotkey let restartKey = doc.createElement("key"); @@ -17,7 +18,7 @@ function main(win) { restartKey.setAttribute("modifiers", "accel,alt"); restartKey.setAttribute("oncommand", "void(0);"); restartKey.addEventListener("command", restart, true); - let mainKS = doc.getElementById("mainKeyset"); + let mainKS = $("mainKeyset"); mainKS.appendChild(restartKey); // add menu bar item @@ -27,11 +28,11 @@ function main(win) { restartMI.setAttribute("accesskey", "R"); restartMI.setAttribute("key", "RR:Restart"); restartMI.addEventListener("command", restart, true); - let fileMenu = doc.getElementById("menu_FilePopup"); - fileMenu.insertBefore(restartMI, doc.getElementById("menu_FileQuitItem")); + let fileMenu = $("menu_FilePopup"); + fileMenu.insertBefore(restartMI, $("menu_FileQuitItem")); // add app (Firefox button) menu item - let appMenu = doc.getElementById("appmenuPrimaryPane"), restartAMI; + let appMenu = $("appmenuPrimaryPane"), restartAMI; if (appMenu) { restartAMI = restartMI.cloneNode(false); restartAMI.setAttribute("id", "appmenu_RestartItem"); @@ -39,7 +40,7 @@ function main(win) { restartAMI.style.listStyleImage = "url('http://picol.org/images/icons/files/png/16/refresh_16.png')"; restartAMI.addEventListener("command", restart, true); - appMenu.insertBefore(restartAMI, doc.getElementById("appmenu-quit")); + appMenu.insertBefore(restartAMI, $("appmenu-quit")); } let idx1 = cleanupAry.push(function() { From 75cf1021585916362548c45947c85b32f1e56484 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 6 Nov 2010 19:13:00 -0700 Subject: [PATCH 017/112] minor comment changes --- bootstrap.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 9826561..4bae0a2 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -21,7 +21,7 @@ function main(win) { let mainKS = $("mainKeyset"); mainKS.appendChild(restartKey); - // add menu bar item + // add menu bar item to File menu let restartMI = doc.createElement("menuitem"); restartMI.setAttribute("id", "menu_FileRestartItem"); restartMI.setAttribute("label", "Restart"); @@ -31,7 +31,7 @@ function main(win) { let fileMenu = $("menu_FilePopup"); fileMenu.insertBefore(restartMI, $("menu_FileQuitItem")); - // add app (Firefox button) menu item + // add app menu item to Firefox button for Windows 7 let appMenu = $("appmenuPrimaryPane"), restartAMI; if (appMenu) { restartAMI = restartMI.cloneNode(false); From 336538e446c0d89f9076e49cec8065987409a463 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 6 Nov 2010 19:22:32 -0700 Subject: [PATCH 018/112] using doc.createElementNS instead of doc.createElement --- bootstrap.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 4bae0a2..0e8fb75 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -1,6 +1,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components; Cu.import("resource://gre/modules/Services.jsm"); +const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" let cleanupAry = []; function restart() ( @@ -12,7 +13,7 @@ function main(win) { function $(id) doc.getElementById(id); // add hotkey - let restartKey = doc.createElement("key"); + let restartKey = doc.createElementNS(NS_XUL, "key"); restartKey.setAttribute("id", "RR:Restart"); restartKey.setAttribute("key", "R"); restartKey.setAttribute("modifiers", "accel,alt"); @@ -22,7 +23,7 @@ function main(win) { mainKS.appendChild(restartKey); // add menu bar item to File menu - let restartMI = doc.createElement("menuitem"); + let restartMI = doc.createElementNS(NS_XUL, "menuitem"); restartMI.setAttribute("id", "menu_FileRestartItem"); restartMI.setAttribute("label", "Restart"); restartMI.setAttribute("accesskey", "R"); From abc307123a0e0ad733fae676af9d8890b78c21d4 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 6 Nov 2010 19:27:52 -0700 Subject: [PATCH 019/112] version 3 --- install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.rdf b/install.rdf index 30110dc..cf41336 100644 --- a/install.rdf +++ b/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 2 + 3 true 2 http://github.com/erikvold/restartless-restart-ffext From f6314eca9afcfdf940c3c570398c614388b8b6ad Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 6 Nov 2010 20:32:27 -0700 Subject: [PATCH 020/112] removing some white space --- bootstrap.js | 2 +- install.rdf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 0e8fb75..c95a46e 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -31,7 +31,7 @@ function main(win) { restartMI.addEventListener("command", restart, true); let fileMenu = $("menu_FilePopup"); fileMenu.insertBefore(restartMI, $("menu_FileQuitItem")); - + // add app menu item to Firefox button for Windows 7 let appMenu = $("appmenuPrimaryPane"), restartAMI; if (appMenu) { diff --git a/install.rdf b/install.rdf index cf41336..ee81ca4 100644 --- a/install.rdf +++ b/install.rdf @@ -12,7 +12,7 @@ http://picol.org/images/icons/files/png/32/refresh_32.png Greg Parris; http://phob.net/ - + From 851ffbe71667908aac02a6dc58e66220a3552db1 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 6 Nov 2010 23:42:25 -0700 Subject: [PATCH 021/112] minor style change --- bootstrap.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bootstrap.js b/bootstrap.js index c95a46e..ffc5efe 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -58,7 +58,8 @@ function main(win) { win.addEventListener("unload", winUnloader, false); } -let install = uninstall = function install(){}; +function install(){} +function uninstall(){} function startup() { let browserWins = Services.wm.getEnumerator("navigator:browser"); while (browserWins.hasMoreElements()) main(browserWins.getNext()); From ebb006025ec62f14892092c5b70e55647cd6b47c Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Thu, 11 Nov 2010 10:18:02 -0800 Subject: [PATCH 022/112] performance tweak: when shutting down the application, there is no reason to do any cleanup. --- bootstrap.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index ffc5efe..26d37a6 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -77,6 +77,7 @@ function startup() { Services.ww.registerNotification(winObs); cleanupAry.push(function() Services.ww.unregisterNotification(winObs)); } -function shutdown() { - for (let [, cleaner] in Iterator(cleanupAry)) cleaner && cleaner(); +function shutdown(data, reason) { + if (reason !== APP_SHUTDOWN) + for (let [, cleaner] in Iterator(cleanupAry)) cleaner && cleaner(); } From 0a3bd62b083f2d25861c6ba8985db454111ec298 Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sun, 21 Nov 2010 14:29:24 -0800 Subject: [PATCH 023/112] Closes #8 allow users to change the hotkey --- bootstrap.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 26d37a6..3aca523 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -1,9 +1,21 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components; Cu.import("resource://gre/modules/Services.jsm"); -const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" +const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; +const PREF_BRANCH = Services.prefs.getBranch("extensions.restartless-restart."); +const PREFS = { + key: "R", + modifiers: "accel,alt" +}; let cleanupAry = []; +function getPref(aName) { + try { + return PREF_BRANCH.getComplexValue(aName, Ci.nsISupportsString).data; + } catch(e) {} + return PREFS[aName]; +} + function restart() ( Cc['@mozilla.org/toolkit/app-startup;1'].getService(Ci.nsIAppStartup) .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart)); @@ -15,8 +27,8 @@ function main(win) { // add hotkey let restartKey = doc.createElementNS(NS_XUL, "key"); restartKey.setAttribute("id", "RR:Restart"); - restartKey.setAttribute("key", "R"); - restartKey.setAttribute("modifiers", "accel,alt"); + restartKey.setAttribute("key", getPref("key")); + restartKey.setAttribute("modifiers", getPref("modifiers")); restartKey.setAttribute("oncommand", "void(0);"); restartKey.addEventListener("command", restart, true); let mainKS = $("mainKeyset"); From 6faa5b45c44faae0657b0d52eae032422ab890c7 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 21 Dec 2010 20:41:55 -0800 Subject: [PATCH 024/112] Closes #10 using local icon --- bootstrap.js | 8 +++++--- images/refresh_16.png | Bin 0 -> 273 bytes install.rdf | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 images/refresh_16.png diff --git a/bootstrap.js b/bootstrap.js index 3aca523..36a6f00 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -8,6 +8,7 @@ const PREFS = { modifiers: "accel,alt" }; let cleanupAry = []; +let logo = "http://picol.org/images/icons/files/png/16/refresh_16.png"; function getPref(aName) { try { @@ -50,8 +51,7 @@ function main(win) { restartAMI = restartMI.cloneNode(false); restartAMI.setAttribute("id", "appmenu_RestartItem"); restartAMI.setAttribute("class", "menuitem-iconic menuitem-iconic-tooltip"); - restartAMI.style.listStyleImage = - "url('http://picol.org/images/icons/files/png/16/refresh_16.png')"; + restartAMI.style.listStyleImage = "url('" + logo + "')"; restartAMI.addEventListener("command", restart, true); appMenu.insertBefore(restartAMI, $("appmenu-quit")); } @@ -72,7 +72,9 @@ function main(win) { function install(){} function uninstall(){} -function startup() { +function startup(data) { + logo = Services.io.newFileURI(data.installPath).spec + "images/refresh_16.png"; + let browserWins = Services.wm.getEnumerator("navigator:browser"); while (browserWins.hasMoreElements()) main(browserWins.getNext()); diff --git a/images/refresh_16.png b/images/refresh_16.png new file mode 100644 index 0000000000000000000000000000000000000000..66e21e3a64ac28d654f36b9dd5265f74f06f22a3 GIT binary patch literal 273 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5XHha1_hE&{2N;tsJ(h$Ko{mK9T|2KA7GkmO?U?UaBKlO07 zgS}YqiyiXQ8Bff5&s@lK#f@F#x7{wq6Koa=p6A+s$wpV4aSwXlkaM6)Wi~4Zi`E&{ z*AsagW@a69kWe{rrI{zese9RW7l{uHGntJZFf+3<++|2q`jX%qvBBX>+a(qDMQTw= zj@J|%d`xa78ZKb$v literal 0 HcmV?d00001 diff --git a/install.rdf b/install.rdf index ee81ca4..a44ca94 100644 --- a/install.rdf +++ b/install.rdf @@ -9,7 +9,7 @@ true 2 http://github.com/erikvold/restartless-restart-ffext - http://picol.org/images/icons/files/png/32/refresh_32.png + https://addons.mozilla.org/en-US/firefox/images/addon_icon/249342 Greg Parris; http://phob.net/ From 3c072ef2c5e87ecaf5a571d0e637ec816581ec31 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Wed, 15 Dec 2010 14:34:51 +0100 Subject: [PATCH 025/112] Add initial Readme (cherry picked from commit 802d8cd6375370bbef083620527f1fc77ae0824a) --- Readme.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Readme.md diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..23d9e3a --- /dev/null +++ b/Readme.md @@ -0,0 +1,8 @@ +Restartless Restart for Firefox 4 +=== +Tiny restartless extension adding browser restart actions to Firefox. +(Oh, the irony) + +The main audience of this extension is other extension developers who need +to restart the browser often. + From 3bdfc0ef07a41db26b32ee7e1f71fdca07ec12b4 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Wed, 22 Dec 2010 21:09:27 -0800 Subject: [PATCH 026/112] separating common utils from code unique to this addon --- bootstrap.js | 45 ++++---------- includes/utils.js | 147 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+), 34 deletions(-) create mode 100644 includes/utils.js diff --git a/bootstrap.js b/bootstrap.js index 36a6f00..fe168ce 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -1,5 +1,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components; +const global = this; Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/AddonManager.jsm"); const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; const PREF_BRANCH = Services.prefs.getBranch("extensions.restartless-restart."); @@ -7,8 +9,7 @@ const PREFS = { key: "R", modifiers: "accel,alt" }; -let cleanupAry = []; -let logo = "http://picol.org/images/icons/files/png/16/refresh_16.png"; +let logo = ""; function getPref(aName) { try { @@ -56,42 +57,18 @@ function main(win) { appMenu.insertBefore(restartAMI, $("appmenu-quit")); } - let idx1 = cleanupAry.push(function() { + unload(function() { mainKS.removeChild(restartKey); fileMenu.removeChild(restartMI); appMenu && appMenu.removeChild(restartAMI); - }) - 1; - let idx2 = cleanupAry.push(function() ( - win.removeEventListener("unload", winUnloader, false))) - 1; - function winUnloader() { - cleanupAry[idx1] = null; - cleanupAry[idx2] = null; - } - win.addEventListener("unload", winUnloader, false); + }, win); } function install(){} function uninstall(){} -function startup(data) { - logo = Services.io.newFileURI(data.installPath).spec + "images/refresh_16.png"; - - let browserWins = Services.wm.getEnumerator("navigator:browser"); - while (browserWins.hasMoreElements()) main(browserWins.getNext()); - - function winObs(aSubject, aTopic) { - if ("domwindowopened" != aTopic) return; - let winLoad = function() { - aSubject.removeEventListener("load", winLoad, false); - if ("navigator:browser" == - aSubject.document.documentElement.getAttribute("windowtype")) - main(aSubject); - } - aSubject.addEventListener("load", winLoad, false); - } - Services.ww.registerNotification(winObs); - cleanupAry.push(function() Services.ww.unregisterNotification(winObs)); -} -function shutdown(data, reason) { - if (reason !== APP_SHUTDOWN) - for (let [, cleaner] in Iterator(cleanupAry)) cleaner && cleaner(); -} +function startup(data) AddonManager.getAddonByID(data.id, function(addon) { + Services.scriptloader.loadSubScript(addon.getResourceURI("includes/utils.js").spec, global); + logo = addon.getResourceURI("images/refresh_16.png").spec; + watchWindows(main); +}); +function shutdown(data, reason) { if (reason !== APP_SHUTDOWN) unload(); } diff --git a/includes/utils.js b/includes/utils.js new file mode 100644 index 0000000..5fb474f --- /dev/null +++ b/includes/utils.js @@ -0,0 +1,147 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Speak Words. + * + * The Initial Developer of the Original Code is The Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Edward Lee + * Erik Vold + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + +/** + * Apply a callback to each open and new browser windows. + * + * @usage watchWindows(callback): Apply a callback to each browser window. + * @param [function] callback: 1-parameter function that gets a browser window. + */ +function watchWindows(callback) { + // Wrap the callback in a function that ignores failures + function watcher(window) { + try { + callback(window); + } + catch(ex) {} + } + + // Wait for the window to finish loading before running the callback + function runOnLoad(window) { + // Listen for one load event before checking the window type + window.addEventListener("load", function() { + window.removeEventListener("load", arguments.callee, false); + + // Now that the window has loaded, only handle browser windows + let doc = window.document.documentElement; + if (doc.getAttribute("windowtype") == "navigator:browser") + watcher(window); + }, false); + } + + // Add functionality to existing windows + let browserWindows = Services.wm.getEnumerator("navigator:browser"); + while (browserWindows.hasMoreElements()) { + // Only run the watcher immediately if the browser is completely loaded + let browserWindow = browserWindows.getNext(); + if (browserWindow.document.readyState == "complete") + watcher(browserWindow); + // Wait for the window to load before continuing + else + runOnLoad(browserWindow); + } + + // Watch for new browser windows opening then wait for it to load + function windowWatcher(subject, topic) { + if (topic == "domwindowopened") + runOnLoad(subject); + } + Services.ww.registerNotification(windowWatcher); + + // Make sure to stop watching for windows if we're unloading + unload(function() Services.ww.unregisterNotification(windowWatcher)); +} + +/** + * Save callbacks to run when unloading. Optionally scope the callback to a + * container, e.g., window. Provide a way to run all the callbacks. + * + * @usage unload(): Run all callbacks and release them. + * + * @usage unload(callback): Add a callback to run on unload. + * @param [function] callback: 0-parameter function to call on unload. + * @return [function]: A 0-parameter function that undoes adding the callback. + * + * @usage unload(callback, container) Add a scoped callback to run on unload. + * @param [function] callback: 0-parameter function to call on unload. + * @param [node] container: Remove the callback when this container unloads. + * @return [function]: A 0-parameter function that undoes adding the callback. + */ +function unload(callback, container) { + // Initialize the array of unloaders on the first usage + let unloaders = unload.unloaders; + if (unloaders == null) + unloaders = unload.unloaders = []; + + // Calling with no arguments runs all the unloader callbacks + if (callback == null) { + unloaders.slice().forEach(function(unloader) unloader()); + unloaders.length = 0; + return; + } + + // The callback is bound to the lifetime of the container if we have one + if (container != null) { + // Remove the unloader when the container unloads + container.addEventListener("unload", removeUnloader, false); + + // Wrap the callback to additionally remove the unload listener + let origCallback = callback; + callback = function() { + container.removeEventListener("unload", removeUnloader, false); + origCallback(); + } + } + + // Wrap the callback in a function that ignores failures + function unloader() { + try { + callback(); + } + catch(ex) {} + } + unloaders.push(unloader); + + // Provide a way to remove the unloader + function removeUnloader() { + let index = unloaders.indexOf(unloader); + if (index != -1) + unloaders.splice(index, 1); + } + return removeUnloader; +} From ea59f3f50f0f33007ece8fe0009faa291eed5690 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Thu, 23 Dec 2010 20:23:39 -0800 Subject: [PATCH 027/112] Closes #11 Use local icons --- icon.png | Bin 0 -> 459 bytes icon64.png | Bin 0 -> 1608 bytes install.rdf | 1 - 3 files changed, 1 deletion(-) create mode 100644 icon.png create mode 100644 icon64.png diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..27f0340946797dc1dfe998371c3c400b389d6577 GIT binary patch literal 459 zcmV;+0W|)JP)UC z<{n~<{HrLQ^z_amA%Jq5^F=k+gJ&F@BI8ai<($~uIy&T>W1nf1> zZYV?E#+_3h55RiqP+_d)=Cc5T(fLH($h89Yas&%tG&&9)=1GH*ceDT|Zb!eC^ejvX z;8BrE9ajX`wuDj$bu^1+f*sdttWf|BqMU zF`PO9++$dB5vA+2RfCb&yoju;SbmsVRCN_YzVvEQ)yF6idnK4RLTiIIe~!H=(*Qf* zEMjM_Yd>p0MeY`U7@ckY}!^WATjAG43WHN=c)O9TLz zu|gRf%m(Pygn-=*f{Y=|;H81ANE1x*Op?p6_abp@g9G0<{7C{ln5VZdeuZ3}}q@NNk#=XI1tH>Wi6DiKf}kLXj-nDlQl_4pvYn3& zf-V%K!O;ICynoYv3GIihOE4R8!m&{+bVo;Ql@aC!p6ID~p>9!KG zY5yz}lmjQ6w#VUcbj{*3WdA#~Jo{wJWLwol*SVR;7xIFAO@~=zAfp)ZK5DDnXE&H~ z%v{bM`P%Qt`#C_7c|7X2jll=&4!)y>58eA5*8yx8i!LztiJ>90g`A3Xn>S@sM2-%i zscUdI(%{YK9PBVIu3$X!v(nzs(UotHxpIKwFEZoBL8#cYU{85|mEX-IbKjAgLmKM;iR+oO=Q+LC(eTnit5@G0^>52X{ z?{H|W_O{3RZr9ATCQ>kvz4XmEVtCSgi{*8z!{-RjPbW-_v_C(0W$Ci2oN}E9uG3@N z!ZiskH{Y6(wBd-Wg&*zrG-xFMXP-Gk1F`q|ub!;fMQgv}o9?55n;N4X14z>`UVs;^RE3gFLn*B1J~1u;&3r z+gI7bnxnr>gC>PnYFx(lSF%t&Gou122fGS4i+gQ^8>m3jBkE%db@RO4RW3Jsw zP<0%*to;s8_6x=ZRQ5gqcdfy2O+D5mM(k?Bti$r;3;34Z118KBlg;@iDbf*y=w(& z1W0rQP5<5VAJMwy30zgHlD%d)bdYqdx0cW$n?Aohsi;!r7m;VV>Ui| zXzREPO!hS^6bl(S^p$tAEOqm44{ROnr6wxPw`UbOQFBB_mDEW^V!B3 zbwh{B>tTqKTRC+vT~;*HnE#ERJkQTKVIkE^?&%-??0$&BW;^-!OGpDm&@(jHJ+v*b z$u{BzeV4FWlapivkQ|+rqL3^!`Aoa2cJkN(kuS&!m}Mp$7SGjdQ``gOVq>u99VNAv?)$}_c zlU}t9_~I6IbyEwyBQ5Gw83sx@qc?Hu i)Ha(vfz`lha3}RX=_xXHEE~mEAYd`KGMWPui~a#k6sWfV literal 0 HcmV?d00001 diff --git a/install.rdf b/install.rdf index a44ca94..796d138 100644 --- a/install.rdf +++ b/install.rdf @@ -9,7 +9,6 @@ true 2 http://github.com/erikvold/restartless-restart-ffext - https://addons.mozilla.org/en-US/firefox/images/addon_icon/249342 Greg Parris; http://phob.net/ From 2025ec329b96885c528bf4faff3c7281a362063a Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Thu, 23 Dec 2010 20:32:13 -0800 Subject: [PATCH 028/112] add contributor --- install.rdf | 1 + 1 file changed, 1 insertion(+) diff --git a/install.rdf b/install.rdf index 796d138..74cc039 100644 --- a/install.rdf +++ b/install.rdf @@ -11,6 +11,7 @@ http://github.com/erikvold/restartless-restart-ffext Greg Parris; http://phob.net/ + Nils Maier; https://tn123.org/ From 0333daee53a3ee3778188845e107a6e41938b112 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Thu, 23 Dec 2010 20:37:10 -0800 Subject: [PATCH 029/112] moving files needed in the xpi in to the 'src' dir --- bootstrap.js => src/bootstrap.js | 0 icon.png => src/icon.png | Bin icon64.png => src/icon64.png | Bin {images => src/images}/refresh_16.png | Bin {includes => src/includes}/utils.js | 0 install.rdf => src/install.rdf | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename bootstrap.js => src/bootstrap.js (100%) rename icon.png => src/icon.png (100%) rename icon64.png => src/icon64.png (100%) rename {images => src/images}/refresh_16.png (100%) rename {includes => src/includes}/utils.js (100%) rename install.rdf => src/install.rdf (100%) diff --git a/bootstrap.js b/src/bootstrap.js similarity index 100% rename from bootstrap.js rename to src/bootstrap.js diff --git a/icon.png b/src/icon.png similarity index 100% rename from icon.png rename to src/icon.png diff --git a/icon64.png b/src/icon64.png similarity index 100% rename from icon64.png rename to src/icon64.png diff --git a/images/refresh_16.png b/src/images/refresh_16.png similarity index 100% rename from images/refresh_16.png rename to src/images/refresh_16.png diff --git a/includes/utils.js b/src/includes/utils.js similarity index 100% rename from includes/utils.js rename to src/includes/utils.js diff --git a/install.rdf b/src/install.rdf similarity index 100% rename from install.rdf rename to src/install.rdf From 8f020d3452906ff8283228654dfd2ead871ce42e Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Thu, 23 Dec 2010 20:41:01 -0800 Subject: [PATCH 030/112] 4pre --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index 74cc039..7019f42 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 3 + 4pre true 2 http://github.com/erikvold/restartless-restart-ffext From 05be3672f12dea12fb2a39723c9cfdf528ff2bf3 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Mon, 3 Jan 2011 20:10:10 -0800 Subject: [PATCH 031/112] using a general include() function --- src/bootstrap.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index fe168ce..da46521 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -1,5 +1,4 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components; -const global = this; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/AddonManager.jsm"); @@ -11,6 +10,9 @@ const PREFS = { }; let logo = ""; +(function(global) global.include = function include(src) ( + Services.scriptloader.loadSubScript(src, global)))(this); + function getPref(aName) { try { return PREF_BRANCH.getComplexValue(aName, Ci.nsISupportsString).data; @@ -67,7 +69,7 @@ function main(win) { function install(){} function uninstall(){} function startup(data) AddonManager.getAddonByID(data.id, function(addon) { - Services.scriptloader.loadSubScript(addon.getResourceURI("includes/utils.js").spec, global); + include(addon.getResourceURI("includes/utils.js").spec); logo = addon.getResourceURI("images/refresh_16.png").spec; watchWindows(main); }); From 91bf487bff8f68a10442f543aead1074ca61e5ae Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Mon, 3 Jan 2011 20:11:50 -0800 Subject: [PATCH 032/112] adding a license to the bootstrap.js --- src/bootstrap.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/bootstrap.js b/src/bootstrap.js index da46521..f18aed1 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -1,3 +1,32 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MIT/X11 License + * + * Copyright (c) 2010 Erik Vold + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * Contributor(s): + * Erik Vold (Original Author) + * Greg Parris + * + * ***** END LICENSE BLOCK ***** */ + const {classes: Cc, interfaces: Ci, utils: Cu} = Components; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/AddonManager.jsm"); From 256b1cc388f79f50e29d55d338bb54d835102d2f Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Mon, 3 Jan 2011 20:15:46 -0800 Subject: [PATCH 033/112] adding a LICENSE.txt --- LICENSE.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..33acbd0 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2010 Erik Vold + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. From ee10af12f0bec2331b9a5fa537c9b1fcd4b6ccfb Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 21 Jan 2011 20:18:54 -0800 Subject: [PATCH 034/112] Closes #7 using FUEL to restart --- src/bootstrap.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index f18aed1..af02652 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -49,9 +49,8 @@ function getPref(aName) { return PREFS[aName]; } -function restart() ( - Cc['@mozilla.org/toolkit/app-startup;1'].getService(Ci.nsIAppStartup) - .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart)); +function restart() (Cc["@mozilla.org/fuel/application;1"] + .getService(Ci.fuelIApplication).restart()); function main(win) { let doc = win.document; From 312dba716ee21d2d431566ee88ce2d410a9b9b61 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Tue, 25 Jan 2011 18:46:42 +0100 Subject: [PATCH 035/112] Fix restart action to work correctly on all platforms * FUEL is only available in Firefox and actually buggy when it comes to extIApplication.restart. * SMILE would be the Seamonkey equivalent, but is currently broken in horrible ways. * There is also STEEL for Thunderbird, no idea in what state it currently is. Hence use roll our own "low-level" implementation, getting the bits hopefully right, as opposed to the bit-rotted extIApplication implementations. --- src/bootstrap.js | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index af02652..ef35919 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -24,10 +24,12 @@ * Contributor(s): * Erik Vold (Original Author) * Greg Parris + * Nils Maier * * ***** END LICENSE BLOCK ***** */ -const {classes: Cc, interfaces: Ci, utils: Cu} = Components; +const {classes: Cc, interfaces: Ci, utils: Cu, Constructor: ctor} = Components; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/AddonManager.jsm"); @@ -37,6 +39,19 @@ const PREFS = { key: "R", modifiers: "accel,alt" }; +const RESTART_FLAGS = Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart; +const RESTART_ACTION = "restart"; + +XPCOMUtils.defineLazyServiceGetter( + this, + "AppStartup", + "@mozilla.org/toolkit/app-startup;1", + "nsIAppStartup"); + +const SupportsBool = ctor( + "@mozilla.org/supports-PRBool;1", + "nsISupportsPRBool"); + let logo = ""; (function(global) global.include = function include(src) ( @@ -49,8 +64,28 @@ function getPref(aName) { return PREFS[aName]; } -function restart() (Cc["@mozilla.org/fuel/application;1"] - .getService(Ci.fuelIApplication).restart()); +function restart() { + // Application shutdown sequence + // First ask observers if a restart is fine with them + let canceled = new SupportsBool(); + Services.obs.notifyObservers( + canceled, + "quit-application-requested", + RESTART_ACTION); + if (canceled.data) + return false; // somebody canceled our quit request + + // Then notify observers that the quit/restart is happening + Services.obs.notifyObservers( + null, + "quit-application-granted", + RESTART_ACTION); + + // Finally restart + AppStartup.quit(RESTART_FLAGS); + + return true; +} function main(win) { let doc = win.document; From 0f23ddb1b3341d2b2ca6d0f6d7a216b613069f95 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Wed, 26 Jan 2011 09:37:29 +0100 Subject: [PATCH 036/112] No need to post quit-application-granted nsAppStartup will attempt to send it is well (not quit-application-requested). This used to be buggy under certain circumstances but since this extension targets moz-2 exclusively, so this isn't necessary anymore. --- src/bootstrap.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index ef35919..e54fa07 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -75,13 +75,9 @@ function restart() { if (canceled.data) return false; // somebody canceled our quit request - // Then notify observers that the quit/restart is happening - Services.obs.notifyObservers( - null, - "quit-application-granted", - RESTART_ACTION); - // Finally restart + // No need to notify observers about quit-application granted, nsAppStartup + // does that for us AppStartup.quit(RESTART_FLAGS); return true; From 7147579c32fa1ac3dd95721fd519802aff15c1f8 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Wed, 26 Jan 2011 18:17:37 -0800 Subject: [PATCH 037/112] Revert "Closes #7 using FUEL to restart" This reverts commit ee10af12f0bec2331b9a5fa537c9b1fcd4b6ccfb. --- src/bootstrap.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index af02652..f18aed1 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -49,8 +49,9 @@ function getPref(aName) { return PREFS[aName]; } -function restart() (Cc["@mozilla.org/fuel/application;1"] - .getService(Ci.fuelIApplication).restart()); +function restart() ( + Cc['@mozilla.org/toolkit/app-startup;1'].getService(Ci.nsIAppStartup) + .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart)); function main(win) { let doc = win.document; From 0401508d9966de89960c46ff5b47bdf1651bf182 Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sun, 12 Dec 2010 09:30:18 -0600 Subject: [PATCH 038/112] notify observers of intent to restart, and the user if it is denied --- src/bootstrap.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index f18aed1..014fbbe 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -49,9 +49,17 @@ function getPref(aName) { return PREFS[aName]; } -function restart() ( - Cc['@mozilla.org/toolkit/app-startup;1'].getService(Ci.nsIAppStartup) - .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart)); +function restart() { + let stopIt = Cc["@mozilla.org/supports-PRBool;1"] + .createInstance(Ci.nsISupportsPRBool); + Services.obs.notifyObservers(stopIt, "quit-application-requested", "restart"); + if (stopIt.data) + return Services.prompt.alert( + null, "Restartless Restart", "Something denied the restart request."); + + Cc['@mozilla.org/toolkit/app-startup;1'].getService(Ci.nsIAppStartup) + .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart); +} function main(win) { let doc = win.document; From 86d4701fcee622ad3932f113984f0a305e4875d5 Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sun, 21 Nov 2010 17:32:40 -0600 Subject: [PATCH 039/112] setting up pref change observing --- src/bootstrap.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bootstrap.js b/src/bootstrap.js index 0e61236..a6e0668 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -38,6 +38,11 @@ const PREFS = { key: "R", modifiers: "accel,alt" }; +let PREF_OBSERVER = { + observe: function(aSubject, aTopic, aData) { + if ("nsPref:changed" != aTopic || !PREFS[aData]) return; + } +} let logo = ""; @@ -110,8 +115,12 @@ function main(win) { function install(){} function uninstall(){} function startup(data) AddonManager.getAddonByID(data.id, function(addon) { + var prefs = PREF_BRANCH; include(addon.getResourceURI("includes/utils.js").spec); logo = addon.getResourceURI("images/refresh_16.png").spec; watchWindows(main); + prefs = prefs.QueryInterface(Components.interfaces.nsIPrefBranch2); + prefs.addObserver("", PREF_OBSERVER, false); + unload(function() prefs.removeObserver("", PREF_OBSERVER)); }); function shutdown(data, reason) { if (reason !== APP_SHUTDOWN) unload(); } From a29659b2171536cd2e41c82251a1b84978af8eea Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 1 Feb 2011 18:58:53 -0800 Subject: [PATCH 040/112] updating current hotkey elements when the hotkey changes --- src/bootstrap.js | 3 +++ src/includes/utils.js | 60 ++++++++++++++++++++++++++++++------------- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index a6e0668..4790833 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -41,6 +41,9 @@ const PREFS = { let PREF_OBSERVER = { observe: function(aSubject, aTopic, aData) { if ("nsPref:changed" != aTopic || !PREFS[aData]) return; + runOnWindows(function(win) { + win.document.getElementById("RR:Restart").setAttribute(aData, getPref(aData)); + }); } } diff --git a/src/includes/utils.js b/src/includes/utils.js index 5fb474f..4462703 100644 --- a/src/includes/utils.js +++ b/src/includes/utils.js @@ -35,14 +35,32 @@ * * ***** END LICENSE BLOCK ***** */ +/** + * Waits for a browser window to finish loading before running the callback + * + * @usage runOnLoad(window, callback): Apply a callback to to run on a window when it loads. + * @param [function] callback: 1-parameter function that gets a browser window. + */ +// +function runOnLoad(window, callback) { + // Listen for one load event before checking the window type + window.addEventListener("load", function() { + window.removeEventListener("load", arguments.callee, false); + + // Now that the window has loaded, only handle browser windows + if (window.document.documentElement.getAttribute("windowtype") == "navigator:browser") + callback(window); + }, false); +} + /** - * Apply a callback to each open and new browser windows. + * Add functionality to existing browser windows * - * @usage watchWindows(callback): Apply a callback to each browser window. + * @usage runOnWindows(callback): Apply a callback to each open browser window. * @param [function] callback: 1-parameter function that gets a browser window. */ -function watchWindows(callback) { +function runOnWindows(callback) { // Wrap the callback in a function that ignores failures function watcher(window) { try { @@ -51,19 +69,6 @@ function watchWindows(callback) { catch(ex) {} } - // Wait for the window to finish loading before running the callback - function runOnLoad(window) { - // Listen for one load event before checking the window type - window.addEventListener("load", function() { - window.removeEventListener("load", arguments.callee, false); - - // Now that the window has loaded, only handle browser windows - let doc = window.document.documentElement; - if (doc.getAttribute("windowtype") == "navigator:browser") - watcher(window); - }, false); - } - // Add functionality to existing windows let browserWindows = Services.wm.getEnumerator("navigator:browser"); while (browserWindows.hasMoreElements()) { @@ -73,13 +78,32 @@ function watchWindows(callback) { watcher(browserWindow); // Wait for the window to load before continuing else - runOnLoad(browserWindow); + runOnLoad(browserWindow, watcher); + } +} + +/** + * Apply a callback to each open and new browser windows. + * + * @usage watchWindows(callback): Apply a callback to each browser window. + * @param [function] callback: 1-parameter function that gets a browser window. + */ +function watchWindows(callback) { + // Wrap the callback in a function that ignores failures + function watcher(window) { + try { + callback(window); + } + catch(ex) {} } + // Add functionality to existing windows + runOnWindows(callback); + // Watch for new browser windows opening then wait for it to load function windowWatcher(subject, topic) { if (topic == "domwindowopened") - runOnLoad(subject); + runOnLoad(subject, watcher); } Services.ww.registerNotification(windowWatcher); From 8ab1d11a0a836a41613e1d1a32e66ccd597f92e0 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 1 Feb 2011 19:39:52 -0800 Subject: [PATCH 041/112] Closes #17 hotkey visibly changes on OSX when it actually changes --- src/bootstrap.js | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index 4790833..36d91a0 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -42,7 +42,10 @@ let PREF_OBSERVER = { observe: function(aSubject, aTopic, aData) { if ("nsPref:changed" != aTopic || !PREFS[aData]) return; runOnWindows(function(win) { - win.document.getElementById("RR:Restart").setAttribute(aData, getPref(aData)); + var doc = win.document; + function $(id) doc.getElementById(id); + $("RR:Restart").setAttribute(aData, getPref(aData)); + addMenuItem(doc, $); }); } } @@ -59,6 +62,22 @@ function getPref(aName) { return PREFS[aName]; } +function addMenuItem(doc, $) { + var menuitem = $("menu_FileRestartItem"); + if (menuitem) + menuitem.parentNode.removeChild(menuitem); + + // add menu bar item to File menu + let restartMI = doc.createElementNS(NS_XUL, "menuitem"); + restartMI.setAttribute("id", "menu_FileRestartItem"); + restartMI.setAttribute("label", "Restart"); + restartMI.setAttribute("accesskey", "R"); + restartMI.setAttribute("key", "RR:Restart"); + restartMI.addEventListener("command", restart, true); + let fileMenu = $("menu_FilePopup"); + fileMenu.insertBefore(restartMI, $("menu_FileQuitItem")); +} + function restart() { let canceled = Cc["@mozilla.org/supports-PRBool;1"] .createInstance(Ci.nsISupportsPRBool); @@ -88,14 +107,7 @@ function main(win) { mainKS.appendChild(restartKey); // add menu bar item to File menu - let restartMI = doc.createElementNS(NS_XUL, "menuitem"); - restartMI.setAttribute("id", "menu_FileRestartItem"); - restartMI.setAttribute("label", "Restart"); - restartMI.setAttribute("accesskey", "R"); - restartMI.setAttribute("key", "RR:Restart"); - restartMI.addEventListener("command", restart, true); - let fileMenu = $("menu_FilePopup"); - fileMenu.insertBefore(restartMI, $("menu_FileQuitItem")); + addMenuItem(doc, $); // add app menu item to Firefox button for Windows 7 let appMenu = $("appmenuPrimaryPane"), restartAMI; From 718b5dee09e0a126adbdb62c19aafe2582bb2567 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 1 Feb 2011 19:52:41 -0800 Subject: [PATCH 042/112] Closes #12 adding a build.sh --- .gitignore | 1 + build.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 build.sh diff --git a/.gitignore b/.gitignore index 1c6c0e0..dbbaea9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ .project .settings *.xpi +build diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..7068e0a --- /dev/null +++ b/build.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +VER=`grep -Go 'version\>\(.*\)\<' src/install.rdf | grep -Go '>\(.*\)<' | sed -e 's/[><]*//g'` +XPI="restartless-restart-$VER.xpi" + +# Copy base structure to a temporary build directory and move in to it +echo "Creating build directory ..." +cd src +rm -rf build +mkdir build +cp -r \ + bootstrap.js images includes install.rdf icon.png icon64.png \ + build/ +cd build + +echo "Cleaning up unwanted files ..." +find . -depth -name '*~' -exec rm -rf "{}" \; +find . -depth -name '#*' -exec rm -rf "{}" \; +find . -depth -name '.DS_Store' -exec rm "{}" \; +find . -depth -name 'Thumbs.db' -exec rm "{}" \; + +echo "Creating $XPI ..." +zip -qr9XD "../../$XPI" * + +echo "Cleaning up temporary files ..." +cd .. +rm -rf build +cd .. From ee5325aca0f483d03035460a50ca0998e4d6f7fe Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 1 Feb 2011 19:54:20 -0800 Subject: [PATCH 043/112] 4 --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index 7019f42..bedb374 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 4pre + 4 true 2 http://github.com/erikvold/restartless-restart-ffext From 1b1124f2e149b69c3910e77d45bb07495da1b140 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 1 Feb 2011 22:32:53 -0800 Subject: [PATCH 044/112] 4.1pre --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index bedb374..7a8adec 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 4 + 4.1pre true 2 http://github.com/erikvold/restartless-restart-ffext From c1ca90b9555a37016867070eba38fdd86085f341 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 1 Feb 2011 22:55:50 -0800 Subject: [PATCH 045/112] bug fixes: minor mem leaks and error after changing hotkey and disabling --- src/bootstrap.js | 64 +++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index 36d91a0..d63b875 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -33,6 +33,9 @@ Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/AddonManager.jsm"); const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; +const keyID = "RR:Restart"; +const fileMenuitemID = "menu_FileRestartItem"; + const PREF_BRANCH = Services.prefs.getBranch("extensions.restartless-restart."); const PREFS = { key: "R", @@ -42,10 +45,8 @@ let PREF_OBSERVER = { observe: function(aSubject, aTopic, aData) { if ("nsPref:changed" != aTopic || !PREFS[aData]) return; runOnWindows(function(win) { - var doc = win.document; - function $(id) doc.getElementById(id); - $("RR:Restart").setAttribute(aData, getPref(aData)); - addMenuItem(doc, $); + win.document.getElementById(keyID).setAttribute(aData, getPref(aData)); + addMenuItem(win); }); } } @@ -62,20 +63,27 @@ function getPref(aName) { return PREFS[aName]; } -function addMenuItem(doc, $) { - var menuitem = $("menu_FileRestartItem"); - if (menuitem) - menuitem.parentNode.removeChild(menuitem); +function addMenuItem(win) { + var $ = function(id) win.document.getElementById(id); - // add menu bar item to File menu - let restartMI = doc.createElementNS(NS_XUL, "menuitem"); - restartMI.setAttribute("id", "menu_FileRestartItem"); - restartMI.setAttribute("label", "Restart"); - restartMI.setAttribute("accesskey", "R"); - restartMI.setAttribute("key", "RR:Restart"); - restartMI.addEventListener("command", restart, true); - let fileMenu = $("menu_FilePopup"); - fileMenu.insertBefore(restartMI, $("menu_FileQuitItem")); + function removeMI() { + var menuitem = $(fileMenuitemID); + menuitem && menuitem.parentNode.removeChild(menuitem); + } + removeMI(); + + // add the new menuitem to File menu + let (restartMI = win.document.createElementNS(NS_XUL, "menuitem")) { + restartMI.setAttribute("id", fileMenuitemID); + restartMI.setAttribute("label", "Restart"); + restartMI.setAttribute("accesskey", "R"); + restartMI.setAttribute("key", keyID); + restartMI.addEventListener("command", restart, true); + + $("menu_FilePopup").insertBefore(restartMI, $("menu_FileQuitItem")); + } + + unload(removeMI, win); } function restart() { @@ -97,17 +105,17 @@ function main(win) { function $(id) doc.getElementById(id); // add hotkey - let restartKey = doc.createElementNS(NS_XUL, "key"); - restartKey.setAttribute("id", "RR:Restart"); - restartKey.setAttribute("key", getPref("key")); - restartKey.setAttribute("modifiers", getPref("modifiers")); - restartKey.setAttribute("oncommand", "void(0);"); - restartKey.addEventListener("command", restart, true); - let mainKS = $("mainKeyset"); - mainKS.appendChild(restartKey); + let (restartKey = doc.createElementNS(NS_XUL, "key")) { + restartKey.setAttribute("id", keyID); + restartKey.setAttribute("key", getPref("key")); + restartKey.setAttribute("modifiers", getPref("modifiers")); + restartKey.setAttribute("oncommand", "void(0);"); + restartKey.addEventListener("command", restart, true); + $("mainKeyset").appendChild(restartKey); + } // add menu bar item to File menu - addMenuItem(doc, $); + addMenuItem(win); // add app menu item to Firefox button for Windows 7 let appMenu = $("appmenuPrimaryPane"), restartAMI; @@ -121,8 +129,8 @@ function main(win) { } unload(function() { - mainKS.removeChild(restartKey); - fileMenu.removeChild(restartMI); + var key = $(keyID); + key && key.parentNode.removeChild(key); appMenu && appMenu.removeChild(restartAMI); }, win); } From ef982b77338edeca70496c86edcbe0da67cc4331 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 1 Feb 2011 22:58:26 -0800 Subject: [PATCH 046/112] 4.1 --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index 7a8adec..9ae4f8c 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 4.1pre + 4.1 true 2 http://github.com/erikvold/restartless-restart-ffext From e3665e6c7f6421a20577a91d10f39ea68b8174e2 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 1 Feb 2011 23:18:31 -0800 Subject: [PATCH 047/112] less is more --- build.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 7068e0a..70a70c2 100644 --- a/build.sh +++ b/build.sh @@ -2,9 +2,9 @@ VER=`grep -Go 'version\>\(.*\)\<' src/install.rdf | grep -Go '>\(.*\)<' | sed -e 's/[><]*//g'` XPI="restartless-restart-$VER.xpi" +echo "Building $XPI ..." # Copy base structure to a temporary build directory and move in to it -echo "Creating build directory ..." cd src rm -rf build mkdir build @@ -13,16 +13,14 @@ cp -r \ build/ cd build -echo "Cleaning up unwanted files ..." +# Cleaning up unwanted files find . -depth -name '*~' -exec rm -rf "{}" \; find . -depth -name '#*' -exec rm -rf "{}" \; find . -depth -name '.DS_Store' -exec rm "{}" \; find . -depth -name 'Thumbs.db' -exec rm "{}" \; -echo "Creating $XPI ..." zip -qr9XD "../../$XPI" * -echo "Cleaning up temporary files ..." cd .. rm -rf build cd .. From b49e42f20fb2aacdff48fefaeae9ef5991f6522c Mon Sep 17 00:00:00 2001 From: xabolcs Date: Sun, 6 Feb 2011 16:37:13 -0800 Subject: [PATCH 048/112] restartMI is undefined (regression by resolving #17) --- src/bootstrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index d63b875..8d47fd7 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -120,7 +120,7 @@ function main(win) { // add app menu item to Firefox button for Windows 7 let appMenu = $("appmenuPrimaryPane"), restartAMI; if (appMenu) { - restartAMI = restartMI.cloneNode(false); + restartAMI = $(fileMenuitemID).cloneNode(false); restartAMI.setAttribute("id", "appmenu_RestartItem"); restartAMI.setAttribute("class", "menuitem-iconic menuitem-iconic-tooltip"); restartAMI.style.listStyleImage = "url('" + logo + "')"; From 35b639bef2c07cdc59e8d1c544cdc8ee4fb79e32 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Mon, 7 Feb 2011 19:25:53 -0800 Subject: [PATCH 049/112] Closes #14 using a separate keyset --- src/bootstrap.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index 8d47fd7..efe3cbe 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -33,6 +33,7 @@ Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/AddonManager.jsm"); const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; +const keysetID = "restartless-restart-keyset"; const keyID = "RR:Restart"; const fileMenuitemID = "menu_FileRestartItem"; @@ -104,6 +105,9 @@ function main(win) { let doc = win.document; function $(id) doc.getElementById(id); + let rrKeyset = doc.createElementNS(NS_XUL, "keyset"); + rrKeyset.setAttribute("id", keysetID); + // add hotkey let (restartKey = doc.createElementNS(NS_XUL, "key")) { restartKey.setAttribute("id", keyID); @@ -111,7 +115,7 @@ function main(win) { restartKey.setAttribute("modifiers", getPref("modifiers")); restartKey.setAttribute("oncommand", "void(0);"); restartKey.addEventListener("command", restart, true); - $("mainKeyset").appendChild(restartKey); + $("mainKeyset").parentNode.appendChild(rrKeyset).appendChild(restartKey); } // add menu bar item to File menu @@ -129,8 +133,7 @@ function main(win) { } unload(function() { - var key = $(keyID); - key && key.parentNode.removeChild(key); + rrKeyset.parentNode.removeChild(rrKeyset); appMenu && appMenu.removeChild(restartAMI); }, win); } From 2904eebb1fc00c65deded5772b7d458b7726543a Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Mon, 7 Feb 2011 19:33:35 -0800 Subject: [PATCH 050/112] 4.2 --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index 9ae4f8c..080431b 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 4.1 + 4.2 true 2 http://github.com/erikvold/restartless-restart-ffext From 4dd34f9dbdeca3e142464afd7eddf78c0bec3599 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Wed, 16 Feb 2011 07:37:01 -0800 Subject: [PATCH 051/112] Closes #18 localizing RR --- src/bootstrap.js | 23 +++++++++++---- src/includes/l10n.js | 53 ++++++++++++++++++++++++++++++++++ src/locale/de/rr.properties | 1 + src/locale/en-US/rr.properties | 2 ++ src/locale/ja-JP/rr.properties | 1 + src/locale/pt-BR/rr.properties | 1 + src/locale/ru-RU/rr.properties | 1 + 7 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 src/includes/l10n.js create mode 100644 src/locale/de/rr.properties create mode 100644 src/locale/en-US/rr.properties create mode 100644 src/locale/ja-JP/rr.properties create mode 100644 src/locale/pt-BR/rr.properties create mode 100644 src/locale/ru-RU/rr.properties diff --git a/src/bootstrap.js b/src/bootstrap.js index efe3cbe..f106b35 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -39,14 +39,24 @@ const fileMenuitemID = "menu_FileRestartItem"; const PREF_BRANCH = Services.prefs.getBranch("extensions.restartless-restart."); const PREFS = { - key: "R", - modifiers: "accel,alt" + get key() _("restart.ak", getPref("locale")), + modifiers: "accel,alt", + locale: undefined }; let PREF_OBSERVER = { observe: function(aSubject, aTopic, aData) { - if ("nsPref:changed" != aTopic || !PREFS[aData]) return; + if ("nsPref:changed" != aTopic || !(aData in PREFS)) return; runOnWindows(function(win) { - win.document.getElementById(keyID).setAttribute(aData, getPref(aData)); + switch (aData) { + case "locale": + win.document.getElementById(keyID) + .setAttribute("label", _("restart", getPref("locale"))); + break; + default: + win.document.getElementById(keyID) + .setAttribute(aData, getPref(aData)); + break; + } addMenuItem(win); }); } @@ -76,7 +86,7 @@ function addMenuItem(win) { // add the new menuitem to File menu let (restartMI = win.document.createElementNS(NS_XUL, "menuitem")) { restartMI.setAttribute("id", fileMenuitemID); - restartMI.setAttribute("label", "Restart"); + restartMI.setAttribute("label", _("restart", getPref("locale"))); restartMI.setAttribute("accesskey", "R"); restartMI.setAttribute("key", keyID); restartMI.addEventListener("command", restart, true); @@ -141,6 +151,9 @@ function main(win) { function install(){} function uninstall(){} function startup(data) AddonManager.getAddonByID(data.id, function(addon) { + include(addon.getResourceURI("includes/l10n.js").spec); + l10n(addon); + var prefs = PREF_BRANCH; include(addon.getResourceURI("includes/utils.js").spec); logo = addon.getResourceURI("images/refresh_16.png").spec; diff --git a/src/includes/l10n.js b/src/includes/l10n.js new file mode 100644 index 0000000..1d4bef9 --- /dev/null +++ b/src/includes/l10n.js @@ -0,0 +1,53 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MIT/X11 License + * + * Copyright (c) 2010 Erik Vold + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * Contributor(s): + * Erik Vold (Original Author) + * + * ***** END LICENSE BLOCK ***** */ + +var l10n = (function(global) { + return function(addon) { + // get selected locale + let locale = Cc["@mozilla.org/chrome/chrome-registry;1"] + .getService(Ci.nsIXULChromeRegistry).getSelectedLocale("global"); + + let defaultBundle = Services.strings.createBundle( + addon.getResourceURI("locale/" + locale + "/rr.properties").spec); + let engBundle = Services.strings.createBundle( + addon.getResourceURI("locale/en-US/rr.properties").spec); + + global._ = function l10n_underscore(aKey, aLocale) { + if (aLocale) + var localeBundle = Services.strings.createBundle( + addon.getResourceURI("locale/" + aLocale + "/rr.properties").spec); + try { + return (localeBundle && localeBundle.GetStringFromName(aKey)) + || defaultBundle.GetStringFromName(aKey) + || engBundle.GetStringFromName(aKey); + } catch (e) { + return engBundle.GetStringFromName(aKey); + } + } + } +})(this); diff --git a/src/locale/de/rr.properties b/src/locale/de/rr.properties new file mode 100644 index 0000000..4857b3e --- /dev/null +++ b/src/locale/de/rr.properties @@ -0,0 +1 @@ +restart=Neu starten diff --git a/src/locale/en-US/rr.properties b/src/locale/en-US/rr.properties new file mode 100644 index 0000000..5c3616b --- /dev/null +++ b/src/locale/en-US/rr.properties @@ -0,0 +1,2 @@ +restart=Restart +restart.ak=R diff --git a/src/locale/ja-JP/rr.properties b/src/locale/ja-JP/rr.properties new file mode 100644 index 0000000..4a4a6f5 --- /dev/null +++ b/src/locale/ja-JP/rr.properties @@ -0,0 +1 @@ +restart=再起動します。 diff --git a/src/locale/pt-BR/rr.properties b/src/locale/pt-BR/rr.properties new file mode 100644 index 0000000..a460a15 --- /dev/null +++ b/src/locale/pt-BR/rr.properties @@ -0,0 +1 @@ +restart=Reiniciar diff --git a/src/locale/ru-RU/rr.properties b/src/locale/ru-RU/rr.properties new file mode 100644 index 0000000..46fc5bc --- /dev/null +++ b/src/locale/ru-RU/rr.properties @@ -0,0 +1 @@ +restart=Перезапуск From dea835f8071fbfb7c44a35f6f7a458f49dd470b7 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Wed, 16 Feb 2011 07:47:00 -0800 Subject: [PATCH 052/112] moving 'rr.properties' string out of l10n.js so that it can be reused by others. --- src/bootstrap.js | 2 +- src/includes/l10n.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index f106b35..b517a4e 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -152,7 +152,7 @@ function install(){} function uninstall(){} function startup(data) AddonManager.getAddonByID(data.id, function(addon) { include(addon.getResourceURI("includes/l10n.js").spec); - l10n(addon); + l10n(addon, "rr.properties"); var prefs = PREF_BRANCH; include(addon.getResourceURI("includes/utils.js").spec); diff --git a/src/includes/l10n.js b/src/includes/l10n.js index 1d4bef9..f76f8a1 100644 --- a/src/includes/l10n.js +++ b/src/includes/l10n.js @@ -27,20 +27,20 @@ * ***** END LICENSE BLOCK ***** */ var l10n = (function(global) { - return function(addon) { + return function(addon, filename) { // get selected locale let locale = Cc["@mozilla.org/chrome/chrome-registry;1"] .getService(Ci.nsIXULChromeRegistry).getSelectedLocale("global"); let defaultBundle = Services.strings.createBundle( - addon.getResourceURI("locale/" + locale + "/rr.properties").spec); + addon.getResourceURI("locale/" + locale + "/" + filename).spec); let engBundle = Services.strings.createBundle( - addon.getResourceURI("locale/en-US/rr.properties").spec); + addon.getResourceURI("locale/en-US/" + filename).spec); global._ = function l10n_underscore(aKey, aLocale) { if (aLocale) var localeBundle = Services.strings.createBundle( - addon.getResourceURI("locale/" + aLocale + "/rr.properties").spec); + addon.getResourceURI("locale/" + aLocale + "/" + filename).spec); try { return (localeBundle && localeBundle.GetStringFromName(aKey)) || defaultBundle.GetStringFromName(aKey) From 5e941bde745f4e6386b746a627e3b2c77157e703 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Wed, 16 Feb 2011 07:48:42 -0800 Subject: [PATCH 053/112] l10n() returns _() so that one can more easily define multiple _s --- src/includes/l10n.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/includes/l10n.js b/src/includes/l10n.js index f76f8a1..d5a3a8d 100644 --- a/src/includes/l10n.js +++ b/src/includes/l10n.js @@ -37,7 +37,7 @@ var l10n = (function(global) { let engBundle = Services.strings.createBundle( addon.getResourceURI("locale/en-US/" + filename).spec); - global._ = function l10n_underscore(aKey, aLocale) { + return global._ = function l10n_underscore(aKey, aLocale) { if (aLocale) var localeBundle = Services.strings.createBundle( addon.getResourceURI("locale/" + aLocale + "/" + filename).spec); From c88e3eacef41c987bb01bf4a9295dbcb657ea50d Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Thu, 17 Feb 2011 20:52:53 -0800 Subject: [PATCH 054/112] l10n: Try using 'en' if 'en-US' DNE for example. --- src/includes/l10n.js | 61 +++++++++++++++++++------- src/locale/{en-US => en}/rr.properties | 0 2 files changed, 44 insertions(+), 17 deletions(-) rename src/locale/{en-US => en}/rr.properties (100%) diff --git a/src/includes/l10n.js b/src/includes/l10n.js index d5a3a8d..a41e45f 100644 --- a/src/includes/l10n.js +++ b/src/includes/l10n.js @@ -27,27 +27,54 @@ * ***** END LICENSE BLOCK ***** */ var l10n = (function(global) { - return function(addon, filename) { - // get selected locale - let locale = Cc["@mozilla.org/chrome/chrome-registry;1"] - .getService(Ci.nsIXULChromeRegistry).getSelectedLocale("global"); + let splitter = /(\w+)-\w+/; - let defaultBundle = Services.strings.createBundle( - addon.getResourceURI("locale/" + locale + "/" + filename).spec); - let engBundle = Services.strings.createBundle( - addon.getResourceURI("locale/en-US/" + filename).spec); + // get user's locale + let locale = Cc["@mozilla.org/chrome/chrome-registry;1"] + .getService(Ci.nsIXULChromeRegistry).getSelectedLocale("global"); + + function getStr(aStrBundle, aKey) { + if (!aStrBundle) return false; + try { + return aStrBundle.GetStringFromName(aKey); + } catch (e) {} + return ""; + } + + return function(addon, filename, defaultLocale) { + defaultLocale = defaultLocale || "en"; + function filepath(locale) addon + .getResourceURI("locale/" + locale + "/" + filename).spec + + let defaultBundle = Services.strings.createBundle(filepath(locale)); + + let defaultBasicBundle; + let (locale_base = locale.match(splitter)) { + if (locale_base) { + defaultBasicBundle = Services.strings.createBundle( + filepath(locale_base[1])); + } + } + + let addonsDefaultBundle = + Services.strings.createBundle(filepath(defaultLocale)); return global._ = function l10n_underscore(aKey, aLocale) { - if (aLocale) - var localeBundle = Services.strings.createBundle( - addon.getResourceURI("locale/" + aLocale + "/" + filename).spec); - try { - return (localeBundle && localeBundle.GetStringFromName(aKey)) - || defaultBundle.GetStringFromName(aKey) - || engBundle.GetStringFromName(aKey); - } catch (e) { - return engBundle.GetStringFromName(aKey); + let localeBundle, localeBasicBundle; + if (aLocale) { + localeBundle = Services.strings.createBundle(filepath(aLocale)); + + let locale_base = aLocale.match(splitter) + if (locale_base) + localeBasicBundle = Services.strings.createBundle( + filepath(locale_base[1])); } + + return getStr(localeBundle, aKey) + || getStr(localeBasicBundle, aKey) + || (defaultBundle && (getStr(defaultBundle, aKey) || (defaultBundle = null))) + || (defaultBasicBundle && (getStr(defaultBasicBundle, aKey) || (defaultBasicBundle = null))) + || getStr(addonsDefaultBundle, aKey); } } })(this); diff --git a/src/locale/en-US/rr.properties b/src/locale/en/rr.properties similarity index 100% rename from src/locale/en-US/rr.properties rename to src/locale/en/rr.properties From 7daa60b606a7253535b4e5836ded4474df54bf20 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 18 Feb 2011 18:50:29 -0800 Subject: [PATCH 055/112] improving the japanese translation, I think. --- src/locale/ja-JP/rr.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locale/ja-JP/rr.properties b/src/locale/ja-JP/rr.properties index 4a4a6f5..bd734c7 100644 --- a/src/locale/ja-JP/rr.properties +++ b/src/locale/ja-JP/rr.properties @@ -1 +1 @@ -restart=再起動します。 +restart=再起動 From 5e2be7acbfaf3c6be0a8bc889dded6810f5bd60d Mon Sep 17 00:00:00 2001 From: xabolcs Date: Mon, 28 Feb 2011 22:59:11 +0100 Subject: [PATCH 056/112] getting work with Shredder (Thunderbird 3.3a2, 3.3a3) --- src/bootstrap.js | 34 +++++++++++++++++++++++++++++++--- src/includes/utils.js | 19 +++++++++++-------- src/install.rdf | 8 ++++++++ 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index b517a4e..4a1cb37 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -37,6 +37,34 @@ const keysetID = "restartless-restart-keyset"; const keyID = "RR:Restart"; const fileMenuitemID = "menu_FileRestartItem"; +const XULAPPNAME = Cc["@mozilla.org/xre/app-info;1"] + .getService(Ci.nsIXULAppInfo) + .name; + +const XUL_APP_SPECIFIC = { + get windowType() { + switch (XULAPPNAME) { + case "Thunderbird": + return "mail:3pane"; + break; + default: //"Firefox", "SeaMonkey" + return "navigator:browser"; + break; + } + } + + , get baseKeyset() { + switch (XULAPPNAME) { + case "Thunderbird": + return "mailKeys"; + break; + default: //"Firefox", "SeaMonkey" + return "mainKeyset"; + break; + } + } +} + const PREF_BRANCH = Services.prefs.getBranch("extensions.restartless-restart."); const PREFS = { get key() _("restart.ak", getPref("locale")), @@ -58,7 +86,7 @@ let PREF_OBSERVER = { break; } addMenuItem(win); - }); + }, XUL_APP_SPECIFIC.windowType); } } @@ -125,7 +153,7 @@ function main(win) { restartKey.setAttribute("modifiers", getPref("modifiers")); restartKey.setAttribute("oncommand", "void(0);"); restartKey.addEventListener("command", restart, true); - $("mainKeyset").parentNode.appendChild(rrKeyset).appendChild(restartKey); + $(XUL_APP_SPECIFIC.baseKeyset).parentNode.appendChild(rrKeyset).appendChild(restartKey); } // add menu bar item to File menu @@ -157,7 +185,7 @@ function startup(data) AddonManager.getAddonByID(data.id, function(addon) { var prefs = PREF_BRANCH; include(addon.getResourceURI("includes/utils.js").spec); logo = addon.getResourceURI("images/refresh_16.png").spec; - watchWindows(main); + watchWindows(main, XUL_APP_SPECIFIC.windowType); prefs = prefs.QueryInterface(Components.interfaces.nsIPrefBranch2); prefs.addObserver("", PREF_OBSERVER, false); unload(function() prefs.removeObserver("", PREF_OBSERVER)); diff --git a/src/includes/utils.js b/src/includes/utils.js index ae230d7..f439eb9 100644 --- a/src/includes/utils.js +++ b/src/includes/utils.js @@ -40,14 +40,15 @@ * * @usage runOnLoad(window, callback): Apply a callback to to run on a window when it loads. * @param [function] callback: 1-parameter function that gets a browser window. + * @param [function] winType: a parameter that defines what kind of window is "browser window". */ -function runOnLoad(window, callback) { +function runOnLoad(window, callback, winType) { // Listen for one load event before checking the window type window.addEventListener("load", function() { window.removeEventListener("load", arguments.callee, false); // Now that the window has loaded, only handle browser windows - if (window.document.documentElement.getAttribute("windowtype") == "navigator:browser") + if (window.document.documentElement.getAttribute("windowtype") == winType) callback(window); }, false); } @@ -58,8 +59,9 @@ function runOnLoad(window, callback) { * * @usage runOnWindows(callback): Apply a callback to each open browser window. * @param [function] callback: 1-parameter function that gets a browser window. + * @param [function] winType: a parameter that defines what kind of window is "browser window". */ -function runOnWindows(callback) { +function runOnWindows(callback, winType) { // Wrap the callback in a function that ignores failures function watcher(window) { try { @@ -69,7 +71,7 @@ function runOnWindows(callback) { } // Add functionality to existing windows - let browserWindows = Services.wm.getEnumerator("navigator:browser"); + let browserWindows = Services.wm.getEnumerator(winType); while (browserWindows.hasMoreElements()) { // Only run the watcher immediately if the browser is completely loaded let browserWindow = browserWindows.getNext(); @@ -77,7 +79,7 @@ function runOnWindows(callback) { watcher(browserWindow); // Wait for the window to load before continuing else - runOnLoad(browserWindow, watcher); + runOnLoad(browserWindow, watcher, winType); } } @@ -86,8 +88,9 @@ function runOnWindows(callback) { * * @usage watchWindows(callback): Apply a callback to each browser window. * @param [function] callback: 1-parameter function that gets a browser window. + * @param [function] winType: a parameter that defines what kind of window is "browser window". */ -function watchWindows(callback) { +function watchWindows(callback, winType) { // Wrap the callback in a function that ignores failures function watcher(window) { try { @@ -97,12 +100,12 @@ function watchWindows(callback) { } // Add functionality to existing windows - runOnWindows(callback); + runOnWindows(callback, winType); // Watch for new browser windows opening then wait for it to load function windowWatcher(subject, topic) { if (topic == "domwindowopened") - runOnLoad(subject, watcher); + runOnLoad(subject, watcher, winType); } Services.ww.registerNotification(windowWatcher); diff --git a/src/install.rdf b/src/install.rdf index 080431b..9516590 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -29,5 +29,13 @@ 2.1.* + + + + {3550f703-e582-4d05-9a08-453d09bdfdc6} + 3.3a1 + 3.3a3pre* + + From 4ddf56e61a2dd35a629da1002e5de0e300319cfe Mon Sep 17 00:00:00 2001 From: networm <> Date: Sat, 26 Mar 2011 11:37:41 -0500 Subject: [PATCH 057/112] Adding Chinese Simplified (zh-CN) and Chinese Traditional (zh-TW) --- src/locale/zh-CN/rr.properties | 2 ++ src/locale/zh-TW/rr.properties | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 src/locale/zh-CN/rr.properties create mode 100644 src/locale/zh-TW/rr.properties diff --git a/src/locale/zh-CN/rr.properties b/src/locale/zh-CN/rr.properties new file mode 100644 index 0000000..e1a643d --- /dev/null +++ b/src/locale/zh-CN/rr.properties @@ -0,0 +1,2 @@ +restart=\u91CD\u65B0\u542F\u52A8 +restart.ak=R diff --git a/src/locale/zh-TW/rr.properties b/src/locale/zh-TW/rr.properties new file mode 100644 index 0000000..eb8fcca --- /dev/null +++ b/src/locale/zh-TW/rr.properties @@ -0,0 +1,2 @@ +restart=\u91CD\u65B0\u555F\u52D5 +restart.ak=R From ae456473da2e964ed50f24e490c62b991a6d18b3 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 8 Apr 2011 11:35:06 -0700 Subject: [PATCH 058/112] 4.3pre --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index 080431b..d52ff81 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 4.2 + 4.3pre true 2 http://github.com/erikvold/restartless-restart-ffext From b57d5f85197096420b252c093c9a4b68f36ba3f6 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 8 Apr 2011 11:35:36 -0700 Subject: [PATCH 059/112] 4.* for Firefox --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index d52ff81..ed9efab 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -18,7 +18,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 4.0b4 - 4.0.* + 4.* From 75c5764b0a8dbbca65fd5824272f807d0982e3b2 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 8 Apr 2011 18:16:15 -0700 Subject: [PATCH 060/112] Closes #26 using Services.strings.flushBundles when unloading --- src/bootstrap.js | 6 ++++-- src/includes/l10n.js | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index b517a4e..302f5a6 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -151,11 +151,13 @@ function main(win) { function install(){} function uninstall(){} function startup(data) AddonManager.getAddonByID(data.id, function(addon) { + var prefs = PREF_BRANCH; include(addon.getResourceURI("includes/l10n.js").spec); + include(addon.getResourceURI("includes/utils.js").spec); + l10n(addon, "rr.properties"); + unload(l10n.unload); - var prefs = PREF_BRANCH; - include(addon.getResourceURI("includes/utils.js").spec); logo = addon.getResourceURI("images/refresh_16.png").spec; watchWindows(main); prefs = prefs.QueryInterface(Components.interfaces.nsIPrefBranch2); diff --git a/src/includes/l10n.js b/src/includes/l10n.js index a41e45f..edc668b 100644 --- a/src/includes/l10n.js +++ b/src/includes/l10n.js @@ -41,7 +41,7 @@ var l10n = (function(global) { return ""; } - return function(addon, filename, defaultLocale) { + function l10n(addon, filename, defaultLocale) { defaultLocale = defaultLocale || "en"; function filepath(locale) addon .getResourceURI("locale/" + locale + "/" + filename).spec @@ -77,4 +77,8 @@ var l10n = (function(global) { || getStr(addonsDefaultBundle, aKey); } } + + l10n.unload = Services.strings.flushBundles; + + return l10n; })(this); From a1a7aaab75b40df222ea84bcdd61767e023b1308 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 8 Apr 2011 18:53:25 -0700 Subject: [PATCH 061/112] Closes #21 adding a option to disable fastload --- src/bootstrap.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index 302f5a6..714c975 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -38,10 +38,12 @@ const keyID = "RR:Restart"; const fileMenuitemID = "menu_FileRestartItem"; const PREF_BRANCH = Services.prefs.getBranch("extensions.restartless-restart."); +// pref defaults const PREFS = { get key() _("restart.ak", getPref("locale")), modifiers: "accel,alt", - locale: undefined + locale: undefined, + "disable_fastload": false }; let PREF_OBSERVER = { observe: function(aSubject, aTopic, aData) { @@ -52,7 +54,8 @@ let PREF_OBSERVER = { win.document.getElementById(keyID) .setAttribute("label", _("restart", getPref("locale"))); break; - default: + case "key": + case "modifiers": win.document.getElementById(keyID) .setAttribute(aData, getPref(aData)); break; @@ -68,9 +71,18 @@ let logo = ""; Services.scriptloader.loadSubScript(src, global)))(this); function getPref(aName) { - try { - return PREF_BRANCH.getComplexValue(aName, Ci.nsISupportsString).data; - } catch(e) {} + var pref = PREF_BRANCH; + var type = pref.getPrefType(aName); + + // if the type is valid, then return the value + switch(type) { + case pref.PREF_STRING: + return pref.getComplexValue(aName, Ci.nsISupportsString).data; + case pref.PREF_BOOL: + return pref.getBoolPref(aName); + } + + // return default return PREFS[aName]; } @@ -105,6 +117,10 @@ function restart() { if (canceled.data) return false; // somebody canceled our quit request + // disable fastload cache? + if (getPref("disable_fastload")) Services.appinfo.invalidateCachesOnRestart(); + + // restart Cc['@mozilla.org/toolkit/app-startup;1'].getService(Ci.nsIAppStartup) .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart); From 164141568793fd893e84930d26e47c55684fece5 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 8 Apr 2011 19:17:48 -0700 Subject: [PATCH 062/112] 3.* for Thunderbird --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index 9516590..292f38c 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -34,7 +34,7 @@ {3550f703-e582-4d05-9a08-453d09bdfdc6} 3.3a1 - 3.3a3pre* + 3.* From d06b18389b3754985bd2f4c8824e65e72d1326bc Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 8 Apr 2011 19:29:13 -0700 Subject: [PATCH 063/112] minor style changes --- src/bootstrap.js | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index 4a1cb37..7557550 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -37,32 +37,18 @@ const keysetID = "restartless-restart-keyset"; const keyID = "RR:Restart"; const fileMenuitemID = "menu_FileRestartItem"; -const XULAPPNAME = Cc["@mozilla.org/xre/app-info;1"] - .getService(Ci.nsIXULAppInfo) - .name; - -const XUL_APP_SPECIFIC = { - get windowType() { - switch (XULAPPNAME) { - case "Thunderbird": - return "mail:3pane"; - break; - default: //"Firefox", "SeaMonkey" - return "navigator:browser"; - break; - } - } - - , get baseKeyset() { - switch (XULAPPNAME) { - case "Thunderbird": - return "mailKeys"; - break; - default: //"Firefox", "SeaMonkey" - return "mainKeyset"; - break; - } - } +switch(Services.appinfo.name) { +case "Thunderbird": + var XUL_APP_SPECIFIC = { + windowType: "mail:3pane", + baseKeyset: "mailKeys" + }; + break; +default: //"Firefox", "SeaMonkey" + var XUL_APP_SPECIFIC = { + windowType: "navigator:browser", + baseKeyset: "mainKeyset" + }; } const PREF_BRANCH = Services.prefs.getBranch("extensions.restartless-restart."); From 770c5afdc8ad0f2eeb6dfed5174e8e069d446430 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 8 Apr 2011 21:23:25 -0700 Subject: [PATCH 064/112] minor style changes, and now using Gecko internals to check if we can quit. --- src/bootstrap.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index 06b09a4..f523868 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -40,13 +40,13 @@ const fileMenuitemID = "menu_FileRestartItem"; switch(Services.appinfo.name) { case "Thunderbird": var XUL_APP_SPECIFIC = { - windowType: "mail:3pane", + winType: "mail:3pane", baseKeyset: "mailKeys" }; break; default: //"Firefox", "SeaMonkey" var XUL_APP_SPECIFIC = { - windowType: "navigator:browser", + winType: "navigator:browser", baseKeyset: "mainKeyset" }; } @@ -75,7 +75,7 @@ let PREF_OBSERVER = { break; } addMenuItem(win); - }, XUL_APP_SPECIFIC.windowType); + }, XUL_APP_SPECIFIC.winType); } } @@ -124,12 +124,8 @@ function addMenuItem(win) { } function restart() { - let canceled = Cc["@mozilla.org/supports-PRBool;1"] - .createInstance(Ci.nsISupportsPRBool); - - Services.obs.notifyObservers(canceled, "quit-application-requested", "restart"); - - if (canceled.data) return false; // somebody canceled our quit request + if (!Services.wm.getMostRecentWindow(XUL_APP_SPECIFIC.winType).canQuitApplication()) + return false; // something aborted our quit request // disable fastload cache? if (getPref("disable_fastload")) Services.appinfo.invalidateCachesOnRestart(); @@ -189,7 +185,7 @@ function startup(data) AddonManager.getAddonByID(data.id, function(addon) { unload(l10n.unload); logo = addon.getResourceURI("images/refresh_16.png").spec; - watchWindows(main, XUL_APP_SPECIFIC.windowType); + watchWindows(main, XUL_APP_SPECIFIC.winType); prefs = prefs.QueryInterface(Components.interfaces.nsIPrefBranch2); prefs.addObserver("", PREF_OBSERVER, false); unload(function() prefs.removeObserver("", PREF_OBSERVER)); From eac2e4c46d750752875bb6f6837711432a24a944 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sat, 9 Apr 2011 12:16:04 -0700 Subject: [PATCH 065/112] 5 --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index 0aee076..2cff965 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 4.3pre + 5 true 2 http://github.com/erikvold/restartless-restart-ffext From 4717e7f8694095af753c653a6aba3934613e4686 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sun, 10 Apr 2011 16:15:48 -0700 Subject: [PATCH 066/112] including the locale folder in builds --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 70a70c2..7dcd623 100644 --- a/build.sh +++ b/build.sh @@ -9,7 +9,7 @@ cd src rm -rf build mkdir build cp -r \ - bootstrap.js images includes install.rdf icon.png icon64.png \ + bootstrap.js images includes locale install.rdf icon.png icon64.png \ build/ cd build From c5c2ee7c49cf35d056292c804e4b5abbe8ba6d44 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sun, 10 Apr 2011 16:17:06 -0700 Subject: [PATCH 067/112] simulating the addon object for better performance. --- src/bootstrap.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index f523868..d138a26 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -30,7 +30,6 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components; Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/AddonManager.jsm"); const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; const keysetID = "restartless-restart-keyset"; @@ -174,9 +173,15 @@ function main(win) { }, win); } +var addon = { + getResourceURI: function(filePath) ({ + spec: __SCRIPT_URI_SPEC__ + "/../" + filePath + }) +} + function install(){} function uninstall(){} -function startup(data) AddonManager.getAddonByID(data.id, function(addon) { +function startup() { var prefs = PREF_BRANCH; include(addon.getResourceURI("includes/l10n.js").spec); include(addon.getResourceURI("includes/utils.js").spec); @@ -189,5 +194,5 @@ function startup(data) AddonManager.getAddonByID(data.id, function(addon) { prefs = prefs.QueryInterface(Components.interfaces.nsIPrefBranch2); prefs.addObserver("", PREF_OBSERVER, false); unload(function() prefs.removeObserver("", PREF_OBSERVER)); -}); +}; function shutdown(data, reason) { if (reason !== APP_SHUTDOWN) unload(); } From 8ed6890e81e54f562b7a970189a70b8f4e5c22f2 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 12 Apr 2011 21:29:40 -0700 Subject: [PATCH 068/112] Revert "minor style changes, and now using Gecko internals to check if we can quit." This reverts commit 770c5afdc8ad0f2eeb6dfed5174e8e069d446430. --- src/bootstrap.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index d138a26..86d775c 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -39,13 +39,13 @@ const fileMenuitemID = "menu_FileRestartItem"; switch(Services.appinfo.name) { case "Thunderbird": var XUL_APP_SPECIFIC = { - winType: "mail:3pane", + windowType: "mail:3pane", baseKeyset: "mailKeys" }; break; default: //"Firefox", "SeaMonkey" var XUL_APP_SPECIFIC = { - winType: "navigator:browser", + windowType: "navigator:browser", baseKeyset: "mainKeyset" }; } @@ -74,7 +74,7 @@ let PREF_OBSERVER = { break; } addMenuItem(win); - }, XUL_APP_SPECIFIC.winType); + }, XUL_APP_SPECIFIC.windowType); } } @@ -123,8 +123,12 @@ function addMenuItem(win) { } function restart() { - if (!Services.wm.getMostRecentWindow(XUL_APP_SPECIFIC.winType).canQuitApplication()) - return false; // something aborted our quit request + let canceled = Cc["@mozilla.org/supports-PRBool;1"] + .createInstance(Ci.nsISupportsPRBool); + + Services.obs.notifyObservers(canceled, "quit-application-requested", "restart"); + + if (canceled.data) return false; // somebody canceled our quit request // disable fastload cache? if (getPref("disable_fastload")) Services.appinfo.invalidateCachesOnRestart(); @@ -190,7 +194,7 @@ function startup() { unload(l10n.unload); logo = addon.getResourceURI("images/refresh_16.png").spec; - watchWindows(main, XUL_APP_SPECIFIC.winType); + watchWindows(main, XUL_APP_SPECIFIC.windowType); prefs = prefs.QueryInterface(Components.interfaces.nsIPrefBranch2); prefs.addObserver("", PREF_OBSERVER, false); unload(function() prefs.removeObserver("", PREF_OBSERVER)); From 110a3cb5debc3c3d08d4a88144971827fc93a394 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 12 Apr 2011 21:40:23 -0700 Subject: [PATCH 069/112] Closes #29 Supporting Fennec. --- src/bootstrap.js | 38 +++++++++++++++++++++++++------------- src/install.rdf | 9 +++++++++ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index 86d775c..10d5621 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -35,19 +35,17 @@ const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; const keysetID = "restartless-restart-keyset"; const keyID = "RR:Restart"; const fileMenuitemID = "menu_FileRestartItem"; +var XUL_APP = {name: Services.appinfo.name}; switch(Services.appinfo.name) { case "Thunderbird": - var XUL_APP_SPECIFIC = { - windowType: "mail:3pane", - baseKeyset: "mailKeys" - }; + XUL_APP.winType = "mail:3pane"; + XUL_APP.baseKeyset = "mailKeys"; break; +case "Fennec": break; default: //"Firefox", "SeaMonkey" - var XUL_APP_SPECIFIC = { - windowType: "navigator:browser", - baseKeyset: "mainKeyset" - }; + XUL_APP.winType = "navigator:browser"; + XUL_APP.baseKeyset = "mainKeyset"; } const PREF_BRANCH = Services.prefs.getBranch("extensions.restartless-restart."); @@ -74,7 +72,7 @@ let PREF_OBSERVER = { break; } addMenuItem(win); - }, XUL_APP_SPECIFIC.windowType); + }, XUL_APP.winType); } } @@ -154,7 +152,7 @@ function main(win) { restartKey.setAttribute("modifiers", getPref("modifiers")); restartKey.setAttribute("oncommand", "void(0);"); restartKey.addEventListener("command", restart, true); - $(XUL_APP_SPECIFIC.baseKeyset).parentNode.appendChild(rrKeyset).appendChild(restartKey); + $(XUL_APP.baseKeyset).parentNode.appendChild(rrKeyset).appendChild(restartKey); } // add menu bar item to File menu @@ -183,9 +181,23 @@ var addon = { }) } -function install(){} +function disable(id) { + Cu.import("resource://gre/modules/AddonManager.jsm"); + AddonManager.getAddonByID(id, function(addon) { + addon.userDisabled = true; + }); +} + +function install(data) { + if ("Fennec" == XUL_APP.name) disable(data.id); +} function uninstall(){} -function startup() { +function startup(data, reason) { + if ("Fennec" == XUL_APP.name) { + if (ADDON_ENABLE == reason) restart(); + disable(data.id); + } + var prefs = PREF_BRANCH; include(addon.getResourceURI("includes/l10n.js").spec); include(addon.getResourceURI("includes/utils.js").spec); @@ -194,7 +206,7 @@ function startup() { unload(l10n.unload); logo = addon.getResourceURI("images/refresh_16.png").spec; - watchWindows(main, XUL_APP_SPECIFIC.windowType); + watchWindows(main, XUL_APP.winType); prefs = prefs.QueryInterface(Components.interfaces.nsIPrefBranch2); prefs.addObserver("", PREF_OBSERVER, false); unload(function() prefs.removeObserver("", PREF_OBSERVER)); diff --git a/src/install.rdf b/src/install.rdf index 2cff965..d62afdb 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -9,6 +9,7 @@ true 2 http://github.com/erikvold/restartless-restart-ffext + Fennec users enable to restart, otherwise a File -> Restart menu item will be added. Greg Parris; http://phob.net/ Nils Maier; https://tn123.org/ @@ -37,5 +38,13 @@ 3.* + + + + {a23983c0-fd0e-11dc-95ff-0800200c9a66} + 4.0b4 + 4.* + + From 1a2cbdacfd70e2638475de0bc9851168c0c81c37 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Wed, 13 Apr 2011 08:53:49 -0700 Subject: [PATCH 070/112] Closes #27 adding a opt-in toolbar button --- src/bootstrap.js | 86 +++++++++++++++++++++++++++++++++++++---------- src/icon16.png | Bin 0 -> 273 bytes src/install.rdf | 2 +- 3 files changed, 69 insertions(+), 19 deletions(-) create mode 100644 src/icon16.png diff --git a/src/bootstrap.js b/src/bootstrap.js index 10d5621..808d727 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -54,25 +54,16 @@ const PREFS = { get key() _("restart.ak", getPref("locale")), modifiers: "accel,alt", locale: undefined, - "disable_fastload": false + "disable_fastload": false, + toolbar: null, + "toolbar.before": null }; + +var prefChgHandlers = []; let PREF_OBSERVER = { observe: function(aSubject, aTopic, aData) { if ("nsPref:changed" != aTopic || !(aData in PREFS)) return; - runOnWindows(function(win) { - switch (aData) { - case "locale": - win.document.getElementById(keyID) - .setAttribute("label", _("restart", getPref("locale"))); - break; - case "key": - case "modifiers": - win.document.getElementById(keyID) - .setAttribute(aData, getPref(aData)); - break; - } - addMenuItem(win); - }, XUL_APP.winType); + prefChgHandlers.forEach(function(func) func && func(aData)); } } @@ -97,6 +88,18 @@ function getPref(aName) { return PREFS[aName]; } +function setPref(aKey, aVal) { + aVal = ("wrapper-restartlessrestart-toolbarbutton" == aVal) ? "" : aVal; + switch (typeof(aVal)) { + case "string": + var ss = Cc["@mozilla.org/supports-string;1"] + .createInstance(Ci.nsISupportsString); + ss.data = aVal; + PREF_BRANCH.setComplexValue(aKey, Ci.nsISupportsString, ss); + break; + } +} + function addMenuItem(win) { var $ = function(id) win.document.getElementById(id); @@ -141,12 +144,13 @@ function restart() { function main(win) { let doc = win.document; function $(id) doc.getElementById(id); + function xul(type) doc.createElementNS(NS_XUL, type); - let rrKeyset = doc.createElementNS(NS_XUL, "keyset"); + let rrKeyset = xul("keyset"); rrKeyset.setAttribute("id", keysetID); // add hotkey - let (restartKey = doc.createElementNS(NS_XUL, "key")) { + let (restartKey = xul("key")) { restartKey.setAttribute("id", keyID); restartKey.setAttribute("key", getPref("key")); restartKey.setAttribute("modifiers", getPref("modifiers")); @@ -169,9 +173,55 @@ function main(win) { appMenu.insertBefore(restartAMI, $("appmenu-quit")); } + // add toolbar button + let rrTBB = xul("toolbarbutton"); + rrTBB.setAttribute("id", "restartlessrestart-toolbarbutton"); + rrTBB.setAttribute("type", "button"); + rrTBB.setAttribute("image", addon.getResourceURI("icon16.png").spec); + rrTBB.setAttribute("class", "toolbarbutton-1 chromeclass-toolbar-additional"); + rrTBB.setAttribute("label", _("restart", getPref("locale"))); + rrTBB.addEventListener("command", restart, true); + let tbID = getPref("toolbar"); + ($("navigator-toolbox") || $("mail-toolbox")).palette.appendChild(rrTBB); + if (tbID) { + var tb = $(tbID); + if (tb) + tb.insertItem("restartlessrestart-toolbarbutton", $(getPref("toolbar.before")), null, false); + } + + function saveTBNodeInfo(aEvt) { + if (rrTBB != aEvt.target) return; + rrTBB.setAttribute("label", _("restart", getPref("locale"))); + setPref("toolbar", rrTBB.parentNode.getAttribute("id") || ""); + setPref("toolbar.before", (rrTBB.nextSibling || "") && rrTBB.nextSibling.getAttribute("id")); + } + win.addEventListener("DOMNodeInserted", saveTBNodeInfo, false); + win.addEventListener("DOMNodeRemoved", saveTBNodeInfo, false); + + var prefChgHanderIndex = prefChgHandlers.push(function(aData) { + switch (aData) { + case "locale": + let label = _("restart", getPref("locale")); + $(keyID).setAttribute("label", label); + rrTBB.setAttribute("label", label); + break; + case "key": + case "modifiers": + $(keyID).setAttribute(aData, getPref(aData)); + break; + } + addMenuItem(win); + }) - 1; + unload(function() { rrKeyset.parentNode.removeChild(rrKeyset); appMenu && appMenu.removeChild(restartAMI); + rrTBBB.parentNode.removeChild(rrTBB); + rrTBB.parentNode.removeChild(rrTBB); + saveTBNodeInfo(); + win.removeEventListener("DOMNodeInserted", saveTBNodeInfo); + win.removeEventListener("DOMNodeRemoved", saveTBNodeInfo, false); + prefChgHandlers[prefChgHanderIndex] = null; }, win); } @@ -211,4 +261,4 @@ function startup(data, reason) { prefs.addObserver("", PREF_OBSERVER, false); unload(function() prefs.removeObserver("", PREF_OBSERVER)); }; -function shutdown(data, reason) { if (reason !== APP_SHUTDOWN) unload(); } +function shutdown(data, reason) unload() diff --git a/src/icon16.png b/src/icon16.png new file mode 100644 index 0000000000000000000000000000000000000000..66e21e3a64ac28d654f36b9dd5265f74f06f22a3 GIT binary patch literal 273 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5XHha1_hE&{2N;tsJ(h$Ko{mK9T|2KA7GkmO?U?UaBKlO07 zgS}YqiyiXQ8Bff5&s@lK#f@F#x7{wq6Koa=p6A+s$wpV4aSwXlkaM6)Wi~4Zi`E&{ z*AsagW@a69kWe{rrI{zese9RW7l{uHGntJZFf+3<++|2q`jX%qvBBX>+a(qDMQTw= zj@J|%d`xa78ZKb$v literal 0 HcmV?d00001 diff --git a/src/install.rdf b/src/install.rdf index d62afdb..6255ecf 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -19,7 +19,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 4.0b4 - 4.* + 6.* From 9ec6122537bc99b23068fbcfee2fdb48407fc942 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Mon, 18 Apr 2011 22:59:39 -0700 Subject: [PATCH 071/112] 6 --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index 6255ecf..1e1373b 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 5 + 6 true 2 http://github.com/erikvold/restartless-restart-ffext From 57631299891dbc56967bb7a91845fd99e73d0d2b Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Mon, 18 Apr 2011 23:02:02 -0700 Subject: [PATCH 072/112] 7pre --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index 1e1373b..00fb85f 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 6 + 7pre true 2 http://github.com/erikvold/restartless-restart-ffext From 20e441c0523cfb780144381a29431ac4b23c4408 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Mon, 18 Apr 2011 23:19:02 -0700 Subject: [PATCH 073/112] including icon16.png in the build process --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 7dcd623..b2b3eae 100644 --- a/build.sh +++ b/build.sh @@ -9,7 +9,7 @@ cd src rm -rf build mkdir build cp -r \ - bootstrap.js images includes locale install.rdf icon.png icon64.png \ + bootstrap.js images includes locale install.rdf icon.png icon16.png icon64.png \ build/ cd build From 71de6969738b8aee4625d20239aec0c5aa5a5e7f Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 19 Apr 2011 15:32:15 -0700 Subject: [PATCH 074/112] Closes #34 use the 'currentset' attribute as a fallback for the extensions.restartless-restart.toolbar.before preference --- src/bootstrap.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index 808d727..7bfa975 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -185,8 +185,22 @@ function main(win) { ($("navigator-toolbox") || $("mail-toolbox")).palette.appendChild(rrTBB); if (tbID) { var tb = $(tbID); - if (tb) - tb.insertItem("restartlessrestart-toolbarbutton", $(getPref("toolbar.before")), null, false); + if (tb) { + let b4ID = getPref("toolbar.before"); + let b4 = $(b4ID); + if (!b4) { // fallback for issue 34 + let currentset = tb.getAttribute("currentset").split(","); + let i = currentset.indexOf("restartlessrestart-toolbarbutton") + 1; + if (i > 0) { + let len = currentset.length; + for (; i < len; i++) { + b4 = $(currentset[i]); + if (b4) break; + } + } + } + tb.insertItem("restartlessrestart-toolbarbutton", b4, null, false); + } } function saveTBNodeInfo(aEvt) { From 10a31845507c4c40e6af5d7a6e2f3dea2bfb1218 Mon Sep 17 00:00:00 2001 From: supahgreg Date: Tue, 19 Apr 2011 13:48:19 -0500 Subject: [PATCH 075/112] Closes #30 RR button position not kept when placed in the nav-bar. (cherry picked from commit 87e33d52ff86a2148e132086db61473600f5ad5e) --- src/bootstrap.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index 7bfa975..7d60704 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -207,7 +207,8 @@ function main(win) { if (rrTBB != aEvt.target) return; rrTBB.setAttribute("label", _("restart", getPref("locale"))); setPref("toolbar", rrTBB.parentNode.getAttribute("id") || ""); - setPref("toolbar.before", (rrTBB.nextSibling || "") && rrTBB.nextSibling.getAttribute("id")); + setPref("toolbar.before", (rrTBB.nextSibling || "") + && rrTBB.nextSibling.getAttribute("id").replace(/^wrapper-/i, "")); } win.addEventListener("DOMNodeInserted", saveTBNodeInfo, false); win.addEventListener("DOMNodeRemoved", saveTBNodeInfo, false); From b889e38c0679cd6a69149dc9753620b07feedf54 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 19 Apr 2011 15:36:00 -0700 Subject: [PATCH 076/112] bug fix: when calling saveTBNodeInfo w/out a event argument --- src/bootstrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index 7d60704..ba8e21b 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -204,7 +204,7 @@ function main(win) { } function saveTBNodeInfo(aEvt) { - if (rrTBB != aEvt.target) return; + if (aEvt && rrTBB != aEvt.target) return; rrTBB.setAttribute("label", _("restart", getPref("locale"))); setPref("toolbar", rrTBB.parentNode.getAttribute("id") || ""); setPref("toolbar.before", (rrTBB.nextSibling || "") From 1c4f8c747ba4f20290ade3d879805b70da1c3cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20Hiort=20af=20Orn=C3=A4s?= Date: Tue, 19 Apr 2011 18:31:44 -0700 Subject: [PATCH 077/112] sv-SE --- src/install.rdf | 2 ++ src/locale/sv-SE/rr.properties | 1 + 2 files changed, 3 insertions(+) create mode 100644 src/locale/sv-SE/rr.properties diff --git a/src/install.rdf b/src/install.rdf index 00fb85f..259432a 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -14,6 +14,8 @@ Greg Parris; http://phob.net/ Nils Maier; https://tn123.org/ + Mikael Hiort af Ornäs + diff --git a/src/locale/sv-SE/rr.properties b/src/locale/sv-SE/rr.properties new file mode 100644 index 0000000..ba30d97 --- /dev/null +++ b/src/locale/sv-SE/rr.properties @@ -0,0 +1 @@ +restart=Starta om From 5bfb80948382a8a0a4f2288ea7f761d1056accab Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 19 Apr 2011 18:34:51 -0700 Subject: [PATCH 078/112] removing some redundant translations --- src/locale/zh-CN/rr.properties | 1 - src/locale/zh-TW/rr.properties | 1 - 2 files changed, 2 deletions(-) diff --git a/src/locale/zh-CN/rr.properties b/src/locale/zh-CN/rr.properties index e1a643d..de6819b 100644 --- a/src/locale/zh-CN/rr.properties +++ b/src/locale/zh-CN/rr.properties @@ -1,2 +1 @@ restart=\u91CD\u65B0\u542F\u52A8 -restart.ak=R diff --git a/src/locale/zh-TW/rr.properties b/src/locale/zh-TW/rr.properties index eb8fcca..a28e557 100644 --- a/src/locale/zh-TW/rr.properties +++ b/src/locale/zh-TW/rr.properties @@ -1,2 +1 @@ restart=\u91CD\u65B0\u555F\u52D5 -restart.ak=R From 7c61ccfaa0a4e6a0f0edc2a011c35b75313c6ffe Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 19 Apr 2011 18:54:56 -0700 Subject: [PATCH 079/112] Closes #31 Russian FF shows menu item untranslated --- src/includes/l10n.js | 4 ++-- src/locale/{ru-RU => ru}/rr.properties | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename src/locale/{ru-RU => ru}/rr.properties (100%) diff --git a/src/includes/l10n.js b/src/includes/l10n.js index edc668b..5633c7b 100644 --- a/src/includes/l10n.js +++ b/src/includes/l10n.js @@ -72,8 +72,8 @@ var l10n = (function(global) { return getStr(localeBundle, aKey) || getStr(localeBasicBundle, aKey) - || (defaultBundle && (getStr(defaultBundle, aKey) || (defaultBundle = null))) - || (defaultBasicBundle && (getStr(defaultBasicBundle, aKey) || (defaultBasicBundle = null))) + || getStr(defaultBundle, aKey) + || getStr(defaultBasicBundle, aKey) || getStr(addonsDefaultBundle, aKey); } } diff --git a/src/locale/ru-RU/rr.properties b/src/locale/ru/rr.properties similarity index 100% rename from src/locale/ru-RU/rr.properties rename to src/locale/ru/rr.properties From 9df35291c4953f6d90ed1e0fee72991039d18ad2 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 19 Apr 2011 19:54:15 -0700 Subject: [PATCH 080/112] adding Norwegian translation from Google Translate --- src/locale/no/rr.properties | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/locale/no/rr.properties diff --git a/src/locale/no/rr.properties b/src/locale/no/rr.properties new file mode 100644 index 0000000..8f78b32 --- /dev/null +++ b/src/locale/no/rr.properties @@ -0,0 +1 @@ +restart=Start på nytt From 0ef66a2b1224f1a6c5a6ba81c231872daac2ba6b Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 19 Apr 2011 19:56:52 -0700 Subject: [PATCH 081/112] adding Spanish translation from Google Translate --- src/locale/es/rr.properties | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/locale/es/rr.properties diff --git a/src/locale/es/rr.properties b/src/locale/es/rr.properties new file mode 100644 index 0000000..6ea7768 --- /dev/null +++ b/src/locale/es/rr.properties @@ -0,0 +1 @@ +restart=Reinicie From 07b4ffbcc911bbbf089de4187a8d563c04af4bd1 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 19 Apr 2011 23:06:53 -0700 Subject: [PATCH 082/112] listening to 'aftercustomization' instead of 'DOMNodeInserted' --- src/bootstrap.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index ba8e21b..5aa4e1c 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -204,14 +204,11 @@ function main(win) { } function saveTBNodeInfo(aEvt) { - if (aEvt && rrTBB != aEvt.target) return; - rrTBB.setAttribute("label", _("restart", getPref("locale"))); setPref("toolbar", rrTBB.parentNode.getAttribute("id") || ""); setPref("toolbar.before", (rrTBB.nextSibling || "") && rrTBB.nextSibling.getAttribute("id").replace(/^wrapper-/i, "")); } - win.addEventListener("DOMNodeInserted", saveTBNodeInfo, false); - win.addEventListener("DOMNodeRemoved", saveTBNodeInfo, false); + win.addEventListener("aftercustomization", saveTBNodeInfo, false); var prefChgHanderIndex = prefChgHandlers.push(function(aData) { switch (aData) { @@ -233,9 +230,7 @@ function main(win) { appMenu && appMenu.removeChild(restartAMI); rrTBBB.parentNode.removeChild(rrTBB); rrTBB.parentNode.removeChild(rrTBB); - saveTBNodeInfo(); - win.removeEventListener("DOMNodeInserted", saveTBNodeInfo); - win.removeEventListener("DOMNodeRemoved", saveTBNodeInfo, false); + win.removeEventListener("aftercustomization", saveTBNodeInfo); prefChgHandlers[prefChgHanderIndex] = null; }, win); } From 30f09df72ffdd75f84183b8560926ed7824d3284 Mon Sep 17 00:00:00 2001 From: xabolcs Date: Sun, 1 May 2011 23:00:08 +0200 Subject: [PATCH 083/112] a new contributor (cherry picked from commit c7112d7d9b75c8a78d98642c75d4d66be8c2711a) --- src/bootstrap.js | 1 + src/install.rdf | 1 + 2 files changed, 2 insertions(+) diff --git a/src/bootstrap.js b/src/bootstrap.js index 5aa4e1c..5c7297a 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -25,6 +25,7 @@ * Erik Vold (Original Author) * Greg Parris * Nils Maier + * Szabolcs Hubai * * ***** END LICENSE BLOCK ***** */ diff --git a/src/install.rdf b/src/install.rdf index 259432a..d65803c 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -13,6 +13,7 @@ Greg Parris; http://phob.net/ Nils Maier; https://tn123.org/ + Szabolcs Hubai Mikael Hiort af Ornäs From c0c23f7babb694f0e7b090daf116bbf4280f9f4c Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Tue, 3 May 2011 12:10:05 -0700 Subject: [PATCH 084/112] 7 --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index d65803c..714da55 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 7pre + 7 true 2 http://github.com/erikvold/restartless-restart-ffext From 90600139aee81edbea96b7e3b1f509d1451ab3b5 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 13 May 2011 18:52:29 -0700 Subject: [PATCH 085/112] 8pre --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index 714da55..526998b 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 7 + 8pre true 2 http://github.com/erikvold/restartless-restart-ffext From 8e1d4ea9bb7022c25c76b26af98732b18d620819 Mon Sep 17 00:00:00 2001 From: Markus Brandt Date: Fri, 13 May 2011 18:57:11 -0700 Subject: [PATCH 086/112] icon is shown with the File menu's 'Restart' menuitem. --- src/bootstrap.js | 2 ++ src/install.rdf | 1 + 2 files changed, 3 insertions(+) diff --git a/src/bootstrap.js b/src/bootstrap.js index 5c7297a..40eec4d 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -113,9 +113,11 @@ function addMenuItem(win) { // add the new menuitem to File menu let (restartMI = win.document.createElementNS(NS_XUL, "menuitem")) { restartMI.setAttribute("id", fileMenuitemID); + restartMI.setAttribute("class", "menuitem-iconic"); restartMI.setAttribute("label", _("restart", getPref("locale"))); restartMI.setAttribute("accesskey", "R"); restartMI.setAttribute("key", keyID); + restartMI.style.listStyleImage = "url('" + logo + "')"; restartMI.addEventListener("command", restart, true); $("menu_FilePopup").insertBefore(restartMI, $("menu_FileQuitItem")); diff --git a/src/install.rdf b/src/install.rdf index 526998b..480bc6b 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -14,6 +14,7 @@ Greg Parris; http://phob.net/ Nils Maier; https://tn123.org/ Szabolcs Hubai + Markus Brandt Mikael Hiort af Ornäs From 78ea050a09ceb5637d39cfdf946c68dcc618e2cc Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Wed, 25 May 2011 08:55:59 -0700 Subject: [PATCH 087/112] 7.* for Firefox --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index 480bc6b..5139ef5 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -23,7 +23,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 4.0b4 - 6.* + 7.* From 14a06718331ec571352391f4f7455a1c2e548aab Mon Sep 17 00:00:00 2001 From: Samuel Bronson Date: Wed, 1 Jun 2011 13:47:28 -0700 Subject: [PATCH 088/112] Edited Readme.md via GitHub --- Readme.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 23d9e3a..4c29fff 100644 --- a/Readme.md +++ b/Readme.md @@ -1,8 +1,9 @@ Restartless Restart for Firefox 4 === -Tiny restartless extension adding browser restart actions to Firefox. +Tiny [restartless][1] extension adding browser restart actions to Firefox. (Oh, the irony) The main audience of this extension is other extension developers who need to restart the browser often. +[1]: https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions \ No newline at end of file From 7b320b013977f4fcb97e8eb664800158d847d805 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sun, 5 Jun 2011 10:49:49 -0700 Subject: [PATCH 089/112] adding options to EM for FF7+ users --- src/bootstrap.js | 42 +++++++++++--------------- src/includes/prefs.js | 70 +++++++++++++++++++++++++++++++++++++++++++ src/install.rdf | 1 + src/options.xul | 12 ++++++++ 4 files changed, 100 insertions(+), 25 deletions(-) create mode 100644 src/includes/prefs.js create mode 100644 src/options.xul diff --git a/src/bootstrap.js b/src/bootstrap.js index 40eec4d..9fed152 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -49,15 +49,15 @@ default: //"Firefox", "SeaMonkey" XUL_APP.baseKeyset = "mainKeyset"; } -const PREF_BRANCH = Services.prefs.getBranch("extensions.restartless-restart."); -// pref defaults +const PREF_BRANCH = "extensions.restartless-restart."; const PREFS = { - get key() _("restart.ak", getPref("locale")), modifiers: "accel,alt", - locale: undefined, + locale: Cc["@mozilla.org/chrome/chrome-registry;1"] + .getService(Ci.nsIXULChromeRegistry).getSelectedLocale("global"), "disable_fastload": false, - toolbar: null, - "toolbar.before": null + toolbar: "", + "toolbar.before": "", + get key() _("restart.ak", getPref("locale")) }; var prefChgHandlers = []; @@ -73,22 +73,6 @@ let logo = ""; (function(global) global.include = function include(src) ( Services.scriptloader.loadSubScript(src, global)))(this); -function getPref(aName) { - var pref = PREF_BRANCH; - var type = pref.getPrefType(aName); - - // if the type is valid, then return the value - switch(type) { - case pref.PREF_STRING: - return pref.getComplexValue(aName, Ci.nsISupportsString).data; - case pref.PREF_BOOL: - return pref.getBoolPref(aName); - } - - // return default - return PREFS[aName]; -} - function setPref(aKey, aVal) { aVal = ("wrapper-restartlessrestart-toolbarbutton" == aVal) ? "" : aVal; switch (typeof(aVal)) { @@ -96,7 +80,8 @@ function setPref(aKey, aVal) { var ss = Cc["@mozilla.org/supports-string;1"] .createInstance(Ci.nsISupportsString); ss.data = aVal; - PREF_BRANCH.setComplexValue(aKey, Ci.nsISupportsString, ss); + Services.prefs.getBranch(PREF_BRANCH) + .setComplexValue(aKey, Ci.nsISupportsString, ss); break; } } @@ -261,13 +246,20 @@ function startup(data, reason) { disable(data.id); } - var prefs = PREF_BRANCH; - include(addon.getResourceURI("includes/l10n.js").spec); + var prefs = Services.prefs.getBranch(PREF_BRANCH); + + // include utils include(addon.getResourceURI("includes/utils.js").spec); + // init l10n + include(addon.getResourceURI("includes/l10n.js").spec); l10n(addon, "rr.properties"); unload(l10n.unload); + // init prefs + include(addon.getResourceURI("includes/prefs.js").spec); + setDefaultPrefs(); + logo = addon.getResourceURI("images/refresh_16.png").spec; watchWindows(main, XUL_APP.winType); prefs = prefs.QueryInterface(Components.interfaces.nsIPrefBranch2); diff --git a/src/includes/prefs.js b/src/includes/prefs.js new file mode 100644 index 0000000..1285234 --- /dev/null +++ b/src/includes/prefs.js @@ -0,0 +1,70 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Speak Words. + * + * The Initial Developer of the Original Code is The Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Edward Lee + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/** + * Get the preference value of type specified in PREFS + */ +function getPref(key) { + // Cache the prefbranch after first use + if (getPref.branch == null) + getPref.branch = Services.prefs.getBranch(PREF_BRANCH); + + // Figure out what type of pref to fetch + switch (typeof PREFS[key]) { + case "boolean": + return getPref.branch.getBoolPref(key); + case "string": + return getPref.branch.getCharPref(key); + } + return null; +} + +/** + * Initialize default preferences specified in PREFS + */ +function setDefaultPrefs() { + let branch = Services.prefs.getDefaultBranch(PREF_BRANCH); + for (let [key, val] in Iterator(PREFS)) { + switch (typeof val) { + case "boolean": + branch.setBoolPref(key, val); + break; + case "string": + branch.setCharPref(key, val); + break; + } + } +} diff --git a/src/install.rdf b/src/install.rdf index 5139ef5..d94df0e 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -10,6 +10,7 @@ 2 http://github.com/erikvold/restartless-restart-ffext Fennec users enable to restart, otherwise a File -> Restart menu item will be added. + 2 Greg Parris; http://phob.net/ Nils Maier; https://tn123.org/ diff --git a/src/options.xul b/src/options.xul new file mode 100644 index 0000000..2e2c0b5 --- /dev/null +++ b/src/options.xul @@ -0,0 +1,12 @@ + + + + Default is "R" + + + Default is "accel,alt" + + + This will invalidate caches on the next restart, so all fast load data to be re-created. + + From 89096c2fe690053658ee4a7db1ff66165efb959e Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sun, 5 Jun 2011 10:51:52 -0700 Subject: [PATCH 090/112] Closes #36 Japanese locale file directory shoud be ja, not ja-JP --- src/locale/{ja-JP => ja}/rr.properties | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/locale/{ja-JP => ja}/rr.properties (100%) diff --git a/src/locale/ja-JP/rr.properties b/src/locale/ja/rr.properties similarity index 100% rename from src/locale/ja-JP/rr.properties rename to src/locale/ja/rr.properties From 06bf81764bbe15dcd7ebd2034a90e5d65f6199e3 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sun, 5 Jun 2011 10:55:51 -0700 Subject: [PATCH 091/112] adding extensions.restartless-restart.locale pref to options.xul --- src/options.xul | 1 + 1 file changed, 1 insertion(+) diff --git a/src/options.xul b/src/options.xul index 2e2c0b5..52ba64e 100644 --- a/src/options.xul +++ b/src/options.xul @@ -6,6 +6,7 @@ Default is "accel,alt" + This will invalidate caches on the next restart, so all fast load data to be re-created. From 0f021c869aee7645a871fc75ef632d68ae818ee6 Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sun, 12 Jun 2011 12:05:13 -0500 Subject: [PATCH 092/112] minor fix: typo in var name --- src/bootstrap.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index 9fed152..411b1b0 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -198,7 +198,7 @@ function main(win) { } win.addEventListener("aftercustomization", saveTBNodeInfo, false); - var prefChgHanderIndex = prefChgHandlers.push(function(aData) { + var prefChgHandlerIndex = prefChgHandlers.push(function(aData) { switch (aData) { case "locale": let label = _("restart", getPref("locale")); @@ -219,7 +219,7 @@ function main(win) { rrTBBB.parentNode.removeChild(rrTBB); rrTBB.parentNode.removeChild(rrTBB); win.removeEventListener("aftercustomization", saveTBNodeInfo); - prefChgHandlers[prefChgHanderIndex] = null; + prefChgHandlers[prefChgHandlerIndex] = null; }, win); } From 75cc86353fad7cac5bf11141797d8abd878237aa Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Mon, 13 Jun 2011 20:33:55 -0700 Subject: [PATCH 093/112] using a better include() function --- src/bootstrap.js | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index 9fed152..4be2e79 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -70,8 +70,25 @@ let PREF_OBSERVER = { let logo = ""; -(function(global) global.include = function include(src) ( - Services.scriptloader.loadSubScript(src, global)))(this); + +/* Includes a javascript file with loadSubScript +* +* @param src (String) +* The url of a javascript file to include. +*/ +(function(global) global.include = function include(src) { + var o = {}; + Components.utils.import("resource://gre/modules/Services.jsm", o); + var uri = o.Services.io.newURI( + src, null, o.Services.io.newURI(__SCRIPT_URI_SPEC__, null, null)); + o.Services.scriptloader.loadSubScript(uri.spec, global); +})(this); + + +include("includes/utils.js"); +include("includes/l10n.js"); +include("includes/prefs.js"); + function setPref(aKey, aVal) { aVal = ("wrapper-restartlessrestart-toolbarbutton" == aVal) ? "" : aVal; @@ -248,16 +265,11 @@ function startup(data, reason) { var prefs = Services.prefs.getBranch(PREF_BRANCH); - // include utils - include(addon.getResourceURI("includes/utils.js").spec); - - // init l10n - include(addon.getResourceURI("includes/l10n.js").spec); + // setup l10n l10n(addon, "rr.properties"); unload(l10n.unload); - // init prefs - include(addon.getResourceURI("includes/prefs.js").spec); + // setup prefs setDefaultPrefs(); logo = addon.getResourceURI("images/refresh_16.png").spec; From 09c3ace3c06fafa131b10e64959e4b795241249f Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sun, 19 Jun 2011 12:08:54 -0700 Subject: [PATCH 094/112] adding a requre() method for commonjs style packages, and creating a unload package. --- src/bootstrap.js | 22 ++++++++++ src/packages/unload.js | 96 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 src/packages/unload.js diff --git a/src/bootstrap.js b/src/bootstrap.js index 4be2e79..51077f2 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -84,7 +84,29 @@ let logo = ""; o.Services.scriptloader.loadSubScript(uri.spec, global); })(this); +/* Imports a commonjs style javascript file with loadSubScrpt + * + * @param src (String) + * The url of a javascript file. + */ +(function(global) global.require = function require(src) { + var scope = {require: global.require, exports: {}}; + var tools = {}; + Components.utils.import("resource://gre/modules/Services.jsm", tools); + var baseURI = tools.Services.io.newURI(__SCRIPT_URI_SPEC__, null, null); + try { + var uri = tools.Services.io.newURI( + "packages/" + src + ".js", null, baseURI); + tools.Services.scriptloader.loadSubScript(uri.spec, scope); + } catch (e) { + var uri = tools.Services.io.newURI(src, null, baseURI); + tools.Services.scriptloader.loadSubScript(uri.spec, scope); + } + return scope.exports; +})(this); + +var {unload} = require("unload"); include("includes/utils.js"); include("includes/l10n.js"); include("includes/prefs.js"); diff --git a/src/packages/unload.js b/src/packages/unload.js new file mode 100644 index 0000000..9f5a683 --- /dev/null +++ b/src/packages/unload.js @@ -0,0 +1,96 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Speak Words. + * + * The Initial Developer of the Original Code is The Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Edward Lee + * Erik Vold + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + +/** + * Save callbacks to run when unloading. Optionally scope the callback to a + * container, e.g., window. Provide a way to run all the callbacks. + * + * @usage unload(): Run all callbacks and release them. + * + * @usage unload(callback): Add a callback to run on unload. + * @param [function] callback: 0-parameter function to call on unload. + * @return [function]: A 0-parameter function that undoes adding the callback. + * + * @usage unload(callback, container) Add a scoped callback to run on unload. + * @param [function] callback: 0-parameter function to call on unload. + * @param [node] container: Remove the callback when this container unloads. + * @return [function]: A 0-parameter function that undoes adding the callback. + */ +exports.unload = function unload(callback, container) { + // Initialize the array of unloaders on the first usage + let unloaders = unload.unloaders; + if (unloaders == null) + unloaders = unload.unloaders = []; + + // Calling with no arguments runs all the unloader callbacks + if (callback == null) { + unloaders.slice().forEach(function(unloader) unloader()); + unloaders.length = 0; + return; + } + + // The callback is bound to the lifetime of the container if we have one + if (container != null) { + // Remove the unloader when the container unloads + container.addEventListener("unload", removeUnloader, false); + + // Wrap the callback to additionally remove the unload listener + let origCallback = callback; + callback = function() { + container.removeEventListener("unload", removeUnloader, false); + origCallback(); + } + } + + // Wrap the callback in a function that ignores failures + function unloader() { + try { + callback(); + } + catch(ex) {} + } + unloaders.push(unloader); + + // Provide a way to remove the unloader + function removeUnloader() { + let index = unloaders.indexOf(unloader); + if (index != -1) + unloaders.splice(index, 1); + } + return removeUnloader; +} From b0f90a5c641a6d35307f31960a6958ee6480c1fd Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Sun, 19 Jun 2011 12:25:25 -0700 Subject: [PATCH 095/112] converting utils.js to commonjs style --- src/bootstrap.js | 32 +++++---- src/packages/chrome.js | 4 ++ .../utils.js => packages/window-utils.js} | 69 ++----------------- 3 files changed, 29 insertions(+), 76 deletions(-) create mode 100644 src/packages/chrome.js rename src/{includes/utils.js => packages/window-utils.js} (67%) diff --git a/src/bootstrap.js b/src/bootstrap.js index 51077f2..360f229 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -89,25 +89,29 @@ let logo = ""; * @param src (String) * The url of a javascript file. */ -(function(global) global.require = function require(src) { - var scope = {require: global.require, exports: {}}; - var tools = {}; - Components.utils.import("resource://gre/modules/Services.jsm", tools); - var baseURI = tools.Services.io.newURI(__SCRIPT_URI_SPEC__, null, null); - try { - var uri = tools.Services.io.newURI( - "packages/" + src + ".js", null, baseURI); - tools.Services.scriptloader.loadSubScript(uri.spec, scope); - } catch (e) { - var uri = tools.Services.io.newURI(src, null, baseURI); - tools.Services.scriptloader.loadSubScript(uri.spec, scope); +(function(global) { + var modules = {}; + global.require = function require(src) { + if (modules[src]) return modules[src]; + var scope = {require: global.require, exports: {}}; + var tools = {}; + Components.utils.import("resource://gre/modules/Services.jsm", tools); + var baseURI = tools.Services.io.newURI(__SCRIPT_URI_SPEC__, null, null); + try { + var uri = tools.Services.io.newURI( + "packages/" + src + ".js", null, baseURI); + tools.Services.scriptloader.loadSubScript(uri.spec, scope); + } catch (e) { + var uri = tools.Services.io.newURI(src, null, baseURI); + tools.Services.scriptloader.loadSubScript(uri.spec, scope); + } + return modules[src] = scope.exports; } - return scope.exports; })(this); var {unload} = require("unload"); -include("includes/utils.js"); +var {runOnLoad, runOnWindows, watchWindows} = require("window-utils"); include("includes/l10n.js"); include("includes/prefs.js"); diff --git a/src/packages/chrome.js b/src/packages/chrome.js new file mode 100644 index 0000000..285cb3c --- /dev/null +++ b/src/packages/chrome.js @@ -0,0 +1,4 @@ + +exports.Cc = Components.classes; +exports.Ci = Components.interfaces; +exports.Cu = Components.utils; diff --git a/src/includes/utils.js b/src/packages/window-utils.js similarity index 67% rename from src/includes/utils.js rename to src/packages/window-utils.js index f439eb9..c8629ce 100644 --- a/src/includes/utils.js +++ b/src/packages/window-utils.js @@ -35,6 +35,10 @@ * * ***** END LICENSE BLOCK ***** */ +var {Cc, Ci, Cu} = require("chrome"); +var {unload} = require("unload"); +Cu.import("resource://gre/modules/Services.jsm", this); + /** * Waits for a browser window to finish loading before running the callback * @@ -42,7 +46,7 @@ * @param [function] callback: 1-parameter function that gets a browser window. * @param [function] winType: a parameter that defines what kind of window is "browser window". */ -function runOnLoad(window, callback, winType) { +exports.runOnLoad = function runOnLoad(window, callback, winType) { // Listen for one load event before checking the window type window.addEventListener("load", function() { window.removeEventListener("load", arguments.callee, false); @@ -61,7 +65,7 @@ function runOnLoad(window, callback, winType) { * @param [function] callback: 1-parameter function that gets a browser window. * @param [function] winType: a parameter that defines what kind of window is "browser window". */ -function runOnWindows(callback, winType) { +exports.runOnWindows = function runOnWindows(callback, winType) { // Wrap the callback in a function that ignores failures function watcher(window) { try { @@ -90,7 +94,7 @@ function runOnWindows(callback, winType) { * @param [function] callback: 1-parameter function that gets a browser window. * @param [function] winType: a parameter that defines what kind of window is "browser window". */ -function watchWindows(callback, winType) { +exports.watchWindows = function watchWindows(callback, winType) { // Wrap the callback in a function that ignores failures function watcher(window) { try { @@ -112,62 +116,3 @@ function watchWindows(callback, winType) { // Make sure to stop watching for windows if we're unloading unload(function() Services.ww.unregisterNotification(windowWatcher)); } - -/** - * Save callbacks to run when unloading. Optionally scope the callback to a - * container, e.g., window. Provide a way to run all the callbacks. - * - * @usage unload(): Run all callbacks and release them. - * - * @usage unload(callback): Add a callback to run on unload. - * @param [function] callback: 0-parameter function to call on unload. - * @return [function]: A 0-parameter function that undoes adding the callback. - * - * @usage unload(callback, container) Add a scoped callback to run on unload. - * @param [function] callback: 0-parameter function to call on unload. - * @param [node] container: Remove the callback when this container unloads. - * @return [function]: A 0-parameter function that undoes adding the callback. - */ -function unload(callback, container) { - // Initialize the array of unloaders on the first usage - let unloaders = unload.unloaders; - if (unloaders == null) - unloaders = unload.unloaders = []; - - // Calling with no arguments runs all the unloader callbacks - if (callback == null) { - unloaders.slice().forEach(function(unloader) unloader()); - unloaders.length = 0; - return; - } - - // The callback is bound to the lifetime of the container if we have one - if (container != null) { - // Remove the unloader when the container unloads - container.addEventListener("unload", removeUnloader, false); - - // Wrap the callback to additionally remove the unload listener - let origCallback = callback; - callback = function() { - container.removeEventListener("unload", removeUnloader, false); - origCallback(); - } - } - - // Wrap the callback in a function that ignores failures - function unloader() { - try { - callback(); - } - catch(ex) {} - } - unloaders.push(unloader); - - // Provide a way to remove the unloader - function removeUnloader() { - let index = unloaders.indexOf(unloader); - if (index != -1) - unloaders.splice(index, 1); - } - return removeUnloader; -} From be84b4b5304ce44e26d49555aadc8c0bd9bb5e0b Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 12 Aug 2011 12:07:00 -0700 Subject: [PATCH 096/112] FF max ver is 8.* Fennec max ver is 6.* --- src/install.rdf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/install.rdf b/src/install.rdf index d94df0e..ba12b64 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -24,7 +24,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 4.0b4 - 7.* + 8.* @@ -48,7 +48,7 @@ {a23983c0-fd0e-11dc-95ff-0800200c9a66} 4.0b4 - 4.* + 6.* From 285ed35e2ec9234f4e12377cb8f26e52004249d8 Mon Sep 17 00:00:00 2001 From: xabolcs Date: Sat, 27 Aug 2011 00:25:27 +0200 Subject: [PATCH 097/112] including options.xul in build process --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index b2b3eae..0da4731 100644 --- a/build.sh +++ b/build.sh @@ -9,7 +9,7 @@ cd src rm -rf build mkdir build cp -r \ - bootstrap.js images includes locale install.rdf icon.png icon16.png icon64.png \ + bootstrap.js images includes locale install.rdf icon.png icon16.png icon64.png options.xul \ build/ cd build From 187af60d3aad25af586f47b9ac864c72b0ec5e9c Mon Sep 17 00:00:00 2001 From: xabolcs Date: Mon, 29 Aug 2011 03:30:12 +0200 Subject: [PATCH 098/112] rrTBBB is undefined (regression by resolving #27) --- src/bootstrap.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index 360f229..7a3490d 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -259,7 +259,6 @@ function main(win) { unload(function() { rrKeyset.parentNode.removeChild(rrKeyset); appMenu && appMenu.removeChild(restartAMI); - rrTBBB.parentNode.removeChild(rrTBB); rrTBB.parentNode.removeChild(rrTBB); win.removeEventListener("aftercustomization", saveTBNodeInfo); prefChgHandlers[prefChgHanderIndex] = null; From 92d1b7cf9d9a979f2de4d2d798fc7cdb1d60b98b Mon Sep 17 00:00:00 2001 From: xabolcs Date: Mon, 29 Aug 2011 20:54:57 +0200 Subject: [PATCH 099/112] including packages in build process --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 0da4731..33a27fc 100644 --- a/build.sh +++ b/build.sh @@ -9,7 +9,7 @@ cd src rm -rf build mkdir build cp -r \ - bootstrap.js images includes locale install.rdf icon.png icon16.png icon64.png options.xul \ + bootstrap.js images includes packages locale install.rdf icon.png icon16.png icon64.png options.xul \ build/ cd build From 4c9a622446fd5cf43fc34ee256bdadcc30cc24af Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Thu, 8 Sep 2011 19:13:56 -0700 Subject: [PATCH 100/112] ignoring *.komodoproject files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index dbbaea9..b904072 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ .settings *.xpi build +*.komodoproject From 71a34686580159d307a3e124a254715bbc4abc03 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 30 Sep 2011 06:57:02 -0700 Subject: [PATCH 101/112] Closes #45 fixing error in Fennec --- src/includes/prefs.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/includes/prefs.js b/src/includes/prefs.js index 1285234..f92de1f 100644 --- a/src/includes/prefs.js +++ b/src/includes/prefs.js @@ -37,11 +37,18 @@ /** * Get the preference value of type specified in PREFS */ -function getPref(key) { + +function getPref(key, aDefault) { // Cache the prefbranch after first use if (getPref.branch == null) getPref.branch = Services.prefs.getBranch(PREF_BRANCH); + var prefType = getPref.branch.getPrefType(key); + + // underlying preferences object throws an exception if pref doesn't exist + if (prefType == getPref.branch.PREF_INVALID) + return aDefault; + // Figure out what type of pref to fetch switch (typeof PREFS[key]) { case "boolean": From 7ca3e6dc3cf7e3f3590fd3107cfae3e5ba049fd7 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 30 Sep 2011 06:58:30 -0700 Subject: [PATCH 102/112] Closes #44 uping max supported version numbers --- src/install.rdf | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/install.rdf b/src/install.rdf index ba12b64..01f35e1 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -24,7 +24,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 4.0b4 - 8.* + 10.0a1 @@ -32,23 +32,23 @@ {92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} 2.1a3 - 2.1.* + 2.7a1 - + - {3550f703-e582-4d05-9a08-453d09bdfdc6} - 3.3a1 - 3.* + {a23983c0-fd0e-11dc-95ff-0800200c9a66} + 4.0b4 + 10.0a1 - + - {a23983c0-fd0e-11dc-95ff-0800200c9a66} - 4.0b4 - 6.* + {3550f703-e582-4d05-9a08-453d09bdfdc6} + 3.3a1 + 10.0a1 From 217fba8b5b8d562543f693790deed9069c132305 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 30 Sep 2011 06:59:39 -0700 Subject: [PATCH 103/112] 8 --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index 01f35e1..739776b 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 8pre + 8 true 2 http://github.com/erikvold/restartless-restart-ffext From ded4c0a1879fa55fec8dbbbca3a5065f433ef0b5 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 30 Sep 2011 07:09:45 -0700 Subject: [PATCH 104/112] 9pre --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index 739776b..594a89f 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 8 + 9pre true 2 http://github.com/erikvold/restartless-restart-ffext From c1f528f12f323417dc6a309bb2cfaf163d83d525 Mon Sep 17 00:00:00 2001 From: Morac2 Date: Mon, 28 Jan 2013 23:33:32 -0500 Subject: [PATCH 105/112] Update src/packages/unload.js --- src/packages/unload.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/packages/unload.js b/src/packages/unload.js index 9f5a683..69fb3d0 100644 --- a/src/packages/unload.js +++ b/src/packages/unload.js @@ -67,12 +67,13 @@ exports.unload = function unload(callback, container) { // The callback is bound to the lifetime of the container if we have one if (container != null) { // Remove the unloader when the container unloads - container.addEventListener("unload", removeUnloader, false); + container.addEventListener("unload", unloader, false); // Wrap the callback to additionally remove the unload listener let origCallback = callback; callback = function() { - container.removeEventListener("unload", removeUnloader, false); + container.removeEventListener("unload", unloader, false); + removeUnloader(); origCallback(); } } From 7969f84fcb806aa7439eb4037700d75913ebdd6a Mon Sep 17 00:00:00 2001 From: Morac2 Date: Mon, 28 Jan 2013 23:39:48 -0500 Subject: [PATCH 106/112] Update src/packages/unload.js --- src/packages/unload.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/packages/unload.js b/src/packages/unload.js index 69fb3d0..ef1db9f 100644 --- a/src/packages/unload.js +++ b/src/packages/unload.js @@ -20,6 +20,7 @@ * Contributor(s): * Edward Lee * Erik Vold + * Michael Kraft * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or From 16fbe9ddae52f36085b46e76d8ff41335a9f0e5e Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Mon, 28 Jan 2013 21:25:45 -0800 Subject: [PATCH 107/112] 9 --- src/install.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.rdf b/src/install.rdf index 594a89f..dd90be7 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 9pre + 9 true 2 http://github.com/erikvold/restartless-restart-ffext From 2b305e0851642f6c05a3bfcde68f1df375f2b3be Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Mon, 26 Aug 2013 07:27:41 +0200 Subject: [PATCH 108/112] Delete Readme.md --- Readme.md | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 Readme.md diff --git a/Readme.md b/Readme.md deleted file mode 100644 index 4c29fff..0000000 --- a/Readme.md +++ /dev/null @@ -1,9 +0,0 @@ -Restartless Restart for Firefox 4 -=== -Tiny [restartless][1] extension adding browser restart actions to Firefox. -(Oh, the irony) - -The main audience of this extension is other extension developers who need -to restart the browser often. - -[1]: https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions \ No newline at end of file From 32f65a992a609431ff6bd22ca5e881d4cbf2613a Mon Sep 17 00:00:00 2001 From: Andre Miranda Date: Mon, 16 Jun 2014 23:15:42 -0300 Subject: [PATCH 109/112] icon remix for new firefox ui Improved icons for a better mix with the new firefox ui --- src/bootstrap.js | 2 +- src/icon.png | Bin 459 -> 1872 bytes src/icon.svg | 106 ++++++++++++++++++++++++++++++++++++++ src/icon16.png | Bin 273 -> 842 bytes src/icon64.png | Bin 1608 -> 3943 bytes src/images/refresh_16.png | Bin 273 -> 842 bytes 6 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 src/icon.svg diff --git a/src/bootstrap.js b/src/bootstrap.js index 4561442..5cb62ab 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -208,7 +208,7 @@ function main(win) { let rrTBB = xul("toolbarbutton"); rrTBB.setAttribute("id", "restartlessrestart-toolbarbutton"); rrTBB.setAttribute("type", "button"); - rrTBB.setAttribute("image", addon.getResourceURI("icon16.png").spec); + rrTBB.setAttribute("image", addon.getResourceURI("icon.png").spec); rrTBB.setAttribute("class", "toolbarbutton-1 chromeclass-toolbar-additional"); rrTBB.setAttribute("label", _("restart", getPref("locale"))); rrTBB.addEventListener("command", restart, true); diff --git a/src/icon.png b/src/icon.png index 27f0340946797dc1dfe998371c3c400b389d6577..6764413ae138a338429d66b4ba33d45e92a12f3e 100644 GIT binary patch delta 1858 zcmV-I2fg^q1JDkTBYyw{b3#c}2nYxWd_TC08jxyNJNt)Xi_-h;|>kn2*U2c{_ ze4Cl?Gz`Pj^?!`a=(@>_I1GazhyvyNz9mVV2;=xU*WmGEd-u9G1yJni$=8wfBL?lL ztFIUJ_4Q`f%0dVMA_5W3i(ENYN}*bxbuHfGz}+O_000l-|j%pXjg zt;V2Fj(;B*I&)osO}+ge7Z86g6jtXA!$>o692*y>FS-E6IiQiTXNOMnBJyH!Fq3be z`vio(Uzgga*Q~iCYgtwbQJN{mlT(vtBZD`L4-MJZ01OTeinFEK`z=k)YxDU!F`qS~ zG*j{%r&d;s;@H9AKP~kh7sq#ccWwdE{`U3`vwyv~xNp^PLW-`+^ zy8CwCdlf*jIG7RO;ikr>JOD5=Jl{j5Qg)*V#f4qAY>3g33B~HMiHQj(iXt#Ggb?T` z6n}IaFnuBQM^lc@nXS?^i2T*YiC9^CK#k&H8~Jd?f{7 z=C7Hikrt%yd$x+>7jD)Z0LF)gY(aR#v45Sk78)Cy>V(j~2>_y49Lz9tgQjU|_xpjb znB~b^0RR9|6u;>>wwvgi^YhC(01)}MN{0}_P3V+Th?O$DnREZRRR9E>bX+F@=3lX< z=>X6M02)ZO5y>b42%`{!=-jbm$KqQBAbjnVFM=F1gNPudgi>n02uZQc;B@R?p?}nG zl{o-JhFY7^^mHV|aSTDi1^~gDy3Fza3<(4PO$!CK^zOXliJtzuZxld~`jlyzX_7$@ z0E7|%h%+rMvkcZ1D=;&plprFlt9M`>0Ce~D-xq^VXhPn0qX0zofMr_w^RKhmfzeG&Sd?rmc7?PNHkuz>ZADXtgX0%nYRzYPG5qQvX8=KpB2H z2m=noFnzG0z9HMv+?>s1j2rbvSMR_&LG<%NVO2gU@JgiuB6{!8fu}B{0DnjJ?VBT@ zuTm}BNkd)NA*Gg%jHTiWgM(VJSd>fM+rE9fA&FjUZf-S_HAX3gOVgK}C{{a?cIk3_ z_~7tSrQ)-WV=o+zO9E`_9e8l__9su>S*qH(_BGDt?YrOY-Zt>r6X}bJZ=jzU!VVICoLP`lC1cJcF>HnOrgnty=4p{ZNivPKK z)%?CP2m+j+Jnt&S4<8*Jerq9sJUdfF9ty=R{s7{O@7&`gNtFKQvp7W3tGBb5?$|c6evC-kz7We3~zKqiD z?-}@MKAZbVQ&Y1{GJjwAKRI>5n=8-l9y>VlGyrt>?m7v&_|&M#|>m$KQMWm#D%q=4`FVYxEr5j*oEhet==UWwj{0RW); wyH9=;y80PFp98Z3=uKkvUC<{n~<{Hrs>hg3~9 z_HqOZU^F@o9p*`ck$1EJCT>T+mh>!43E)wYN*z}O(7ArR#0>n#^h?95{CWm9E1Fd) z0bGoj_3TdpdVh{zHGl=N6~B97w(9?nSK%?7Isx2cSaK1i>$Fvak=MM4tgBdlm|9eI z6+^!CYEjk4C=q)lm^VUegEoJTy(!ZGJK!v0XRd2MYd=Nq6eKxw3E)*s(jX|nh^h-M zfSkDm(1~R`i++P=?g5m@Iw`rOdZVK(Ujx9ERS%Tt0xNuG;<=blQmK+nSmfKX1QH^5 c42uE20IAvWllx@4iU0rr07*qoM6N<$f_ELn1ONa4 diff --git a/src/icon.svg b/src/icon.svg new file mode 100644 index 0000000..871c865 --- /dev/null +++ b/src/icon.svg @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/src/icon16.png b/src/icon16.png index 66e21e3a64ac28d654f36b9dd5265f74f06f22a3..27e3c2e1dcd1c3710f927994d0b6ba0e45855a60 100644 GIT binary patch delta 819 zcmV-31I+x90?G!EB!2{RLP=Bz2nYy#2xN!=000SaNLh0L007*U6n-*G+?>Lx&_VB8Vu0>X1YPT|_)cLa~J*x@B3HGJh(fkF_EdD~v7@>Mbe= zqC-$bw+=-?(qT=j9lv%ycW379WQeu>&d>9M=MR6vImdE#_w}*$b9R#?h)s-%>p3{* zLHN1kyU!lnz4;O=Aj<`r?$cWsQ|={_HJepM5g212gn)An+jaa|(|l_!%(p)r>i_na z;CS|Iw-#H~V}BS%UAbHiinjGV48s{hAc&&4I%y>9B}pPbe$IR=T8pO#uU#7dBWUY5 zvoRUhpU30Ix`oAsylq*dbHuwamdm*SkjeB`Q=R3Ec;Y}Rm8#88O?{gFQP?#)e4{`B zkWBZv*R{3j9hOy`p115nBe$-+Te%egGTGkNbh>_^dVf`Qd~)*ZlY#3O57M@d>;_HM z8iF7|(XqxWl>uNlcXjkvq3|k-B2?-6rna7*7?lNS4--YhbzL)Xz5Yt&B}#sI&~fY_ zrp4-+PqtD{utN|8luG`u<=3qQ^Z9$*wtvd9EX$I#p8^m$=iopD0G*wka&tDTRuZ^U zn4p571b<%0x-tv4xc!=*M|Bo=JIqUfkN3nRZ$a;ZO?|j_kxy7<&wCS3DMKV`T3`y0Ovd`Q=W>eS_7q&3RHlu z>l=%%W4ewr;d^eQ<1e%<%_1wm5dhlT`xGS^d`Kpe8zf1BIa~PXnNyqR=IRLmjE$Wy x{VZ1i07trdTLmg~P(s5X3h&(SzcTT!+;1o%PJx19|k z81Mj@12W(P0|fxx0AV8ZU`<%CK=g*vBnP4!E0f`S{8{kVw=*d+8 vix@1m_7loX40sG6DmOCV@B&r?00ImER04Lch>;#W00000NkvXXu0mjf_yt}V diff --git a/src/icon64.png b/src/icon64.png index 861a3e3ae995fa003454cac7925ba352bb8f1678..ca6fe06d5e10b09e5985dde5177cd98466647515 100644 GIT binary patch delta 3886 zcmV+}57F?*4Cfw@I|~DL000Aa0e#hi%#lVXe-7kHL_t(|oaLKoY+ToM$A9O|o1Mc= zq(oA3V#QmXATFA;ZnL;qP{445x=Mp6hHFcr9F&nn(-0+jX`8Y%ntF*zIhI64Xk}6g z>=bkjyKbF04O}Z*1EjH$7U&1Bk}XOUDN^KcxXjF3PCv}N(ai9Xq9~4RpnqU6_uV)5 zf4p=4@7{CoIromJD*vBhR{8;VbaYe)?cmL>A=e1ng3=;riy|#R6EK5t8kN(ar$rc6 zIBnqm{K@@$U#ql!Qi&dL*WLHExQ=xz$Obj|0!nCEf`s=_o>zE&?(E5*4h{}FE3E3u z5zyV;ZM-v*ywec2DRLtq03t#x8Y32qe_;lLn5Ic67{oMlWmUztEo|GtvMp@OB9qOM zN=;!|R$L}^xtfY$b1f2_*Gz{eqHbXB~HszidScon9Z8)+hP z{=q)w^19jCS*E6vB&VjxWYXS^tf+f1V;g_>^r6SbE>-tSB4G2j&KnIw9#!}pe?Tx8 zq+wM9RfzKHXZYy zKyDEc>T2t#tEhut^v$KHCV#ua}eLc@!lrdZ+0e9}`ygGoq z09+pk1ZZk%CK`z@+Xz*~FpOol2N*gv#Q69afC@Y~(AV3o7h%+r3D~@2*B1=opH-<3 zg~Bv9HDj9Qk`#9whw14Qb8~Z8wvBDu*tUi1x&WAFkf3Q|22H}DFxAyHf5c+3C6OQ^ zjE$Y;)ag^GDk#s+M)c0X-rl*T*tMjE(B^Hsen$*mR3#dZSFyUW5yJ=oxwj}Hg>SFU zbzP=XQw75pKn4iewk5W0K^jt|7#knMG))qTYHDg~NK_>jeO5z5Baujy<0sz1ah$Kj z(t?P5btygJf<2&h$GuI8fBRpc>k^3sjSZ{MH(ubaPfkv9ZeqOfh6OS%ybSuHz+0{x zIPHje>Z!hmCfeHCf@z}71Z6E6SS#=csBS>G%99t5$7ybACK`<`+S4+b3~#*oI*#Lj z$b$p>AM3g#0$N+UBgB%&6#4x~Btp}g=0&~y%*-@n<73#i?Nz-jf6Ad5N&j&0z=7!t zDN~Fs?VTUPA5VQB@V?YyEva&n%mO&F#CM z66JQ&G-+;XDJ*Ep9}F;lZj5BIFg3j;cs zlZ=d<@zo1p-P(0Tqfvk>i6`$~NUkpd#*DKIWlcC7CKip&dw{B;|Z0&?wwpQ>z0Ut zzTSS&y{gK)@4ky=W#|1yRnPYVXm8!N^UCtyln}6ae_Q8Tpbem=y0##s7`APbOiltg zptl|Fd;Im4FlafLJv+1q__1wU44*mU+fyTv2z7OJpoBCa50uL=%C5c)1S64X$&^>} z_9rKDJ^-HVKhXP91?*Zf1_uWn2i*=>lamvq(`jE4RyVH66;!_5-Q8VcbIFAuw*sE` zoagwmf7z@z-sW(%d&MnU2EKQo_buQcz?qSp8!9Iu5{VEFhXEQ-j3hr(+`d4-9UUFj zz~=!X;Yi^J#UxB7Cjb!Pi6aMlPpz;m%Z5tkL4jl{l`1&IauTYmYjQs}WJ7V=0s#Rh zcnc5=hr$?!G4JiWu1h+d1|geuLyuI{qKm|lfBpN%74}0e4k?GKQj;e@6@LN*{uFZE zrMRJoxw%}{NnBoes_&tR71V!apz<6*DmCTn2V$|9=hr^cdUxl?z4~Gw@F{?BI5O|; z14SXNK3@s_FBL})_Phq1vMh_a^qemVRr#>mb>-7uT`>X8K*9SLH*{T>bS^8awxj=2 ze<2$#3970B{|1msrONLC5YDe_M5M*LX8>$&Z(jw3{l-3k>pEU}=yI<3E*6UX1R#^n z#XaS=n89G~!qrj&)QL7jF1zd3&~b7bGJ>A2p#GN(QFjQyvMt{sP*~fDHhXmjfMGZ- zx$pBMq9p3e6QIZkngBJ;(*U+*m)7TPe+ioT9zfX;kbFhJ2>1^Hr?4gWftmaL5Y8lr zA=d+7eoqbt3#;3*A)w^aD@BRM;)ZViT2!YhrTj`@Vqzi#xVdmWmyaxsWeQ1?s8`7K z07J(C)OCHwj^Pm_hHp&$K|x~8`Za)&8|yO9mZDr`A(LVNxGrM=Zk{y{Uc>Xgf5C02 zknSr23#$bv3FJJeYGG)g=bd@Z35wmj#G4f6vcJ5PWpr36fey&h1S{O}r@ zX3!f3S8v*}^ZN1!cXxLiTXyXFe~zLL8AYDvazo%xfRdEChujeGd_Y+b$nT>~sk%6h z<2x04A+n+J)ndUN9UbB0qp9x$9V=+dMI)EXA86gRh4i)N>nj!-?(vO0HCey{+cPI4nF3kjZ9z*$V|j1OfpBy)N3guI;Y7?`z4J*`Ffv`G6515-CirmmMM^ zDr^I&s;cts!BeRz@A^l@n- zuCBo}O~T-(j8dfzfkjrox8z1v3_m#^i?E$J9#Mla? zGTBVwY+kwG@-F{=kkGnq=ar~F3k2)y>WRnW^K?;F&P|;2@))oK_o01feYocj7zzWUj=&AD^q0Jvi8 z@sqXi`G6grKLEKU6bco#$zb6_OViUSre~%R=7z%3fdt&=Lp)yy3K7;cJLId3<#0*p`la zukw@8+TMAatH#fPDS6|E8mbG3OdlQcHKbyDj zzNK7-s(c@aCKA;&H#L{&Rjf-kn_>9Ou;%Ld=D-t=zP)4uwrt;Zs~U2I{IW8?r#9bU zKR@7S{PsOJi0}kp*3{JSp({Q_qAF1cSyh!#C`4Ude?8Y-dmXj4bpSCDJ+ifp18kzumAvjV?1 zW~%R6f6Vw20=Dkh^=UEWd4;fPnwX}EWm{NQ?vu@C%gVV=Hk%=9WechEVr0##Eh7B3 zX`0m4*7+Lk_gS~@ikxFZ{;YL-=S`lx^{Z?4qWr>f9LCR$m5}cp*2=H=hSk*#3muFq zh6#m}pg$m=9JOtmRO-_6p9-G^N=|xua9y|Hf56JirfE`FSI_wP7>axr_!&S~SC`xR zjeA=);QVHKdO8-5#fin@*tW&U=!h5XO{$|Cmb!aw-gVb~35oK6D8IR6i*qPl`Gxi#%FEsv1y6>D{_j5e=9czd51@Q!Yb)= ze+)tHl&Qw1rh!0nQ%f$C&Yv>%=IzDGmX+nrx84Nh?Sa0Yt4ov?kuBRhU(x&@HS%~V zYzJ>Ubm-wE7lDd}aWgajYXNECf@9wAW7~P3B9bbXt*UCMZbk5phds7_b@i7n)_ABO z0fU2s4*6k~wX!87ETud<=lu&tU-grJf4Hyr9aQfTXdO7vvuCl@<6@|67DIRy_)IpN zAsh-{a5^n6&w6M7ax#1|aG>|_rK(ubOokZ7a{#k5vsjk3I6>Ow#E3lG18gze1BA!}J=Ga2s~4yYar z1cHBlc;6!xKaX%(2!LGjGTxBvQjzg#Z8m delta 1532 zcmXApdpy&77{|Y6M$~fa;{JP4qBhHrR}vP(M6u|&ZG&P^LqYzKA-3PdH#CFEj#BQUZ-a!1;9+I5o20p zUgWz114~hQI2y`EIWP!jcyA7bnDBNU%x6K2M1)Ib)nx+!jMN@l2FgNsAPDBLS>$7)-D`*q4JokGqxZZyhIqVP&CbrLP_8t$qs2M z62}4IC0p4|l2tyY+UJd=W%Ag`EEITqLo^iSu@f@XZ1NUXJP)RE*gIh8Cj_G;{>c3m zPDD~uRX3?o6b?HP=JH`aB_Wf{kEb{}tfs{5iIf9?uVDDlLIwSAj|Q=f9gT%su$sXu z{eyw47B$ZW>lHvffTm4;AR-6AztF2OE=1 zd#q0t=0O+FV}hneN<|1d*p*$;rA%Tiu^i+k$G*QTSCyn8@=VJMrvn!z5G5MAx~QC+Bzhy6X)yNI*c=O8lZIcbr|T$6R1{_ShkhKObZP zQO1ezn_nMw5HoW zV@Ctg7YN?CrytWirN7bes?pJN1e+HVI$DZ5uk0Dho#ocqHUn2_Q7u98Sn2f-3y6v! z#NNPz`fLX@l5@xHtENVp>zch!Ew@pz)=TcGZgRMxKElc?-^xZyPEckt18eX%Nmh?> zBg!1~+Zku;e(h}*P0L%Jy9Vdh4kw>|qg|={WEaIk7_~1XSwJW@PXsclZYbp zKw)&88BuX&px%xcIiazq(|PGhQ0`OuAxh87IP76gwFH#=K0P%sX5TFa19%tYGLW=Ef}g5r(Upg2b|P)AI;{u|xYq(fU5u9Q*9o!4zG#14 ztOOT_J1whf>ec)MtMvz-8@upQh>H%6!Bg&3!Tx!cBj$=taU{Z&xqUHl1n`sudH?OU zFKEru*my~kIC$l-{~+;7Zxx|KFx|G)?>n_;eCNk^#clyIqI6&zJbrMKeW|%5vPh7la6&^py0m!YOxLV3J!PSeAQaBFt7iqX~)q+Mayp zM6GyDn|fcO-8b)W(MBdsG@~W7Xw_fnC~@d~`Ja)MP9OR6qsa6dlIf2?z`tzh^~(*4 zZ9z_s#k0u+PwDHLDxEJo2-ChCJQ(_IH1=Nf_Kvdl;Cio44tcgJVYX2k(*U6n-*G+?>Lx&_VB8Vu0>X1YPT|_)cLa~J*x@B3HGJh(fkF_EdD~v7@>Mbe= zqC-$bw+=-?(qT=j9lv%ycW379WQeu>&d>9M=MR6vImdE#_w}*$b9R#?h)s-%>p3{* zLHN1kyU!lnz4;O=Aj<`r?$cWsQ|={_HJepM5g212gn)An+jaa|(|l_!%(p)r>i_na z;CS|Iw-#H~V}BS%UAbHiinjGV48s{hAc&&4I%y>9B}pPbe$IR=T8pO#uU#7dBWUY5 zvoRUhpU30Ix`oAsylq*dbHuwamdm*SkjeB`Q=R3Ec;Y}Rm8#88O?{gFQP?#)e4{`B zkWBZv*R{3j9hOy`p115nBe$-+Te%egGTGkNbh>_^dVf`Qd~)*ZlY#3O57M@d>;_HM z8iF7|(XqxWl>uNlcXjkvq3|k-B2?-6rna7*7?lNS4--YhbzL)Xz5Yt&B}#sI&~fY_ zrp4-+PqtD{utN|8luG`u<=3qQ^Z9$*wtvd9EX$I#p8^m$=iopD0G*wka&tDTRuZ^U zn4p571b<%0x-tv4xc!=*M|Bo=JIqUfkN3nRZ$a;ZO?|j_kxy7<&wCS3DMKV`T3`y0Ovd`Q=W>eS_7q&3RHlu z>l=%%W4ewr;d^eQ<1e%<%_1wm5dhlT`xGS^d`Kpe8zf1BIa~PXnNyqR=IRLmjE$Wy x{VZ1i07trdTLmg~P(s5X3h&(SzcTT!+;1o%PJx19|k z81Mj@12W(P0|fxx0AV8ZU`<%CK=g*vBnP4!E0f`S{8{kVw=*d+8 vix@1m_7loX40sG6DmOCV@B&r?00ImER04Lch>;#W00000NkvXXu0mjf_yt}V From ad94e2bef5cb6651c3fff265e4909c5ae109ebe9 Mon Sep 17 00:00:00 2001 From: Onno Ekker Date: Wed, 12 Nov 2014 15:55:18 +0100 Subject: [PATCH 110/112] Rename restart.ak to restart.key, add restart.accesskey and add Dutch locale --- src/bootstrap.js | 4 ++-- src/install.rdf | 3 ++- src/locale/de/rr.properties | 2 ++ src/locale/en/rr.properties | 3 ++- src/locale/es/rr.properties | 2 ++ src/locale/ja/rr.properties | 2 ++ src/locale/nl/rr.properties | 3 +++ src/locale/no/rr.properties | 2 ++ src/locale/pt-BR/rr.properties | 2 ++ src/locale/ru/rr.properties | 2 ++ src/locale/sv-SE/rr.properties | 2 ++ src/locale/zh-CN/rr.properties | 2 ++ src/locale/zh-TW/rr.properties | 2 ++ 13 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 src/locale/nl/rr.properties diff --git a/src/bootstrap.js b/src/bootstrap.js index 5cb62ab..a65dde0 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -57,7 +57,7 @@ const PREFS = { "disable_fastload": false, toolbar: "", "toolbar.before": "", - get key() _("restart.ak", getPref("locale")) + get key() _("restart.key", getPref("locale")) }; var prefChgHandlers = []; @@ -143,7 +143,7 @@ function addMenuItem(win) { restartMI.setAttribute("id", fileMenuitemID); restartMI.setAttribute("class", "menuitem-iconic"); restartMI.setAttribute("label", _("restart", getPref("locale"))); - restartMI.setAttribute("accesskey", "R"); + restartMI.setAttribute("accesskey", _("restart.accesskey", getPref("locale"))); restartMI.setAttribute("key", keyID); restartMI.style.listStyleImage = "url('" + logo + "')"; restartMI.addEventListener("command", restart, true); diff --git a/src/install.rdf b/src/install.rdf index dd90be7..77b7706 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -5,7 +5,7 @@ Erik Vold restartless.restart@erikvold.com Restartless Restart - 9 + 10 true 2 http://github.com/erikvold/restartless-restart-ffext @@ -18,6 +18,7 @@ Markus Brandt Mikael Hiort af Ornäs + Onno Ekker diff --git a/src/locale/de/rr.properties b/src/locale/de/rr.properties index 4857b3e..1e0d0db 100644 --- a/src/locale/de/rr.properties +++ b/src/locale/de/rr.properties @@ -1 +1,3 @@ restart=Neu starten +restart.accesskey=r +restart.key=R \ No newline at end of file diff --git a/src/locale/en/rr.properties b/src/locale/en/rr.properties index 5c3616b..e8face6 100644 --- a/src/locale/en/rr.properties +++ b/src/locale/en/rr.properties @@ -1,2 +1,3 @@ restart=Restart -restart.ak=R +restart.accesskey=R +restart.key=R diff --git a/src/locale/es/rr.properties b/src/locale/es/rr.properties index 6ea7768..e8f46ae 100644 --- a/src/locale/es/rr.properties +++ b/src/locale/es/rr.properties @@ -1 +1,3 @@ restart=Reinicie +restart.accesskey=R +restart.key=R diff --git a/src/locale/ja/rr.properties b/src/locale/ja/rr.properties index bd734c7..2d4207b 100644 --- a/src/locale/ja/rr.properties +++ b/src/locale/ja/rr.properties @@ -1 +1,3 @@ restart=再起動 +restart.accesskey=R +restart.key=R diff --git a/src/locale/nl/rr.properties b/src/locale/nl/rr.properties new file mode 100644 index 0000000..6867d0e --- /dev/null +++ b/src/locale/nl/rr.properties @@ -0,0 +1,3 @@ +restart=Herstarten +restart.accesskey=H +restart.key=R diff --git a/src/locale/no/rr.properties b/src/locale/no/rr.properties index 8f78b32..57c7adc 100644 --- a/src/locale/no/rr.properties +++ b/src/locale/no/rr.properties @@ -1 +1,3 @@ restart=Start på nytt +restart.accesskey=r +restart.key=R diff --git a/src/locale/pt-BR/rr.properties b/src/locale/pt-BR/rr.properties index a460a15..775a1bd 100644 --- a/src/locale/pt-BR/rr.properties +++ b/src/locale/pt-BR/rr.properties @@ -1 +1,3 @@ restart=Reiniciar +restart.accesskey=R +restart.key=R diff --git a/src/locale/ru/rr.properties b/src/locale/ru/rr.properties index 46fc5bc..72ca6e8 100644 --- a/src/locale/ru/rr.properties +++ b/src/locale/ru/rr.properties @@ -1 +1,3 @@ restart=Перезапуск +restart.accesskey=R +restart.key=R diff --git a/src/locale/sv-SE/rr.properties b/src/locale/sv-SE/rr.properties index ba30d97..b55b9ba 100644 --- a/src/locale/sv-SE/rr.properties +++ b/src/locale/sv-SE/rr.properties @@ -1 +1,3 @@ restart=Starta om +restart.accesskey=r +restart.key=R diff --git a/src/locale/zh-CN/rr.properties b/src/locale/zh-CN/rr.properties index de6819b..c1575e4 100644 --- a/src/locale/zh-CN/rr.properties +++ b/src/locale/zh-CN/rr.properties @@ -1 +1,3 @@ restart=\u91CD\u65B0\u542F\u52A8 +restart.accesskey=R +restart.key=R diff --git a/src/locale/zh-TW/rr.properties b/src/locale/zh-TW/rr.properties index a28e557..1ce8f9f 100644 --- a/src/locale/zh-TW/rr.properties +++ b/src/locale/zh-TW/rr.properties @@ -1 +1,3 @@ restart=\u91CD\u65B0\u555F\u52D5 +restart.accesskey=R +restart.key=R From 08dc6e9da478ad60dea7d5a950fb841951d92bf8 Mon Sep 17 00:00:00 2001 From: Onno Ekker Date: Wed, 12 Nov 2014 16:01:18 +0100 Subject: [PATCH 111/112] Add newline to last line --- src/locale/de/rr.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locale/de/rr.properties b/src/locale/de/rr.properties index 1e0d0db..7892237 100644 --- a/src/locale/de/rr.properties +++ b/src/locale/de/rr.properties @@ -1,3 +1,3 @@ restart=Neu starten restart.accesskey=r -restart.key=R \ No newline at end of file +restart.key=R From 60378fb41aa25cad3d33bedcdaadb5b43f6c5eeb Mon Sep 17 00:00:00 2001 From: Onno Ekker Date: Thu, 19 Nov 2015 12:03:50 +0100 Subject: [PATCH 112/112] Fix error with let and conditional block in FX 45 --- src/bootstrap.js | 6 ++++-- src/includes/l10n.js | 9 ++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index a65dde0..cc2df96 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -139,7 +139,8 @@ function addMenuItem(win) { removeMI(); // add the new menuitem to File menu - let (restartMI = win.document.createElementNS(NS_XUL, "menuitem")) { + let restartMI = win.document.createElementNS(NS_XUL, "menuitem"); + if (restartMI) { restartMI.setAttribute("id", fileMenuitemID); restartMI.setAttribute("class", "menuitem-iconic"); restartMI.setAttribute("label", _("restart", getPref("locale"))); @@ -181,7 +182,8 @@ function main(win) { rrKeyset.setAttribute("id", keysetID); // add hotkey - let (restartKey = xul("key")) { + let restartKey = xul("key"); + if (restartKey) { restartKey.setAttribute("id", keyID); restartKey.setAttribute("key", getPref("key")); restartKey.setAttribute("modifiers", getPref("modifiers")); diff --git a/src/includes/l10n.js b/src/includes/l10n.js index 5633c7b..e3973a5 100644 --- a/src/includes/l10n.js +++ b/src/includes/l10n.js @@ -49,11 +49,10 @@ var l10n = (function(global) { let defaultBundle = Services.strings.createBundle(filepath(locale)); let defaultBasicBundle; - let (locale_base = locale.match(splitter)) { - if (locale_base) { - defaultBasicBundle = Services.strings.createBundle( - filepath(locale_base[1])); - } + let locale_base = locale.match(splitter); + if (locale_base) { + defaultBasicBundle = Services.strings.createBundle( + filepath(locale_base[1])); } let addonsDefaultBundle =