From 5c3eb74cd88c353940f4453488b8cfdcee9fd2c5 Mon Sep 17 00:00:00 2001 From: "mcmullen%netscape.com" Date: Fri, 26 Mar 1999 23:55:32 +0000 Subject: [PATCH] First Checked In. --- xpfe/AppCores/idl/PrefsCore.idl | 15 + xpfe/AppCores/public/nsIDOMPrefsCore.h | 67 ++++ xpfe/AppCores/src/nsJSPrefsCore.cpp | 464 +++++++++++++++++++++++ xpfe/AppCores/src/nsPrefsCore.cpp | 207 ++++++++++ xpfe/AppCores/src/nsPrefsCore.h | 67 ++++ xpfe/AppCores/src/nsPrefsCoreFactory.cpp | 0 xpfe/AppCores/src/nsPrefsCoreFactory.h | 0 xpfe/AppCores/xul/PrefsWindow.html | 21 + xpfe/AppCores/xul/PrefsWindow.js | 40 ++ xpfe/AppCores/xul/pref-appearance.html | 69 ++++ xpfe/AppCores/xul/pref-fonts.html | 16 + xpfe/AppCores/xul/pref-navigator.html | 90 +++++ xpfe/AppCores/xul/prefbottom.html | 53 +++ xpfe/AppCores/xul/preftree.css | 63 +++ xpfe/AppCores/xul/preftree.xul | 180 +++++++++ 15 files changed, 1352 insertions(+) create mode 100644 xpfe/AppCores/idl/PrefsCore.idl create mode 100644 xpfe/AppCores/public/nsIDOMPrefsCore.h create mode 100644 xpfe/AppCores/src/nsJSPrefsCore.cpp create mode 100644 xpfe/AppCores/src/nsPrefsCore.cpp create mode 100644 xpfe/AppCores/src/nsPrefsCore.h create mode 100644 xpfe/AppCores/src/nsPrefsCoreFactory.cpp create mode 100644 xpfe/AppCores/src/nsPrefsCoreFactory.h create mode 100644 xpfe/AppCores/xul/PrefsWindow.html create mode 100644 xpfe/AppCores/xul/PrefsWindow.js create mode 100644 xpfe/AppCores/xul/pref-appearance.html create mode 100644 xpfe/AppCores/xul/pref-fonts.html create mode 100644 xpfe/AppCores/xul/pref-navigator.html create mode 100644 xpfe/AppCores/xul/prefbottom.html create mode 100644 xpfe/AppCores/xul/preftree.css create mode 100644 xpfe/AppCores/xul/preftree.xul diff --git a/xpfe/AppCores/idl/PrefsCore.idl b/xpfe/AppCores/idl/PrefsCore.idl new file mode 100644 index 00000000000..87b56d1cee4 --- /dev/null +++ b/xpfe/AppCores/idl/PrefsCore.idl @@ -0,0 +1,15 @@ +interface PrefsCore : BaseAppCore +{ +/* IID: { 0x55af8384, 0xe11e, 0x11d2, \ + {0x91, 0x5f, 0xa0, 0x53, 0xf0, 0x5f, 0xf7, 0xbc}} */ + + void PrefsCore(); + + void ChangePanel(in wstring url); + void PanelLoaded(in Window win); + + void SavePrefs(); + void CancelPrefs(); +}; + + diff --git a/xpfe/AppCores/public/nsIDOMPrefsCore.h b/xpfe/AppCores/public/nsIDOMPrefsCore.h new file mode 100644 index 00000000000..864290850e4 --- /dev/null +++ b/xpfe/AppCores/public/nsIDOMPrefsCore.h @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ +/* AUTO-GENERATED. DO NOT EDIT!!! */ + +#ifndef nsIDOMPrefsCore_h__ +#define nsIDOMPrefsCore_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" +#include "nsIDOMBaseAppCore.h" + +class nsIDOMWindow; + +#define NS_IDOMPREFSCORE_IID \ + { 0x55af8384, 0xe11e, 0x11d2, \ + {0x91, 0x5f, 0xa0, 0x53, 0xf0, 0x5f, 0xf7, 0xbc}} + +class nsIDOMPrefsCore : public nsIDOMBaseAppCore { +public: + static const nsIID& GetIID() { static nsIID iid = NS_IDOMPREFSCORE_IID; return iid; } + + NS_IMETHOD ChangePanel(const nsString& aUrl)=0; + + NS_IMETHOD PanelLoaded(nsIDOMWindow* aWin)=0; + + NS_IMETHOD SavePrefs()=0; + + NS_IMETHOD CancelPrefs()=0; +}; + + +#define NS_DECL_IDOMPREFSCORE \ + NS_IMETHOD ChangePanel(const nsString& aUrl); \ + NS_IMETHOD PanelLoaded(nsIDOMWindow* aWin); \ + NS_IMETHOD SavePrefs(); \ + NS_IMETHOD CancelPrefs(); \ + + + +#define NS_FORWARD_IDOMPREFSCORE(_to) \ + NS_IMETHOD ChangePanel(const nsString& aUrl) { return _to##ChangePanel(aUrl); } \ + NS_IMETHOD PanelLoaded(nsIDOMWindow* aWin) { return _to##PanelLoaded(aWin); } \ + NS_IMETHOD SavePrefs() { return _to##SavePrefs(); } \ + NS_IMETHOD CancelPrefs() { return _to##CancelPrefs(); } \ + + +extern "C" NS_DOM nsresult NS_InitPrefsCoreClass(nsIScriptContext *aContext, void **aPrototype); + +extern "C" NS_DOM nsresult NS_NewScriptPrefsCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); + +#endif // nsIDOMPrefsCore_h__ diff --git a/xpfe/AppCores/src/nsJSPrefsCore.cpp b/xpfe/AppCores/src/nsJSPrefsCore.cpp new file mode 100644 index 00000000000..775fb573a57 --- /dev/null +++ b/xpfe/AppCores/src/nsJSPrefsCore.cpp @@ -0,0 +1,464 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ +/* AUTO-GENERATED. DO NOT EDIT!!! */ + +#include "jsapi.h" +#include "nsJSUtils.h" +#include "nscore.h" +#include "nsIScriptContext.h" +#include "nsIJSScriptObject.h" +#include "nsIScriptObjectOwner.h" +#include "nsIScriptGlobalObject.h" +#include "nsIPtr.h" +#include "nsString.h" +#include "nsIDOMPrefsCore.h" +#include "nsIDOMWindow.h" +#include "nsIScriptNameSpaceManager.h" +#include "nsRepository.h" +#include "nsDOMCID.h" + + +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); +static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); +static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); +static NS_DEFINE_IID(kIPrefsCoreIID, NS_IDOMPREFSCORE_IID); +static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID); + +NS_DEF_PTR(nsIDOMPrefsCore); +NS_DEF_PTR(nsIDOMWindow); + + +/***********************************************************************/ +// +// PrefsCore Properties Getter +// +PR_STATIC_CALLBACK(JSBool) +GetPrefsCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMPrefsCore *a = (nsIDOMPrefsCore*)JS_GetPrivate(cx, obj); + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == a) { + return JS_TRUE; + } + + if (JSVAL_IS_INT(id)) { + switch(JSVAL_TO_INT(id)) { + case 0: + default: + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp); + } + + return PR_TRUE; +} + +/***********************************************************************/ +// +// PrefsCore Properties Setter +// +PR_STATIC_CALLBACK(JSBool) +SetPrefsCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMPrefsCore *a = (nsIDOMPrefsCore*)JS_GetPrivate(cx, obj); + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == a) { + return JS_TRUE; + } + + if (JSVAL_IS_INT(id)) { + switch(JSVAL_TO_INT(id)) { + case 0: + default: + return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp); + } + + return PR_TRUE; +} + + +// +// PrefsCore finalizer +// +PR_STATIC_CALLBACK(void) +FinalizePrefsCore(JSContext *cx, JSObject *obj) +{ + nsJSUtils::nsGenericFinalize(cx, obj); +} + + +// +// PrefsCore enumerate +// +PR_STATIC_CALLBACK(JSBool) +EnumeratePrefsCore(JSContext *cx, JSObject *obj) +{ + return nsJSUtils::nsGenericEnumerate(cx, obj); +} + + +// +// PrefsCore resolve +// +PR_STATIC_CALLBACK(JSBool) +ResolvePrefsCore(JSContext *cx, JSObject *obj, jsval id) +{ + return nsJSUtils::nsGenericResolve(cx, obj, id); +} + + +// +// Native method ChangePanel +// +PR_STATIC_CALLBACK(JSBool) +PrefsCoreChangePanel(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMPrefsCore *nativeThis = (nsIDOMPrefsCore*)JS_GetPrivate(cx, obj); + JSBool rBool = JS_FALSE; + nsAutoString b0; + + *rval = JSVAL_NULL; + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + if (argc >= 1) { + + nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]); + + if (NS_OK != nativeThis->ChangePanel(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function ChangePanel requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method PanelLoaded +// +PR_STATIC_CALLBACK(JSBool) +PrefsCorePanelLoaded(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMPrefsCore *nativeThis = (nsIDOMPrefsCore*)JS_GetPrivate(cx, obj); + JSBool rBool = JS_FALSE; + nsIDOMWindowPtr b0; + + *rval = JSVAL_NULL; + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + if (argc >= 1) { + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIWindowIID, + "Window", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->PanelLoaded(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function PanelLoaded requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method SavePrefs +// +PR_STATIC_CALLBACK(JSBool) +PrefsCoreSavePrefs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMPrefsCore *nativeThis = (nsIDOMPrefsCore*)JS_GetPrivate(cx, obj); + JSBool rBool = JS_FALSE; + + *rval = JSVAL_NULL; + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + if (argc >= 0) { + + if (NS_OK != nativeThis->SavePrefs()) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function SavePrefs requires 0 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method CancelPrefs +// +PR_STATIC_CALLBACK(JSBool) +PrefsCoreCancelPrefs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMPrefsCore *nativeThis = (nsIDOMPrefsCore*)JS_GetPrivate(cx, obj); + JSBool rBool = JS_FALSE; + + *rval = JSVAL_NULL; + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + if (argc >= 0) { + + if (NS_OK != nativeThis->CancelPrefs()) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function CancelPrefs requires 0 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +/***********************************************************************/ +// +// class for PrefsCore +// +JSClass PrefsCoreClass = { + "PrefsCore", + JSCLASS_HAS_PRIVATE, + JS_PropertyStub, + JS_PropertyStub, + GetPrefsCoreProperty, + SetPrefsCoreProperty, + EnumeratePrefsCore, + ResolvePrefsCore, + JS_ConvertStub, + FinalizePrefsCore +}; + + +// +// PrefsCore class properties +// +static JSPropertySpec PrefsCoreProperties[] = +{ + {0} +}; + + +// +// PrefsCore class methods +// +static JSFunctionSpec PrefsCoreMethods[] = +{ + {"ChangePanel", PrefsCoreChangePanel, 1}, + {"PanelLoaded", PrefsCorePanelLoaded, 1}, + {"SavePrefs", PrefsCoreSavePrefs, 0}, + {"CancelPrefs", PrefsCoreCancelPrefs, 0}, + {0} +}; + + +// +// PrefsCore constructor +// +PR_STATIC_CALLBACK(JSBool) +PrefsCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsresult result; + nsIID classID; + nsIScriptContext* context = (nsIScriptContext*)JS_GetContextPrivate(cx); + nsIScriptNameSpaceManager* manager; + nsIDOMPrefsCore *nativeThis; + nsIScriptObjectOwner *owner = nsnull; + + static NS_DEFINE_IID(kIDOMPrefsCoreIID, NS_IDOMPREFSCORE_IID); + + result = context->GetNameSpaceManager(&manager); + if (NS_OK != result) { + return JS_FALSE; + } + + result = manager->LookupName("PrefsCore", PR_TRUE, classID); + NS_RELEASE(manager); + if (NS_OK != result) { + return JS_FALSE; + } + + result = nsRepository::CreateInstance(classID, + nsnull, + kIDOMPrefsCoreIID, + (void **)&nativeThis); + if (NS_OK != result) { + return JS_FALSE; + } + + // XXX We should be calling Init() on the instance + + result = nativeThis->QueryInterface(kIScriptObjectOwnerIID, (void **)&owner); + if (NS_OK != result) { + NS_RELEASE(nativeThis); + return JS_FALSE; + } + + owner->SetScriptObject((void *)obj); + JS_SetPrivate(cx, obj, nativeThis); + + NS_RELEASE(owner); + return JS_TRUE; +} + +// +// PrefsCore class initialization +// +extern "C" NS_DOM nsresult NS_InitPrefsCoreClass(nsIScriptContext *aContext, void **aPrototype) +{ + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + JSObject *proto = nsnull; + JSObject *constructor = nsnull; + JSObject *parent_proto = nsnull; + JSObject *global = JS_GetGlobalObject(jscontext); + jsval vp; + + if ((PR_TRUE != JS_LookupProperty(jscontext, global, "PrefsCore", &vp)) || + !JSVAL_IS_OBJECT(vp) || + ((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) || + (PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) || + !JSVAL_IS_OBJECT(vp)) { + + if (NS_OK != NS_InitBaseAppCoreClass(aContext, (void **)&parent_proto)) { + return NS_ERROR_FAILURE; + } + proto = JS_InitClass(jscontext, // context + global, // global object + parent_proto, // parent proto + &PrefsCoreClass, // JSClass + PrefsCore, // JSNative ctor + 0, // ctor args + PrefsCoreProperties, // proto props + PrefsCoreMethods, // proto funcs + nsnull, // ctor props (static) + nsnull); // ctor funcs (static) + if (nsnull == proto) { + return NS_ERROR_FAILURE; + } + + } + else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) { + proto = JSVAL_TO_OBJECT(vp); + } + else { + return NS_ERROR_FAILURE; + } + + if (aPrototype) { + *aPrototype = proto; + } + return NS_OK; +} + + +// +// Method for creating a new PrefsCore JavaScript object +// +extern "C" NS_DOM nsresult NS_NewScriptPrefsCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) +{ + NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptPrefsCore"); + JSObject *proto; + JSObject *parent; + nsIScriptObjectOwner *owner; + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + nsresult result = NS_OK; + nsIDOMPrefsCore *aPrefsCore; + + if (nsnull == aParent) { + parent = nsnull; + } + else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) { + NS_RELEASE(owner); + return NS_ERROR_FAILURE; + } + NS_RELEASE(owner); + } + else { + return NS_ERROR_FAILURE; + } + + if (NS_OK != NS_InitPrefsCoreClass(aContext, (void **)&proto)) { + return NS_ERROR_FAILURE; + } + + result = aSupports->QueryInterface(kIPrefsCoreIID, (void **)&aPrefsCore); + if (NS_OK != result) { + return result; + } + + // create a js object for this class + *aReturn = JS_NewObject(jscontext, &PrefsCoreClass, proto, parent); + if (nsnull != *aReturn) { + // connect the native object to the js object + JS_SetPrivate(jscontext, (JSObject *)*aReturn, aPrefsCore); + } + else { + NS_RELEASE(aPrefsCore); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} diff --git a/xpfe/AppCores/src/nsPrefsCore.cpp b/xpfe/AppCores/src/nsPrefsCore.cpp new file mode 100644 index 00000000000..63e2f53a5a3 --- /dev/null +++ b/xpfe/AppCores/src/nsPrefsCore.cpp @@ -0,0 +1,207 @@ + +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (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 Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#include "nsPrefsCore.h" +#include "nsIBrowserWindow.h" +#include "nsIWebShell.h" +#include "pratom.h" +#include "nsIComponentManager.h" +#include "nsAppCores.h" +#include "nsAppCoresCIDs.h" +#include "nsAppCoresManager.h" + +#include "nsIScriptGlobalObject.h" + +#include "nsIScriptContext.h" +#include "nsIScriptContextOwner.h" +#include "nsIDOMDocument.h" +#include "nsIDocument.h" +#include "nsIDOMWindow.h" +#include "nsIWebShellWindow.h" + +// Globals +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIPrefsCoreIID, NS_IDOMPREFSCORE_IID); + +static NS_DEFINE_IID(kIDOMDocumentIID, nsIDOMDocument::GetIID()); +static NS_DEFINE_IID(kIDocumentIID, nsIDocument::GetIID()); + +static NS_DEFINE_IID(kPrefsCoreCID, NS_PREFSCORE_CID); +static NS_DEFINE_IID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID); + + +//---------------------------------------------------------------------------------------- +nsPrefsCore::nsPrefsCore() +//---------------------------------------------------------------------------------------- +: mTreeScriptContext(nsnull) +, mPanelScriptContext(nsnull) +, mTreeWindow(nsnull) +, mPanelWindow(nsnull) +{ + + printf("Created nsPrefsCore\n"); + +} + +//---------------------------------------------------------------------------------------- +nsPrefsCore::~nsPrefsCore() +//---------------------------------------------------------------------------------------- +{ + NS_IF_RELEASE(mTreeScriptContext); + NS_IF_RELEASE(mPanelScriptContext); + + NS_IF_RELEASE(mTreeWindow); + NS_IF_RELEASE(mPanelWindow); +} + + +NS_IMPL_ISUPPORTS_INHERITED(nsPrefsCore, nsBaseAppCore, nsIDOMPrefsCore) + +//---------------------------------------------------------------------------------------- +NS_IMETHODIMP nsPrefsCore::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +//---------------------------------------------------------------------------------------- +{ + NS_PRECONDITION(nsnull != aScriptObject, "null arg"); + nsresult res = NS_OK; + if (nsnull == mScriptObject) + { + res = NS_NewScriptPrefsCore(aContext, + (nsISupports *)(nsIDOMPrefsCore*)this, + nsnull, + &mScriptObject); + } + + *aScriptObject = mScriptObject; + return res; +} + +//---------------------------------------------------------------------------------------- +NS_IMETHODIMP nsPrefsCore::Init(const nsString& aId) +//---------------------------------------------------------------------------------------- +{ + return nsBaseAppCore::Init(aId); +} + +#if 0 +//---------------------------------------------------------------------------------------- +NS_IMETHODIMP nsPrefsCore::SetPrefsTree(nsIDOMWindow* aWin) +//---------------------------------------------------------------------------------------- +{ + if (!aWin) + return NS_OK; + mTreeWindow = aWin; + NS_ADDREF(aWin); + mTreeScriptContext = GetScriptContext(aWin); + return NS_OK; +} +#endif // 0 + +//---------------------------------------------------------------------------------------- +NS_IMETHODIMP nsPrefsCore::ChangePanel(const nsString& aURL) +// Start loading of a new prefs panel. +//---------------------------------------------------------------------------------------- +{ + NS_ASSERTION(mPanelWindow, "panel window is null"); + if (!mPanelWindow) + return NS_OK; + nsCOMPtr globalScript(do_QueryInterface(mPanelWindow)); + if (!globalScript) + return NS_ERROR_FAILURE; + nsCOMPtr webshell; + globalScript->GetWebShell(getter_AddRefs(webshell)); + if (!webshell) + return NS_ERROR_FAILURE; + webshell->LoadURL(aURL); + return NS_OK; +} + +//---------------------------------------------------------------------------------------- +NS_IMETHODIMP nsPrefsCore::PanelLoaded(nsIDOMWindow* aWin) +// Callback after loading of a new prefs panel. +//---------------------------------------------------------------------------------------- +{ + if (mPanelWindow == aWin) + return NS_OK; + if (mPanelWindow) + NS_RELEASE(mPanelWindow); + mPanelWindow = aWin; + if (!aWin) + return NS_OK; + NS_ADDREF(aWin); + mPanelScriptContext = GetScriptContext(aWin); + return NS_OK; +} + +//---------------------------------------------------------------------------------------- +static nsCOMPtr + DOMWindowToWebShellWindow(nsIDOMWindow *DOMWindow) +// horribly complicated routine simply to convert from one to the other +//---------------------------------------------------------------------------------------- +{ + nsCOMPtr webWindow; + nsCOMPtr globalScript(do_QueryInterface(DOMWindow)); + nsCOMPtr webshell; + if (globalScript) + globalScript->GetWebShell(getter_AddRefs(webshell)); + if (webshell) + { + nsCOMPtr webshellContainer; + webshell->GetContainer(*getter_AddRefs(webshellContainer)); + webWindow = do_QueryInterface(webshellContainer); + } + return webWindow; +} + +//---------------------------------------------------------------------------------------- +static nsresult Close(nsIDOMWindow*& dw) +//---------------------------------------------------------------------------------------- +{ + if (!dw) + return NS_ERROR_FAILURE; + nsIDOMWindow* top; + dw->GetTop(&top); + if (!top) + return NS_ERROR_FAILURE; + nsCOMPtr parent = DOMWindowToWebShellWindow(top); + if (parent) + parent->Close(); + NS_IF_RELEASE(dw); + return NS_OK; +} + +//---------------------------------------------------------------------------------------- +NS_IMETHODIMP nsPrefsCore::SavePrefs() +//---------------------------------------------------------------------------------------- +{ + // Do the prefs stuff... + + // Then close + return Close(mPanelWindow); +} + +//---------------------------------------------------------------------------------------- +NS_IMETHODIMP nsPrefsCore::CancelPrefs() +//---------------------------------------------------------------------------------------- +{ + // Do the prefs stuff... + + // Then close + return Close(mPanelWindow); +} diff --git a/xpfe/AppCores/src/nsPrefsCore.h b/xpfe/AppCores/src/nsPrefsCore.h new file mode 100644 index 00000000000..d3ad7cc1f5e --- /dev/null +++ b/xpfe/AppCores/src/nsPrefsCore.h @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ +#ifndef nsPrefsCorePrivate_h___ +#define nsPrefsCorePrivate_h___ + +//#include "nsAppCores.h" + +#include "nscore.h" +#include "nsString.h" +#include "nsISupports.h" + +#include "nsIDOMPrefsCore.h" +#include "nsBaseAppCore.h" + +class nsIBrowserWindow; +class nsIWebShell; +class nsIScriptContext; +class nsIDOMWindow; + +//======================================================================================== +class nsPrefsCore +//======================================================================================== + : public nsBaseAppCore + , public nsIDOMPrefsCore +{ + public: + + nsPrefsCore(); + virtual ~nsPrefsCore(); + + + NS_DECL_ISUPPORTS_INHERITED + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD Init(const nsString& aId); + NS_IMETHOD GetId(nsString& aId) { return nsBaseAppCore::GetId(aId); } + NS_IMETHOD SetDocumentCharset(const nsString& aCharset) { return nsBaseAppCore::SetDocumentCharset(aCharset); } + + NS_DECL_IDOMPREFSCORE + + protected: + + nsString mTreeScript; + nsString mPanelScript; + + nsIScriptContext* mTreeScriptContext; + nsIScriptContext* mPanelScriptContext; + + nsIDOMWindow* mTreeWindow; + nsIDOMWindow* mPanelWindow; +}; + +#endif // nsPrefsCore_h___ diff --git a/xpfe/AppCores/src/nsPrefsCoreFactory.cpp b/xpfe/AppCores/src/nsPrefsCoreFactory.cpp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/xpfe/AppCores/src/nsPrefsCoreFactory.h b/xpfe/AppCores/src/nsPrefsCoreFactory.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/xpfe/AppCores/xul/PrefsWindow.html b/xpfe/AppCores/xul/PrefsWindow.html new file mode 100644 index 00000000000..4e04cc24728 --- /dev/null +++ b/xpfe/AppCores/xul/PrefsWindow.html @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/xpfe/AppCores/xul/PrefsWindow.js b/xpfe/AppCores/xul/PrefsWindow.js new file mode 100644 index 00000000000..0a909f9cb2d --- /dev/null +++ b/xpfe/AppCores/xul/PrefsWindow.js @@ -0,0 +1,40 @@ +var prefsCore; + +function StartUp(windowName) +{ + dump("\nDoing " + windowName + " startup...\n"); + prefsCore = XPAppCoresManager.Find("PrefsCore"); + dump("Looking up PrefsCore...\n"); + if (prefsCore == null) + { + dump("Creating PrefsCore...\n"); + prefsCore = new PrefsCore(); + if (prefsCore != null) + { + dump("PrefsCore has been created.\n"); + prefsCore.Init("PrefsCore"); + if (windowName != "Top" && windowName != "Bottom") + { + prefsCore.PanelLoaded(window); + } + } + else + { + dump("PrefsCore was not created"); + } + } + else + { + dump("PrefsCore has already been created! Hurrah!\n"); + } +} + +function DoSave() +{ + prefsCore.SavePrefs(); +} + +function DoCancel() +{ + prefsCore.CancelPrefs(); +} diff --git a/xpfe/AppCores/xul/pref-appearance.html b/xpfe/AppCores/xul/pref-appearance.html new file mode 100644 index 00000000000..b85ae0df1a6 --- /dev/null +++ b/xpfe/AppCores/xul/pref-appearance.html @@ -0,0 +1,69 @@ + + + +Sample Prefs Panel + + + + + + + +
+ Appearance +
+
+ + On startup, launch + +
+ + + + + +
Navigator
Messenger
Composer
Calendar
+
+ +
+
+ + Show toolbars as + +
+ + + + +
Pictures and Text
Pictures Only
Text Only
+
+ + + diff --git a/xpfe/AppCores/xul/pref-fonts.html b/xpfe/AppCores/xul/pref-fonts.html new file mode 100644 index 00000000000..aea7b7819c9 --- /dev/null +++ b/xpfe/AppCores/xul/pref-fonts.html @@ -0,0 +1,16 @@ + + +Sample Prefs Panel + + + + + + +

Fonts panel

+

Watch this space...

+ + + + diff --git a/xpfe/AppCores/xul/pref-navigator.html b/xpfe/AppCores/xul/pref-navigator.html new file mode 100644 index 00000000000..464d36d0e58 --- /dev/null +++ b/xpfe/AppCores/xul/pref-navigator.html @@ -0,0 +1,90 @@ + + + + + + + +
+Navigator +
+
+ + + +Navigator starts with + + + + + + + +
Blank Page
Home Page
Last Page vistited
+ +Home page + + + + + + +
Clicking the Home button will take you to this page.
Location: +
+
+ +History + + + +History is a list of the pages you have previously vistited. + + + +
Pages in history expire after:days
+ + +Home page + + + +
Clear the list of sites on the location bar: + +
+ +
+
+ + \ No newline at end of file diff --git a/xpfe/AppCores/xul/prefbottom.html b/xpfe/AppCores/xul/prefbottom.html new file mode 100644 index 00000000000..d452decae1b --- /dev/null +++ b/xpfe/AppCores/xul/prefbottom.html @@ -0,0 +1,53 @@ + + + + + + + + + + + + + +
+
+
+ + + + + + + + + + +
+
+
+ + + diff --git a/xpfe/AppCores/xul/preftree.css b/xpfe/AppCores/xul/preftree.css new file mode 100644 index 00000000000..6d3afdf3eb2 --- /dev/null +++ b/xpfe/AppCores/xul/preftree.css @@ -0,0 +1,63 @@ +window { + display: block; + width: 100%; + border: thin black solid bottom; +} + +tree { + display: table; + background-color: white; + border: none; + border-spacing: 0px; + border-collapse: collapse; + width: 100%; +} + +treeitem { + display: table-row; + visibility: visible; +} + +treehead { + display: table-header-group; +} + +treebody { + display: table-row-group; +} + +treehead > treeitem { + visibility: visible; +} +treeitem[open] > treechildren > treeitem { + visibility: visible; +} +treebody > treeitem { + visibility: visible; +} + + +treecell { + display: table-cell; + color: black; + font-family: Arial; + font-size: 12pt; +} + +treehead treeitem treecell { + background-color: white; + border: thin black solid; + color: black; +} + +treeicon { + display: list-item; + list-style-image: url("http://rava/~hyatt/ClosedRead.gif"); + list-style-position: inside; +} + +treecell[selectedcell] { + background-color: yellow; +} + + diff --git a/xpfe/AppCores/xul/preftree.xul b/xpfe/AppCores/xul/preftree.xul new file mode 100644 index 00000000000..40543b9333f --- /dev/null +++ b/xpfe/AppCores/xul/preftree.xul @@ -0,0 +1,180 @@ + + + + + + + + + + function ClickChangePanel(node) + { + url = node.getAttribute('name'); + ChangePanelURL(url); + } + + function ChangePanelURL(url) + { + dump("ChangePanel(" + url + ")\n"); + var prefsCore = XPAppCoresManager.Find("PrefsCore"); + if (!prefsCore) + { + prefsCore = new PrefsCore(); + if (prefsCore) + { + prefsCore.Init("PrefsCore"); + } + } + if (prefsCore) + { + prefsCore.ChangePanel(url); + } + + return true; + } + + + + + + + + + + Appearance + + + + Fonts + + + Colors + + + + + + + + Navigator + + + + Languages + + + Applications + + + Smart Browsing + + + + + + + + Mail & News + + + + Identity + + + Mail Servers + + + News Servers + + + Addressing + + + Messages + + + Window Settings + + + Copies & Folders + + + Formatting + + + Return Receipts + + + Disk Space + + + + + + + + Composer + + + + Publish + + + + + + + + Roaming Access + + + + Server Info + + + File Selection + + + + + + + + Offline + + + + Download + + + + + + + + Advanced + + + + Publish + + + Cache + + + Proxies + + + Smart Update + + + + + + + + + + \ No newline at end of file