[tbb-commits] [torbutton/master] Bug 26321: Move 'New Identity', 'New Circuit' to File, hamburger menus

gk at torproject.org gk at torproject.org
Wed Jul 25 05:52:39 UTC 2018


commit 25786da78e5646ddbccaee769a9356e0b4f39e42
Author: Arthur Edelstein <arthuredelstein at gmail.com>
Date:   Fri Jun 22 14:47:25 2018 -0700

    Bug 26321: Move 'New Identity', 'New Circuit' to File, hamburger menus
    
    This patch moves the menu items from the torbutton to the menubar
    and the app menu. Needs the 26321 patch in tor-browser.git.
    
    Also hides the "New Private Window" and "Restore Previous Session"
    items from the app menu.
    
    (Design by Pearl Crescent and Antonela Debiasi.)
---
 src/chrome.manifest                       |  1 +
 src/chrome/content/menu-items-overlay.xul | 29 +++++++++++++++++++++++++++++
 src/chrome/content/popup.xul              | 13 -------------
 src/chrome/content/torbutton.js           | 12 ++++++++----
 src/chrome/skin/torbutton.css             |  8 ++++++++
 5 files changed, 46 insertions(+), 17 deletions(-)

diff --git a/src/chrome.manifest b/src/chrome.manifest
index 7b57d399..18c5f5b9 100644
--- a/src/chrome.manifest
+++ b/src/chrome.manifest
@@ -14,6 +14,7 @@ override chrome://branding/locale/brand.properties chrome://torbutton/locale/bra
 overlay chrome://browser/content/aboutDialog.xul chrome://torbutton/content/aboutDialog.xul
 
 # UI customization
+overlay chrome://browser/content/browser.xul chrome://torbutton/content/menu-items-overlay.xul
 overlay chrome://browser/content/browser.xul chrome://torbutton/content/menu-overlay.xul
 overlay about:preferences chrome://torbutton/content/privacy-prefs-overlay.xul
 overlay chrome://browser/content/browser.xul chrome://torbutton/content/tor-circuit-display.xul
diff --git a/src/chrome/content/menu-items-overlay.xul b/src/chrome/content/menu-items-overlay.xul
new file mode 100644
index 00000000..274c9c71
--- /dev/null
+++ b/src/chrome/content/menu-items-overlay.xul
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?> <!-- -*- Mode: HTML -*- -->
+
+<!DOCTYPE overlay SYSTEM "chrome://torbutton/locale/torbutton.dtd">
+
+<overlay id="torbutton-menu-overlay"
+         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <menuitem id="menu_newIdentity"
+            accesskey="&torbutton.context_menu.new_identity_key;"
+            key="torbutton-new-identity-key"
+            label="&torbutton.context_menu.new_identity;"
+            oncommand="torbutton_new_identity();"/>
+  <menuitem id="menu_newCircuit"
+            accesskey="&torbutton.context_menu.new_circuit_key;"
+            key="torbutton-new-circuit-key"
+            label="&torbutton.context_menu.new_circuit;"
+            oncommand="torbutton_new_circuit();"/>
+  <toolbarbutton id="appMenuNewIdentity"
+                 key="torbutton-new-identity-key"
+                 label="&torbutton.context_menu.new_identity;"
+                 oncommand="torbutton_new_identity();"/>
+  <toolbarbutton id="appMenuNewCircuit"
+                 key="torbutton-new-circuit-key"
+                 label="&torbutton.context_menu.new_circuit;"
+                 oncommand="torbutton_new_circuit();"/>
+  <toolbarbutton id="appMenu-private-window-button"
+                 hidden="true"/>
+  <toolbarbutton id="appMenuRestoreLastSession"
+                 hidden="true"/>
+</overlay>
diff --git a/src/chrome/content/popup.xul b/src/chrome/content/popup.xul
index b088a829..b4191e30 100644
--- a/src/chrome/content/popup.xul
+++ b/src/chrome/content/popup.xul
@@ -15,19 +15,6 @@
          anchor="torbutton-button" position="after_start" >
     <hbox align="start">
       <vbox>
-        <menuitem id="torbutton-new-identity"
-                  label="&torbutton.context_menu.new_identity;"
-                  accesskey="&torbutton.context_menu.new_identity_key;"
-                  key="torbutton-new-identity-key"
-                  insertafter="context-stop"
-                  oncommand="torbutton_new_identity()"/>
-        <menuitem id="torbutton-new-circuit"
-                  label="&torbutton.context_menu.new_circuit;"
-                  accesskey="&torbutton.context_menu.new_circuit_key;"
-                  key="torbutton-new-circuit-key"
-                  insertafter="context-stop"
-                  oncommand="torbutton_new_circuit()"/>
-        <menuseparator/>
         <menuitem id="torbutton-cookie-protector"
                   label="&torbutton.context_menu.cookieProtections;"
                   accesskey="&torbutton.context_menu.cookieProtections.key;"
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 885a141a..18895927 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -949,7 +949,8 @@ function torbutton_new_identity() {
   try {
     // Make sure that we can only click once on New Identiy to avoid race
     // conditions leading to failures (see bug 11783 for an example).
-    document.getElementById("torbutton-new-identity").disabled = true;
+    document.getElementById("menu_newIdentity").disabled = true;
+    document.getElementById("appMenuNewIdentity").disabled = true;
 
     let shouldConfirm =  m_tb_prefs.getBoolPref("extensions.torbutton.confirm_newnym");
 
@@ -972,7 +973,8 @@ function torbutton_new_identity() {
       if (confirmed) {
         torbutton_do_new_identity();
       } else {
-        document.getElementById("torbutton-new-identity").disabled = false;
+        document.getElementById("menu_newIdentity").disabled = false;
+        document.getElementById("appMenuNewIdentity").disabled = false;
       }
     } else {
         torbutton_do_new_identity();
@@ -980,7 +982,8 @@ function torbutton_new_identity() {
   } catch(e) {
     // If something went wrong make sure we have the New Identity button
     // enabled (again).
-    document.getElementById("torbutton-new-identity").disabled = false;
+    document.getElementById("menu_newIdentity").disabled = false;
+    document.getElementById("appMenuNewIdentity").disabled = false;
     torbutton_log(5, "Unexpected error on new identity: "+e);
     window.alert("Torbutton: Unexpected error on new identity: "+e);
   }
@@ -1769,7 +1772,8 @@ function torbutton_check_protections()
   document.getElementById("torbutton-cookie-protector").hidden = m_tb_prefs.getBoolPref("browser.privatebrowsing.autostart");
 
   if (!m_tb_control_pass || (!m_tb_control_ipc_file && !m_tb_control_port)) {
-    document.getElementById("torbutton-new-identity").disabled = true;
+    document.getElementById("menu_newIdentity").disabled = true;
+    document.getElementById("appMenuNewIdentity").disabled = true;
   }
 
   if (!m_tb_tbb && m_tb_prefs.getBoolPref("extensions.torbutton.prompt_torbrowser")) {
diff --git a/src/chrome/skin/torbutton.css b/src/chrome/skin/torbutton.css
index 14166b73..cf90ae6d 100644
--- a/src/chrome/skin/torbutton.css
+++ b/src/chrome/skin/torbutton.css
@@ -59,3 +59,11 @@ svg#tor-circuit circle.node-circle {
     stroke-width: 2px;
     fill: white;
 }
+
+#appMenuNewIdentity {
+    list-style-image: url("chrome://browser/skin/reload.svg");
+}
+
+#appMenuNewCircuit {
+    list-style-image: url("chrome://torbutton/skin/relay.svg");
+}



More information about the tbb-commits mailing list