зеркало из https://github.com/mozilla/pjs.git
bug 235763 Print dialog show list printer descriptions if available
patch by Roland Mainz <roland.mainz@nrubsig.org> r+sr=roc
This commit is contained in:
Родитель
7a225dfb0a
Коммит
6700a8a774
|
@ -1033,6 +1033,11 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
||||||
mGlobalPrinterList = new nsStringArray();
|
mGlobalPrinterList = new nsStringArray();
|
||||||
if (!mGlobalPrinterList)
|
if (!mGlobalPrinterList)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
nsresult rv;
|
||||||
|
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
|
|
||||||
#ifdef USE_XPRINT
|
#ifdef USE_XPRINT
|
||||||
XPPrinterList plist = XpuGetPrinterList(nsnull, &mGlobalNumPrinters);
|
XPPrinterList plist = XpuGetPrinterList(nsnull, &mGlobalNumPrinters);
|
||||||
|
@ -1040,9 +1045,13 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
||||||
if (plist && (mGlobalNumPrinters > 0))
|
if (plist && (mGlobalNumPrinters > 0))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for( i = 0 ; i < mGlobalNumPrinters ; i++ )
|
for( i = 0 ; i < mGlobalNumPrinters ; i++ )
|
||||||
{
|
{
|
||||||
mGlobalPrinterList->AppendString(nsString(NS_ConvertASCIItoUCS2(plist[i].name)));
|
/* Add name to our list of printers... */
|
||||||
|
mGlobalPrinterList->AppendString(nsString(NS_ConvertUTF8toUCS2(plist[i].name)));
|
||||||
|
|
||||||
|
/* ... and store the description text for this printer */
|
||||||
|
pPrefs->SetCharPref(nsPrintfCString(256, "print.printer_%s.printer_description", plist[i].name).get(), plist[i].desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
XpuFreePrinterList(plist);
|
XpuFreePrinterList(plist);
|
||||||
|
@ -1050,7 +1059,6 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
||||||
#endif /* USE_XPRINT */
|
#endif /* USE_XPRINT */
|
||||||
|
|
||||||
#ifdef USE_POSTSCRIPT
|
#ifdef USE_POSTSCRIPT
|
||||||
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID);
|
|
||||||
PRBool psPrintModuleEnabled = PR_TRUE;
|
PRBool psPrintModuleEnabled = PR_TRUE;
|
||||||
|
|
||||||
const char *val = PR_GetEnv("MOZILLA_POSTSCRIPT_ENABLED");
|
const char *val = PR_GetEnv("MOZILLA_POSTSCRIPT_ENABLED");
|
||||||
|
@ -1060,10 +1068,8 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (pPrefs) {
|
if (NS_FAILED(pPrefs->GetBoolPref("print.postscript.enabled", &psPrintModuleEnabled))) {
|
||||||
if (NS_FAILED(pPrefs->GetBoolPref("print.postscript.enabled", &psPrintModuleEnabled))) {
|
psPrintModuleEnabled = PR_TRUE;
|
||||||
psPrintModuleEnabled = PR_TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1076,9 +1082,7 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
||||||
printerList = PR_GetEnv("MOZILLA_POSTSCRIPT_PRINTER_LIST");
|
printerList = PR_GetEnv("MOZILLA_POSTSCRIPT_PRINTER_LIST");
|
||||||
|
|
||||||
if (!printerList) {
|
if (!printerList) {
|
||||||
if (pPrefs) {
|
(void) pPrefs->CopyCharPref("print.printer_list", &printerList);
|
||||||
(void) pPrefs->CopyCharPref("print.printer_list", &printerList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (printerList) {
|
if (printerList) {
|
||||||
|
|
|
@ -1034,6 +1034,11 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
||||||
mGlobalPrinterList = new nsStringArray();
|
mGlobalPrinterList = new nsStringArray();
|
||||||
if (!mGlobalPrinterList)
|
if (!mGlobalPrinterList)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
nsresult rv;
|
||||||
|
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
|
|
||||||
#ifdef USE_XPRINT
|
#ifdef USE_XPRINT
|
||||||
XPPrinterList plist = XpuGetPrinterList(nsnull, &mGlobalNumPrinters);
|
XPPrinterList plist = XpuGetPrinterList(nsnull, &mGlobalNumPrinters);
|
||||||
|
@ -1041,9 +1046,13 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
||||||
if (plist && (mGlobalNumPrinters > 0))
|
if (plist && (mGlobalNumPrinters > 0))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for( i = 0 ; i < mGlobalNumPrinters ; i++ )
|
for( i = 0 ; i < mGlobalNumPrinters ; i++ )
|
||||||
{
|
{
|
||||||
mGlobalPrinterList->AppendString(nsString(NS_ConvertASCIItoUCS2(plist[i].name)));
|
/* Add name to our list of printers... */
|
||||||
|
mGlobalPrinterList->AppendString(nsString(NS_ConvertUTF8toUCS2(plist[i].name)));
|
||||||
|
|
||||||
|
/* ... and store the description text for this printer */
|
||||||
|
pPrefs->SetCharPref(nsPrintfCString(256, "print.printer_%s.printer_description", plist[i].name).get(), plist[i].desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
XpuFreePrinterList(plist);
|
XpuFreePrinterList(plist);
|
||||||
|
@ -1051,7 +1060,6 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
||||||
#endif /* USE_XPRINT */
|
#endif /* USE_XPRINT */
|
||||||
|
|
||||||
#ifdef USE_POSTSCRIPT
|
#ifdef USE_POSTSCRIPT
|
||||||
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID);
|
|
||||||
PRBool psPrintModuleEnabled = PR_TRUE;
|
PRBool psPrintModuleEnabled = PR_TRUE;
|
||||||
|
|
||||||
const char *val = PR_GetEnv("MOZILLA_POSTSCRIPT_ENABLED");
|
const char *val = PR_GetEnv("MOZILLA_POSTSCRIPT_ENABLED");
|
||||||
|
@ -1061,10 +1069,8 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (pPrefs) {
|
if (NS_FAILED(pPrefs->GetBoolPref("print.postscript.enabled", &psPrintModuleEnabled))) {
|
||||||
if (NS_FAILED(pPrefs->GetBoolPref("print.postscript.enabled", &psPrintModuleEnabled))) {
|
psPrintModuleEnabled = PR_TRUE;
|
||||||
psPrintModuleEnabled = PR_TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1077,9 +1083,7 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
||||||
printerList = PR_GetEnv("MOZILLA_POSTSCRIPT_PRINTER_LIST");
|
printerList = PR_GetEnv("MOZILLA_POSTSCRIPT_PRINTER_LIST");
|
||||||
|
|
||||||
if (!printerList) {
|
if (!printerList) {
|
||||||
if (pPrefs) {
|
(void) pPrefs->CopyCharPref("print.printer_list", &printerList);
|
||||||
(void) pPrefs->CopyCharPref("print.printer_list", &printerList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (printerList) {
|
if (printerList) {
|
||||||
|
|
|
@ -60,6 +60,7 @@ function initDialog()
|
||||||
dialog = new Object;
|
dialog = new Object;
|
||||||
|
|
||||||
dialog.propertiesButton = document.getElementById("properties");
|
dialog.propertiesButton = document.getElementById("properties");
|
||||||
|
dialog.descText = document.getElementById("descText");
|
||||||
|
|
||||||
dialog.destGroup = document.getElementById("destGroup");
|
dialog.destGroup = document.getElementById("destGroup");
|
||||||
dialog.fileRadio = document.getElementById("fileRadio");
|
dialog.fileRadio = document.getElementById("fileRadio");
|
||||||
|
@ -134,6 +135,20 @@ function doEnablePrintToFile(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------
|
||||||
|
function getPrinterDescription(printerName)
|
||||||
|
{
|
||||||
|
var s = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
/* This may not work with non-ASCII test (see bug 235763 comment #16) */
|
||||||
|
s = gPrefs.getCharPref("print.printer_" + printerName + ".printer_description")
|
||||||
|
} catch(e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
function listElement(aListElement)
|
function listElement(aListElement)
|
||||||
{
|
{
|
||||||
|
@ -146,13 +161,16 @@ listElement.prototype =
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
// remove the menupopup node child of the menulist.
|
// remove the menupopup node child of the menulist.
|
||||||
this.listElement.removeChild(this.listElement.firstChild);
|
var popup = this.listElement.firstChild;
|
||||||
|
if (popup) {
|
||||||
|
this.listElement.removeChild(popup);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
appendPrinterNames:
|
appendPrinterNames:
|
||||||
function (aDataObject)
|
function (aDataObject)
|
||||||
{
|
{
|
||||||
var popupNode = document.createElement("menupopup");
|
var list = document.getElementById("printerList");
|
||||||
var strDefaultPrinterName = "";
|
var strDefaultPrinterName = "";
|
||||||
var printerName;
|
var printerName;
|
||||||
|
|
||||||
|
@ -163,10 +181,8 @@ listElement.prototype =
|
||||||
var printerNameStr = printerName.toString();
|
var printerNameStr = printerName.toString();
|
||||||
if (strDefaultPrinterName == "")
|
if (strDefaultPrinterName == "")
|
||||||
strDefaultPrinterName = printerNameStr;
|
strDefaultPrinterName = printerNameStr;
|
||||||
var itemNode = document.createElement("menuitem");
|
|
||||||
itemNode.setAttribute("value", printerNameStr);
|
list.appendItem(printerNameStr, printerNameStr, getPrinterDescription(printerNameStr));
|
||||||
itemNode.setAttribute("label", printerNameStr);
|
|
||||||
popupNode.appendChild(itemNode);
|
|
||||||
}
|
}
|
||||||
if (strDefaultPrinterName != "") {
|
if (strDefaultPrinterName != "") {
|
||||||
this.listElement.removeAttribute("disabled");
|
this.listElement.removeAttribute("disabled");
|
||||||
|
@ -186,7 +202,6 @@ listElement.prototype =
|
||||||
doEnablePrintToFile(false);
|
doEnablePrintToFile(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.listElement.appendChild(popupNode);
|
|
||||||
return strDefaultPrinterName;
|
return strDefaultPrinterName;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -213,6 +228,8 @@ function setPrinterDefaultsForSelectedPrinter()
|
||||||
{
|
{
|
||||||
gPrintSettings.printerName = dialog.printerList.value;
|
gPrintSettings.printerName = dialog.printerList.value;
|
||||||
|
|
||||||
|
dialog.descText.value = getPrinterDescription(gPrintSettings.printerName);
|
||||||
|
|
||||||
// First get any defaults from the printer
|
// First get any defaults from the printer
|
||||||
printService.initPrintSettingsFromPrinter(gPrintSettings.printerName, gPrintSettings);
|
printService.initPrintSettingsFromPrinter(gPrintSettings.printerName, gPrintSettings);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
Dan Rosen <dr@netscape.com>
|
Dan Rosen <dr@netscape.com>
|
||||||
Jessica Blanco <jblanco@us.ibm.com>
|
Jessica Blanco <jblanco@us.ibm.com>
|
||||||
Asko Tontti <atontti@cc.hut.fi>
|
Asko Tontti <atontti@cc.hut.fi>
|
||||||
Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
Roland Mainz <roland.mainz@nrubsig.org>
|
||||||
|
|
||||||
Alternatively, the contents of this file may be used under the terms of
|
Alternatively, the contents of this file may be used under the terms of
|
||||||
either of the GNU General Public License Version 2 or later (the "GPL"),
|
either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||||
|
@ -69,20 +69,15 @@
|
||||||
<rows>
|
<rows>
|
||||||
<row align="center">
|
<row align="center">
|
||||||
<hbox align="center" pack="end">
|
<hbox align="center" pack="end">
|
||||||
<label value="&printTo.label;"/>
|
<label id="descTextLabel" control="descText" value="&descText.label;"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
<radiogroup id="destGroup" orient="horizontal">
|
<label id="descText" flex="1" value="-" />
|
||||||
<radio id="printerRadio" label="&printerRadio.label;" oncommand="if (!this.disabled) doEnablePrintToFile(false);"/>
|
|
||||||
<radio id="fileRadio" label="&fileRadio.label;" oncommand="if (!this.disabled) doEnablePrintToFile(true);"/>
|
|
||||||
</radiogroup>
|
|
||||||
</row>
|
</row>
|
||||||
<row align="center">
|
<row align="center">
|
||||||
<hbox align="center" pack="end">
|
<hbox align="center" pack="end">
|
||||||
<label id="printerLabel" value="&printerInput.label;"/>
|
<label id="printerLabel" value="&printerInput.label;"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
<menulist id="printerList" flex="1" oncommand="setPrinterDefaultsForSelectedPrinter();">
|
<menulist id="printerList" flex="1" type="description" oncommand="setPrinterDefaultsForSelectedPrinter();"/>
|
||||||
<menupopup/>
|
|
||||||
</menulist>
|
|
||||||
<button id="properties" label="&propertiesButton.label;" oncommand="displayPropertiesDialog();"/>
|
<button id="properties" label="&propertiesButton.label;" oncommand="displayPropertiesDialog();"/>
|
||||||
</row>
|
</row>
|
||||||
<row align="center">
|
<row align="center">
|
||||||
|
@ -92,6 +87,15 @@
|
||||||
<textbox id="fileInput" flex="1" onblur="stripTrailingWhitespace(this)"/>
|
<textbox id="fileInput" flex="1" onblur="stripTrailingWhitespace(this)"/>
|
||||||
<button id="chooseFile" label="&chooseButton.label;" oncommand="onChooseFile()"/>
|
<button id="chooseFile" label="&chooseButton.label;" oncommand="onChooseFile()"/>
|
||||||
</row>
|
</row>
|
||||||
|
<row align="center">
|
||||||
|
<hbox align="center" pack="end">
|
||||||
|
<label value="&printTo.label;"/>
|
||||||
|
</hbox>
|
||||||
|
<radiogroup id="destGroup" orient="horizontal">
|
||||||
|
<radio id="printerRadio" label="&printerRadio.label;" oncommand="if (!this.disabled) doEnablePrintToFile(false);"/>
|
||||||
|
<radio id="fileRadio" label="&fileRadio.label;" oncommand="if (!this.disabled) doEnablePrintToFile(true);"/>
|
||||||
|
</radiogroup>
|
||||||
|
</row>
|
||||||
</rows>
|
</rows>
|
||||||
|
|
||||||
</grid>
|
</grid>
|
||||||
|
|
|
@ -11,10 +11,11 @@
|
||||||
<!ENTITY fileRadio.label "File">
|
<!ENTITY fileRadio.label "File">
|
||||||
|
|
||||||
<!ENTITY propertiesButton.label "Properties...">
|
<!ENTITY propertiesButton.label "Properties...">
|
||||||
|
<!ENTITY descText.label "Printer Description:">
|
||||||
<!ENTITY printer.label "Printer">
|
<!ENTITY printer.label "Printer">
|
||||||
<!ENTITY printerInput.label "Printer:">
|
<!ENTITY printerInput.label "Printer Name:">
|
||||||
<!ENTITY fileInput.label "File:">
|
<!ENTITY fileInput.label "File Name:">
|
||||||
<!ENTITY chooseButton.label "Choose File...">
|
<!ENTITY chooseButton.label "Select File...">
|
||||||
|
|
||||||
<!ENTITY printrangeGroup.label "Print Range">
|
<!ENTITY printrangeGroup.label "Print Range">
|
||||||
<!ENTITY allpagesRadio.label "All Pages">
|
<!ENTITY allpagesRadio.label "All Pages">
|
||||||
|
|
Загрузка…
Ссылка в новой задаче