[Pkg-mozext-commits] [nostalgy] 75/252: *** empty log message ***

David Prévot taffit at moszumanska.debian.org
Tue Jun 14 15:24:43 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository nostalgy.

commit f4e90792c73c75ee644a7c185cb4a101368dff4a
Author: frisch <frisch at 56b81dcf-5a2f-0410-9db0-014be2e416ff>
Date:   Thu May 10 16:46:03 2007 +0000

    *** empty log message ***
---
 CHANGES                        |   8 ++-
 content/about.xhtml            |  23 ++++++--
 content/edit_prefs.js          | 127 ++++++++++++++++++++++++++++++-----------
 content/edit_prefs.xul         |  13 ++++-
 content/edit_rule.js           |  20 ++++++-
 content/edit_rule.xul          |  12 ++--
 content/folders.js             |  43 ++++++++++++++
 content/nostalgy.js            |  69 +++++++++++++++++++---
 content/thunderbirdOverlay.xul |   3 +
 install.rdf                    |   2 +-
 10 files changed, 260 insertions(+), 60 deletions(-)

diff --git a/CHANGES b/CHANGES
index 963207a..0b95395 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,8 +1,12 @@
-Since 0.2.8
+0.2.9
+  - the user can define custom shortcuts (Go/Save/Copy to some specific folder)
+  - new "shift-G" shortcut (Go as suggested)
   - new option "always include tags"; when disabled, tags are added to the
     completion box only if the input box starts with ":" or if
     there is no matching folder
-  - it is possible to create a new tag in the completion box
+  - it is possible to create new tags in the completion box
+  - the "`" shortcut now cycles through "view messages from same sender"
+    -> "view messages with same subject" -> "normal view"
 
 0.2.8
   - make it work again with TB 1.5
diff --git a/content/about.xhtml b/content/about.xhtml
index 7698946..e288ab6 100644
--- a/content/about.xhtml
+++ b/content/about.xhtml
@@ -107,6 +107,14 @@ uppercase, you don't need to press Shift.</p>
    displayed message (up and down) by pressing Ctrl-Left/Ctrl-Right.
    </p>
 
+   <h3>Custom shortcuts</h3>
+
+   <p>
+   In the preference dialog, you can define any number of custom
+   keyboard shortcuts. A custom shortcut triggers
+   a Go, a Save or a Copy command to a specific folder.
+   </p>
+
    <h3>Rules</h3>
 
    <p>Nostalgy has a notion of rule. A rule associates a folder to a
@@ -115,8 +123,8 @@ uppercase, you don't need to press Shift.</p>
    A rule can be restricted to match messages only under
    a given server/folder. When a rule selects a folder for a given message,
     Nostalgy
-   informs you in the status line.  You can then use the Shift-S/Shift-C
-   shortcuts to move/copy directly the message to this folder.  
+   informs you in the status line.  You can then use the Shift-S/Shift-C/Shift-G
+   shortcuts to move/copy/go directly to this folder.  
    Nostalgy's rules can be edited from the preference dialog.</p>
 
    <p>
@@ -128,7 +136,7 @@ uppercase, you don't need to press Shift.</p>
 
    <p>
    When no rule apply to a given message, Nostalgy proposes to re-use
-   (with Shift-S/Shift-C) the folder same as for the last move/copy 
+   (with Shift-S/Shift-C/Shift-G) the folder same as for the last move/copy 
    operation folder. If the folder lookup has been restricted
    to the current server (in the Nostalgy preference dialog), then
    the last operation folder is attached to the current server. Otherwise,
@@ -147,9 +155,11 @@ uppercase, you don't need to press Shift.</p>
    <li>The key "`" (backquote) launches a QuickSearch for messages
 	from the same sender as the currently selected message.
 	This re-creates the famous Alt-Click behavior from Eudora.
-	If you press the same key again, the QuickSearch is cancelled.
+	If you press the same key again, messages with the same
+        subject are searched. And if you press again,
+        the QuickSearch is cancelled.
 	In the Sent folder, the search is done on the first recipient (To:
-	header)	instead.</li>
+	header)	instead of the sender.</li>
    </ul>
 
 <h3>Tags</h3>
@@ -204,7 +214,8 @@ opens the file attachment dialog.</p>
    defined. The second tab has five switches to control the way the completion
    box (where folder names are proposed) is populated (see below).
    The third pane allows you to configure Nostalgy's shortcuts
-   (click on the key to change it) or to disable some of them.
+   (click on the key to change it), to disable some of them,
+   or to manage custom shortcuts.
    You might need to restart Thunderbird for changes to shortcuts
    to take effect.
    </p>
diff --git a/content/edit_prefs.js b/content/edit_prefs.js
index 30ec24c..8407607 100644
--- a/content/edit_prefs.js
+++ b/content/edit_prefs.js
@@ -4,6 +4,11 @@ var gList = null;
 
 var wait_key = null;
 var wait_key_old = "";
+var key_rows = null;
+var folder_select = null;
+var kKeysPrefs = "extensions.nostalgy.keys.";
+var kCustomActionsPrefs = "extensions.nostalgy.actions.";
+var max_custom = (-1);
 
 var keys = [
  ["save","Save message","S"],
@@ -11,8 +16,9 @@ var keys = [
  ["copy","Copy message","C"],
  ["copy_suggest","Copy as suggested","shift C"],
  ["go","Go to folder","G"],
+ ["go_suggest","Go as suggested","shift G"],
  ["hide_folders","Hide folder pane","L"],
- ["search_sender","Show messages from same sender","`"],
+ ["search_sender","Show messages with same sender/same subject","`"],
 ];
 
 (function () {
@@ -161,8 +167,27 @@ function onAcceptChanges() {
  
   if (wait_key) { wait_key.value = wait_key_old; wait_key = null; }
   for (var i in keys)
-    prefs.setCharPref("extensions.nostalgy.keys."+keys[i][0],
-                      gEBI("key_" + keys[i][0]).value);
+    prefs.setCharPref(kKeysPrefs+keys[i][0],gEBI("key_" + keys[i][0]).value);
+
+
+  var a = prefs.getChildList(kKeysPrefs, { });
+  for (var i in a) {
+    var id = a[i].substr(kKeysPrefs.length);
+    if (id.substr(0,1) == "_") {
+      try {
+       prefs.clearUserPref(kKeysPrefs+id);
+       prefs.clearUserPref(kCustomActionsPrefs+id); 
+      } catch (ex) { }
+    }
+  }
+
+  var e = document.getElementsByTagName("label");
+  for (var i = 0; i < e.length; i++)
+   if (e[i].id.substr(0,5) == "key__") {
+      var id = e[i].id.substr(4);
+      prefs.setCharPref(kKeysPrefs+id,e[i].value);
+      prefs.setCharPref(kCustomActionsPrefs+id,e[i].previousSibling.value);
+   }
 
   window.close();
 }
@@ -197,19 +222,34 @@ function createElem(tag,attrs,children) {
 }
 
 function createKeyRow(id,txt,v) {
+  var is_custom = id.substr(0,1) == "_";
+  var buttons = [ ];
+  if (!is_custom)
+   buttons.push(createElem("label", { class:"text-link", value:"disable",
+          onclick:"this.parentNode.previousSibling.value = '(disabled)';"}));
+  else
+   buttons.push(createElem("label", { class:"text-link", value:"delete",
+          onclick:"RemoveRow(this.parentNode.parentNode);" }));
+
   return createElem("row",{ }, [
-    createElem("label", { value:txt+":" }),
+    createElem("label", { value:txt }),
     createElem("label", { id:"key_" + id, class:"text-link", 
                           value:v, 
                           onclick:"WaitKey(this);",
                           onblur:"Cancel(this);" }),
-    createElem("label", { class:"text-link", value:"disable",
-                   onclick:"this.previousSibling.value = '(disabled)';"} )
+    createElem("hbox", { }, buttons)
   ]);
 }
 
+function RemoveRow(r) {
+  r.parentNode.removeChild(r);
+}
+
 function onNostalgyLoad() {
+  NostalgyFolderSelectionBoxes();
+
   gList = gEBI("rules");
+  folder_select = gEBI("folderselect");
 
   var prefs = Components.classes["@mozilla.org/preferences-service;1"].
                          getService(Components.interfaces.nsIPrefBranch);
@@ -223,12 +263,26 @@ function onNostalgyLoad() {
  for (var n in nostalgy_completion_options)
    gEBI(n).checked = getBoolPref(prefs, n);
 
- for (var i in keys) {
+ key_rows = gEBI("key_rows");
+ for (var i = 0; i < keys.length; i++) {
   var v = keys[i][2];
   try {
-    v = prefs.getCharPref("extensions.nostalgy.keys." + keys[i][0]);
+    v = prefs.getCharPref(kKeysPrefs + keys[i][0]);
   } catch (ex) { }
-  gEBI("key_rows").appendChild(createKeyRow(keys[i][0],keys[i][1],v));
+  key_rows.appendChild(createKeyRow(keys[i][0],keys[i][1],v));
+ }
+
+ var a = prefs.getChildList(kKeysPrefs, { });
+ for (var i in a) {
+   var id = a[i].substr(kKeysPrefs.length);
+   if (id.substr(0,1) == "_") {
+     var n = parseInt(id.substr(1));
+     try {
+       if (n > max_custom) max_custom = n; 
+       var cmd = prefs.getCharPref(kCustomActionsPrefs + id);
+       key_rows.appendChild(createKeyRow(id,cmd,prefs.getCharPref(a[i])));
+     } catch (ex) { }
+   }
  }
 }
 
@@ -244,6 +298,9 @@ function onKeyPress(ev) {
   } else if (wait_key && ev.keyCode != 13) {
     Recognize(ev,wait_key);
     wait_key = null;
+  } else if (ev.keyCode == KeyEvent.DOM_VK_RETURN) {
+    ev.preventDefault();
+    ev.stopPropagation();
   }
 }
 
@@ -251,29 +308,8 @@ function onKeyPress(ev) {
 function Recognize(ev, tgt) {
  ev.preventDefault();
  ev.stopPropagation();
-
- var gVKNames = [];
-
- for (var property in KeyEvent) {
-  gVKNames[KeyEvent[property]] = property.replace("DOM_VK_","");
- }
-
- var comps = [];
- if(ev.altKey) comps.push("alt");
- if(ev.ctrlKey) comps.push("control");
- if(ev.metaKey) comps.push("meta");
- if(ev.shiftKey) comps.push("shift");
-
-
- var k = "";
- if(ev.charCode == 32) k = "SPACE";
- else if(ev.charCode) k = String.fromCharCode(ev.charCode).toUpperCase();
- else k = gVKNames[ev.keyCode];
-
- if (!k) return;
- comps.push(k);
-
- tgt.value = comps.join(" ");
+ var k = RecognizeKey(ev);
+ if (k) tgt.value = k;
 }
 
 function WaitKey(tgt) {
@@ -284,7 +320,32 @@ function WaitKey(tgt) {
 }
 
 function Cancel(tgt) {
-  if (tgt == wait_key) { wait_key.value = wait_key_old; wait_key = null; }
+  if (tgt == wait_key) { 
+   var old = wait_key_old;
+   setTimeout(function() {
+      if (document.commandDispatcher.focusedElement != tgt) {
+        tgt.value = old;
+        if (tgt == wait_key) wait_key = null;
+      }
+   },500);
+  }
+}
+
+function SelectFolder() {
+  if (folder_select.value != "") {
+    var folder = NostalgyResolveFolder(folder_select.value);
+    if (folder) { 
+      var name = folder_name(folder);
+      max_custom++;
+      var cmd = gEBI("cmdkind").selectedItem.value;
+      key_rows.appendChild(createKeyRow("_" + max_custom,cmd + " -> " + name,
+                           "(disabled)"));
+      folder_select.value = "";
+      var e = gEBI("key__" + max_custom);
+      e.focus();
+      WaitKey(e);
+    }
+  }
 }
 
 window.addEventListener("load", onNostalgyLoad, false);
diff --git a/content/edit_prefs.xul b/content/edit_prefs.xul
index f35e1fa..d442ec7 100644
--- a/content/edit_prefs.xul
+++ b/content/edit_prefs.xul
@@ -79,10 +79,21 @@ shortcuts to move/copy the message to this folder.</label>
 
  <tabpanel>
  <groupbox style="width:800px">
-   <grid>
+   <grid style="overflow:auto; height:300px">
    <columns> <column/> <column width="150"/> <column/> </columns>
    <rows id="key_rows"/>
    </grid>
+  <separator orient="horizontal"/>
+  <hbox>
+  <radiogroup id="cmdkind" orient="horizontal">
+  <radio value="Go" label="Go" selected="true"/>
+  <radio value="Save" label="Save"/>
+  <radio value="Copy" label="Copy"/>
+  </radiogroup>
+  <textbox style="width:600px" type="autocomplete" id="folderselect" 
+           nostalgyfolderbox="SelectFolder();"/>
+  <button label="Create"  oncommand="SelectFolder();"/>
+  </hbox>
  </groupbox>
  </tabpanel>
  </tabpanels>
diff --git a/content/edit_rule.js b/content/edit_rule.js
index 63f75a9..b462b4d 100644
--- a/content/edit_rule.js
+++ b/content/edit_rule.js
@@ -8,11 +8,11 @@ function onNostalgyLoad() {
  var rule = window.arguments[0];
  if (!rule) { alert("rule=null!"); }
 
+ NostalgyFolderSelectionBoxes();
+
  gContainsSelect = gEBI("contains");
  gFolderSelect = gEBI("folderselect");
- NostalgyFolderSelectionBox(gFolderSelect);
  gUnderSelect = gEBI("underselect");
- NostalgyFolderSelectionBox(gUnderSelect);
 
  gContainsSelect.focus();
 
@@ -25,9 +25,17 @@ function onNostalgyLoad() {
 }
 
 function onAcceptChanges() {
+/*
+ var f = document.commandDispatcher.focusedElement;
+ while (f && f.tagName != "textbox") f = f.parentNode;
+ if (f && f.hasAttribute("nostalgyfolderbox"))
+   eval(f.getAttribute("nostalgyfolderbox"));
+*/
+
  var folder = FindFolderExact(gFolderSelect.value);
  if (!folder) {
    alert("Please choose an existing folder");
+   gFolderSelect.focus();
    return false;
  }
  if (gContainsSelect.value == "") {
@@ -62,4 +70,12 @@ function ChooseUnder() {
   }
 }
 
+function OnKeyPressTxt(ev) {
+  if (ev.keyCode==KeyEvent.DOM_VK_RETURN) {
+   setTimeout(function(){gUnderSelect.focus();},30);
+   ev.preventDefault();
+   ev.stopPropagation();
+  }
+}
+
 window.addEventListener("load", onNostalgyLoad, false);
\ No newline at end of file
diff --git a/content/edit_rule.xul b/content/edit_rule.xul
index 08521bc..047e0f5 100644
--- a/content/edit_rule.xul
+++ b/content/edit_rule.xul
@@ -34,21 +34,19 @@
 
     <row>
       <label value="for substring"/>
-      <textbox id="contains"/>
+      <textbox id="contains" onkeypress="OnKeyPressTxt(event);"/>
     </row>
 
     <row>
       <label value="when message is under folder"/>
-      <textbox type="autocomplete" tabScrolling="false" id="underselect"
-             flex="3" maxrows="15" crop="end" ontextentered="ChooseUnder();"
-             ontextcommand="ChooseUnder();"/>
+      <textbox type="autocomplete" id="underselect"
+               nostalgyfolderbox="ChooseUnder();"/>
     </row>
 
     <row>
       <label value="then save to"/>
-      <textbox type="autocomplete" tabScrolling="false" id="folderselect"
-             flex="3" maxrows="15" crop="end"  ontextcommand="ChooseUnder();"
-             ontextentered="ChooseFolder();"/>
+      <textbox type="autocomplete" id="folderselect"
+             nostalgyfolderbox="ChooseFolder();"/>
     </row>
   </rows>
 </grid>
diff --git a/content/folders.js b/content/folders.js
index a731857..bfc01fa 100644
--- a/content/folders.js
+++ b/content/folders.js
@@ -212,12 +212,29 @@ function NostalgyProcessKeyPress(aEvent) {
 }
 
 function NostalgyFolderSelectionBox(box) {
+ var cmd = box.getAttribute("nostalgyfolderbox");
+ if (cmd) {
+  box.setAttribute("ontextentered",cmd);
+  box.setAttribute("ontextcommand",cmd);
+  box.setAttribute("maxrows","15");
+  box.setAttribute("crop","end");
+  box.setAttribute("flex","3");
+  box.setAttribute("tabScrolling","false");
+ }
+
  box.shell_completion = false;
  box.addSession(new NostalgyAutocomplete(box));
  box.processInput = NostalgyProcessInput;  
  box.processKeyPress = NostalgyProcessKeyPress; 
 }
 
+function NostalgyFolderSelectionBoxes() {
+ var e = document.getElementsByTagName("textbox");
+ for (var i = 0; i < e.length; i++)
+  if (e[i].hasAttribute("nostalgyfolderbox"))
+    NostalgyFolderSelectionBox(e[i]);
+}
+
 /** Looking up folders by name **/
 
 function NostalgyCompleteUnique(s) {
@@ -412,3 +429,29 @@ function IterateMatches(uri,shell,f) {
   }
 }
 
+
+var gVKNames = null;
+
+function RecognizeKey(ev) {
+ if (gVKNames == null) {
+  gVKNames = [];
+  for (var property in KeyEvent)
+    gVKNames[KeyEvent[property]] = property.replace("DOM_VK_","");
+ }
+
+ var comps = [];
+ if(ev.altKey) comps.push("alt");
+ if(ev.ctrlKey) comps.push("control");
+ if(ev.metaKey) comps.push("meta");
+ if(ev.shiftKey) comps.push("shift");
+
+ var k = "";
+ if(ev.charCode == 32) k = "SPACE";
+ else if(ev.charCode) k = String.fromCharCode(ev.charCode).toUpperCase();
+ else k = gVKNames[ev.keyCode];
+
+ if (!k) return "";
+ comps.push(k);
+ return comps.join(" ");
+}
+
diff --git a/content/nostalgy.js b/content/nostalgy.js
index b41cfad..b28b855 100644
--- a/content/nostalgy.js
+++ b/content/nostalgy.js
@@ -7,7 +7,8 @@ var nostalgy_statusBar = null;
 var nostalgy_label = null;
 var nostalgy_th_statusBar = null;
 var nostalgy_cmdLabel = null;
-
+var custom_keys = { };
+var timeout_regkey = 0;
 
 /** Keys **/
 
@@ -72,6 +73,17 @@ var NostalgyRules =
        } catch (ex) { }
       }
     }
+    var a = this._branch.getChildList("actions.", { });
+    custom_keys = { };
+    var s = "";
+    for (var i in a) {
+      var id = a[i].substr(8);
+      try {
+        var key = this._branch.getCharPref("keys." + id);
+        var cmd = this._branch.getCharPref("actions." + id);
+       custom_keys[key] = cmd;
+      } catch (ex) { }
+    }
   },
 
   unregister: function()
@@ -115,7 +127,12 @@ var NostalgyRules =
      if (!in_message_window) NostalgyDefLabel();
      return;
     }
-    if (aData.match("keys.")) this.register_keys();
+    if (aData.match("keys.")) {
+      if (timeout_regkey) return;
+      timeout_regkey = 1;
+      var r = this;
+      setTimeout(function() { timeout_regkey = 0; r.register_keys(); }, 1000);
+    }
   },
 
   apply: function(sender,subject,recipients)
@@ -153,7 +170,8 @@ var last_folder = null;
 var gsuggest_folder = null;
 
 function onNostalgyResize() {
-  nostalgy_label.parentNode.maxWidth = document.width * 6 / 10;
+  if (nostalgy_label)
+    nostalgy_label.parentNode.maxWidth = document.width * 6 / 10;
 }
 
 var NostalgyFolderListener = {
@@ -529,17 +547,36 @@ function NostalgyFocusMessagePane() {
   }
 }
 
+var last_cycle_restrict_value = null;
+var last_cycle_restrict = 0;
+
 function NostalgySearchSender() {
+  var input = GetSearchInput();
+  try {
   var recips = gDBView.msgFolder.displayRecipients;
   var key = gDBView.hdrForFirstSelectedMessage.messageKey;
-  var input = GetSearchInput();
   input.focus();
-  input.searchMode =  1; // sender = kQuickSearchSender
+  input.showingSearchCriteria = false;
+  input.clearButtonHidden = false;
   var name = (recips ? MailRecipName() : MailAuthorName());
-  if (input.value == name) input.value = ""; else input.value = name;
-  onEnterInSearchBar(true);
+  var subj = MailSubject();
+  if (input.value != last_cycle_restrict_value) last_cycle_restrict = 0;
+  last_cycle_restrict++;
+  if (last_cycle_restrict == 1)
+  { input.value = name; input.searchMode = kQuickSearchSender; }
+  else if (last_cycle_restrict == 2)
+  { input.value = subj; input.searchMode = kQuickSearchSubject; }
+  else
+  { last_cycle_restrict = 0; input.value = ""; }
+  last_cycle_restrict_value = input.value;
+  onEnterInSearchBar();
   SetFocusThreadPane();
   gDBView.selectMsgByKey(key);
+  } catch (ex) { 
+   input.focus();
+   last_cycle_restrict = 0; input.value = "";  onEnterInSearchBar();
+   SetFocusThreadPane();
+  }
 }
 
 function onNostalgyKeyPress(ev) {
@@ -556,6 +593,7 @@ function onNostalgyKeyPress(ev) {
       GetSearchInput().focus();
       ev.preventDefault();
     }
+    return;
   } 
   if (!nostalgy_statusBar.hidden &&
       document.commandDispatcher.focusedElement.nodeName != "html:input") {
@@ -564,7 +602,22 @@ function onNostalgyKeyPress(ev) {
       nostalgy_folderBox.value =  nostalgy_folderBox.value + 
           String.fromCharCode(ev.charCode);
     }
-      ev.preventDefault();
+    ev.preventDefault();
+    return;
+  }
+  var k = custom_keys[RecognizeKey(ev)];
+  if (k) { ParseCommand(k); ev.preventDefault(); }
+}
+
+function ParseCommand(k) {
+  var spl = k.match(/(.*) -> (.*)/);
+  var folder = NostalgyResolveFolder(spl[2]);
+  if (!folder) { alert("Cannot find folder " + folder); return; }
+  switch (spl[1]) {
+   case "Go": ShowFolder(folder); break;
+   case "Save": MoveToFolder(folder); break;
+   case "Copy": CopyToFolder(folder); break;
+   default: alert("Unknown command " + spl[1]); return;
   }
 }
 
diff --git a/content/thunderbirdOverlay.xul b/content/thunderbirdOverlay.xul
index 0b2a031..3a8e686 100644
--- a/content/thunderbirdOverlay.xul
+++ b/content/thunderbirdOverlay.xul
@@ -21,6 +21,9 @@
   <key id="nostalgy_key_go"
        key="G" 
        oncommand="NostalgyCmd('&nostalgy.go-memo;', ShowFolder, false);"/>
+  <key id="nostalgy_key_go_suggest"
+       key="G" modifiers="shift" 
+       oncommand="NostalgySuggested('&nostalgy.go-memo;', ShowFolder);"/>
   <key id = "nostalgy_key_save"
        key="S" 
        oncommand="NostalgyCmd('&nostalgy.move-memo;', MoveToFolder, true);"/>
diff --git a/install.rdf b/install.rdf
index d60c284..454ac40 100644
--- a/install.rdf
+++ b/install.rdf
@@ -5,7 +5,7 @@
   <RDF:Description RDF:about="urn:mozilla:install-manifest"
                    em:id="nostalgy at alain.frisch"
                    em:name="Nostalgy"
-                   em:version="0.2.8"
+                   em:version="0.2.9"
                    em:creator="Alain Frisch"
                    em:description="Adds shortcuts to change folder, move message, with folder completion"
                    em:homepageURL="http://alain.frisch.fr/soft_mozilla.html"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/nostalgy.git



More information about the Pkg-mozext-commits mailing list