diff --git a/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp b/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp index 24bc107deef..ba213d2469d 100644 --- a/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp +++ b/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp @@ -1033,6 +1033,11 @@ nsresult GlobalPrinters::InitializeGlobalPrinters () mGlobalPrinterList = new nsStringArray(); if (!mGlobalPrinterList) return NS_ERROR_OUT_OF_MEMORY; + + nsresult rv; + nsCOMPtr pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv); + if (NS_FAILED(rv)) + return rv; #ifdef USE_XPRINT XPPrinterList plist = XpuGetPrinterList(nsnull, &mGlobalNumPrinters); @@ -1040,9 +1045,13 @@ nsresult GlobalPrinters::InitializeGlobalPrinters () if (plist && (mGlobalNumPrinters > 0)) { 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); @@ -1050,7 +1059,6 @@ nsresult GlobalPrinters::InitializeGlobalPrinters () #endif /* USE_XPRINT */ #ifdef USE_POSTSCRIPT - nsCOMPtr pPrefs = do_GetService(NS_PREF_CONTRACTID); PRBool psPrintModuleEnabled = PR_TRUE; const char *val = PR_GetEnv("MOZILLA_POSTSCRIPT_ENABLED"); @@ -1060,10 +1068,8 @@ nsresult GlobalPrinters::InitializeGlobalPrinters () } else { - if (pPrefs) { - if (NS_FAILED(pPrefs->GetBoolPref("print.postscript.enabled", &psPrintModuleEnabled))) { - psPrintModuleEnabled = PR_TRUE; - } + if (NS_FAILED(pPrefs->GetBoolPref("print.postscript.enabled", &psPrintModuleEnabled))) { + psPrintModuleEnabled = PR_TRUE; } } @@ -1076,9 +1082,7 @@ nsresult GlobalPrinters::InitializeGlobalPrinters () printerList = PR_GetEnv("MOZILLA_POSTSCRIPT_PRINTER_LIST"); if (!printerList) { - if (pPrefs) { - (void) pPrefs->CopyCharPref("print.printer_list", &printerList); - } + (void) pPrefs->CopyCharPref("print.printer_list", &printerList); } if (printerList) { diff --git a/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp b/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp index 2e53bc0d8bd..67a5f4b5bf5 100644 --- a/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp +++ b/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp @@ -1034,6 +1034,11 @@ nsresult GlobalPrinters::InitializeGlobalPrinters () mGlobalPrinterList = new nsStringArray(); if (!mGlobalPrinterList) return NS_ERROR_OUT_OF_MEMORY; + + nsresult rv; + nsCOMPtr pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv); + if (NS_FAILED(rv)) + return rv; #ifdef USE_XPRINT XPPrinterList plist = XpuGetPrinterList(nsnull, &mGlobalNumPrinters); @@ -1041,9 +1046,13 @@ nsresult GlobalPrinters::InitializeGlobalPrinters () if (plist && (mGlobalNumPrinters > 0)) { 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); @@ -1051,7 +1060,6 @@ nsresult GlobalPrinters::InitializeGlobalPrinters () #endif /* USE_XPRINT */ #ifdef USE_POSTSCRIPT - nsCOMPtr pPrefs = do_GetService(NS_PREF_CONTRACTID); PRBool psPrintModuleEnabled = PR_TRUE; const char *val = PR_GetEnv("MOZILLA_POSTSCRIPT_ENABLED"); @@ -1061,10 +1069,8 @@ nsresult GlobalPrinters::InitializeGlobalPrinters () } else { - if (pPrefs) { - if (NS_FAILED(pPrefs->GetBoolPref("print.postscript.enabled", &psPrintModuleEnabled))) { - psPrintModuleEnabled = PR_TRUE; - } + if (NS_FAILED(pPrefs->GetBoolPref("print.postscript.enabled", &psPrintModuleEnabled))) { + psPrintModuleEnabled = PR_TRUE; } } @@ -1077,9 +1083,7 @@ nsresult GlobalPrinters::InitializeGlobalPrinters () printerList = PR_GetEnv("MOZILLA_POSTSCRIPT_PRINTER_LIST"); if (!printerList) { - if (pPrefs) { - (void) pPrefs->CopyCharPref("print.printer_list", &printerList); - } + (void) pPrefs->CopyCharPref("print.printer_list", &printerList); } if (printerList) { diff --git a/mozilla/xpfe/global/resources/content/printdialog.js b/mozilla/xpfe/global/resources/content/printdialog.js index 233efd0bc0c..31f5daec0ab 100644 --- a/mozilla/xpfe/global/resources/content/printdialog.js +++ b/mozilla/xpfe/global/resources/content/printdialog.js @@ -60,6 +60,7 @@ function initDialog() dialog = new Object; dialog.propertiesButton = document.getElementById("properties"); + dialog.descText = document.getElementById("descText"); dialog.destGroup = document.getElementById("destGroup"); 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) { @@ -146,13 +161,16 @@ listElement.prototype = function () { // 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: function (aDataObject) { - var popupNode = document.createElement("menupopup"); + var list = document.getElementById("printerList"); var strDefaultPrinterName = ""; var printerName; @@ -163,10 +181,8 @@ listElement.prototype = var printerNameStr = printerName.toString(); if (strDefaultPrinterName == "") strDefaultPrinterName = printerNameStr; - var itemNode = document.createElement("menuitem"); - itemNode.setAttribute("value", printerNameStr); - itemNode.setAttribute("label", printerNameStr); - popupNode.appendChild(itemNode); + + list.appendItem(printerNameStr, printerNameStr, getPrinterDescription(printerNameStr)); } if (strDefaultPrinterName != "") { this.listElement.removeAttribute("disabled"); @@ -186,7 +202,6 @@ listElement.prototype = doEnablePrintToFile(false); } - this.listElement.appendChild(popupNode); return strDefaultPrinterName; } }; @@ -213,6 +228,8 @@ function setPrinterDefaultsForSelectedPrinter() { gPrintSettings.printerName = dialog.printerList.value; + dialog.descText.value = getPrinterDescription(gPrintSettings.printerName); + // First get any defaults from the printer printService.initPrintSettingsFromPrinter(gPrintSettings.printerName, gPrintSettings); diff --git a/mozilla/xpfe/global/resources/content/printdialog.xul b/mozilla/xpfe/global/resources/content/printdialog.xul index ba3bf08514e..8f2d650384e 100644 --- a/mozilla/xpfe/global/resources/content/printdialog.xul +++ b/mozilla/xpfe/global/resources/content/printdialog.xul @@ -26,7 +26,7 @@ Dan Rosen Jessica Blanco Asko Tontti - Roland Mainz + Roland Mainz 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"), @@ -69,20 +69,15 @@ - - - - - + - - - +