[Pkg-mozext-commits] [itsalltext] 46/459: Added a filepicker

David Prévot taffit at moszumanska.debian.org
Tue Feb 24 23:26:05 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 7a7d86b7d485495a87db1c626c521b245aeccd42
Author: Christian Höltje <docwhat at gerf.org>
Date:   Wed Jan 3 20:49:40 2007 -0500

    Added a filepicker
---
 chrome/content/itsalltext.js                    | 11 -----
 chrome/content/preferences.js                   | 31 ++++++++++++++
 chrome/content/{options.xul => preferences.xul} |  3 ++
 install.rdf                                     | 57 ++++++++++---------------
 4 files changed, 56 insertions(+), 46 deletions(-)

diff --git a/chrome/content/itsalltext.js b/chrome/content/itsalltext.js
index 8e3a180..421f474 100644
--- a/chrome/content/itsalltext.js
+++ b/chrome/content/itsalltext.js
@@ -108,13 +108,6 @@ function ItsAllTextOverlay() {
     }
   };
 
-  var makeLocalFile = function(path) {
-    var obj = Components.classes["@mozilla.org/file/local;1"].
-      createInstance(Components.interfaces.nsILocalFile);
-    obj.initWithPath(path);
-    return obj;
-  };
-
   /**
    * Returns the directory where we put files to edit.
    * @returns nsILocalFile The location where we should write editable files.
@@ -243,10 +236,6 @@ function ItsAllTextOverlay() {
   that.getEditor = function() {
     var editor = that.preferences.data.editor;
 
-    // @todo The prefereces dialog should have a filepicker: http://developer.mozilla.org/en/docs/nsIFilePicker
-    // @todo If the editor fails, we should open preferences. (!)
-    // @todo MacOSX: add support for "open -a <app> <file>". (!)
-
     // create an nsILocalFile for the executable
     var file = Components.
       classes["@mozilla.org/file/local;1"].
diff --git a/chrome/content/preferences.js b/chrome/content/preferences.js
new file mode 100644
index 0000000..8ec47bf
--- /dev/null
+++ b/chrome/content/preferences.js
@@ -0,0 +1,31 @@
+// @todo The prefereces dialog should have a filepicker: http://developer.mozilla.org/en/docs/nsIFilePicker
+// @todo If the editor fails, we should open preferences. (!)
+// @todo MacOSX: add support for "open -a <app> <file>". (!)
+
+
+/**
+ * Open a filepicker to select the value of the editor.
+ */
+function pref_editor_select() {
+  var tb = document.getElementById('editor');
+  
+  const nsIFilePicker = Components.interfaces.nsIFilePicker;
+ 
+  var fp = Components.classes["@mozilla.org/filepicker;1"].
+    createInstance(nsIFilePicker);
+  fp.init(window, "Choose your editor", nsIFilePicker.modeOpen);
+  fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterApps);
+
+  var initdir = Components.classes["@mozilla.org/file/local;1"].
+    createInstance(Components.interfaces.nsILocalFile);
+  initdir.initWithPath('/usr/bin');
+  if (initdir.exists() && initdir.isDirectory()) {
+    fp.displayDirectory = initdir;
+  }
+  
+  var rv = fp.show();
+  if (rv == nsIFilePicker.returnOK) {
+    var file = fp.file;
+    tb.value = file.path;
+  }
+}
diff --git a/chrome/content/options.xul b/chrome/content/preferences.xul
similarity index 90%
rename from chrome/content/options.xul
rename to chrome/content/preferences.xul
index 151b6dc..3bdaafc 100644
--- a/chrome/content/options.xul
+++ b/chrome/content/preferences.xul
@@ -4,6 +4,8 @@
 <prefwindow id="itsalltext-prefs"
      title="It's All Text Preferences"
      xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script type="application/x-javascript" src="preferences.js"/>
  
 <prefpane id="itsalltext-pane" label="It's All Text Preferences">
   <preferences>
@@ -21,6 +23,7 @@
     <hbox align="right">
       <label control="editor" value="Editor (needs full path): "/>
       <textbox preference="pref_editor" id="editor" size="20"/>
+      <button oncommand="pref_editor_select();"><description>Browse</description></button>
     </hbox>
     <hbox align="right">
       <label control="seconds" value="Seconds between refreshing: "/>
diff --git a/install.rdf b/install.rdf
index c9dec12..6c899fe 100644
--- a/install.rdf
+++ b/install.rdf
@@ -1,35 +1,22 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
-  <Description about="urn:mozilla:install-manifest">
-
-    <em:id>itsalltext at docwhat.gerf.org</em:id>
-	<em:version>0.3</em:version>
-    <em:type>2</em:type>
-
-    <!-- Front End Metadata -->
-    <em:name>It's All Text!</em:name>
-    <em:description>
-      Edit text using your favorite editor!
-    </em:description>
-    <em:homepageURL>http://addons.mozilla.org/firefox/4125</em:homepageURL>
-    <em:optionsURL>chrome://itsalltext/content/options.xul</em:optionsURL>
-    <em:iconURL>chrome://itsalltext/content/icon.png</em:iconURL>
-    <em:aboutURL>chrome://itsalltext/content/about.xul</em:aboutURL>
-
-    <!-- Author and Contributors -->
-    <em:creator>Christian Höltje</em:creator>
-    <!-- <em:contributor></em:contributor> -->
-
-    <!-- Firefox -->
-    <em:targetApplication>
-      <Description>
-         <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
-         <em:minVersion>1.5</em:minVersion>
-         <em:maxVersion>2.0.0.*</em:maxVersion>
-       </Description>
-	</em:targetApplication>
-  </Description>
-
-</RDF>
+<?xml version="1.0"?>
+<RDF:RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#"
+         xmlns:NC="http://home.netscape.com/NC-rdf#"
+         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+  <RDF:Description RDF:about="rdf:#$dlkc22"
+                   em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
+                   em:minVersion="1.5"
+                   em:maxVersion="2.0.0.*" />
+  <RDF:Description RDF:about="urn:mozilla:install-manifest"
+                   em:id="itsalltext at docwhat.gerf.org"
+                   em:version="0.3.1"
+                   em:type="2"
+                   em:name="It's All Text!"
+                   em:description="Edit text using your favorite editor!"
+                   em:homepageURL="http://addons.mozilla.org/firefox/4125"
+                   em:optionsURL="chrome://itsalltext/content/preferences.xul"
+                   em:iconURL="chrome://itsalltext/content/icon.png"
+                   em:aboutURL="chrome://itsalltext/content/about.xul"
+                   em:creator="Christian Höltje">
+    <em:targetApplication RDF:resource="rdf:#$dlkc22"/>
+  </RDF:Description>
+</RDF:RDF>

-- 
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