Bug 512146 - Make "Delete History for (host|domain) available in History context menus, r/sr=Neil
authorJens Hatlak <jh@junetz.de>
Tue, 01 Sep 2009 23:29:47 +0200
changeset 3484 c98edd97fb3fd24ce6996cb704006ccf7c1ba8f2
parent 3483 49795b7f767f41d824036347128de7dec8fef443
child 3485 42bada3ecb39ffb4ccea7142b889fe625e7f5ac6
push idunknown
push userunknown
push dateunknown
bugs512146
Bug 512146 - Make "Delete History for (host|domain) available in History context menus, r/sr=Neil
suite/common/history/controller.js
suite/common/history/history-panel.xul
suite/common/history/history.js
suite/common/history/history.xul
suite/common/history/placesOverlay.xul
--- a/suite/common/history/controller.js
+++ b/suite/common/history/controller.js
@@ -101,30 +101,38 @@ PlacesController.prototype = {
             return true;
         }
       }
       return false;
     case "placesCmd_open":
       var selectedNode = this._view.selectedNode;
       return selectedNode && PlacesUtils.nodeIsURI(selectedNode);
     case "placesCmd_delete:hostname":
-      gDeleteByHostname.accessKey = PlacesUIUtils.getString("delete.hostname.accesskey");
+      gDeleteByHostname.setAttribute("accesskey",
+                                     PlacesUIUtils.getString("delete.hostname.accesskey"));
       if (gLastHostname) {
-        gDeleteByHostname.label = PlacesUIUtils.getFormattedString("delete.hostname.true", [gLastHostname]);
+        gDeleteByHostname.setAttribute("label",
+                                       PlacesUIUtils.getFormattedString("delete.hostname.true",
+                                                                        [gLastHostname]));
         return true;
       }
-      gDeleteByHostname.label = PlacesUIUtils.getString("delete.hostname.false");
+      gDeleteByHostname.setAttribute("label",
+                                     PlacesUIUtils.getString("delete.hostname.false"));
       return false;
     case "placesCmd_delete:domain":
-      gDeleteByDomain.accessKey = PlacesUIUtils.getString("delete.domain.accesskey");
+      gDeleteByDomain.setAttribute("accesskey",
+                                   PlacesUIUtils.getString("delete.domain.accesskey"));
       if (gLastDomain) {
-        gDeleteByDomain.label = PlacesUIUtils.getFormattedString("delete.domain.true", [gLastDomain]);
+        gDeleteByDomain.setAttribute("label",
+                                     PlacesUIUtils.getFormattedString("delete.domain.true",
+                                                                      [gLastDomain]));
         return true;
       }
-      gDeleteByDomain.label = PlacesUIUtils.getString("delete.domain.false");
+      gDeleteByDomain.setAttribute("label",
+                                   PlacesUIUtils.getString("delete.domain.false"));
       return false;
     default:
       return false;
     }
   },
 
   doCommand: function PC_doCommand(aCommand) {
     switch (aCommand) {
--- a/suite/common/history/history-panel.xul
+++ b/suite/common/history/history-panel.xul
@@ -78,16 +78,17 @@
     </toolbarbutton>
   </hbox>
 
   <tree id="historyTree"
         class="sidebar-placesTree plain"
         flex="1"
         type="places"
         context="placesContext"
+        onselect="historyOnSelect();"
         onkeypress="SidebarUtils.handleTreeKeyPress(event);"
         onclick="SidebarUtils.handleTreeClick(this, event, true);"
         onmousemove="SidebarUtils.handleTreeMouseMove(event);"
         onmouseout="SidebarUtils.clearURLFromStatusBar();">
     <treecols context="">
       <treecol label="&col.title.label;" id="Name" flex="4"
                persist="width hidden ordinal sortActive sortDirection"/>
       <splitter class="tree-splitter"/>
--- a/suite/common/history/history.js
+++ b/suite/common/history/history.js
@@ -49,18 +49,18 @@ var gETLDService;
 var gDeleteByHostname;
 var gDeleteByDomain;
 var gHistoryStatus;
 var gHistoryGrouping = "day";
 
 function HistoryCommonInit()
 {
   gHistoryTree = document.getElementById("historyTree");
-  gDeleteByHostname = document.getElementById("menu_deleteByHostname");
-  gDeleteByDomain = document.getElementById("menu_deleteByDomain");
+  gDeleteByHostname = document.getElementById("placesCmd_delete:hostname");
+  gDeleteByDomain = document.getElementById("placesCmd_delete:domain");
   gHistoryStatus = document.getElementById("statusbar-display");
   gSearchBox = document.getElementById("search-box");
 
   gPrefService = Components.classes["@mozilla.org/preferences-service;1"]
                            .getService(Components.interfaces.nsIPrefBranch);
   PREF = gPrefService;    // need this for bookmarks.js
 
   try {
@@ -112,17 +112,18 @@ function historyOnSelect()
           gETLDService =
             Components.classes["@mozilla.org/network/effective-tld-service;1"]
                       .getService(Components.interfaces.nsIEffectiveTLDService);
         gLastDomain = gETLDService.getBaseDomainFromHost(gLastHostname);
       } catch (e) {}
     }
   }
 
-  gHistoryStatus.label = url;
+  if (gHistoryStatus)
+    gHistoryStatus.label = url;
 
   updateHistoryCommands();
 }
 
 function UpdateViewColumns(aMenuItem)
 {
   while (aMenuItem) {
     // Each menuitem should be checked if its column is not hidden.
--- a/suite/common/history/history.xul
+++ b/suite/common/history/history.xul
@@ -75,20 +75,17 @@
              oncommand="focusElement(gSearchBox);"/>
   </commandset>
   <commandset id="selectEditMenuItems">
     <command id="cmd_cut"/>
     <command id="cmd_copy"/>
     <command id="cmd_delete"/>
     <command id="cmd_selectAll"/>
   </commandset>
-  <commandset id="placesCommands">
-    <command id="placesCmd_delete:hostname" oncommand="goDoCommand('placesCmd_delete:hostname');"/>
-    <command id="placesCmd_delete:domain" oncommand="goDoCommand('placesCmd_delete:domain');"/>
-  </commandset>
+  <commandset id="placesCommands"/>
 
   <broadcaster id="Communicator:WorkMode"/>
 
   <keyset id="tasksKeys">
     <!-- File Menu -->
     <key id="key_close"/>
     <key id="key_quit"/>
     <!-- Edit Menu -->
--- a/suite/common/history/placesOverlay.xul
+++ b/suite/common/history/placesOverlay.xul
@@ -73,16 +73,20 @@
               events="focus,sort"
               oncommandupdate="updateHistoryCommands(this.firstChild);">
     <command id="placesCmd_open"
              oncommand="goDoCommand('placesCmd_open');"/>
     <command id="placesCmd_open:window"
              oncommand="goDoCommand('placesCmd_open:window');"/>
     <command id="placesCmd_open:tab"
              oncommand="goDoCommand('placesCmd_open:tab');"/>
+    <command id="placesCmd_delete:hostname"
+             oncommand="goDoCommand('placesCmd_delete:hostname');"/>
+    <command id="placesCmd_delete:domain"
+             oncommand="goDoCommand('placesCmd_delete:domain');"/>
   </commandset>
 
   <popup id="placesContext"
          onpopupshowing="this._view = PlacesUIUtils.getViewForNode(document.popupNode);
                          return this._view.buildContextMenu(this);"
          onpopuphiding="this._view.destroyContextMenu();">
     <menuitem id="placesContext_open"
               command="placesCmd_open"
@@ -120,16 +124,22 @@
               accesskey="&copyCmd.accesskey;"
               selection="any"/>
     <menuseparator id="placesContext_editSeparator"/>
     <menuitem id="placesContext_delete"
               command="cmd_delete"
               label="&deleteCmd.label;"
               accesskey="&deleteCmd.accesskey;"
               selection="link|host|day"/>
+    <menuitem id="placesContext_deleteByHostname"
+              command="placesCmd_delete:hostname"
+              selection="link|host"/>
+    <menuitem id="placesContext_deleteByDomain"
+              command="placesCmd_delete:domain"
+              selection="link|host"/>
     <menuitem id="placesContext_selectAll"
               command="cmd_selectAll"
               label="&selectAllCmd.label;"
               accesskey="&selectAllCmd.accesskey;"
               selection="any"/>
   </popup>
 
   <menupopup id="viewPopup">