Dynamic charset menu in Composer. Bug #38079

This commit is contained in:
cata%netscape.com 2000-05-16 22:20:18 +00:00
Родитель 961c3b7a46
Коммит 50782fc359
4 изменённых файлов: 162 добавлений и 1 удалений

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

@ -31,6 +31,7 @@
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
<?xul-overlay href="chrome://global/content/tasksOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/sidebar/sidebarOverlay.xul"?>
<?xul-overlay href="chrome://global/content/charsetOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://editor/locale/editor.dtd">
@ -105,12 +106,15 @@
<menuitem id="viewSourceMenuitem"/>
<menuitem id="viewParagraphMarks"/>
<menuseparator />
<!-- Deprecated BEGIN
<menu id="charsetMenu"/>
<menu id="charsetMenu1"/>
<menu id="charsetMenu2"/>
<menu id="charsetMenu3"/>
<menu id="charsetMenu4"/>
<menu id="charsetMenu5"/>
END of Deprecated -->
<menu id = "composerCharsetMenu" />
</menupopup>
</menu>

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

@ -62,6 +62,7 @@ static const char * kURINC_BrowserMore5CharsetMenuRoot = "NC:BrowserMore5Charset
static const char * kURINC_BrowserMore6CharsetMenuRoot = "NC:BrowserMore6CharsetMenuRoot";
static const char * kURINC_MaileditCharsetMenuRoot = "NC:MaileditCharsetMenuRoot";
static const char * kURINC_MailviewCharsetMenuRoot = "NC:MailviewCharsetMenuRoot";
static const char * kURINC_ComposerCharsetMenuRoot = "NC:ComposerCharsetMenuRoot";
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Name);
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Checked);
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, BookmarkSeparator);
@ -114,6 +115,7 @@ private:
static nsIRDFResource * kNC_BrowserMore6CharsetMenuRoot;
static nsIRDFResource * kNC_MaileditCharsetMenuRoot;
static nsIRDFResource * kNC_MailviewCharsetMenuRoot;
static nsIRDFResource * kNC_ComposerCharsetMenuRoot;
static nsIRDFResource * kNC_Name;
static nsIRDFResource * kNC_Checked;
static nsIRDFResource * kNC_CharsetDetector;
@ -124,6 +126,7 @@ private:
nsVoidArray mBrowserMenu;
nsVoidArray mMailviewMenu;
nsVoidArray mComposerMenu;
nsresult Init();
nsresult Done();
@ -137,6 +140,8 @@ private:
nsresult InitMailviewMenu();
nsresult InitComposerMenu();
nsresult InitStaticMenu(nsIRDFService * aRDFServ,
nsICharsetConverterManager2 * aCCMan, nsISupportsArray * aDecs,
nsIRDFResource * aResource, char * aKey, nsVoidArray * aArray);
@ -305,6 +310,7 @@ nsIRDFResource * nsCharsetMenu::kNC_BrowserMore5CharsetMenuRoot = NULL;
nsIRDFResource * nsCharsetMenu::kNC_BrowserMore6CharsetMenuRoot = NULL;
nsIRDFResource * nsCharsetMenu::kNC_MaileditCharsetMenuRoot = NULL;
nsIRDFResource * nsCharsetMenu::kNC_MailviewCharsetMenuRoot = NULL;
nsIRDFResource * nsCharsetMenu::kNC_ComposerCharsetMenuRoot = NULL;
nsIRDFResource * nsCharsetMenu::kNC_Name = NULL;
nsIRDFResource * nsCharsetMenu::kNC_Checked = NULL;
nsIRDFResource * nsCharsetMenu::kNC_CharsetDetector = NULL;
@ -322,6 +328,7 @@ nsCharsetMenu::nsCharsetMenu()
InitBrowserMenu();
InitMaileditMenu();
InitMailviewMenu();
InitComposerMenu();
}
nsCharsetMenu::~nsCharsetMenu()
@ -330,6 +337,7 @@ nsCharsetMenu::~nsCharsetMenu()
FreeMenuItemArray(&mBrowserMenu);
FreeMenuItemArray(&mMailviewMenu);
FreeMenuItemArray(&mComposerMenu);
PR_AtomicDecrement(&g_InstanceCount);
}
@ -354,6 +362,7 @@ nsresult nsCharsetMenu::Init()
rdfServ->GetResource(kURINC_BrowserMore6CharsetMenuRoot, &kNC_BrowserMore6CharsetMenuRoot);
rdfServ->GetResource(kURINC_MaileditCharsetMenuRoot, &kNC_MaileditCharsetMenuRoot);
rdfServ->GetResource(kURINC_MailviewCharsetMenuRoot, &kNC_MailviewCharsetMenuRoot);
rdfServ->GetResource(kURINC_ComposerCharsetMenuRoot, &kNC_ComposerCharsetMenuRoot);
rdfServ->GetResource(kURINC_Name, &kNC_Name);
rdfServ->GetResource(kURINC_Checked, &kNC_Checked);
rdfServ->GetResource(kURINC_CharsetDetector, &kNC_CharsetDetector);
@ -388,6 +397,8 @@ nsresult nsCharsetMenu::Init()
if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_MailviewCharsetMenuRoot, NULL);
if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_ComposerCharsetMenuRoot, NULL);
if (NS_FAILED(res)) goto done;
res = rdfServ->RegisterDataSource(this, PR_FALSE);
@ -424,6 +435,7 @@ done:
NS_IF_RELEASE(kNC_BrowserMore6CharsetMenuRoot);
NS_IF_RELEASE(kNC_MaileditCharsetMenuRoot);
NS_IF_RELEASE(kNC_MailviewCharsetMenuRoot);
NS_IF_RELEASE(kNC_ComposerCharsetMenuRoot);
NS_IF_RELEASE(kNC_Name);
NS_IF_RELEASE(kNC_Checked);
NS_IF_RELEASE(kNC_CharsetDetector);
@ -599,6 +611,29 @@ nsresult nsCharsetMenu::InitMailviewMenu()
return res;
}
nsresult nsCharsetMenu::InitComposerMenu()
{
nsresult res = NS_OK;
NS_WITH_SERVICE(nsIRDFService, rdfServ, kRDFServiceCID, &res);
if (NS_FAILED(res)) return res;
NS_WITH_SERVICE(nsICharsetConverterManager2, ccMan, kCharsetConverterManagerCID, &res);
if (NS_FAILED(res)) return res;
nsCOMPtr<nsISupportsArray> decs;
res = ccMan->GetDecoderList(getter_AddRefs(decs));
if (NS_FAILED(res)) return res;
// even if we fail, the show must go on
char * prefKey = "intl.charsetmenu.browser.static";
res = InitStaticMenu(rdfServ, ccMan, decs, kNC_ComposerCharsetMenuRoot,
prefKey, &mComposerMenu);
NS_ASSERTION(NS_SUCCEEDED(res), "error initializing composer static charset menu");
return res;
}
nsresult nsCharsetMenu::InitStaticMenu(
nsIRDFService * aRDFServ,
nsICharsetConverterManager2 * aCCMan,

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

@ -36,6 +36,25 @@ function MailMultiplexHandler(event)
}
}
function ComposerMultiplexHandler(event)
{
var node = event.target;
var name = node.getAttribute('name');
var charset;
if (name == 'detectorGroup') {
SelectDetector(event, true);
} else if (name == 'charsetGroup') {
charset = node.getAttribute('id');
charset = charset.substring('charset.'.length, charset.length)
EditorSetDocumentCharacterSet(charset);
} else if (name == 'charsetCustomize') {
//do nothing - please remove this else statement, once the charset prefs moves to the pref window
} else {
EditorSetDocumentCharacterSet(node.getAttribute('id'));
}
}
function SetDefaultCharacterSet(charset)
{
dump("Charset Overlay menu item pressed: " + charset + "\n");

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

@ -9,6 +9,109 @@
<script language="JavaScript" src="chrome://global/content/charsetOverlay.js"/>
<!-- Composer Charset Menu -->
<menu id="composerCharsetMenu" value="&charsetMenu.label;" datasources="rdf:charset-menu" ref="NC:ComposerCharsetMenuRoot" oncommand="ComposerMultiplexHandler(event)" oncreate="UpdateMenus()">
<template>
<rule rdf:type="http://home.netscape.com/NC-rdf#CharsetDetector">
<menupopup>
<menuitem type="radio" name="detectorGroup" checked="rdf:http://home.netscape.com/NC-rdf#Checked" uri="..." value="rdf:http://home.netscape.com/NC-rdf#Name"/>
</menupopup>
</rule>
<rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">
<menupopup>
<menuseparator uri="..." />
</menupopup>
</rule>
<rule>
<menupopup>
<menuitem type="radio" name="charsetGroup" checked="rdf:http://home.netscape.com/NC-rdf#Checked" uri="..." value="rdf:http://home.netscape.com/NC-rdf#Name"/>
</menupopup>
</rule>
</template>
<menupopup>
<menu value="&charsetMenuMore1.label;" datasources="rdf:charset-menu" ref="NC:BrowserMore1CharsetMenuRoot">
<template>
<rule>
<menupopup>
<menuitem uri="..." value="rdf:http://home.netscape.com/NC-rdf#Name"/>
</menupopup>
</rule>
</template>
<menupopup>
</menupopup>
</menu>
<menu value="&charsetMenuMore2.label;" datasources="rdf:charset-menu" ref="NC:BrowserMore2CharsetMenuRoot">
<template>
<rule>
<menupopup>
<menuitem uri="..." value="rdf:http://home.netscape.com/NC-rdf#Name"/>
</menupopup>
</rule>
</template>
<menupopup>
</menupopup>
</menu>
<menu value="&charsetMenuMore3.label;" datasources="rdf:charset-menu" ref="NC:BrowserMore3CharsetMenuRoot">
<template>
<rule>
<menupopup>
<menuitem uri="..." value="rdf:http://home.netscape.com/NC-rdf#Name"/>
</menupopup>
</rule>
</template>
<menupopup>
</menupopup>
</menu>
<menu value="&charsetMenuMore4.label;" datasources="rdf:charset-menu" ref="NC:BrowserMore4CharsetMenuRoot">
<template>
<rule>
<menupopup>
<menuitem uri="..." value="rdf:http://home.netscape.com/NC-rdf#Name"/>
</menupopup>
</rule>
</template>
<menupopup>
</menupopup>
</menu>
<menu value="&charsetMenuMore5.label;" datasources="rdf:charset-menu" ref="NC:BrowserMore5CharsetMenuRoot">
<template>
<rule>
<menupopup>
<menuitem uri="..." value="rdf:http://home.netscape.com/NC-rdf#Name"/>
</menupopup>
</rule>
</template>
<menupopup>
</menupopup>
</menu>
<menu value="&charsetMenuMore6.label;" datasources="rdf:charset-menu" ref="NC:BrowserMore6CharsetMenuRoot">
<template>
<rule>
<menupopup>
<menuitem uri="..." value="rdf:http://home.netscape.com/NC-rdf#Name"/>
</menupopup>
</rule>
</template>
<menupopup>
</menupopup>
</menu>
<menu value="&charsetMenuMore.label;" datasources="rdf:charset-menu" ref="NC:BrowserMoreCharsetMenuRoot">
<template>
<rule>
<menupopup>
<menuitem uri="..." value="rdf:http://home.netscape.com/NC-rdf#Name"/>
</menupopup>
</rule>
</template>
<menupopup>
</menupopup>
</menu>
<menuseparator />
<menuitem value="&charsetCustomize.label;" />
</menupopup>
</menu>
<!-- Mail View Charset Menu -->
<menu id="mailviewCharsetMenu" value="&charsetMenu.label;" datasources="rdf:charset-menu" ref="NC:MailviewCharsetMenuRoot" oncommand="MailMultiplexHandler(event)" oncreate="UpdateCharsetDetector()">
<template>