[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-launcher/master] Add bridge relay help button to network settings dialog.



commit 56a7e93004b1eaaeec3d66ca1f41bf623af3802c
Author: Kathy Brade <brade@xxxxxxxxxxxxxx>
Date:   Thu Apr 18 16:41:52 2013 -0400

    Add bridge relay help button to network settings dialog.
---
 src/chrome/content/.network-settings.js.swp |  Bin 0 -> 32768 bytes
 src/chrome/content/network-settings.js      |   91 ++++++++++++++++++++-------
 src/chrome/content/network-settings.xul     |   27 ++++++---
 src/chrome/locale/en/network-settings.dtd   |    5 ++
 src/chrome/locale/en/torlauncher.properties |    1 +
 src/chrome/skin/network-settings.css        |   14 ++++
 6 files changed, 106 insertions(+), 32 deletions(-)

diff --git a/src/chrome/content/.network-settings.js.swp b/src/chrome/content/.network-settings.js.swp
new file mode 100644
index 0000000..ce49066
Binary files /dev/null and b/src/chrome/content/.network-settings.js.swp differ
diff --git a/src/chrome/content/network-settings.js b/src/chrome/content/network-settings.js
index 97e26d6..f8dd976 100644
--- a/src/chrome/content/network-settings.js
+++ b/src/chrome/content/network-settings.js
@@ -46,6 +46,8 @@ var gTorProcessService = null;
 var gObsService = null;
 var gIsInitialBootstrap = false;
 var gIsBootstrapComplete = false;
+var gRestoreAfterHelpPanelID = null;
+var gRestoreAfterCancelBtnLabel = null;
 
 
 function initDialog()
@@ -85,14 +87,14 @@ function initDialog()
   if (TorLauncherUtil.shouldStartAndOwnTor &&
       !gTorProcessService.TorIsProcessReady)
   {
-    showOrHideSettings(false, true);  // Show "Waiting for tor to start"
+    showPanel("startingTor");
     gObsService.addObserver(gObserver, kTorProcessReadyTopic, false);
     gObsService.addObserver(gObserver, kTorProcessExitedTopic, false);
     gObsService.addObserver(gObserver, kTorProcessDidNotStartTopic, false);
   }
   else
   { 
-    showOrHideSettings(true, false);
+    showPanel("settings");
     readTorSettings();
   }
 
@@ -109,11 +111,11 @@ var gObserver = {
 
     if (kTorProcessReadyTopic == aTopic)
     {
-      showOrHideSettings(true, false);
+      showPanel("settings");
       readTorSettings();
     }
     else if (kTorProcessDidNotStartTopic == aTopic)
-      showOrHideSettings(false, false);
+      showPanel("errorPanel");
     else
       close();
   }
@@ -137,7 +139,7 @@ function readTorSettings()
   if (!didSucceed)
   {
     // Unable to communicate with tor.  Hide settings and display an error.
-    showOrHideSettings(false, false);
+    showPanel("errorPanel");
 
     setTimeout(function()
         {
@@ -153,42 +155,45 @@ function readTorSettings()
 }
 
 
-function showOrHideSettings(aShow, aIsStartingTor)
+function showPanel(aPanelID)
 {
-  showOrHideElem("settings", aShow);
-  showOrHideElem("startingTor", !aShow && aIsStartingTor);
+  var deckElem = document.getElementById("deck");
+  if (deckElem)
+    deckElem.selectedPanel = document.getElementById(aPanelID);
 
-  var okBtn = document.documentElement.getButton("accept");
-  if (okBtn)
-  {
-    if (aShow)
-    {
-      okBtn.removeAttribute("hidden");
-      okBtn.focus();
-    }
-    else
-      okBtn.setAttribute("hidden", true);
-  }
+  showOrHideButton("accept", (aPanelID == "settings"), true);
+  showOrHideButton("extra1", (aPanelID != "bridgeHelp"), false);
 }
 
 
-function showOrHideElem(aID, aShow)
+function showOrHideButton(aID, aShow, aFocus)
 {
   if (!aID)
     return;
 
-  var e = document.getElementById(aID);
-  if (e)
+  var btn = document.documentElement.getButton(aID);
+  if (btn)
   {
     if (aShow)
-      e.removeAttribute("hidden");
+    {
+      btn.removeAttribute("hidden");
+      if (aFocus)
+        btn.focus()
+    }
     else
-      e.setAttribute("hidden", true);
+      btn.setAttribute("hidden", true);
   }
 }
 
+
 function onCancel()
 {
+  if (gRestoreAfterHelpPanelID) // Is help open?
+  {
+    closeHelp();
+    return false;
+  }
+
   if (gIsInitialBootstrap) try
   {
     var obsSvc = Cc["@mozilla.org/observer-service;1"]
@@ -208,6 +213,44 @@ function onCopyLog()
 }
 
 
+function onOpenHelp()
+{
+  if (gRestoreAfterHelpPanelID) // Already open?
+    return;
+
+  var deckElem = document.getElementById("deck");
+  if (!deckElem)
+    return;
+
+  gRestoreAfterHelpPanelID = deckElem.selectedPanel.id;
+  var cancelBtn = document.documentElement.getButton("cancel");
+  if (cancelBtn)
+  {
+    gRestoreAfterCancelBtnLabel = cancelBtn.label;
+    cancelBtn.label = TorLauncherUtil.getLocalizedString("done");
+  }
+  else
+    gRestoreAfterCancelBtnLabel = null;
+
+    showPanel("bridgeHelp");
+}
+
+
+function closeHelp()
+{
+  if (!gRestoreAfterHelpPanelID)  // Already closed?
+    return;
+
+  var cancelBtn = document.documentElement.getButton("cancel");
+  if (cancelBtn && gRestoreAfterCancelBtnLabel)
+    cancelBtn.label = gRestoreAfterCancelBtnLabel;
+  gRestoreAfterCancelBtnLabel = null;
+  
+  showPanel(gRestoreAfterHelpPanelID);
+  gRestoreAfterHelpPanelID = null;
+}
+
+
 // Returns true if successful.
 function initProxySettings()
 {
diff --git a/src/chrome/content/network-settings.xul b/src/chrome/content/network-settings.xul
index 6e6c882..ddd2b86 100644
--- a/src/chrome/content/network-settings.xul
+++ b/src/chrome/content/network-settings.xul
@@ -16,19 +16,20 @@
         title="&torsettings.dialog.title;"
         windowtype="TorLauncher:NetworkSettings"
         persist="screenX screenY"
-        buttons="accept,cancel,extra1"
+        buttons="accept,cancel,extra1,help"
         buttonlabelextra1="&torsettings.copyLog;"
         ondialogaccept="return applySettings();"
         ondialogcancel="return onCancel();"
         ondialogextra1="onCopyLog();"
+        ondialoghelp="onOpenHelp();"
         onload="initDialog();">
 
   <script type="application/x-javascript"
           src="chrome://torlauncher/content/network-settings.js"/>
 
-  <stack>
+  <deck id="deck">
     <vbox id="settings">
-      <vbox flex="1">
+      <vbox>
         <hbox id="tbb-header">
           <vbox>
             <spacer flex="1" />
@@ -95,7 +96,7 @@
         </groupbox>
       </vbox>
 
-      <vbox flex="1">
+      <vbox>
         <checkbox id="useFirewallPorts" groupboxID="firewallSpecificSettings"
                   label="&torsettings.firewall.checkbox;"
                   oncommand="toggleElemUI(this)"/>
@@ -108,14 +109,17 @@
         </groupbox>
       </vbox>
 
-      <vbox flex="1">
+      <vbox>
         <checkbox id="useBridges" groupboxID="bridgeSpecificSettings"
                   label="&torsettings.useBridges.checkbox;"
                   oncommand="toggleElemUI(this);" />
         <groupbox id="bridgeSpecificSettings">
           <hbox>
             <vbox flex="1">
-              <label value="&torsettings.useBridges.label;" control="bridgeList"/>
+              <hbox align="center">
+                <button dlgtype="help"/>
+                <label value="&torsettings.useBridges.label;" control="bridgeList"/>
+              </hbox>
               <textbox id="bridgeList" multiline="true" rows="4" />
             </vbox>
     <!--
@@ -132,7 +136,7 @@
         </groupbox>
       </vbox>
     </vbox>
-    <vbox id="startingTor" flex="1">
+    <vbox id="startingTor">
       <spring flex="1" />
       <hbox>
         <spring flex="1" />
@@ -141,6 +145,13 @@
       </hbox>
       <spring flex="1" />
     </vbox>
-  </stack>
+    <vbox id="bridgeHelp">
+      <hbox align="middle"><label>&torsettings.bridgeHelpTitle;</label></hbox>
+      <description>&torsettings.bridgeHelp1;</description>
+      <description>&torsettings.bridgeHelp2;</description>
+      <description>&torsettings.bridgeHelp3;</description>
+    </vbox>
+    <vbox id="errorPanel"/>
+  </deck>
   <spring />
 </dialog>
diff --git a/src/chrome/locale/en/network-settings.dtd b/src/chrome/locale/en/network-settings.dtd
index 3382b17..99ea45c 100644
--- a/src/chrome/locale/en/network-settings.dtd
+++ b/src/chrome/locale/en/network-settings.dtd
@@ -21,3 +21,8 @@
 <!ENTITY torsettings.useBridges.checkbox "My ISP blocks connections to the Tor network">
 <!ENTITY torsettings.useBridges.label "Enter one or more bridge relays in the form address:port.">
 <!ENTITY torsettings.copyLog "Copy Tor Log To Clipboard">
+<!ENTITY torsettings.bridgeHelpTitle "Bridge Relay Help">
+<!ENTITY torsettings.bridgeHelp1 "Bridge relays (or 'bridges' for short) are Tor relays that aren't listed in the main directory. Since there is no complete public list of them, even if your ISP is filtering connections to all the known Tor relays they probably won't be able to block all the bridges.">
+<!ENTITY torsettings.bridgeHelp2 "To obtain some bridge relays, use a web browser to visit the following page:  https://bridges.torproject.org";>
+
+<!ENTITY torsettings.bridgeHelp3 "Another way to find public bridge addresses is to send mail to bridges@xxxxxxxxxxxxxx with the line 'get bridges' by itself in the body of the message. However, so we can make it harder for an attacker to learn lots of bridge addresses, you must send this request from an email address at one of the following domains: gmail.com or yahoo.com.">
diff --git a/src/chrome/locale/en/torlauncher.properties b/src/chrome/locale/en/torlauncher.properties
index 0453faa..362f122 100644
--- a/src/chrome/locale/en/torlauncher.properties
+++ b/src/chrome/locale/en/torlauncher.properties
@@ -25,3 +25,4 @@ torlauncher.error_bridges_missing=You must specify one or more bridges.
 torlauncher.connect=Connect
 torlauncher.quit=Quit
 torlauncher.quit_win=Exit
+torlauncher.done=Done
diff --git a/src/chrome/skin/network-settings.css b/src/chrome/skin/network-settings.css
index e165bca..32cdd07 100644
--- a/src/chrome/skin/network-settings.css
+++ b/src/chrome/skin/network-settings.css
@@ -41,3 +41,17 @@ dialog.initialBootstrap #tbb-header {
   font-size: 120%;
   font-weight: bold;
 }
+
+#bridgeHelp {
+  margin: 30px;
+}
+
+#bridgeHelp label {
+  font-size: 120%;
+  font-weight: bold;
+  margin: 0px 0px 20px 0px;
+}
+
+#bridgeHelp description {
+  margin-bottom: 15px;
+}

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits