mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
40799 : [CountryPicker] Add language/country selector to ProfileCreation UI.
r=sspitzer,racham,a=msanz.
This commit is contained in:
parent
4e1cb6473a
commit
a4ade66319
@ -69,6 +69,7 @@ interface nsIProfile : nsISupports {
|
||||
|
||||
void createNewProfile(in wstring profileName,
|
||||
in wstring nativeProfileDir,
|
||||
in wstring langcode,
|
||||
in boolean useExistingDir);
|
||||
|
||||
void renameProfile(in wstring oldName, in wstring newName);
|
||||
|
@ -78,6 +78,23 @@ function onCancel()
|
||||
}
|
||||
}
|
||||
|
||||
function selectLocale(langcode)
|
||||
{
|
||||
try {
|
||||
var chromeRegistry = Components.classes["component://netscape/chrome/chrome-registry"].getService();
|
||||
if ( chromeRegistry ) {
|
||||
chromeRegistry = chromeRegistry.QueryInterface( Components.interfaces.nsIChromeRegistry );
|
||||
}
|
||||
var old_lang = chromeRegistry.getSelectedLocale("navigator");
|
||||
chromeRegistry.selectLocale(langcode, false);
|
||||
}
|
||||
catch(e) {
|
||||
dump("\n--> createPrifleWizard.js: selectLocale() failed!\n");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function onFinish()
|
||||
{
|
||||
dump("*** IN ONFINISH\n");
|
||||
@ -92,19 +109,25 @@ function onFinish()
|
||||
var profName = wizardManager.WSM.PageData["newProfile1_2"].ProfileName.value;
|
||||
dump("**** profName: "+ profName + "\n");
|
||||
var profDir = wizardManager.WSM.PageData["newProfile1_2"].ProfileDir.rootFolder;
|
||||
proceed = processCreateProfileData( profName, profDir );
|
||||
if( proceed ) {
|
||||
if( window.opener ) {
|
||||
window.opener.CreateProfile( profName, profDir );
|
||||
window.close();
|
||||
}
|
||||
|
||||
// Get langcode
|
||||
var langcode = window.frames["content"].document.getElementById("langList").selectedItem.getAttribute("data");
|
||||
proceed = processCreateProfileData( profName, profDir, langcode);
|
||||
if( proceed ) {
|
||||
if( window.opener ) {
|
||||
window.opener.CreateProfile( profName, profDir );
|
||||
window.close();
|
||||
|
||||
// select locale
|
||||
selectLocale(langcode);
|
||||
}
|
||||
else {
|
||||
profile.startApprunner( profName );
|
||||
ExitApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
/** void processCreateProfileData( void ) ;
|
||||
@ -112,7 +135,7 @@ function onFinish()
|
||||
* - in: nothing
|
||||
* - out: nothing
|
||||
**/
|
||||
function processCreateProfileData( aProfName, aProfDir )
|
||||
function processCreateProfileData( aProfName, aProfDir, langcode)
|
||||
{
|
||||
try {
|
||||
// note: deleted check for empty profName string here as this should be
|
||||
@ -165,8 +188,9 @@ function processCreateProfileData( aProfName, aProfDir )
|
||||
}
|
||||
|
||||
dump("*** going to create a new profile called " + aProfName + " in folder: " + aProfDir + "\n");
|
||||
profile.createNewProfile( aProfName, aProfDir, useExistingDir );
|
||||
return true;
|
||||
profile.createNewProfile( aProfName, aProfDir, langcode, useExistingDir );
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(e) {
|
||||
dump("*** Failed to create a profile\n");
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
<box class="box-header" id="header" value="&profileWizard.title;"/>
|
||||
<box id="contentarea" flex="1">
|
||||
<html:iframe src="about:blank" style="width: 40em; height: 17em; overflow: auto;" name="content" id="content" flex="1"/>
|
||||
<html:iframe src="about:blank" style="width: 40em; height: 23em; overflow: auto;" name="content" id="content" flex="1"/>
|
||||
</box>
|
||||
<box id="wizardButtons"/>
|
||||
<box class="box-status" id="status" value="&window.title.label;" progress=""/>
|
||||
|
@ -145,3 +145,12 @@ function setDisplayToDefaultFolder()
|
||||
// reset the display field
|
||||
updateProfileName();
|
||||
}
|
||||
|
||||
function selectionChanged()
|
||||
{
|
||||
var selected = document.getElementById("langList").selectedItem;
|
||||
dump("\n --> selectionChanged, val=" + selected.getAttribute("value") +
|
||||
", id=" + selected.getAttribute("id") +
|
||||
", data=" + selected.getAttribute("data") +
|
||||
"\n");
|
||||
}
|
||||
|
@ -56,11 +56,44 @@
|
||||
<button id="useDefault" value="&button.usedefault.label;" oncommand="setDisplayToDefaultFolder();" disabled="true"/>
|
||||
</box>
|
||||
</box>
|
||||
|
||||
<titledbox>
|
||||
<title><text value="&langSelBox.title.label;" /></title>
|
||||
|
||||
<box id="localeListbox" flex="100">
|
||||
<box flex="10" orient="vertical">
|
||||
<text class="label"
|
||||
value="&langList.txt.label;"
|
||||
accesskey="l" for="langList"/>
|
||||
<menulist id="langList"
|
||||
ref="urn:mozilla:locale:root" datasources="rdf:chrome"
|
||||
sortResource="http://www.mozilla.org/rdf/chrome#name"
|
||||
sortDirection="ascending"
|
||||
oncommand="selectionChanged()">
|
||||
|
||||
<template>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.mozilla.org/rdf/chrome#displayName"
|
||||
data="rdf:http://www.mozilla.org/rdf/chrome#name"
|
||||
uri="..."/>
|
||||
</menupopup>
|
||||
</template>
|
||||
</menulist>
|
||||
</box>
|
||||
<box flex="20" halign="right" orient="vertical">
|
||||
<spring flex="10"/>
|
||||
<!--
|
||||
<button flex="1" valign="bottom"
|
||||
value="&moreBtn.label;" />
|
||||
-->
|
||||
</box>
|
||||
</box>
|
||||
</titledbox>
|
||||
<!-- end here -->
|
||||
|
||||
<separator/>
|
||||
|
||||
<!--spring flex="1"/-->
|
||||
|
||||
<html id="finishtext">&pnl2.finish.text;</html>
|
||||
|
||||
|
||||
</window>
|
||||
|
||||
|
@ -5,4 +5,8 @@
|
||||
<!ENTITY pnl2.finish.text "Click Finish to create this new profile.">
|
||||
<!ENTITY button.choosefolder.label "Choose Folder...">
|
||||
<!ENTITY button.usedefault.label "Use Default">
|
||||
<!ENTITY pnl2.defaultPName.label "Default User">
|
||||
<!ENTITY pnl2.defaultPName.label "Default User">
|
||||
|
||||
<!ENTITY langSelBox.title.label "Language/Region Selection">
|
||||
<!ENTITY langList.txt.label "Select UI Language and Regional Content">
|
||||
<!ENTITY moreBtn.label "For more choices...">
|
||||
|
@ -523,7 +523,7 @@ nsProfile::ProcessArgs(nsICmdLineService *cmdLineArgs,
|
||||
#endif /* DEBUG_profile */
|
||||
|
||||
nsAutoString currProfileDir; currProfileDir.AssignWithConversion(currProfileDirSpec.GetNativePathCString());
|
||||
rv = CreateNewProfile(currProfileName.GetUnicode(), currProfileDir.GetUnicode(), PR_TRUE);
|
||||
rv = CreateNewProfile(currProfileName.GetUnicode(), currProfileDir.GetUnicode(), nsnull, PR_TRUE);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*profileDirSet = PR_TRUE;
|
||||
mCurrentProfileAvailable = PR_TRUE;
|
||||
@ -674,7 +674,7 @@ NS_IMETHODIMP nsProfile::GetProfileDir(const PRUnichar *profileName, nsFileSpec*
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr <nsIFileSpec> profDefaultsDir;
|
||||
|
||||
|
||||
rv = locator->GetFileLocation(
|
||||
nsSpecialFileSpec::App_ProfileDefaultsFolder50,
|
||||
getter_AddRefs(profDefaultsDir));
|
||||
@ -830,7 +830,8 @@ NS_IMETHODIMP nsProfile::SetProfileDir(const PRUnichar *profileName, nsFileSpec&
|
||||
// Creates a new profile
|
||||
NS_IMETHODIMP
|
||||
nsProfile::CreateNewProfile(const PRUnichar* profileName,
|
||||
const PRUnichar* nativeProfileDir,
|
||||
const PRUnichar* nativeProfileDir,
|
||||
const PRUnichar* langcode,
|
||||
PRBool useExistingDir)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(profileName);
|
||||
@ -916,7 +917,7 @@ nsProfile::CreateNewProfile(const PRUnichar* profileName,
|
||||
// Get profile defaults folder..
|
||||
nsCOMPtr <nsIFileSpec> profDefaultsDir;
|
||||
rv = locator->GetFileLocation(
|
||||
nsSpecialFileSpec::App_ProfileDefaultsFolder50,
|
||||
nsSpecialFileSpec::App_ProfileDefaultsFolder50_nloc,
|
||||
getter_AddRefs(profDefaultsDir));
|
||||
|
||||
if (NS_FAILED(rv) || !profDefaultsDir)
|
||||
@ -928,6 +929,16 @@ nsProfile::CreateNewProfile(const PRUnichar* profileName,
|
||||
|
||||
profDefaultsDir->GetFileSpec(&defaultsDirSpec);
|
||||
|
||||
if (langcode) {
|
||||
// caller prefers locale subdir
|
||||
nsFileSpec tmpdir;
|
||||
tmpdir = defaultsDirSpec;
|
||||
tmpdir += langcode;
|
||||
|
||||
if (tmpdir.Exists())
|
||||
defaultsDirSpec = tmpdir;
|
||||
|
||||
}
|
||||
// Copy contents from defaults folder.
|
||||
if (defaultsDirSpec.Exists() && (!useExistingDir))
|
||||
{
|
||||
@ -1522,7 +1533,7 @@ nsProfile::CreateDefaultProfile(void)
|
||||
nsAutoString dirSpecStr; dirSpecStr.AssignWithConversion(profileDirSpec.GetNativePathCString());
|
||||
|
||||
nsAutoString defaultProfileName; defaultProfileName.AssignWithConversion(DEFAULT_PROFILE_NAME);
|
||||
rv = CreateNewProfile(defaultProfileName.GetUnicode(), dirSpecStr.GetUnicode(), PR_TRUE);
|
||||
rv = CreateNewProfile(defaultProfileName.GetUnicode(), dirSpecStr.GetUnicode(), nsnull, PR_TRUE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user