[Pkg-mozext-commits] [itsalltext] 163/459: Added bad editor dialog box.

David Prévot taffit at moszumanska.debian.org
Tue Feb 24 23:26:17 UTC 2015


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

taffit pushed a commit to branch master
in repository itsalltext.

commit 47e0e3296fbbaa282001ee1f236afba95ef6e7e8
Author: docwhat at gerf.org <docwhat at gerf.org>
Date:   Thu Mar 8 10:43:45 2007 -0500

    Added bad editor dialog box.
---
 chrome/content/badeditor.js              | 21 ++++++++++++++++++++
 chrome/content/badeditor.xul             | 34 ++++++++++++++++++++++++++++++++
 chrome/content/cacheobj.js               | 25 ++++++++++++-----------
 chrome/content/itsalltext.js             | 10 ++++++++++
 chrome/content/newextension.xul          |  2 +-
 chrome/locale/en-US/badeditor.dtd        | 10 ++++++++++
 chrome/locale/en-US/badeditor.properties |  1 +
 defaults/preferences/itsalltext.js       |  2 +-
 8 files changed, 92 insertions(+), 13 deletions(-)

diff --git a/chrome/content/badeditor.js b/chrome/content/badeditor.js
new file mode 100644
index 0000000..28af752
--- /dev/null
+++ b/chrome/content/badeditor.js
@@ -0,0 +1,21 @@
+/**
+ * Pass back the values that that the user selected.
+ */
+function onOK() {
+    window['arguments'][0].out = {
+        do_preferences: true
+    };
+    return true;
+}
+function doOnload() {
+    var locale = document.getElementById("strings");
+    var params = window['arguments'][0];
+    var r=document.getElementById('reason');
+    if(params.exists) {
+        r.appendChild(document.createTextNode(params.exception));
+    } else {
+        var textnode = document.createTextNode(locale.getFormattedString('enoent', [params.path]));
+
+        r.appendChild(textnode);
+    }
+}
diff --git a/chrome/content/badeditor.xul b/chrome/content/badeditor.xul
new file mode 100644
index 0000000..1267ca3
--- /dev/null
+++ b/chrome/content/badeditor.xul
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
+
+<!DOCTYPE badeditorwindow SYSTEM "chrome://itsalltext/locale/badeditor.dtd" >
+
+<dialog
+  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+  id="ItsAllTextBadEditor"
+  title="&title;"
+  buttonlabelaccept="&pref.label;"
+  ondialogaccept="return onOK();"
+  onload="doOnload();"
+  >
+
+  <script type="application/x-javascript" src="chrome://itsalltext/content/badeditor.js"/>
+  <stringbundleset id="strbundles">
+    <stringbundle id="strings" src="chrome://itsalltext/locale/badeditor.properties"/>
+  </stringbundleset>
+
+  <dialogheader title="&header;"/>
+  <vbox>
+    <description>&helptext;</description>
+    <spacer flex="1"/>
+    <groupbox flex="1">
+      <caption label="&reason;"/>
+      <description id="reason" style="max-width: 30em;">
+      </description>
+    </groupbox>
+  </vbox>
+    
+</dialog>
+<!-- Local Variables: -->
+<!-- mode: xml -->
+<!-- End: -->
diff --git a/chrome/content/cacheobj.js b/chrome/content/cacheobj.js
index 369d88f..2e28f0a 100644
--- a/chrome/content/cacheobj.js
+++ b/chrome/content/cacheobj.js
@@ -193,19 +193,17 @@ CacheObj.prototype.getStyle = function(node, attr) {
 /**
  * Edit a textarea as a file.
  * @param {String} extension The extension of the file to edit.
- * @param {boolean} retried This is used internally.
  */
-CacheObj.prototype.edit = function(extension, retried) {
+CacheObj.prototype.edit = function(extension) {
     if (typeof(extension) == 'string') {
         this.setExtension(extension);
     }
-    if (typeof(retried) == 'undefined') { retried = false; }
     var filename = this.write();
     this.initial_background = this.node.style.backgroundColor;
     this.initial_color      = this.node.style.color;
-    try {
-        var program = ItsAllText.getEditor();
+    var program = ItsAllText.getEditor();
              
+    try {
         // create an nsIProcess
         var process = Components.
             classes["@mozilla.org/process/util;1"].
@@ -222,12 +220,17 @@ CacheObj.prototype.edit = function(extension, retried) {
         process.run(false, args, args.length, result);
         this._is_watching = true;
     } catch(e) {
-        if (!retried) {
-            window.openDialog('chrome://itsalltext/chrome/preferences.xul',
-                              ItsAllText.localeString('no_editor_pref'), 
-                              "chrome,titlebar,toolbar,centerscreen,modal",
-                              "badeditor");
-            this.edit(extension, true); // Try one more time.
+        var params = {out:null,
+                      exists: program.exists(),
+                      path: program.path,
+                      exception: e };
+        window.openDialog('chrome://itsalltext/chrome/badeditor.xul',
+                          null,
+                          "chrome,titlebar,toolbar,centerscreen,modal",
+                          params);
+        if(params.out.do_preferences) {
+            ItsAllText.openPreferences();
+            this.edit(extension);
         }
     }
 };
diff --git a/chrome/content/itsalltext.js b/chrome/content/itsalltext.js
index 78ae328..9138d4e 100644
--- a/chrome/content/itsalltext.js
+++ b/chrome/content/itsalltext.js
@@ -347,6 +347,16 @@ var ItsAllText = function() {
             return extensions;
         }
     };
+    
+    /**
+     * Open the preferences dialog box.
+     * @private
+     */
+    that.openPreferences = function() {
+        window.openDialog('chrome://itsalltext/chrome/preferences.xul',
+                          'itsalltext_preferences',
+                          "chrome,titlebar,toolbar,centerscreen,modal");
+    };
 
     /**
      * A Preference Option: Append an extension
diff --git a/chrome/content/newextension.xul b/chrome/content/newextension.xul
index 0c52308..8b1a16a 100644
--- a/chrome/content/newextension.xul
+++ b/chrome/content/newextension.xul
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
 
-<!DOCTYPE prefwindow SYSTEM "chrome://itsalltext/locale/newextension.dtd" >
+<!DOCTYPE newextwindow SYSTEM "chrome://itsalltext/locale/newextension.dtd" >
 <dialog
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   id="ItsAllTextNewExtension"
diff --git a/chrome/locale/en-US/badeditor.dtd b/chrome/locale/en-US/badeditor.dtd
new file mode 100644
index 0000000..2d43157
--- /dev/null
+++ b/chrome/locale/en-US/badeditor.dtd
@@ -0,0 +1,10 @@
+<!ENTITY title              "It's All Text! was unable to open your editor">
+<!ENTITY header             "Unable to open your editor">
+<!ENTITY pref.label         "Preferences">
+<!ENTITY helptext           "I was unable to run your editor.
+
+You can now either cancel your editor or you can use the preferences to choose a new editor.  Please make sure that you use the full path to the editor and that the editor is executable.
+
+Thank you.
+">
+<!ENTITY reason             "Reason:">
diff --git a/chrome/locale/en-US/badeditor.properties b/chrome/locale/en-US/badeditor.properties
new file mode 100644
index 0000000..f1614ff
--- /dev/null
+++ b/chrome/locale/en-US/badeditor.properties
@@ -0,0 +1 @@
+enoent=The path '%1$S' does not exist.
diff --git a/defaults/preferences/itsalltext.js b/defaults/preferences/itsalltext.js
index 85345a0..a385078 100644
--- a/defaults/preferences/itsalltext.js
+++ b/defaults/preferences/itsalltext.js
@@ -1,5 +1,5 @@
 pref("extensions.itsalltext.charset",  "UTF-8");
-pref("extensions.itsalltext.editor",   "/usr/bin/gedit");
+pref("extensions.itsalltext.editor",   "Please Choose An Editor");
 pref("extensions.itsalltext.refresh",  7);
 pref("extensions.itsalltext.debug",  false);
 pref("extensions.itsalltext.disable_gumdrops", false);

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



More information about the Pkg-mozext-commits mailing list