Rearranged the prefs frames, fixed the window size, instantiated the prefs window from C++ (from new ShowWindow() call).

git-svn-id: svn://10.0.0.236/trunk@25491 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mcmullen%netscape.com
1999-03-29 23:39:38 +00:00
parent baec78bd40
commit 776b866b01
7 changed files with 111 additions and 20 deletions

View File

@@ -5,6 +5,8 @@ interface PrefsCore : BaseAppCore
void PrefsCore();
void ShowWindow(in Window currentFrontWin);
void ChangePanel(in wstring url);
void PanelLoaded(in Window win);

View File

@@ -35,6 +35,8 @@ class nsIDOMPrefsCore : public nsIDOMBaseAppCore {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IDOMPREFSCORE_IID; return iid; }
NS_IMETHOD ShowWindow(nsIDOMWindow* aCurrentFrontWin)=0;
NS_IMETHOD ChangePanel(const nsString& aUrl)=0;
NS_IMETHOD PanelLoaded(nsIDOMWindow* aWin)=0;
@@ -46,6 +48,7 @@ public:
#define NS_DECL_IDOMPREFSCORE \
NS_IMETHOD ShowWindow(nsIDOMWindow* aCurrentFrontWin); \
NS_IMETHOD ChangePanel(const nsString& aUrl); \
NS_IMETHOD PanelLoaded(nsIDOMWindow* aWin); \
NS_IMETHOD SavePrefs(); \
@@ -54,6 +57,7 @@ public:
#define NS_FORWARD_IDOMPREFSCORE(_to) \
NS_IMETHOD ShowWindow(nsIDOMWindow* aCurrentFrontWin) { return _to##ShowWindow(aCurrentFrontWin); } \
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(); } \

View File

@@ -130,6 +130,48 @@ ResolvePrefsCore(JSContext *cx, JSObject *obj, jsval id)
}
//
// Native method ShowWindow
//
PR_STATIC_CALLBACK(JSBool)
PrefsCoreShowWindow(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->ShowWindow(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function ShowWindow requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method ChangePanel
//
@@ -306,6 +348,7 @@ static JSPropertySpec PrefsCoreProperties[] =
//
static JSFunctionSpec PrefsCoreMethods[] =
{
{"ShowWindow", PrefsCoreShowWindow, 1},
{"ChangePanel", PrefsCoreChangePanel, 1},
{"PanelLoaded", PrefsCorePanelLoaded, 1},
{"SavePrefs", PrefsCoreSavePrefs, 0},

View File

@@ -19,13 +19,18 @@
*/
#include "nsPrefsCore.h"
#include "nsIURL.h"
#include "nsIBrowserWindow.h"
#include "nsIWebShell.h"
#include "pratom.h"
#include "nsIComponentManager.h"
#include "nsAppCores.h"
#include "nsAppCoresCIDs.h"
#include "nsAppShellCIDs.h"
#include "nsAppCoresManager.h"
#include "nsIAppShellService.h"
#include "nsIServiceManager.h"
#include "nsIScriptGlobalObject.h"
@@ -42,10 +47,11 @@ 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(kIAppShellServiceIID, NS_IAPPSHELL_SERVICE_IID);
static NS_DEFINE_IID(kPrefsCoreCID, NS_PREFSCORE_CID);
static NS_DEFINE_IID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID);
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
//----------------------------------------------------------------------------------------
nsPrefsCore::nsPrefsCore()
@@ -113,6 +119,44 @@ NS_IMETHODIMP nsPrefsCore::SetPrefsTree(nsIDOMWindow* aWin)
}
#endif // 0
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsPrefsCore::ShowWindow(nsIDOMWindow* /*aCurrentFrontWin*/)
//----------------------------------------------------------------------------------------
{
// Get app shell service.
nsIAppShellService *appShell;
nsresult rv = nsServiceManager::GetService(kAppShellServiceCID,
kIAppShellServiceIID,
(nsISupports**)&appShell);
if (NS_FAILED(rv))
return rv;
nsString controllerCID = "43147b80-8a39-11d2-9938-0080c7cb1081";
nsIWebShellWindow *newWindow;
nsIURL *url;
rv = NS_NewURL(&url, "resource:/res/samples/PrefsWindow.html");
if (NS_FAILED(rv))
return rv;
// Create "save to disk" nsIXULCallbacks...
//nsIXULWindowCallbacks *cb = new nsFindDialogCallbacks( aURL, aContentType );
nsIXULWindowCallbacks *cb = nsnull;
rv = appShell->CreateTopLevelWindow( nsnull,
url,
controllerCID,
newWindow,
nsnull,
cb,
504,
346 );
NS_RELEASE(url);
return rv;
} // nsPrefsCore::ShowPrefsWindow
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsPrefsCore::ChangePanel(const nsString& aURL)
// Start loading of a new prefs panel.

View File

@@ -4,16 +4,15 @@
</script>
</head>
<FRAMESET Rows="*,40" onload = "return StartUp('Top');" border=no>
<FRAMESET cols="128,*" >
<FRAME NAME=preftree SRC="preftree.xul" scrolling="auto" border="yes">
<FRAME NAME=prefpane SRC="pref-appearance.html" scrolling="no" border="no">
<FRAMESET cols="120,*" border="no">
<FRAME NAME=preftree SRC="preftree.xul" scrolling="auto" border="no">
<FRAMESET Rows="*,40" onload = "return StartUp('Top');" border=no>
<FRAME NAME=prefpane SRC="pref-appearance.html" scrolling="no" border="no">
<FRAME NAME=prefbottom SRC="prefbottom.html" border="no" scrolling="no">
</FRAMESET>
<FRAME NAME=prefbottom SRC="prefbottom.html" border="no" scrolling="no">
</FRAMESET>
</html>

View File

@@ -13,10 +13,6 @@ function StartUp(windowName)
{
dump("PrefsCore has been created.\n");
prefsCore.Init("PrefsCore");
if (windowName != "Top" && windowName != "Bottom")
{
prefsCore.PanelLoaded(window);
}
}
else
{
@@ -27,6 +23,10 @@ function StartUp(windowName)
{
dump("PrefsCore has already been created! Hurrah!\n");
}
if (prefsCore != null && windowName != "Top" && windowName != "Bottom")
{
prefsCore.PanelLoaded(window);
}
}
function DoSave()

View File

@@ -312,16 +312,15 @@
function DoPreferences()
{
var toolkitCore = XPAppCoresManager.Find("ToolkitCore");
if (!toolkitCore) {
toolkitCore = new ToolkitCore();
if (toolkitCore) {
toolkitCore.Init("ToolkitCore");
var prefsCore = XPAppCoresManager.Find("PrefsCore");
if (!prefsCore) {
prefsCore = new PrefsCore();
if (prefsCore) {
prefsCore.Init("PrefsCore");
}
}
if (toolkitCore) {
toolkitCore.ShowWindow("resource:/res/samples/PrefsWindow.html",
window);
if (prefsCore) {
prefsCore.ShowWindow(window);
}
}