Bug 30088. Fixed pref handling of typeaheadfind so that it has it's own default preferences file. No need to se prefs manually anymore. Touched up rdf files so that installing via xpi can work. Not part of build

This commit is contained in:
aaronl%netscape.com 2002-07-10 23:34:52 +00:00
Родитель bf47977f38
Коммит 1ab1457f79
10 изменённых файлов: 104 добавлений и 50 удалений

Просмотреть файл

@ -79,3 +79,8 @@ EXTRA_DSO_LDOPTS += \
$(MOZ_UNICHARUTIL_LIBS) \
$(MOZ_COMPONENT_LIBS)
libs::
$(INSTALL) $(srcdir)/resources/content/prefs/typeaheadfind.js $(DIST)/bin/defaults/pref
install::
$(SYSINSTALL) $(IFLAGS1) $(srcdir)/resources/content/prefs/typeaheadfind.js $(DESTDIR)$(mozappdir)/defaults/pref

Просмотреть файл

@ -40,31 +40,16 @@
var gVersion = "0.1";
var err = initInstall("Type Ahead Find", "/Netscape/Type Ahead Find", gVersion);
var err = initInstall("Type Ahead Find", "typeaheadfind", gVersion);
logComment("initInstall: " + err);
var fProgram = getFolder("Program");
var fComponents = getFolder("Components");
// var fChrome = getFolder("Chrome");
logComment("fProgram: " + fProgram);
// addDirectory: blank, archive_dir, install_dir, subdir
err = addDirectory("", "bin", fProgram, "");
if (err != SUCCESS)
cancelInstall(err);
err = addDirectory("", "components", fComponents, "");
if (err != SUCCESS)
cancelInstall(err);
err = addDirectory("", "chrome", fChrome, "");
if (err != SUCCESS)
cancelInstall(err);
err = addDirectory("", gVersion, "bin", fProgram, "", true);
logComment("addDirectory: " + err);
// Register chrome
registerChrome(PACKAGE | DELAYED_CHROME, getFolder("Chrome","typeaheadfind.jar"), "content/typeaheadfind/");
registerChrome(SKIN | DELAYED_CHROME, getFolder("Chrome","typeaheadfind.jar"), "skin/modern/typeaheadfind/");
registerChrome(LOCALE | DELAYED_CHROME, getFolder("Chrome","typeaheadfind.jar"), "locale/en-US/typeaheadfind/");
if (getLastError() == SUCCESS) {

Просмотреть файл

@ -1,9 +1,3 @@
en-win.jar:
locale/en-US/global-platform/typeaheadfind.properties
en-unix.jar:
locale/en-US/global-platform/typeaheadfind.properties
en-mac.jar:
locale/en-US/global-platform/typeaheadfind.properties
typeaheadfind.jar:
locale/en-US/typeaheadfind/contents.rdf (resources/locale/en-US/contents.rdf)
locale/en-US/typeaheadfind/typeaheadfind.properties (resources/locale/en-US/typeaheadfind.properties)

Просмотреть файл

@ -80,3 +80,6 @@ LINCS=\
include <$(DEPTH)\config\rules.mak>
libs::
$(MAKE_INSTALL) resources\content\prefs\typeaheadfind.js $(DIST)\bin\defaults\pref

Просмотреть файл

@ -137,15 +137,17 @@ nsTypeAheadFind::nsTypeAheadFind():
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
if (mFind && prefs) {
AddRef();
// ----------- Listen to prefs
prefs->RegisterCallback("accessibility.typeaheadfind", (PrefChangedFunc)nsTypeAheadFind::TypeAheadFindPrefCallback, (void*)this);
prefs->RegisterCallback("accessibility.typeaheadfind.linksonly", (PrefChangedFunc)nsTypeAheadFind::TypeAheadFindPrefCallback, (void*)this);
prefs->RegisterCallback("accessibility.typeaheadfind.timeout", (PrefChangedFunc)nsTypeAheadFind::TypeAheadFindPrefCallback, (void*)this);
prefs->RegisterCallback("accessibility.browsewithcaret", (PrefChangedFunc)nsTypeAheadFind::TypeAheadFindPrefCallback, (void*)this);
// ----------- Set search options ---------------
mFind->SetFindBackwards(PR_FALSE);
mFind->SetCaseSensitive(PR_FALSE);
mFind->SetWordBreaker(nsnull);
// ----------- Get initial preferences ----------
nsTypeAheadFind::TypeAheadFindPrefsReset("", NS_STATIC_CAST(void*, this));
// ----------- Listen to prefs ------------------
prefs->RegisterCallback("accessibility.typeaheadfind", (PrefChangedFunc)nsTypeAheadFind::TypeAheadFindPrefsReset, NS_STATIC_CAST(void*, this));
prefs->RegisterCallback("accessibility.browsewithcaret", (PrefChangedFunc)nsTypeAheadFind::TypeAheadFindPrefsReset, NS_STATIC_CAST(void*, this));
}
}
@ -159,10 +161,8 @@ nsTypeAheadFind::~nsTypeAheadFind()
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
if (prefs) {
prefs->UnregisterCallback("accessibility.typeaheadfind", (PrefChangedFunc)nsTypeAheadFind::TypeAheadFindPrefCallback, (void*)this);
prefs->UnregisterCallback("accessibility.typeaheadfind.linksonly", (PrefChangedFunc)nsTypeAheadFind::TypeAheadFindPrefCallback, (void*)this);
prefs->UnregisterCallback("accessibility.typeaheadfind.timeout", (PrefChangedFunc)nsTypeAheadFind::TypeAheadFindPrefCallback, (void*)this);
prefs->UnregisterCallback("accessibility.browsewithcaret", (PrefChangedFunc)nsTypeAheadFind::TypeAheadFindPrefCallback, (void*)this);
prefs->UnregisterCallback("accessibility.typeaheadfind", (PrefChangedFunc)nsTypeAheadFind::TypeAheadFindPrefsReset, (void*)this);
prefs->UnregisterCallback("accessibility.browsewithcaret", (PrefChangedFunc)nsTypeAheadFind::TypeAheadFindPrefsReset, (void*)this);
}
}
@ -184,18 +184,20 @@ void nsTypeAheadFind::ReleaseInstance()
// ------- Pref Callbacks (2) ---------------
int PR_CALLBACK nsTypeAheadFind::TypeAheadFindPrefCallback(const char* aPrefName, void* instance_data)
int PR_CALLBACK nsTypeAheadFind::TypeAheadFindPrefsReset(const char* aPrefName, void* instance_data)
{
nsTypeAheadFind* typeAheadFind= NS_STATIC_CAST(nsTypeAheadFind*, instance_data);
NS_ASSERTION(typeAheadFind, "bad instance data");
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
if (!prefs)
return 0;
if (!nsCRT::strcasecmp(aPrefName,"accessibility.typeaheadfind")) {
PRBool wasTypeAheadOn = typeAheadFind->mIsTypeAheadOn;
prefs->GetBoolPref("accessibility.typeaheadfind", &typeAheadFind->mIsTypeAheadOn);
if (typeAheadFind->mIsTypeAheadOn != wasTypeAheadOn) {
nsCOMPtr<nsIWebProgress> progress(do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID));
if (progress) {
PRBool wasTypeAheadOn = typeAheadFind->mIsTypeAheadOn;
prefs->GetBoolPref("accessibility.typeaheadfind", &typeAheadFind->mIsTypeAheadOn);
if (!typeAheadFind->mIsTypeAheadOn) {
typeAheadFind->RemoveCurrentSelectionListener();
typeAheadFind->RemoveCurrentScrollPositionListener();
@ -203,7 +205,7 @@ int PR_CALLBACK nsTypeAheadFind::TypeAheadFindPrefCallback(const char* aPrefName
typeAheadFind->RemoveCurrentWindowFocusListener();
progress->RemoveProgressListener(NS_STATIC_CAST(nsIWebProgressListener*, typeAheadFind));
}
else if (typeAheadFind->mIsTypeAheadOn != wasTypeAheadOn) {
else {
progress->AddProgressListener(NS_STATIC_CAST(nsIWebProgressListener*, typeAheadFind), nsIWebProgress::NOTIFY_STATE_DOCUMENT);
// Initialize string bundle
nsCOMPtr<nsIStringBundleService> stringBundleService(do_GetService(kStringBundleServiceCID));
@ -212,12 +214,9 @@ int PR_CALLBACK nsTypeAheadFind::TypeAheadFindPrefCallback(const char* aPrefName
}
}
}
if (!nsCRT::strcasecmp(aPrefName,"accessibility.typeaheadfind.linksonly"))
prefs->GetBoolPref("accessibility.typeaheadfind.linksonly", &typeAheadFind->mLinksOnlyPref);
if (!nsCRT::strcasecmp(aPrefName,"accessibility.typeaheadfind.timeout"))
prefs->GetIntPref("accessibility.typeaheadfind.timeout", &typeAheadFind->mTimeoutLength);
if (!nsCRT::strcasecmp(aPrefName,"accessibility.browsewithcaret"))
prefs->GetBoolPref("accessibility.browsewithcaret", &typeAheadFind->mCaretBrowsingOn);
prefs->GetBoolPref("accessibility.typeaheadfind.linksonly", &typeAheadFind->mLinksOnlyPref);
prefs->GetIntPref("accessibility.typeaheadfind.timeout", &typeAheadFind->mTimeoutLength);
prefs->GetBoolPref("accessibility.browsewithcaret", &typeAheadFind->mCaretBrowsingOn);
return 0; // PREF_OK
}

Просмотреть файл

@ -60,7 +60,7 @@
#include "nsITypeAheadFind.h"
#include "nsIStringBundle.h"
#define TYPEAHEADFIND_BUNDLE_URL "chrome://global-platform/locale/typeaheadfind.properties"
#define TYPEAHEADFIND_BUNDLE_URL "chrome://typeaheadfind/locale/typeaheadfind.properties"
class nsTypeAheadFind : public nsIDOMFocusListener,
public nsIDOMKeyListener,
@ -112,7 +112,7 @@ public:
static void ReleaseInstance(void);
protected:
static int PR_CALLBACK TypeAheadFindPrefCallback(const char* aPrefName, void* instance_data);
static int PR_CALLBACK TypeAheadFindPrefsReset(const char* aPrefName, void* instance_data);
// Helper methods
void AttachNewSelectionListener();

Просмотреть файл

Просмотреть файл

@ -0,0 +1,41 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Aaron Leventhal <aaronl@netscape.com> (original author)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
pref("accessibility.typeaheadfind", true);
pref("accessibility.typeaheadfind.linksonly", true);
pref("accessibility.typeaheadfind.timeout", 2500);

Просмотреть файл

@ -0,0 +1,21 @@
<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- list all the skins being supplied by this package -->
<RDF:Seq about="urn:mozilla:locale:root">
<RDF:li resource="urn:mozilla:locale:en-US"/>
</RDF:Seq>
<!-- locale information -->
<RDF:Description about="urn:mozilla:locale:en-US">
<chrome:packages>
<RDF:Seq about="urn:mozilla:locale:en-US:packages">
<RDF:li resource="urn:mozilla:locale:en-US:typeaheadfind"/>
</RDF:Seq>
</chrome:packages>
<RDF:Description about="urn:mozilla:locale:en-US:typeaheadfind"
chrome:localeVersion="1.0.0"/>
</RDF:RDF>

Просмотреть файл

@ -0,0 +1,6 @@
textfound = Text found: "
textnotfound = Text not found: "
linkfound = Link found: "
linknotfound = Link not found: "
closequote = "
stopfind = Type ahead find stopped.