Skip to content
Browse files

Prompting users to pick Scratchpad (if available) or a different edit…

…or. Removed 'Scratchpad' as the default, since it isn't always available (introduced in Gecko 6.0).
  • Loading branch information...
1 parent 8f83c5e commit 60ddbb60279292a0968b7188d46c3fd78dcbe304 @supahgreg supahgreg committed Sep 3, 2011
View
1 extension/defaults/preferences/scriptish.js
@@ -5,7 +5,6 @@ pref("extensions.scriptish.blocklist.lastFetch", 0);
pref("extensions.scriptish.blocklist.url", "https://github.com/scriptish/scriptish/raw/master/blocklist.json");
pref("extensions.scriptish.cache.enabled", true);
pref("extensions.scriptish.config.prettyPrint.enabled", false);
-pref("extensions.scriptish.editor", "Scratchpad");
pref("extensions.scriptish.enabled", true);
pref("extensions.scriptish.enabledSchemes.about", false);
pref("extensions.scriptish.enabledSchemes.chrome", false);
View
43 extension/modules/utils/Scriptish_getEditor.js
@@ -30,38 +30,41 @@ const Scriptish_getEditor = function(parentWindow, change) {
return editor;
} else {
Scriptish_log("Editor preference either does not exist or is not executable");
- Scriptish_prefRoot.reset("editor");
+ Scriptish_prefRoot.remove("editor");
}
}
// Ask the user to choose a new editor. Sometimes users get confused and
// pick a non-executable file, so we set this up in a loop so that if they do
// that we can give them an error and try again.
+ var hasScratchpad =
+ !!Services.wm.getMostRecentWindow("navigator:browser").Scratchpad;
+ var sp = Services.prompt;
+ var flags = sp.BUTTON_POS_0 * sp.BUTTON_TITLE_IS_STRING
+ + sp.BUTTON_POS_1 * sp.BUTTON_TITLE_IS_STRING;
+
while (true) {
Scriptish_log("Asking user to choose editor...");
- // Ask if the user wants to use Scratchpad
- var sp = Services.prompt;
- var flags = sp.BUTTON_POS_0 * sp.BUTTON_TITLE_IS_STRING
- + sp.BUTTON_POS_1 * sp.BUTTON_TITLE_IS_STRING;
-
+ // If available, ask if the user wants to use Scratchpad.
// Note: confirmEx always returns 1 if prompt is closed w/ the close button,
// so we need to keep the negative answer at button index 1.
- var answer = sp.confirmEx(
- null,
- Scriptish_stringBundle("editor.useScratchpad"),
- Scriptish_stringBundle("editor.useScratchpad"),
- flags,
- Scriptish_stringBundle("editor.useScratchpad.yes"),
- Scriptish_stringBundle("editor.useScratchpad.no"),
- "",
- null,
- {value:false});
+ if (hasScratchpad) {
+ var answer = sp.confirmEx(
+ null,
+ Scriptish_stringBundle("editor.useScratchpad"),
+ Scriptish_stringBundle("editor.useScratchpad"),
+ flags,
+ Scriptish_stringBundle("editor.useScratchpad.yes"),
+ Scriptish_stringBundle("editor.useScratchpad.no"),
+ "",
+ null,
+ {value:false});
- // The user answered Yes. Set 'editor' back to the default ("Scratchpad").
- if (0 === answer) {
- Scriptish_prefRoot.reset("editor");
- return Scriptish_prefRoot.getValue("editor");
+ // The user answered Yes. Set Scratchpad as the editor.
+ if (0 === answer) {
+ return Scriptish_prefRoot.setValue("editor", "Scratchpad");
+ }
}
var nsIFilePicker = Ci.nsIFilePicker;
View
5 extension/modules/utils/Scriptish_openInEditor.js
@@ -29,10 +29,9 @@ function Scriptish_openInEditor(script, parentWindow) {
Scriptish_launchApplicationWithDoc(editor, file);
}
} catch (e) {
- // Something may be wrong with the editor the user selected. Reset to
- // the default ("Scratchpad").
+ // Something may be wrong with the editor the user selected. Remove it.
Scriptish_alert(Scriptish_stringBundle("editor.couldNotLaunch") + "\n" + e);
- Scriptish_prefRoot.reset("editor");
+ Scriptish_prefRoot.remove("editor");
throw e;
}
}

0 comments on commit 60ddbb6

Please sign in to comment.
Something went wrong with that request. Please try again.