mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-02 20:20:00 +00:00
Converted method names to lowerStartInterCaps, following the JS convention. Combined init() and showWindow to reduce pointless verbosity in javascript usage (since they are always called together). Added a third parameter, an initial panel url, though this is as yet unsupported.
This commit is contained in:
parent
f89448d11d
commit
b1b51a930d
@ -665,8 +665,7 @@
|
||||
{
|
||||
prefwindow = Components.classes['component://netscape/prefwindow'].createInstance(Components.interfaces.nsIPrefWindow);
|
||||
}
|
||||
prefwindow.Init("navigator.js");
|
||||
prefwindow.ShowWindow(window);
|
||||
prefwindow.showWindow("navigator.js", window, "chrome://pref/content/pref-appearance.xul");
|
||||
}
|
||||
|
||||
function BrowserViewSource()
|
||||
|
@ -28,15 +28,14 @@ class nsIDOMWindow;
|
||||
[scriptable, uuid(55AF8384-E11E-11D2-915F-A053F05FF7BC)]
|
||||
interface nsIPrefWindow : nsISupports
|
||||
{
|
||||
void Init(in wstring id);
|
||||
void ShowWindow(in nsIDOMWindow currentFrontWin);
|
||||
void showWindow(in wstring id, in nsIDOMWindow currentFrontWin, in wstring panelURL);
|
||||
|
||||
void ChangePanel(in wstring url);
|
||||
void PanelLoaded(in nsIDOMWindow win);
|
||||
void changePanel(in wstring url); // called by the pref-tree click handler
|
||||
void panelLoaded(in nsIDOMWindow win); // callback notification.
|
||||
|
||||
void SavePrefs();
|
||||
void CancelPrefs();
|
||||
void SetSubstitutionVar(in unsigned long stringnum, in string val);
|
||||
void savePrefs();
|
||||
void cancelPrefs();
|
||||
void setSubstitutionVar(in unsigned long stringnum, in string val);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
|
@ -15,17 +15,6 @@ function StartUp(windowName)
|
||||
}
|
||||
if (prefwindow != null && windowName != "Top" && windowName != "Bottom")
|
||||
{
|
||||
prefwindow.PanelLoaded(window);
|
||||
prefwindow.panelLoaded(window);
|
||||
}
|
||||
}
|
||||
|
||||
function DoSave()
|
||||
{
|
||||
prefwindow.SavePrefs();
|
||||
}
|
||||
|
||||
function DoCancel()
|
||||
{
|
||||
prefwindow.CancelPrefs();
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,8 @@
|
||||
<html:td valign="right" width="160">
|
||||
<html:center>
|
||||
<html:input type="button" align="bottom" value="&helpButton.label;" />
|
||||
<html:input type="button" align="bottom" value="&cancelButton.label;" onclick="DoCancel();" />
|
||||
<html:input type="button" align="bottom" value="&okButton.label;" onclick="DoSave();" />
|
||||
<html:input type="button" align="bottom" value="&cancelButton.label;" onclick="prefwindow.cancelPrefs();" />
|
||||
<html:input type="button" align="bottom" value="&okButton.label;" onclick="prefwindow.savePrefs();" />
|
||||
</html:center>
|
||||
</html:td>
|
||||
</html:tr>
|
||||
|
@ -144,19 +144,32 @@ NS_IMPL_ISUPPORTS( nsPrefWindow, nsIPrefWindow::GetIID())
|
||||
return (sPrefWindow != nsnull);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPrefWindow::Init(const PRUnichar* aID)
|
||||
NS_IMETHODIMP nsPrefWindow::showWindow(
|
||||
const PRUnichar *id,
|
||||
nsIDOMWindow *currentFrontWin,
|
||||
const PRUnichar* panelURL)
|
||||
// The ID is currently only used to display debugging text on the console.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
nsOutputConsoleStream stream;
|
||||
nsOutputConsoleStream stream;
|
||||
char buf[512];
|
||||
stream << "Pref object initialized by "
|
||||
<< nsString(aID).ToCString(buf, sizeof(buf))
|
||||
<< nsEndl;
|
||||
#endif
|
||||
if (!mPrefs)
|
||||
if (mPrefs)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
stream << "Existing pref object reused by "
|
||||
<< nsString(id).ToCString(buf, sizeof(buf))
|
||||
<< nsEndl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
stream << "Pref object initialized by "
|
||||
<< nsString(id).ToCString(buf, sizeof(buf))
|
||||
<< nsEndl;
|
||||
#endif
|
||||
nsIPref* prefs = nsnull;
|
||||
nsresult rv = nsServiceManager::GetService(
|
||||
kPrefCID, nsIPref::GetIID(), (nsISupports**)&prefs);
|
||||
@ -166,8 +179,42 @@ NS_IMETHODIMP nsPrefWindow::Init(const PRUnichar* aID)
|
||||
}
|
||||
if (!mPrefs)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
} // nsPrefWindow::Init()
|
||||
|
||||
// (code adapted from nsToolkitCore::ShowModal. yeesh.)
|
||||
if (mWindow)
|
||||
return NS_OK;
|
||||
nsIWebShellWindow* window = nsnull;
|
||||
nsCOMPtr<nsIURL> urlObj;
|
||||
nsresult rv = NS_NewURL(getter_AddRefs(urlObj), "chrome://pref/content/");
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsIXULWindowCallbacks *cb = nsnull;
|
||||
nsCOMPtr<nsIWebShellWindow> parent;
|
||||
DOMWindowToWebShellWindow(currentFrontWin, &parent);
|
||||
appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window,
|
||||
nsnull, cb, 504, 436);
|
||||
if (window)
|
||||
{
|
||||
mWindow = window;
|
||||
nsCOMPtr<nsIWidget> parentWindowWidgetThing;
|
||||
nsresult gotParent
|
||||
= parent ? parent->GetWidget(*getter_AddRefs(parentWindowWidgetThing)) :
|
||||
NS_ERROR_FAILURE;
|
||||
// Windows OS is the only one that needs the parent disabled, or cares
|
||||
// arguably this should be done by the new window, within ShowModal...
|
||||
if (NS_SUCCEEDED(gotParent))
|
||||
parentWindowWidgetThing->Enable(PR_FALSE);
|
||||
window->ShowModal();
|
||||
if (NS_SUCCEEDED(gotParent))
|
||||
parentWindowWidgetThing->Enable(PR_TRUE);
|
||||
}
|
||||
return rv;
|
||||
} // nsPrefWindow::showWindow()
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
static PRBool CheckAndStrip(
|
||||
@ -566,47 +613,7 @@ nsresult nsPrefWindow::FinalizePrefWidgets()
|
||||
} // nsPrefWindow::FinalizePrefWidgets
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPrefWindow::ShowWindow(nsIDOMWindow* aCurrentFrontWin)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// (code adapted from nsToolkitCore::ShowModal. yeesh.)
|
||||
if (mWindow)
|
||||
return NS_OK;
|
||||
nsIWebShellWindow* window = nsnull;
|
||||
nsCOMPtr<nsIURL> urlObj;
|
||||
nsresult rv = NS_NewURL(getter_AddRefs(urlObj), "chrome://pref/content/");
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsIXULWindowCallbacks *cb = nsnull;
|
||||
nsCOMPtr<nsIWebShellWindow> parent;
|
||||
DOMWindowToWebShellWindow(aCurrentFrontWin, &parent);
|
||||
appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window,
|
||||
nsnull, cb, 504, 436);
|
||||
if (window)
|
||||
{
|
||||
mWindow = window;
|
||||
nsCOMPtr<nsIWidget> parentWindowWidgetThing;
|
||||
nsresult gotParent
|
||||
= parent ? parent->GetWidget(*getter_AddRefs(parentWindowWidgetThing)) :
|
||||
NS_ERROR_FAILURE;
|
||||
// Windows OS is the only one that needs the parent disabled, or cares
|
||||
// arguably this should be done by the new window, within ShowModal...
|
||||
if (NS_SUCCEEDED(gotParent))
|
||||
parentWindowWidgetThing->Enable(PR_FALSE);
|
||||
window->ShowModal();
|
||||
if (NS_SUCCEEDED(gotParent))
|
||||
parentWindowWidgetThing->Enable(PR_TRUE);
|
||||
}
|
||||
return rv;
|
||||
} // nsPrefWindow::ShowWindow
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPrefWindow::ChangePanel(const PRUnichar* aURL)
|
||||
NS_IMETHODIMP nsPrefWindow::changePanel(const PRUnichar* aURL)
|
||||
// Start loading of a new prefs panel.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
@ -630,7 +637,7 @@ NS_IMETHODIMP nsPrefWindow::ChangePanel(const PRUnichar* aURL)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPrefWindow::PanelLoaded(nsIDOMWindow* aWin)
|
||||
NS_IMETHODIMP nsPrefWindow::panelLoaded(nsIDOMWindow* aWin)
|
||||
// Callback after loading of a new prefs panel.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
@ -697,7 +704,7 @@ static nsresult Close(nsIDOMWindow*& dw)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPrefWindow::SavePrefs()
|
||||
NS_IMETHODIMP nsPrefWindow::savePrefs()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
FinalizePrefWidgets();
|
||||
@ -714,7 +721,7 @@ NS_IMETHODIMP nsPrefWindow::SavePrefs()
|
||||
} // nsPrefWindow::SavePrefs
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPrefWindow::CancelPrefs()
|
||||
NS_IMETHODIMP nsPrefWindow::cancelPrefs()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Do the prefs stuff...
|
||||
@ -750,7 +757,7 @@ char* nsPrefWindow::GetSubstitution(nsString& formatstr)
|
||||
} // nsPrefWindow::GetSubstitution
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPrefWindow::SetSubstitutionVar(
|
||||
NS_IMETHODIMP nsPrefWindow::setSubstitutionVar(
|
||||
PRUint32 aStringnum,
|
||||
const char* aVal)
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
@ -30,13 +30,15 @@ class nsPrefWindow
|
||||
// NS_DECL_IAPPSHELLCOMPONENT
|
||||
|
||||
// This class implements the nsIFindComponent interface functions.
|
||||
NS_IMETHOD Init(const PRUnichar *id);
|
||||
NS_IMETHOD ShowWindow(nsIDOMWindow *currentFrontWin);
|
||||
NS_IMETHOD ChangePanel(const PRUnichar *url);
|
||||
NS_IMETHOD PanelLoaded(nsIDOMWindow *win);
|
||||
NS_IMETHOD SavePrefs();
|
||||
NS_IMETHOD CancelPrefs();
|
||||
NS_IMETHOD SetSubstitutionVar(PRUint32 stringnum, const char *val);
|
||||
NS_IMETHOD showWindow(
|
||||
const PRUnichar *id,
|
||||
nsIDOMWindow *currentFrontWin,
|
||||
const PRUnichar* panelURL);
|
||||
NS_IMETHOD changePanel(const PRUnichar *url);
|
||||
NS_IMETHOD panelLoaded(nsIDOMWindow *win);
|
||||
NS_IMETHOD savePrefs();
|
||||
NS_IMETHOD cancelPrefs();
|
||||
NS_IMETHOD setSubstitutionVar(PRUint32 stringnum, const char *val);
|
||||
|
||||
enum TypeOfPref
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user