From a4ac7010fc8422f07e128f67e271c4fe7202902f Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Tue, 7 Aug 2007 12:14:42 +0000 Subject: [PATCH] move remaining preference setting from vimperator.startup to Options() --- chrome/content/vimperator/options.js | 25 +++++++++++++++++++++++++ chrome/content/vimperator/vimperator.js | 22 +--------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/chrome/content/vimperator/options.js b/chrome/content/vimperator/options.js index b249af80..67a3b750 100644 --- a/chrome/content/vimperator/options.js +++ b/chrome/content/vimperator/options.js @@ -227,6 +227,23 @@ function Options() //{{{ document.title = window.content.document.title + " - " + value; // not perfect fix, but good enough } + // + // firefox preferences which need to be changed to work well with vimperator + // + + // work around firefox popup blocker + var popup_allowed_events = loadPreference('dom.popup_allowed_events', 'change click dblclick mouseup reset submit'); + if (!popup_allowed_events.match("keypress")) + storePreference('dom.popup_allowed_events', popup_allowed_events + " keypress"); + + // TODO: shouldn't we be resetting these in destroy() as well? + // we have our own typeahead find implementation + storePreference('accessibility.typeaheadfind.autostart', false); + storePreference('accessibility.typeaheadfind', false); // actually the above setting should do it, but has no effect in firefox + + // start with saved session + storePreference("browser.startup.page", 3); + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ @@ -246,6 +263,14 @@ function Options() //{{{ return null; } + this.destroy = function() + { + // reset some modified firefox prefs + if (loadPreference('dom.popup_allowed_events', 'change click dblclick mouseup reset submit') + == popup_allowed_events + " keypress") + storePreference('dom.popup_allowed_events', popup_allowed_events); + } + // TODO: separate Preferences from Options? Would these utility functions // be better placed in the 'core' vimperator namespace somewhere? Options.setPref = function(name, value) diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js index ea6edea5..94c0bb64 100644 --- a/chrome/content/vimperator/vimperator.js +++ b/chrome/content/vimperator/vimperator.js @@ -69,8 +69,6 @@ const vimperator = (function() //{{{ var callbacks = []; - var popup_allowed_events; // need to change and reset this firefox pref XXX: move to options class - // our services var sound_service = Components.classes['@mozilla.org/sound;1'] .getService(Components.interfaces.nsISound); @@ -626,17 +624,6 @@ const vimperator = (function() //{{{ vimperator.registerCallback("submit", vimperator.modes.EX, function(command) { vimperator.execute(command); } ); vimperator.registerCallback("complete", vimperator.modes.EX, function(str) { return exTabCompletion(str); } ); - // TODO: move most of the following code to Options constructor - - // work around firefox popup blocker - popup_allowed_events = Options.getFirefoxPref('dom.popup_allowed_events', 'change click dblclick mouseup reset submit'); - if (!popup_allowed_events.match("keypress")) - Options.setFirefoxPref('dom.popup_allowed_events', popup_allowed_events + " keypress"); - - // we have our own typeahead find implementation - Options.setFirefoxPref('accessibility.typeaheadfind.autostart', false); - Options.setFirefoxPref('accessibility.typeaheadfind', false); // actually the above setting should do it, but has no effect in firefox - // first time intro message if (Options.getPref("firsttime", true)) { @@ -649,9 +636,6 @@ const vimperator = (function() //{{{ //gURLBar.blur(); // TODO: needed anymore? vimperator.focusContent(); - // firefox preferences which we need to be changed to work well with vimperator - Options.setFirefoxPref("browser.startup.page", 3); // start with saved session - // finally, read a ~/.vimperatorrc // make sourcing asynchronous, otherwise commands that open new tabs won't work setTimeout(function() { @@ -683,12 +667,8 @@ const vimperator = (function() //{{{ // save our preferences vimperator.commandline.destroy(); vimperator.events.destroy(); + vimperator.options.destroy(); vimperator.quickmarks.destroy(); - - // reset some modified firefox prefs - if (Options.getFirefoxPref('dom.popup_allowed_events', 'change click dblclick mouseup reset submit') - == popup_allowed_events + " keypress") - Options.setFirefoxPref('dom.popup_allowed_events', popup_allowed_events); }, // @param value MUST be a string, it can have the following form: "+20%", "200%", "-30"