Bug 456646 - Replace Carbon printing dialog with Cocoa one. r=josh, r=bsmedberg, sr=jst
authorMarkus Stange <mstange@themasta.com>
Thu, 01 Oct 2009 11:15:32 +1300
changeset 33309 8c4658f8f0dc147ef1d39486bb18b7557174deb6
parent 33308 5c503628b3edbfe232dd5d085e64fe96f7c74add
child 33310 4e46887f17bcf285ff61c04f1cddeb99fea1dfbd
child 33698 8d2de8ddfa3b79064d583a93d239153849decef6
push idunknown
push userunknown
push dateunknown
reviewersjosh, bsmedberg, jst
bugs456646
milestone1.9.3a1pre
Bug 456646 - Replace Carbon printing dialog with Cocoa one. r=josh, r=bsmedberg, sr=jst
browser/app/Makefile.in
config/autoconf.mk.in
configure.in
dom/locales/en-US/chrome/printdialog.properties
dom/locales/jar.mn
embedding/components/printingui/src/mac/Makefile.in
embedding/components/printingui/src/mac/nsPrintingPromptService.h
embedding/components/printingui/src/mac/nsPrintingPromptServiceX.mm
embedding/components/printingui/src/win/nsPrintDialogUtil.cpp
toolkit/locales/en-US/chrome/global/gnomeprintdialog.properties
toolkit/locales/en-US/chrome/global/printdialog.properties
toolkit/locales/jar.mn
widget/public/Makefile.in
widget/src/cocoa/Makefile.in
widget/src/cocoa/nsDeviceContextSpecX.h
widget/src/cocoa/nsDeviceContextSpecX.mm
widget/src/cocoa/nsPrintDialogX.h
widget/src/cocoa/nsPrintDialogX.mm
widget/src/cocoa/nsPrintOptionsX.h
widget/src/cocoa/nsPrintOptionsX.mm
widget/src/cocoa/nsPrintSettingsX.h
widget/src/cocoa/nsPrintSettingsX.mm
widget/src/cocoa/nsWidgetFactory.mm
widget/src/gtk2/nsPrintDialogGTK.cpp
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -338,18 +338,20 @@ libs repackage:: $(PROGRAM) application.
 	rsync -a $(DIST)/bin/ $(DIST)/$(APP_NAME).app/Contents/$(APPFILES)
 	$(RM) $(DIST)/$(APP_NAME).app/Contents/$(APPFILES)/mangle $(DIST)/$(APP_NAME).app/Contents/$(APPFILES)/shlibsign
 ifdef LIBXUL_SDK
 	cp $(LIBXUL_DIST)/bin/$(XR_STUB_NAME) $(DIST)/$(APP_NAME).app/Contents/MacOS/firefox-bin
 else
 	rm -f $(DIST)/$(APP_NAME).app/Contents/MacOS/$(PROGRAM)
 	rsync -aL $(PROGRAM) $(DIST)/$(APP_NAME).app/Contents/MacOS
 endif
+ifndef MOZ_COCOA_PRINTING
 	mkdir -p $(DIST)/$(APP_NAME).app/Contents/Plug-Ins
 	rsync -a --copy-unsafe-links $(LIBXUL_DIST)/package/PrintPDE.plugin $(DIST)/$(APP_NAME).app/Contents/Plug-Ins
+endif
 	-cp -L $(DIST)/bin/mangle $(DIST)/bin/shlibsign $(DIST)/$(APP_NAME).app/Contents/$(APPFILES)
 	cp -RL $(DIST)/branding/firefox.icns $(DIST)/$(APP_NAME).app/Contents/Resources/firefox.icns
 	cp -RL $(DIST)/branding/document.icns $(DIST)/$(APP_NAME).app/Contents/Resources/document.icns
 	printf APPLMOZB > $(DIST)/$(APP_NAME).app/Contents/PkgInfo
 #       remove CVS dirs from packaged app
 	find $(DIST)/$(APP_NAME).app -type d -name "CVS" -prune -exec rm -rf {} \;
 
 else
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -84,16 +84,17 @@ MOZ_WIDGET_TOOLKIT	= @MOZ_WIDGET_TOOLKIT
 MOZ_GFX_OPTIMIZE_MOBILE = @MOZ_GFX_OPTIMIZE_MOBILE@
 
 MOZ_DFB			= @MOZ_DFB@
 MOZ_X11			= @MOZ_X11@
 
 MOZ_PANGO = @MOZ_PANGO@
 
 MOZ_CORETEXT = @MOZ_CORETEXT@
+MOZ_COCOA_PRINTING = @MOZ_COCOA_PRINTING@
 
 MOZ_JS_LIBS		   = @MOZ_JS_LIBS@
 
 MOZ_DEBUG	= @MOZ_DEBUG@
 MOZ_DEBUG_MODULES = @MOZ_DEBUG_MODULES@
 MOZ_DEBUG_ENABLE_DEFS		= @MOZ_DEBUG_ENABLE_DEFS@
 MOZ_DEBUG_DISABLE_DEFS	= @MOZ_DEBUG_DISABLE_DEFS@
 MOZ_DEBUG_FLAGS	= @MOZ_DEBUG_FLAGS@
--- a/configure.in
+++ b/configure.in
@@ -3134,45 +3134,61 @@ dnl OS/2 has socket in libc.
 case $target in
 *-os2*)
     ;;
 *)
     AC_CHECK_LIB(socket, socket)
 esac
 
 dnl ========================================================
-dnl Check whether we can compile code for Core Text
+dnl Check whether we can compile code for Core Text and
+dnl Cocoa printing
 dnl (Mac OS X 10.5 or later)
 dnl ========================================================
 case "$target" in
 *-darwin*)
   AC_MSG_CHECKING([for Core Text])
   AC_TRY_COMPILE([#include <ApplicationServices/ApplicationServices.h>],
                  [CTLineRef lineRef;],
-                  ac_cv_have_core_text="yes",
-                  ac_cv_have_core_text="no")
-  AC_MSG_RESULT([$ac_cv_have_core_text])
+                  ac_cv_have_leopard="yes",
+                  ac_cv_have_leopard="no")
+  AC_MSG_RESULT([$ac_cv_have_leopard])
 
   MOZ_CORETEXT=1
 
   MOZ_ARG_DISABLE_BOOL(coretext,
 [  --disable-coretext      Use ATSUI instead of Core Text for text rendering],
     MOZ_CORETEXT=,
     MOZ_CORETEXT=1)
 
   if test -n "$MOZ_CORETEXT"; then
-    if test "$ac_cv_have_core_text" = "no"; then
+    if test "$ac_cv_have_leopard" = "no"; then
       AC_MSG_ERROR([--enable-coretext requires MacOS SDK 10.5 or newer])
      fi
      AC_DEFINE(MOZ_CORETEXT)
   fi
+
+  MOZ_COCOA_PRINTING=1
+
+  MOZ_ARG_DISABLE_BOOL(cocoa-printing,
+[  --disable-cocoa-printing
+                          Use a Carbon print dialog instead of a Cocoa one],
+    MOZ_COCOA_PRINTING=,
+    MOZ_COCOA_PRINTING=1)
+
+  if test -n "$MOZ_COCOA_PRINTING"; then
+    if test "$ac_cv_have_leopard" = "no"; then
+        AC_MSG_ERROR([--enable-cocoa-printing requires MacOS SDK 10.5 or newer])
+    fi
+    AC_DEFINE(MOZ_COCOA_PRINTING)
+  fi
   ;;
 esac
 
-AC_SUBST(MOZ_CORETEXT)
+AC_SUBST(MOZ_COCOA_PRINTING)
 
 XLDFLAGS="$X_LIBS"
 XLIBS="$X_EXTRA_LIBS"
 
 dnl ========================================================
 dnl Checks for X libraries.
 dnl Ordering is important.
 dnl Xt is dependent upon SM as of X11R6
deleted file mode 100644
--- a/dom/locales/en-US/chrome/printdialog.properties
+++ /dev/null
@@ -1,41 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-PrintFrames=Print Frames
-Aslaid=As &laid out on the screen
-selectedframe=The selected &frame
-Eachframe=&Each frame separately
-options=Options
--- a/dom/locales/jar.mn
+++ b/dom/locales/jar.mn
@@ -9,17 +9,16 @@
   locale/@AB_CD@/global/netError.dtd                           (%chrome/netError.dtd)
   locale/@AB_CD@/global/netErrorApp.dtd                        (%chrome/netErrorApp.dtd)
   locale/@AB_CD@/global/global.dtd                             (%chrome/global.dtd)
   locale/@AB_CD@/global/appstrings.properties                  (%chrome/appstrings.properties)
   locale/@AB_CD@/global/charsetTitles.properties               (%chrome/charsetTitles.properties)
   locale/@AB_CD@/global/global-strres.properties               (%chrome/global-strres.properties)
   locale/@AB_CD@/global/plugins.properties                     (%chrome/plugins.properties)
   locale/@AB_CD@/global/nsWebBrowserPersist.properties         (%chrome/nsWebBrowserPersist.properties)
-  locale/@AB_CD@/global/printdialog.properties                 (%chrome/printdialog.properties)
   locale/@AB_CD@/global/xslt/xslt.properties                   (%chrome/xslt/xslt.properties)
   locale/@AB_CD@/global/dom/dom.properties                     (%chrome/dom/dom.properties)
 #ifdef MOZ_SVG
   locale/@AB_CD@/global/svg/svg.properties                     (%chrome/svg/svg.properties)
 #endif
   locale/@AB_CD@/global/layout/MediaDocument.properties        (%chrome/layout/MediaDocument.properties)
   locale/@AB_CD@/global/layout/xmlparser.properties            (%chrome/layout/xmlparser.properties)
   locale/@AB_CD@/global/layout/HtmlForm.properties             (%chrome/layout/HtmlForm.properties)
--- a/embedding/components/printingui/src/mac/Makefile.in
+++ b/embedding/components/printingui/src/mac/Makefile.in
@@ -42,27 +42,29 @@ VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= embedcomponents
 LIBRARY_NAME	= printingui_s
 LIBXUL_LIBRARY	= 1
 
 
+ifndef MOZ_COCOA_PRINTING
 DIRS      = printpde
+endif
 
 CMMSRCS = nsPrintingPromptServiceX.mm
 
 CPPSRCS		= \
       nsPrintProgressParams.cpp \
       nsPrintProgress.cpp \
       $(NULL)
 
-LOCAL_INCLUDES	= \
-		-I$(srcdir)/printpde/public \
-		$(NULL)
+ifndef MOZ_COCOA_PRINTING
+LOCAL_INCLUDES	= -I$(srcdir)/printpde/public
+endif
 
 # we don't want the shared lib, but we want to force the creation of a
 # static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
--- a/embedding/components/printingui/src/mac/nsPrintingPromptService.h
+++ b/embedding/components/printingui/src/mac/nsPrintingPromptService.h
@@ -46,17 +46,16 @@
 
 #include "nsCOMPtr.h"
 #include "nsIPrintingPromptService.h"
 #include "nsPIPromptService.h"
 #include "nsIWindowWatcher.h"
 
 // Printing Progress Includes
 #include "nsPrintProgress.h"
-#include "nsPrintProgressParams.h"
 #include "nsIWebProgressListener.h"
 
 
 class nsIDOMWindow;
 class nsIDialogParamBlock;
 
 class nsPrintingPromptService: public nsIPrintingPromptService,
                                public nsIWebProgressListener
@@ -67,14 +66,12 @@ public:
 
   nsresult Init();
 
   NS_DECL_NSIPRINTINGPROMPTSERVICE
   NS_DECL_NSIWEBPROGRESSLISTENER
   NS_DECL_ISUPPORTS
 
 private:
-  nsCOMPtr<nsIWindowWatcher> mWatcher;
   nsCOMPtr<nsIPrintProgress> mPrintProgress;
-  nsCOMPtr<nsIWebProgressListener> mWebProgressListener;  
 };
 
 #endif
--- a/embedding/components/printingui/src/mac/nsPrintingPromptServiceX.mm
+++ b/embedding/components/printingui/src/mac/nsPrintingPromptServiceX.mm
@@ -39,16 +39,24 @@
 
 #include "nsPrintingPromptService.h"
 
 #include "nsCOMPtr.h"
 #include "nsObjCExceptions.h"
 
 #include "nsIPrintingPromptService.h"
 #include "nsIFactory.h"
+
+#ifdef MOZ_COCOA_PRINTING
+
+#include "nsServiceManagerUtils.h"
+#include "nsIPrintDialogService.h"
+
+#else
+
 #include "nsIDOMWindow.h"
 #include "nsReadableUtils.h"
 #include "nsIEmbeddingSiteWindow.h"
 #include "nsIServiceManager.h"
 #include "nsIWebBrowserChrome.h"
 #include "nsIWindowWatcher.h"
 #include "nsIPrintSettingsX.h"
 #include "nsIDirectoryService.h"
@@ -187,41 +195,74 @@ static void
 SetDictionaryBooleanvalue(CFMutableDictionaryRef aDictionary, CFStringRef aKey, PRBool aValue)
 {
     NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
     CFDictionaryAddValue(aDictionary, aKey, aValue ? kCFBooleanTrue : kCFBooleanFalse);
 
     NS_OBJC_END_TRY_ABORT_BLOCK;
 }
+#endif
 
 //*****************************************************************************
 // nsPrintingPromptService
 //*****************************************************************************   
 
 NS_IMPL_ISUPPORTS2(nsPrintingPromptService, nsIPrintingPromptService, nsIWebProgressListener)
 
-nsPrintingPromptService::nsPrintingPromptService() :
-    mWatcher(do_GetService(NS_WINDOWWATCHER_CONTRACTID))
+nsPrintingPromptService::nsPrintingPromptService()
 {
 }
 
 nsPrintingPromptService::~nsPrintingPromptService()
 {
 }
 
 nsresult nsPrintingPromptService::Init()
 {
     return NS_OK;
 }
 
 //*****************************************************************************
 // nsPrintingPromptService::nsIPrintingPromptService
 //*****************************************************************************   
 
+#ifdef MOZ_COCOA_PRINTING
+
+NS_IMETHODIMP 
+nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings)
+{
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
+  nsCOMPtr<nsIPrintDialogService> dlgPrint(do_GetService(
+                                           NS_PRINTDIALOGSERVICE_CONTRACTID));
+  if (dlgPrint)
+    return dlgPrint->Show(parent, printSettings);
+
+  return NS_ERROR_FAILURE;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
+}
+
+NS_IMETHODIMP 
+nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *printSettings, nsIObserver *aObs)
+{
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+  nsCOMPtr<nsIPrintDialogService> dlgPrint(do_GetService(
+                                           NS_PRINTDIALOGSERVICE_CONTRACTID));
+  if (dlgPrint)
+    return dlgPrint->ShowPageSetup(parent, printSettings);
+
+  return NS_ERROR_FAILURE;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
+}
+
+#else
+
 NS_IMETHODIMP 
 nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings)
 {
     NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
     nsresult rv;
     OSStatus status;
       
@@ -439,29 +480,16 @@ nsPrintingPromptService::ShowPrintDialog
         return NS_ERROR_FAILURE;
 
     return NS_OK;
 
     NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP 
-nsPrintingPromptService::ShowProgress(nsIDOMWindow*            parent, 
-                                      nsIWebBrowserPrint*      webBrowserPrint,    // ok to be null
-                                      nsIPrintSettings*        printSettings,      // ok to be null
-                                      nsIObserver*             openDialogObserver, // ok to be null
-                                      PRBool                   isForPrinting,
-                                      nsIWebProgressListener** webProgressListener,
-                                      nsIPrintProgressParams** printProgressParams,
-                                      PRBool*                  notifyOnOpen)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP 
 nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *printSettings, nsIObserver *aObs)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(printSettings));
   if (!printSettingsX)
     return NS_ERROR_NO_INTERFACE;
   
@@ -497,71 +525,67 @@ nsPrintingPromptService::ShowPageSetup(n
   if (!accepted)
     return NS_ERROR_ABORT;
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
+#endif
+
+NS_IMETHODIMP 
+nsPrintingPromptService::ShowProgress(nsIDOMWindow*            parent, 
+                                      nsIWebBrowserPrint*      webBrowserPrint,    // ok to be null
+                                      nsIPrintSettings*        printSettings,      // ok to be null
+                                      nsIObserver*             openDialogObserver, // ok to be null
+                                      PRBool                   isForPrinting,
+                                      nsIWebProgressListener** webProgressListener,
+                                      nsIPrintProgressParams** printProgressParams,
+                                      PRBool*                  notifyOnOpen)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
 NS_IMETHODIMP 
 nsPrintingPromptService::ShowPrinterProperties(nsIDOMWindow *parent, const PRUnichar *printerName, nsIPrintSettings *printSettings)
 {
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 
 //*****************************************************************************
 // nsPrintingPromptService::nsIWebProgressListener
 //*****************************************************************************   
 
 NS_IMETHODIMP 
 nsPrintingPromptService::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus)
 {
-    if ((aStateFlags & STATE_STOP) && mWebProgressListener) {
-        mWebProgressListener->OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus);
-        if (mPrintProgress) 
-          mPrintProgress->CloseProgressDialog(PR_TRUE);
-        mPrintProgress       = nsnull;
-        mWebProgressListener = nsnull;
-    }
     return NS_OK;
 }
 
 /* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */
 NS_IMETHODIMP 
 nsPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress)
 {
-    if (mWebProgressListener) {
-      return mWebProgressListener->OnProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
-    }
     return NS_OK;
 }
 
 /* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
 NS_IMETHODIMP 
 nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
 {
-    if (mWebProgressListener) {
-        return mWebProgressListener->OnLocationChange(aWebProgress, aRequest, location);
-    }
     return NS_OK;
 }
 
 /* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */
 NS_IMETHODIMP 
 nsPrintingPromptService::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const PRUnichar *aMessage)
 {
-    if (mWebProgressListener) {
-        return mWebProgressListener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
-    }
     return NS_OK;
 }
 
 /* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long state); */
 NS_IMETHODIMP 
 nsPrintingPromptService::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 state)
 {
-    if (mWebProgressListener) {
-        return mWebProgressListener->OnSecurityChange(aWebProgress, aRequest, state);
-    }
     return NS_OK;
 }
--- a/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp
+++ b/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp
@@ -458,20 +458,20 @@ static void SetRadioOfGroup(HWND aDlg, i
 typedef struct {
   char * mKeyStr;
   long   mKeyId;
 } PropKeyInfo;
 
 // These are the control ids used in the dialog and 
 // defined by MS-Windows in commdlg.h
 static PropKeyInfo gAllPropKeys[] = {
-    {"PrintFrames", grp3},
-    {"Aslaid", rad4},
-    {"selectedframe", rad5},
-    {"Eachframe", rad6},
+    {"printFramesTitleWindows", grp3},
+    {"asLaidOutWindows", rad4},
+    {"selectedFrameWindows", rad5},
+    {"separateFramesWindows", rad6},
     {NULL, NULL}};
 
 //--------------------------------------------------------
 //--------------------------------------------------------
 //--------------------------------------------------------
 //--------------------------------------------------------
 // Get the absolute coords of the child windows relative
 // to its parent window
@@ -1275,17 +1275,17 @@ ShowNativePrintDialogEx(HWND            
   prntdlg.nMinPage       = 1;
   prntdlg.nMaxPage       = 0xFFFF;
   prntdlg.nCopies        = 1;
 
   if (ShouldExtendPrintDialog()) {
     // lLcalize the Property Sheet (Tab) title
     nsCAutoString title;
     nsString optionsStr;
-    if (NS_SUCCEEDED(GetLocalizedString(strBundle, "options", optionsStr))) {
+    if (NS_SUCCEEDED(GetLocalizedString(strBundle, "optionsTitleWindows", optionsStr))) {
       // Failure here just means a blank string
       NS_CopyUnicodeToNative(optionsStr, title);
     }
 
     // Temporarily borrow this variable for setting up the radiobuttons
     // if we don't use this, we will need to define a new global var
     gFrameSelectedRadioBtn = howToEnableFrameUI;
     HPROPSHEETPAGE psp[1];
rename from toolkit/locales/en-US/chrome/global/gnomeprintdialog.properties
rename to toolkit/locales/en-US/chrome/global/printdialog.properties
--- a/toolkit/locales/en-US/chrome/global/gnomeprintdialog.properties
+++ b/toolkit/locales/en-US/chrome/global/printdialog.properties
@@ -1,19 +1,38 @@
-printTitle=Print
-optionsTabLabel=Options
-printFramesTitle=Print Frames
+# These strings are used in the native GTK, Mac and Windows print dialogs.
+
+# GTK titles:
+printTitleGTK=Print
+optionsTabLabelGTK=Options
+printFramesTitleGTK=Print Frames
+
+# Mac titles:
+optionsTitleMac=Options:
+appearanceTitleMac=Appearance:
+framesTitleMac=Frames:
+pageHeadersTitleMac=Page Headers:
+pageFootersTitleMac=Page Footers:
+
+# Windows titles:
+optionsTitleWindows=Options
+printFramesTitleWindows=Print Frames
 
 # TRANSLATOR NOTE: For radio button labels and check button labels, an underscore _
-# before a character will turn that character into an accesskey.
+# before a character will turn that character into an accesskey in the GTK dialog.
 # e.g. "_As laid out" will make A the accesskey.
+# In the Windows labels, use an ampersand (&).
+# On Mac, underscores will be stripped.
 
 asLaidOut=_As Laid Out on the Screen
+asLaidOutWindows=As &laid out on the screen
 selectedFrame=The _Selected Frame
+selectedFrameWindows=The selected &frame
 separateFrames=Each Frame on Separate _Pages
+separateFramesWindows=&Each frame separately
 shrinkToFit=Ignore Scaling and S_hrink To Fit Page Width
 selectionOnly=Print Selection _Only
 printBGOptions=Print Backgrounds
 printBGColors=Print Background _Colors
 printBGImages=Print Background I_mages
 headerFooter=Header and Footer
 left=Left
 center=Center
@@ -21,8 +40,20 @@ right=Right
 headerFooterBlank=--blank--
 headerFooterTitle=Title
 headerFooterURL=URL
 headerFooterDate=Date/Time
 headerFooterPage=Page #
 headerFooterPageTotal=Page # of #
 headerFooterCustom=Custom...
 customHeaderFooterPrompt=Please enter your custom header/footer text
+
+# These are for the summary view in the Mac dialog:
+summaryFramesTitle=Print Frames
+summarySelectionOnlyTitle=Print Selection
+summaryShrinkToFitTitle=Shrink To Fit
+summaryPrintBGColorsTitle=Print BG Colors
+summaryPrintBGImagesTitle=Print BG Images
+summaryHeaderTitle=Page Headers
+summaryFooterTitle=Page Footers
+summaryNAValue=N/A
+summaryOnValue=On
+summaryOffValue=Off
--- a/toolkit/locales/jar.mn
+++ b/toolkit/locales/jar.mn
@@ -35,22 +35,22 @@
 + locale/@AB_CD@/global/intl.css                        (%chrome/global/intl.css)
 + locale/@AB_CD@/global/intl.properties                 (%chrome/global/intl.properties)
 + locale/@AB_CD@/global/keys.properties                 (%chrome/global/keys.properties)
 + locale/@AB_CD@/global/languageNames.properties        (%chrome/global/languageNames.properties)
   locale/@AB_CD@/global/license.dtd                     (%chrome/global/license.dtd)
   locale/@AB_CD@/global/mozilla.dtd                     (%chrome/global/mozilla.dtd)
   locale/@AB_CD@/global/notification.dtd                (%chrome/global/notification.dtd)
   locale/@AB_CD@/global/preferences.dtd                 (%chrome/global/preferences.dtd)
-+ locale/@AB_CD@/global/printdialog.dtd                 (%chrome/global/printdialog.dtd)
+  locale/@AB_CD@/global/printdialog.dtd                 (%chrome/global/printdialog.dtd)
 + locale/@AB_CD@/global/printjoboptions.dtd             (%chrome/global/printjoboptions.dtd)
 + locale/@AB_CD@/global/printPageSetup.dtd              (%chrome/global/printPageSetup.dtd)
 + locale/@AB_CD@/global/printPreview.dtd                (%chrome/global/printPreview.dtd)
 + locale/@AB_CD@/global/printPreviewProgress.dtd        (%chrome/global/printPreviewProgress.dtd)
-  locale/@AB_CD@/global/gnomeprintdialog.properties     (%chrome/global/gnomeprintdialog.properties)
++ locale/@AB_CD@/global/printdialog.properties          (%chrome/global/printdialog.properties)
 + locale/@AB_CD@/global/printProgress.dtd               (%chrome/global/printProgress.dtd)
 + locale/@AB_CD@/global/regionNames.properties          (%chrome/global/regionNames.properties)
 + locale/@AB_CD@/global/dialog.properties               (%chrome/global/dialog.properties)
 + locale/@AB_CD@/global/tree.dtd                        (%chrome/global/tree.dtd)
 + locale/@AB_CD@/global/textcontext.dtd                 (%chrome/global/textcontext.dtd)
   locale/@AB_CD@/global/videocontrols.dtd               (%chrome/global/videocontrols.dtd)
 + locale/@AB_CD@/global/viewSource.dtd                  (%chrome/global/viewSource.dtd)
 + locale/@AB_CD@/global/viewSource.properties           (%chrome/global/viewSource.properties)
--- a/widget/public/Makefile.in
+++ b/widget/public/Makefile.in
@@ -59,16 +59,22 @@ EXPORTS		= \
 		nsIDeviceContextSpec.h \
 		nsIMenuRollup.h \
 		$(NULL)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 EXPORTS		+= nsINativeMenuService.h
 endif
 
+ifdef MOZ_COCOA_PRINTING
+EXPORTS		+= \
+		nsIPrintDialogService.h \
+		$(NULL)
+endif
+
 ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
 EXPORTS		+= nsIDragSessionOS2.h
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),beos)
 EXPORTS		+= nsIDragSessionBeOS.h
 endif
 
@@ -106,19 +112,21 @@ XPIDLSRCS	= \
 		nsIIdleService.idl \
 		$(NULL)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 XPIDLSRCS	+= nsIPrintSettingsWin.idl
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
+ifndef MOZ_COCOA_PRINTING
 XPIDLSRCS	+= nsIPrintSettingsX.idl \
 		nsIPrintSessionX.idl
 endif
+endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
 XPIDLSRCS	+= nsIRwsService.idl
 endif
 
 EXPORTS		:= $(addprefix $(srcdir)/, $(EXPORTS))
 
 include $(topsrcdir)/config/rules.mk
--- a/widget/src/cocoa/Makefile.in
+++ b/widget/src/cocoa/Makefile.in
@@ -80,21 +80,26 @@ CMMSRCS = \
 		nsScreenCocoa.mm \
 		nsScreenManagerCocoa.mm \
 		nsSound.mm \
 		nsLookAndFeel.mm \
 		nsNativeThemeCocoa.mm \
 		nsDeviceContextSpecX.mm \
 		nsPrintOptionsX.mm \
 		nsPrintSettingsX.mm \
-		nsPrintSessionX.mm \
 		nsIdleServiceX.mm \
 		nsAccelerometerX.mm \
 		$(NULL)
 
+ifdef MOZ_COCOA_PRINTING
+CMMSRCS	+= nsPrintDialogX.mm
+else
+CMMSRCS	+= nsPrintSessionX.mm
+endif
+
 XPIDLSRCS	+= \
 		nsPIWidgetCocoa.idl \
 		$(NULL)
 
 SHARED_LIBRARY_LIBS = ../xpwidgets/libxpwidgets_s.a
 
 EXTRA_DSO_LDOPTS += \
 		$(MOZ_UNICHARUTIL_LIBS) \
--- a/widget/src/cocoa/nsDeviceContextSpecX.h
+++ b/widget/src/cocoa/nsDeviceContextSpecX.h
@@ -36,46 +36,45 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsDeviceContextSpecX_h_
 #define nsDeviceContextSpecX_h_
 
 #include "nsIDeviceContextSpec.h"
 
-#include <Carbon/Carbon.h>
+#include <ApplicationServices/ApplicationServices.h>
+#ifdef MOZ_COCOA_PRINTING
+#include <Cocoa/Cocoa.h>
+#endif
 
 class nsDeviceContextSpecX : public nsIDeviceContextSpec
 {
 public:
+    NS_DECL_ISUPPORTS
+
     nsDeviceContextSpecX();
 
-    NS_DECL_ISUPPORTS
+    NS_IMETHOD Init(nsIWidget *aWidget, nsIPrintSettings* aPS, PRBool aIsPrintPreview);
     NS_IMETHOD GetSurfaceForPrinter(gfxASurface **surface);
     NS_IMETHOD BeginDocument(PRUnichar*  aTitle, 
                              PRUnichar*  aPrintToFileName,
                              PRInt32     aStartPage, 
                              PRInt32     aEndPage);
     NS_IMETHOD EndDocument();
     NS_IMETHOD BeginPage();
     NS_IMETHOD EndPage();
 
-    /**
-     * Initialize the nsDeviceContextSpecX for use.  This will allocate a printrecord for use
-     * @param aWidget           Unused
-     * @param aPS               Settings for this print job
-     * @param aIsPrintPreview   TRUE if doing print preview, FALSE if normal printing.
-     * @return error status
-     */
-    NS_IMETHOD Init(nsIWidget *aWidget, nsIPrintSettings* aPS, PRBool aIsPrintPreview);
-    
     void GetPaperRect(double* aTop, double* aLeft, double* aBottom, double* aRight);
 
 protected:
-  virtual ~nsDeviceContextSpecX();
+    virtual ~nsDeviceContextSpecX();
 
 protected:
     PMPrintSession    mPrintSession;              // printing context.
     PMPageFormat      mPageFormat;                // page format.
     PMPrintSettings   mPrintSettings;             // print settings.
+#ifdef MOZ_COCOA_PRINTING
+    NSPrintInfo*      mPrintInfo;                 // Cocoa print info.
+#endif
 };
 
 #endif //nsDeviceContextSpecX_h_
--- a/widget/src/cocoa/nsDeviceContextSpecX.mm
+++ b/widget/src/cocoa/nsDeviceContextSpecX.mm
@@ -43,25 +43,33 @@
 
 #include "prmem.h"
 #include "plstr.h"
 #include "nsCRT.h"
 #include <unistd.h>
 
 #include "nsIServiceManager.h"
 #include "nsIPrintOptions.h"
-#include "nsIPrintSettingsX.h"
 
 #include "gfxQuartzSurface.h"
 #include "gfxImageSurface.h"
 
+#ifdef MOZ_COCOA_PRINTING
+#include "nsPrintSettingsX.h"
+#else
+#include "nsIPrintSettingsX.h"
+#endif
+
 nsDeviceContextSpecX::nsDeviceContextSpecX()
 : mPrintSession(NULL)
 , mPageFormat(kPMNoPageFormat)
 , mPrintSettings(kPMNoPrintSettings)
+#ifdef MOZ_COCOA_PRINTING
+, mPrintInfo(nil)
+#endif
 {
 }
 
 nsDeviceContextSpecX::~nsDeviceContextSpecX()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (mPrintSession)
@@ -73,34 +81,46 @@ nsDeviceContextSpecX::~nsDeviceContextSp
 NS_IMPL_ISUPPORTS1(nsDeviceContextSpecX, nsIDeviceContextSpec)
 
 NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIWidget *aWidget,
                                          nsIPrintSettings* aPS,
                                          PRBool aIsPrintPreview)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
+#ifdef MOZ_COCOA_PRINTING
+  nsCOMPtr<nsPrintSettingsX> settings(do_QueryInterface(aPS));
+  if (!settings)
+    return NS_ERROR_NO_INTERFACE;
+
+  mPrintInfo = settings->GetCocoaPrintInfo();
+  mPrintSession = static_cast<PMPrintSession>([mPrintInfo PMPrintSession]);
+  ::PMRetain(mPrintSession);
+  mPageFormat = static_cast<PMPageFormat>([mPrintInfo PMPageFormat]);
+  mPrintSettings = static_cast<PMPrintSettings>([mPrintInfo PMPrintSettings]);
+#else
   nsresult rv;
 
   nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
   if (!printSettingsX)
     return NS_ERROR_NO_INTERFACE;
 
   rv = printSettingsX->GetNativePrintSession(&mPrintSession);
   if (NS_FAILED(rv))
-    return rv;  
+    return rv;
   ::PMRetain(mPrintSession);
 
   rv = printSettingsX->GetPMPageFormat(&mPageFormat);
   if (NS_FAILED(rv))
     return rv;
 
   rv = printSettingsX->GetPMPrintSettings(&mPrintSettings);
   if (NS_FAILED(rv))
     return rv;
+#endif
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsDeviceContextSpecX::BeginDocument(PRUnichar*  aTitle, 
                                                   PRUnichar*  aPrintToFileName,
@@ -137,23 +157,16 @@ NS_IMETHODIMP nsDeviceContextSpecX::EndD
     NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
     ::PMSessionEndDocumentNoDialog(mPrintSession);
     return NS_OK;
 
     NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
-/*
-NS_IMETHODIMP nsDeviceContextSpecX::AbortDocument()
-{
-    return EndDocument();
-}
-*/
-
 NS_IMETHODIMP nsDeviceContextSpecX::BeginPage()
 {
     NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
     PMSessionError(mPrintSession);
     OSStatus status = ::PMSessionBeginPageNoDialog(mPrintSession, mPageFormat, NULL);
     if (status != noErr) return NS_ERROR_ABORT;
     return NS_OK;
new file mode 100644
--- /dev/null
+++ b/widget/src/cocoa/nsPrintDialogX.h
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Mozilla OS X print dialog interface.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Corporation
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Markus Stange <mstange@themasta.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsPrintDialogX_h__
+#define nsPrintDialogX_h__
+
+#include "nsIPrintDialogService.h"
+#include "nsCOMPtr.h"
+
+#import <Cocoa/Cocoa.h>
+
+class nsIPrintSettings;
+class nsIStringBundle;
+
+class nsPrintDialogServiceX : public nsIPrintDialogService
+{
+public:
+  nsPrintDialogServiceX();
+  virtual ~nsPrintDialogServiceX();
+
+  NS_DECL_ISUPPORTS
+
+  NS_IMETHODIMP Init();
+  NS_IMETHODIMP Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings);
+  NS_IMETHODIMP ShowPageSetup(nsIDOMWindow *aParent,
+                              nsIPrintSettings *aSettings);
+};
+
+@interface PrintPanelAccessoryView : NSView
+{
+  nsIPrintSettings* mSettings;
+  nsIStringBundle* mPrintBundle;
+  NSButton* mPrintSelectionOnlyCheckbox;
+  NSButton* mShrinkToFitCheckbox;
+  NSButton* mPrintBGColorsCheckbox;
+  NSButton* mPrintBGImagesCheckbox;
+  NSButtonCell* mAsLaidOutRadio;
+  NSButtonCell* mSelectedFrameRadio;
+  NSButtonCell* mSeparateFramesRadio;
+  NSPopUpButton* mHeaderLeftList;
+  NSPopUpButton* mHeaderCenterList;
+  NSPopUpButton* mHeaderRightList;
+  NSPopUpButton* mFooterLeftList;
+  NSPopUpButton* mFooterCenterList;
+  NSPopUpButton* mFooterRightList;
+}
+
+- (id)initWithSettings:(nsIPrintSettings*)aSettings;
+
+- (void)exportSettings;
+
+@end
+
+@interface PrintPanelAccessoryController : NSViewController <NSPrintPanelAccessorizing>
+
+- (id)initWithSettings:(nsIPrintSettings*)aSettings;
+
+- (void)exportSettings;
+
+@end
+
+#endif
new file mode 100644
--- /dev/null
+++ b/widget/src/cocoa/nsPrintDialogX.mm
@@ -0,0 +1,615 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Mozilla OS X print dialog interface.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Markus Stange <mstange@themasta.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsPrintDialogX.h"
+#include "nsIPrintSettings.h"
+#include "nsPrintSettingsX.h"
+#include "nsCOMPtr.h"
+#include "nsServiceManagerUtils.h"
+#include "nsIWebProgressListener.h"
+#include "nsIStringBundle.h"
+#include "nsCocoaUtils.h"
+
+#import <Cocoa/Cocoa.h>
+#include "nsObjCExceptions.h"
+
+NS_IMPL_ISUPPORTS1(nsPrintDialogServiceX, nsIPrintDialogService)
+
+nsPrintDialogServiceX::nsPrintDialogServiceX()
+{
+}
+
+nsPrintDialogServiceX::~nsPrintDialogServiceX()
+{
+}
+
+NS_IMETHODIMP
+nsPrintDialogServiceX::Init()
+{
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsPrintDialogServiceX::Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings)
+{
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
+  NS_PRECONDITION(aSettings, "aSettings must not be null");
+
+  nsCOMPtr<nsPrintSettingsX> settingsX(do_QueryInterface(aSettings));
+  if (!settingsX)
+    return NS_ERROR_FAILURE;
+
+  NSPrintInfo* printInfo = settingsX->GetCocoaPrintInfo();  
+  
+  NSPrintPanel* panel = [NSPrintPanel printPanel];
+  PrintPanelAccessoryController* viewController =
+    [[PrintPanelAccessoryController alloc] initWithSettings:aSettings];
+  [panel addAccessoryController:viewController];
+  [viewController release];
+
+  // Show the dialog.
+  nsCocoaUtils::PrepareForNativeAppModalDialog();
+  int button = [panel runModalWithPrintInfo:printInfo];
+  nsCocoaUtils::CleanUpAfterNativeAppModalDialog();
+
+  if (button != NSOKButton)
+    return NS_ERROR_ABORT;
+
+  // Export settings.
+  [viewController exportSettings];
+  
+  PRInt16 pageRange;
+  aSettings->GetPrintRange(&pageRange);
+  if (pageRange != nsIPrintSettings::kRangeSelection) {
+    PMPrintSettings nativePrintSettings = (PMPrintSettings)[printInfo PMPrintSettings];
+    UInt32 firstPage, lastPage;
+    OSStatus status = ::PMGetFirstPage(nativePrintSettings, &firstPage);
+    if (status == noErr) {
+      status = ::PMGetLastPage(nativePrintSettings, &lastPage);
+      if (status == noErr && lastPage != LONG_MAX) {
+        aSettings->SetPrintRange(nsIPrintSettings::kRangeSpecifiedPageRange);
+        aSettings->SetStartPageRange(firstPage);
+        aSettings->SetEndPageRange(lastPage);
+      }
+    }
+  }
+  
+  return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
+}
+
+NS_IMETHODIMP
+nsPrintDialogServiceX::ShowPageSetup(nsIDOMWindow *aParent,
+                                     nsIPrintSettings *aNSSettings)
+{
+  NS_PRECONDITION(aParent, "aParent must not be null");
+  NS_PRECONDITION(aNSSettings, "aSettings must not be null");
+  NS_ENSURE_TRUE(aNSSettings, NS_ERROR_FAILURE);
+
+  nsCOMPtr<nsPrintSettingsX> settingsX(do_QueryInterface(aNSSettings));
+  if (!settingsX)
+    return NS_ERROR_FAILURE;
+
+  NSPrintInfo* printInfo = settingsX->GetCocoaPrintInfo();
+  NSPageLayout *pageLayout = [NSPageLayout pageLayout];
+  nsCocoaUtils::PrepareForNativeAppModalDialog();
+  int button = [pageLayout runModalWithPrintInfo:printInfo];
+  nsCocoaUtils::CleanUpAfterNativeAppModalDialog();
+
+  return button == NSOKButton ? NS_OK : NS_ERROR_ABORT;
+}
+
+// Accessory view
+
+@interface PrintPanelAccessoryView (Private)
+
+- (NSString*)localizedString:(const char*)aKey;
+
+- (PRInt16)chosenFrameSetting;
+
+- (const char*)headerFooterStringForList:(NSPopUpButton*)aList;
+
+- (void)exportHeaderFooterSettings;
+
+- (void)initBundle;
+
+- (NSTextField*)label:(const char*)aLabel
+            withFrame:(NSRect)aRect
+            alignment:(NSTextAlignment)aAlignment;
+
+- (void)addLabel:(const char*)aLabel
+       withFrame:(NSRect)aRect
+       alignment:(NSTextAlignment)aAlignment;
+
+- (void)addLabel:(const char*)aLabel withFrame:(NSRect)aRect;
+
+- (void)addCenteredLabel:(const char*)aLabel withFrame:(NSRect)aRect;
+
+- (NSButton*)checkboxWithLabel:(const char*)aLabel andFrame:(NSRect)aRect;
+
+- (NSPopUpButton*)headerFooterItemListWithFrame:(NSRect)aRect
+                                   selectedItem:(const PRUnichar*)aCurrentString;
+
+- (void)addOptionsSection;
+
+- (void)addAppearanceSection;
+
+- (void)addFramesSection;
+
+- (void)addHeaderFooterSection;
+
+- (NSString*)summaryValueForCheckbox:(NSButton*)aCheckbox;
+
+- (NSString*)framesSummaryValue;
+
+- (NSString*)headerSummaryValue;
+
+- (NSString*)footerSummaryValue;
+
+@end
+
+static const char sHeaderFooterTags[][4] =  {"", "&T", "&U", "&D", "&P", "&PT"};
+
+@implementation PrintPanelAccessoryView
+
+// Public methods
+
+- (id)initWithSettings:(nsIPrintSettings*)aSettings
+{
+  [super initWithFrame:NSMakeRect(0, 0, 540, 270)];
+
+  mSettings = aSettings;
+  [self initBundle];
+  [self addOptionsSection];
+  [self addAppearanceSection];
+  [self addFramesSection];
+  [self addHeaderFooterSection];
+
+  return self;
+}
+
+- (void)exportSettings
+{
+  mSettings->SetPrintRange([mPrintSelectionOnlyCheckbox state] == NSOnState ?
+                             (PRInt16)nsIPrintSettings::kRangeSelection :
+                             (PRInt16)nsIPrintSettings::kRangeAllPages);
+  mSettings->SetShrinkToFit([mShrinkToFitCheckbox state] == NSOnState);
+  mSettings->SetPrintBGColors([mPrintBGColorsCheckbox state] == NSOnState);
+  mSettings->SetPrintBGImages([mPrintBGImagesCheckbox state] == NSOnState);
+  mSettings->SetPrintFrameType([self chosenFrameSetting]);
+
+  [self exportHeaderFooterSettings];
+}
+
+- (void)dealloc
+{
+  NS_IF_RELEASE(mPrintBundle);
+  [super dealloc];
+}
+
+// Localization
+
+- (void)initBundle
+{
+  nsCOMPtr<nsIStringBundleService> bundleSvc = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+  bundleSvc->CreateBundle("chrome://global/locale/printdialog.properties", &mPrintBundle);
+}
+
+- (NSString*)localizedString:(const char*)aKey
+{
+  if (!mPrintBundle)
+    return @"";
+
+  nsXPIDLString intlString;
+  mPrintBundle->GetStringFromName(NS_ConvertUTF8toUTF16(aKey).get(), getter_Copies(intlString));
+  NSString* s = [NSString stringWithUTF8String:NS_ConvertUTF16toUTF8(intlString).get()];
+
+  // Remove all underscores (they're used in the GTK dialog for accesskeys).
+  return [s stringByReplacingOccurrencesOfString:@"_" withString:@""];
+}
+
+// Widget helpers
+
+- (NSTextField*)label:(const char*)aLabel
+            withFrame:(NSRect)aRect
+            alignment:(NSTextAlignment)aAlignment
+{
+  NSTextField* label = [[[NSTextField alloc] initWithFrame:aRect] autorelease];
+  [label setStringValue:[self localizedString:aLabel]];
+  [label setEditable:NO];
+  [label setSelectable:NO];
+  [label setBezeled:NO];
+  [label setBordered:NO];
+  [label setDrawsBackground:NO];
+  [label setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
+  [label setAlignment:aAlignment];
+  return label;
+}
+
+- (void)addLabel:(const char*)aLabel
+       withFrame:(NSRect)aRect
+       alignment:(NSTextAlignment)aAlignment
+{
+  NSTextField* label = [self label:aLabel withFrame:aRect alignment:aAlignment];
+  [self addSubview:label];
+}
+
+- (void)addLabel:(const char*)aLabel withFrame:(NSRect)aRect
+{
+  [self addLabel:aLabel withFrame:aRect alignment:NSRightTextAlignment];
+}
+
+- (void)addCenteredLabel:(const char*)aLabel withFrame:(NSRect)aRect
+{
+  [self addLabel:aLabel withFrame:aRect alignment:NSCenterTextAlignment];
+}
+
+- (NSButton*)checkboxWithLabel:(const char*)aLabel andFrame:(NSRect)aRect
+{
+  aRect.origin.y += 4.0f;
+  NSButton* checkbox = [[[NSButton alloc] initWithFrame:aRect] autorelease];
+  [checkbox setButtonType:NSSwitchButton];
+  [checkbox setTitle:[self localizedString:aLabel]];
+  [checkbox setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
+  [checkbox sizeToFit];
+  return checkbox;
+}
+
+- (NSPopUpButton*)headerFooterItemListWithFrame:(NSRect)aRect
+                                   selectedItem:(const PRUnichar*)aCurrentString
+{
+  NSPopUpButton* list = [[[NSPopUpButton alloc] initWithFrame:aRect pullsDown:NO] autorelease];
+  [list setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
+  [[list cell] setControlSize:NSSmallControlSize];
+  NSArray* items =
+    [NSArray arrayWithObjects:[self localizedString:"headerFooterBlank"],
+                              [self localizedString:"headerFooterTitle"],
+                              [self localizedString:"headerFooterURL"],
+                              [self localizedString:"headerFooterDate"],
+                              [self localizedString:"headerFooterPage"],
+                              [self localizedString:"headerFooterPageTotal"],
+                              nil];
+  [list addItemsWithTitles:items];
+
+  NS_ConvertUTF16toUTF8 currentStringUTF8(aCurrentString);
+  for (unsigned int i = 0; i < NS_ARRAY_LENGTH(sHeaderFooterTags); i++) {
+    if (!strcmp(currentStringUTF8.get(), sHeaderFooterTags[i])) {
+      [list selectItemAtIndex:i];
+      break;
+    }
+  }
+
+  return list;
+}
+
+// Build sections
+
+- (void)addOptionsSection
+{
+  // Title
+  [self addLabel:"optionsTitleMac" withFrame:NSMakeRect(0, 240, 151, 22)];
+
+  // "Print Selection Only"
+  mPrintSelectionOnlyCheckbox = [self checkboxWithLabel:"selectionOnly"
+                                               andFrame:NSMakeRect(156, 240, 0, 0)];
+
+  PRBool canPrintSelection;
+  mSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB,
+                             &canPrintSelection);
+  [mPrintSelectionOnlyCheckbox setEnabled:canPrintSelection];
+
+  PRInt16 printRange;
+  mSettings->GetPrintRange(&printRange);
+  if (printRange == nsIPrintSettings::kRangeSelection) {
+    [mPrintSelectionOnlyCheckbox setState:NSOnState];
+  }
+
+  [self addSubview:mPrintSelectionOnlyCheckbox];
+
+  // "Shrink To Fit"
+  mShrinkToFitCheckbox = [self checkboxWithLabel:"shrinkToFit"
+                                        andFrame:NSMakeRect(156, 218, 0, 0)];
+
+  PRBool shrinkToFit;
+  mSettings->GetShrinkToFit(&shrinkToFit);
+  [mShrinkToFitCheckbox setState:(shrinkToFit ? NSOnState : NSOffState)];
+
+  [self addSubview:mShrinkToFitCheckbox];
+}
+
+- (void)addAppearanceSection
+{
+  // Title
+  [self addLabel:"appearanceTitleMac" withFrame:NSMakeRect(0, 188, 151, 22)];
+
+  // "Print Background Colors"
+  mPrintBGColorsCheckbox = [self checkboxWithLabel:"printBGColors"
+                                          andFrame:NSMakeRect(156, 188, 0, 0)];
+
+  PRBool geckoBool;
+  mSettings->GetPrintBGColors(&geckoBool);
+  [mPrintBGColorsCheckbox setState:(geckoBool ? NSOnState : NSOffState)];
+
+  [self addSubview:mPrintBGColorsCheckbox];
+
+  // "Print Background Images"
+  mPrintBGImagesCheckbox = [self checkboxWithLabel:"printBGImages"
+                                          andFrame:NSMakeRect(156, 166, 0, 0)];
+
+  mSettings->GetPrintBGImages(&geckoBool);
+  [mPrintBGImagesCheckbox setState:(geckoBool ? NSOnState : NSOffState)];
+
+  [self addSubview:mPrintBGImagesCheckbox];
+}
+
+- (void)addFramesSection
+{
+  // Title
+  [self addLabel:"framesTitleMac" withFrame:NSMakeRect(0, 124, 151, 22)];
+
+  // Radio matrix
+  NSButtonCell *radio = [[NSButtonCell alloc] init];
+  [radio setButtonType:NSRadioButton];
+  [radio setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
+  NSMatrix *matrix = [[NSMatrix alloc] initWithFrame:NSMakeRect(156, 81, 400, 66)
+                                                mode:NSRadioModeMatrix
+                                           prototype:(NSCell*)radio
+                                        numberOfRows:3
+                                     numberOfColumns:1];
+  [radio release];
+  [matrix setCellSize:NSMakeSize(400, 21)];
+  [self addSubview:matrix];
+  [matrix release];
+  NSArray *cellArray = [matrix cells];
+  mAsLaidOutRadio = [cellArray objectAtIndex:0];
+  mSelectedFrameRadio = [cellArray objectAtIndex:1];
+  mSeparateFramesRadio = [cellArray objectAtIndex:2];
+  [mAsLaidOutRadio setTitle:[self localizedString:"asLaidOut"]];
+  [mSelectedFrameRadio setTitle:[self localizedString:"selectedFrame"]];
+  [mSeparateFramesRadio setTitle:[self localizedString:"separateFrames"]];
+
+  // Radio enabled state
+  PRInt16 frameUIFlag;
+  mSettings->GetHowToEnableFrameUI(&frameUIFlag);
+  if (frameUIFlag == nsIPrintSettings::kFrameEnableNone) {
+    [mAsLaidOutRadio setEnabled:NO];
+    [mSelectedFrameRadio setEnabled:NO];
+    [mSeparateFramesRadio setEnabled:NO];
+  } else if (frameUIFlag == nsIPrintSettings::kFrameEnableAsIsAndEach) {
+    [mSelectedFrameRadio setEnabled:NO];
+  }
+
+  // Radio values
+  PRInt16 printFrameType;
+  mSettings->GetPrintFrameType(&printFrameType);
+  switch (printFrameType) {
+    case nsIPrintSettings::kFramesAsIs:
+      [mAsLaidOutRadio setState:NSOnState];
+      break;
+    case nsIPrintSettings::kSelectedFrame:
+      [mSelectedFrameRadio setState:NSOnState];
+      break;
+    case nsIPrintSettings::kEachFrameSep:
+      [mSeparateFramesRadio setState:NSOnState];
+      break;
+  }
+}
+
+- (void)addHeaderFooterSection
+{
+  // Labels
+  [self addLabel:"pageHeadersTitleMac" withFrame:NSMakeRect(0, 44, 151, 22)];
+  [self addLabel:"pageFootersTitleMac" withFrame:NSMakeRect(0, 0, 151, 22)];
+  [self addCenteredLabel:"left" withFrame:NSMakeRect(156, 22, 100, 22)];
+  [self addCenteredLabel:"center" withFrame:NSMakeRect(256, 22, 100, 22)];
+  [self addCenteredLabel:"right" withFrame:NSMakeRect(356, 22, 100, 22)];
+
+  // Lists
+  nsXPIDLString sel;
+
+  mSettings->GetHeaderStrLeft(getter_Copies(sel));
+  mHeaderLeftList = [self headerFooterItemListWithFrame:NSMakeRect(156, 44, 100, 22)
+                                           selectedItem:sel];
+  [self addSubview:mHeaderLeftList];
+
+  mSettings->GetHeaderStrCenter(getter_Copies(sel));
+  mHeaderCenterList = [self headerFooterItemListWithFrame:NSMakeRect(256, 44, 100, 22)
+                                             selectedItem:sel];
+  [self addSubview:mHeaderCenterList];
+
+  mSettings->GetHeaderStrRight(getter_Copies(sel));
+  mHeaderRightList = [self headerFooterItemListWithFrame:NSMakeRect(356, 44, 100, 22)
+                                            selectedItem:sel];
+  [self addSubview:mHeaderRightList];
+
+  mSettings->GetFooterStrLeft(getter_Copies(sel));
+  mFooterLeftList = [self headerFooterItemListWithFrame:NSMakeRect(156, 0, 100, 22)
+                                           selectedItem:sel];
+  [self addSubview:mFooterLeftList];
+
+  mSettings->GetFooterStrCenter(getter_Copies(sel));
+  mFooterCenterList = [self headerFooterItemListWithFrame:NSMakeRect(256, 0, 100, 22)
+                                             selectedItem:sel];
+  [self addSubview:mFooterCenterList];
+
+  mSettings->GetFooterStrRight(getter_Copies(sel));
+  mFooterRightList = [self headerFooterItemListWithFrame:NSMakeRect(356, 0, 100, 22)
+                                            selectedItem:sel];
+  [self addSubview:mFooterRightList];
+}
+
+// Export settings
+
+- (PRInt16)chosenFrameSetting
+{
+  if ([mAsLaidOutRadio state] == NSOnState)
+    return nsIPrintSettings::kFramesAsIs;
+  if ([mSelectedFrameRadio state] == NSOnState)
+    return nsIPrintSettings::kSelectedFrame;
+  if ([mSeparateFramesRadio state] == NSOnState)
+    return nsIPrintSettings::kEachFrameSep;
+  return nsIPrintSettings::kNoFrames;
+}
+
+- (const char*)headerFooterStringForList:(NSPopUpButton*)aList
+{
+  NSInteger index = [aList indexOfSelectedItem];
+  NS_ASSERTION(index < NSInteger(NS_ARRAY_LENGTH(sHeaderFooterTags)), "Index of dropdown is higher than expected!");
+  return sHeaderFooterTags[index];
+}
+
+- (void)exportHeaderFooterSettings
+{
+  const char* headerFooterStr;
+  headerFooterStr = [self headerFooterStringForList:mHeaderLeftList];
+  mSettings->SetHeaderStrLeft(NS_ConvertUTF8toUTF16(headerFooterStr).get());
+
+  headerFooterStr = [self headerFooterStringForList:mHeaderCenterList];
+  mSettings->SetHeaderStrCenter(NS_ConvertUTF8toUTF16(headerFooterStr).get());
+
+  headerFooterStr = [self headerFooterStringForList:mHeaderRightList];
+  mSettings->SetHeaderStrRight(NS_ConvertUTF8toUTF16(headerFooterStr).get());
+
+  headerFooterStr = [self headerFooterStringForList:mFooterLeftList];
+  mSettings->SetFooterStrLeft(NS_ConvertUTF8toUTF16(headerFooterStr).get());
+
+  headerFooterStr = [self headerFooterStringForList:mFooterCenterList];
+  mSettings->SetFooterStrCenter(NS_ConvertUTF8toUTF16(headerFooterStr).get());
+
+  headerFooterStr = [self headerFooterStringForList:mFooterRightList];
+  mSettings->SetFooterStrRight(NS_ConvertUTF8toUTF16(headerFooterStr).get());
+}
+
+// Summary
+
+- (NSString*)summaryValueForCheckbox:(NSButton*)aCheckbox
+{
+  if (![aCheckbox isEnabled])
+    return [self localizedString:"summaryNAValue"];
+
+  return [aCheckbox state] == NSOnState ?
+    [self localizedString:"summaryOnValue"] :
+    [self localizedString:"summaryOffValue"];
+}
+
+- (NSString*)framesSummaryValue
+{
+  switch([self chosenFrameSetting]) {
+    case nsIPrintSettings::kFramesAsIs:
+      return [self localizedString:"asLaidOut"];
+    case nsIPrintSettings::kSelectedFrame:
+      return [self localizedString:"selectedFrame"];
+    case nsIPrintSettings::kEachFrameSep:
+      return [self localizedString:"separateFrames"];
+  }
+  return [self localizedString:"summaryNAValue"];
+}
+
+- (NSString*)headerSummaryValue
+{
+  return [[mHeaderLeftList titleOfSelectedItem] stringByAppendingString:
+    [@", " stringByAppendingString:
+      [[mHeaderCenterList titleOfSelectedItem] stringByAppendingString:
+        [@", " stringByAppendingString:
+          [mHeaderRightList titleOfSelectedItem]]]]];
+}
+
+- (NSString*)footerSummaryValue
+{
+  return [[mFooterLeftList titleOfSelectedItem] stringByAppendingString:
+    [@", " stringByAppendingString:
+      [[mFooterCenterList titleOfSelectedItem] stringByAppendingString:
+        [@", " stringByAppendingString:
+          [mFooterRightList titleOfSelectedItem]]]]];
+}
+
+- (NSArray*)localizedSummaryItems
+{
+  return [NSArray arrayWithObjects:
+    [NSDictionary dictionaryWithObjectsAndKeys:
+      [self localizedString:"summaryFramesTitle"], NSPrintPanelAccessorySummaryItemNameKey,
+      [self framesSummaryValue], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
+    [NSDictionary dictionaryWithObjectsAndKeys:
+      [self localizedString:"summarySelectionOnlyTitle"], NSPrintPanelAccessorySummaryItemNameKey,
+      [self summaryValueForCheckbox:mPrintSelectionOnlyCheckbox], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
+    [NSDictionary dictionaryWithObjectsAndKeys:
+      [self localizedString:"summaryShrinkToFitTitle"], NSPrintPanelAccessorySummaryItemNameKey,
+      [self summaryValueForCheckbox:mShrinkToFitCheckbox], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
+    [NSDictionary dictionaryWithObjectsAndKeys:
+      [self localizedString:"summaryPrintBGColorsTitle"], NSPrintPanelAccessorySummaryItemNameKey,
+      [self summaryValueForCheckbox:mPrintBGColorsCheckbox], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
+    [NSDictionary dictionaryWithObjectsAndKeys:
+      [self localizedString:"summaryPrintBGImagesTitle"], NSPrintPanelAccessorySummaryItemNameKey,
+      [self summaryValueForCheckbox:mPrintBGImagesCheckbox], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
+    [NSDictionary dictionaryWithObjectsAndKeys:
+      [self localizedString:"summaryHeaderTitle"], NSPrintPanelAccessorySummaryItemNameKey,
+      [self headerSummaryValue], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
+    [NSDictionary dictionaryWithObjectsAndKeys:
+      [self localizedString:"summaryFooterTitle"], NSPrintPanelAccessorySummaryItemNameKey,
+      [self footerSummaryValue], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
+    nil];
+}
+
+@end
+
+// Accessory controller
+
+@implementation PrintPanelAccessoryController
+
+- (id)initWithSettings:(nsIPrintSettings*)aSettings
+{
+  [super initWithNibName:nil bundle:nil];
+  NSView* accView = [[PrintPanelAccessoryView alloc] initWithSettings:aSettings];
+  [self setView:accView];
+  [accView release];
+  return self;
+}
+
+- (void)exportSettings
+{
+  return [(PrintPanelAccessoryView*)[self view] exportSettings];
+}
+
+- (NSArray *)localizedSummaryItems
+{
+  return [(PrintPanelAccessoryView*)[self view] localizedSummaryItems];
+}
+
+@end
--- a/widget/src/cocoa/nsPrintOptionsX.h
+++ b/widget/src/cocoa/nsPrintOptionsX.h
@@ -41,18 +41,21 @@
 
 #include "nsPrintOptionsImpl.h"
 
 class nsPrintOptionsX : public nsPrintOptions
 {
 public:
              nsPrintOptionsX();
   virtual    ~nsPrintOptionsX();
+
+#ifndef MOZ_COCOA_PRINTING
   NS_IMETHOD ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings);
   NS_IMETHOD GetNativeData(PRInt16 aDataType, void * *_retval);
+#endif
 
 protected:
   nsresult   _CreatePrintSettings(nsIPrintSettings **_retval);
   nsresult   ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags);
   nsresult   WritePrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags);
 };
 
 #endif // nsPrintOptionsX_h_
--- a/widget/src/cocoa/nsPrintOptionsX.mm
+++ b/widget/src/cocoa/nsPrintOptionsX.mm
@@ -36,58 +36,67 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsCOMPtr.h"
 #include "nsIServiceManager.h"
 #include "nsPrintOptionsX.h"
 #include "nsPrintSettingsX.h"
 
+#ifndef MOZ_COCOA_PRINTING
 #include "nsCRT.h"
 #include "plbase64.h"
 #include "prmem.h"
+#endif
 
 nsPrintOptionsX::nsPrintOptionsX()
 {
 }
 
 nsPrintOptionsX::~nsPrintOptionsX()
 {
 }
 
+#ifndef MOZ_COCOA_PRINTING
 NS_IMETHODIMP
 nsPrintOptionsX::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 } 
 
 NS_IMETHODIMP
 nsPrintOptionsX::GetNativeData(PRInt16 aDataType, void **_retval)
 {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = nsnull;
 
   return NS_ERROR_NOT_IMPLEMENTED;
 }
+#endif
 
 nsresult
 nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags)
 {
   nsresult rv;
   
   rv = nsPrintOptions::ReadPrefs(aPS, aPrinterName, aFlags);
   NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::ReadPrefs() failed");
-  
+
+#ifdef MOZ_COCOA_PRINTING
+  nsCOMPtr<nsPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
+#else
   nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
+#endif
+
   if (!printSettingsX)
     return NS_ERROR_NO_INTERFACE;
   rv = printSettingsX->ReadPageFormatFromPrefs();
-  NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::ReadPageFormatFromPrefs() failed");
-  
-  return NS_OK;
+  NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintSettingsX::ReadPageFormatFromPrefs() failed");
+
+  return rv;
 }
 
 nsresult nsPrintOptionsX::_CreatePrintSettings(nsIPrintSettings **_retval)
 {
   nsresult rv;
   *_retval = nsnull;
 
   nsPrintSettingsX* printSettings = new nsPrintSettingsX; // does not initially ref count
@@ -107,16 +116,20 @@ nsresult nsPrintOptionsX::_CreatePrintSe
 nsresult
 nsPrintOptionsX::WritePrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags)
 {
   nsresult rv;
 
   rv = nsPrintOptions::WritePrefs(aPS, aPrinterName, aFlags);
   NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::WritePrefs() failed");
 
+#ifdef MOZ_COCOA_PRINTING
+  nsCOMPtr<nsPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
+#else
   nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
+#endif
   if (!printSettingsX)
     return NS_ERROR_NO_INTERFACE;
   rv = printSettingsX->WritePageFormatToPrefs();
-  NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::WritePageFormatToPrefs() failed");
+  NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintSettingsX::WritePageFormatToPrefs() failed");
 
-  return NS_OK;
+  return rv;
 }
--- a/widget/src/cocoa/nsPrintSettingsX.h
+++ b/widget/src/cocoa/nsPrintSettingsX.h
@@ -34,29 +34,43 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsPrintSettingsX_h_
 #define nsPrintSettingsX_h_
 
 #include "nsPrintSettingsImpl.h"  
-#include "nsIPrintSettingsX.h"  
 
-class nsPrintSettingsX : public nsPrintSettings,
-                         public nsIPrintSettingsX
+#ifdef MOZ_COCOA_PRINTING
+#import <Cocoa/Cocoa.h>
+#else
+#include "nsIPrintSettingsX.h"  
+#endif
+
+class nsPrintSettingsX : public nsPrintSettings
+#ifndef MOZ_COCOA_PRINTING
+                       , public nsIPrintSettingsX
+#endif
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
+#ifndef MOZ_COCOA_PRINTING
   NS_DECL_NSIPRINTSETTINGSX
+#endif
 
   nsPrintSettingsX();
   virtual ~nsPrintSettingsX();
+  nsresult Init();
 
-  nsresult Init();
+#ifdef MOZ_COCOA_PRINTING
+  NSPrintInfo* GetCocoaPrintInfo() { return mPrintInfo; }
+  virtual nsresult ReadPageFormatFromPrefs();
+  virtual nsresult WritePageFormatToPrefs();
+#endif
 
 protected:
   nsPrintSettingsX(const nsPrintSettingsX& src);
   nsPrintSettingsX& operator=(const nsPrintSettingsX& rhs);
 
   nsresult _Clone(nsIPrintSettings **_retval);
   nsresult _Assign(nsIPrintSettings *aPS);
 
@@ -65,11 +79,14 @@ protected:
   nsresult InitUnwriteableMargin();
 
   // The out param has a ref count of 1 on return so caller needs to PMRelase() when done.
   OSStatus CreateDefaultPageFormat(PMPrintSession aSession, PMPageFormat& outFormat);
   OSStatus CreateDefaultPrintSettings(PMPrintSession aSession, PMPrintSettings& outSettings);
 
   PMPageFormat mPageFormat;
   PMPrintSettings mPrintSettings;
+#ifdef MOZ_COCOA_PRINTING
+  NSPrintInfo* mPrintInfo;
+#endif
 };
 
 #endif // nsPrintSettingsX_h_
--- a/widget/src/cocoa/nsPrintSettingsX.mm
+++ b/widget/src/cocoa/nsPrintSettingsX.mm
@@ -16,16 +16,17 @@
  *
  * The Initial Developer of the Original Code is
  * Netscape Communications Corporation.
  * Portions created by the Initial Developer are Copyright (C) 1998
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Conrad Carlen <ccarlen@netscape.com>
+ *   Markus Stange <mstange@themasta.com>
  *
  * 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"),
  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -33,40 +34,58 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsPrintSettingsX.h"
 #include "nsObjCExceptions.h"
-#include "nsIPrintSessionX.h"
 
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsServiceManagerUtils.h"
 
 #include "plbase64.h"
 #include "prmem.h"
 #include "prnetdb.h"
 
 #include "nsCocoaWindow.h"
 #include "nsMenuBarX.h"
 #include "nsMenuUtilsX.h"
 
+#define PRINTING_PREF_BRANCH            "print."
+#define MAC_OS_X_PAGE_SETUP_PREFNAME    "macosx.pagesetup-2"
+
+#ifdef MOZ_COCOA_PRINTING
+
+NS_IMPL_ISUPPORTS_INHERITED1(nsPrintSettingsX, nsPrintSettings, nsPrintSettingsX)
+
+nsPrintSettingsX::nsPrintSettingsX()
+{
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
+
+  mPrintInfo = [[NSPrintInfo sharedPrintInfo] copy];
+  mPageFormat = (PMPageFormat)[mPrintInfo PMPageFormat];
+  mPrintSettings = (PMPrintSettings)[mPrintInfo PMPrintSettings];
+
+  NS_OBJC_END_TRY_ABORT_BLOCK;
+}
+
+#else
+
+#include "nsIPrintSessionX.h"
+
 // This struct should be represented identically on all architectures, and
 // there shouldn't be any padding before the data field.
 struct FrozenHandle {
   PRUint32 size;
   char data[0];
 };
 
-#define PRINTING_PREF_BRANCH            "print."
-#define MAC_OS_X_PAGE_SETUP_PREFNAME    "macosx.pagesetup-2"
-
 // Utility class stack-based handle ownership
 class StHandleOwner
 {
 public:
   StHandleOwner(Handle inHandle)
     : mHandle(inHandle)
   {
   }
@@ -135,16 +154,18 @@ protected:
 NS_IMPL_ISUPPORTS_INHERITED1(nsPrintSettingsX, nsPrintSettings, nsIPrintSettingsX)
 
 nsPrintSettingsX::nsPrintSettingsX() :
   mPageFormat(kPMNoPageFormat),
   mPrintSettings(kPMNoPrintSettings)
 {
 }
 
+#endif
+
 nsPrintSettingsX::nsPrintSettingsX(const nsPrintSettingsX& src) :
   mPageFormat(kPMNoPageFormat),
   mPrintSettings(kPMNoPrintSettings)
 {
   *this = src;
 }
 
 nsPrintSettingsX::~nsPrintSettingsX()
@@ -168,16 +189,20 @@ nsPrintSettingsX& nsPrintSettingsX::oper
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   if (this == &rhs) {
     return *this;
   }
   
   nsPrintSettings::operator=(rhs);
 
+#ifdef MOZ_COCOA_PRINTING
+  [mPrintInfo release];
+  mPrintInfo = [rhs.mPrintInfo copy];
+#else
   OSStatus status;
    
   if (mPageFormat != kPMNoPageFormat) {
     ::PMRelease(mPageFormat);
     mPageFormat = kPMNoPageFormat;
   }
   if (rhs.mPageFormat != kPMNoPageFormat) {
     PMPageFormat pageFormat;
@@ -205,26 +230,30 @@ nsPrintSettingsX& nsPrintSettingsX::oper
     if (status == noErr) {
       status = ::PMCopyPrintSettings(rhs.mPrintSettings, printSettings);
       if (status == noErr)
         mPrintSettings = printSettings;
       else
         ::PMRelease(printSettings);
     }
   }
+#endif
 
   return *this;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(*this);
 }
 
 nsresult nsPrintSettingsX::Init()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
+#ifdef MOZ_COCOA_PRINTING
+  return InitUnwriteableMargin();
+#else
   OSStatus status;
 
   PMPrintSession printSession = NULL;
   status = ::PMCreateSession(&printSession);
   
   if (status == noErr) {
     // First, create a default page format
     status = CreateDefaultPageFormat(printSession, mPageFormat);
@@ -234,16 +263,17 @@ nsresult nsPrintSettingsX::Init()
     if (status == noErr) {
       status = CreateDefaultPrintSettings(printSession, mPrintSettings);
     }
     OSStatus tempStatus = ::PMRelease(printSession);
     if (status == noErr)
       status = tempStatus;
   }
   return (status == noErr) ? NS_OK : NS_ERROR_FAILURE;
+#endif
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 // Should be called whenever mPageFormat changes.
 NS_IMETHODIMP nsPrintSettingsX::InitUnwriteableMargin()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@@ -260,16 +290,85 @@ NS_IMETHODIMP nsPrintSettingsX::InitUnwr
   mUnwriteableMargin.bottom = NS_POINTS_TO_TWIPS(paperMargin.bottom);
   mUnwriteableMargin.right  = NS_POINTS_TO_TWIPS(paperMargin.right);
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;  
 }
 
+#ifdef MOZ_COCOA_PRINTING
+NS_IMETHODIMP nsPrintSettingsX::ReadPageFormatFromPrefs()
+{
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
+  nsresult rv;
+  nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  if (NS_FAILED(rv))
+    return rv;
+  nsCOMPtr<nsIPrefBranch> prefBranch;
+  rv = prefService->GetBranch(PRINTING_PREF_BRANCH, getter_AddRefs(prefBranch));
+  if (NS_FAILED(rv))
+    return rv;
+      
+  nsXPIDLCString encodedData;
+  rv = prefBranch->GetCharPref(MAC_OS_X_PAGE_SETUP_PREFNAME, getter_Copies(encodedData));
+  if (NS_FAILED(rv))
+    return rv;
+
+  // decode the base64
+  char* decodedData = PL_Base64Decode(encodedData.get(), encodedData.Length(), nsnull);
+  NSData* data = [NSData dataWithBytes:decodedData length:PL_strlen(decodedData)];
+  if (!data)
+    return NS_ERROR_FAILURE;
+
+  PMPageFormat newPageFormat;
+  OSStatus status = ::PMPageFormatCreateWithDataRepresentation((CFDataRef)data, &newPageFormat);
+  if (status == noErr) {
+    ::PMCopyPageFormat(newPageFormat, mPageFormat);
+    [mPrintInfo updateFromPMPageFormat];
+  }
+  InitUnwriteableMargin();
+
+  return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
+}
+
+NS_IMETHODIMP nsPrintSettingsX::WritePageFormatToPrefs()
+{
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
+  if (mPageFormat == kPMNoPageFormat)
+    return NS_ERROR_NOT_INITIALIZED;
+
+  nsresult rv;
+  nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  if (NS_FAILED(rv))
+    return rv;
+  nsCOMPtr<nsIPrefBranch> prefBranch;
+  rv = prefService->GetBranch(PRINTING_PREF_BRANCH, getter_AddRefs(prefBranch));
+  if (NS_FAILED(rv))
+    return rv;
+
+  NSData* data = nil;
+  OSStatus err = ::PMPageFormatCreateDataRepresentation(mPageFormat, (CFDataRef*)&data, kPMDataFormatXMLDefault);
+  if (err != noErr)
+    return NS_ERROR_FAILURE;
+
+  nsXPIDLCString encodedData;
+  encodedData.Adopt(PL_Base64Encode((char*)[data bytes], [data length], nsnull));
+  if (!encodedData.get())
+    return NS_ERROR_OUT_OF_MEMORY;
+
+  return prefBranch->SetCharPref(MAC_OS_X_PAGE_SETUP_PREFNAME, encodedData);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
+}
+#else
 NS_IMETHODIMP nsPrintSettingsX::GetNativePrintSession(PMPrintSession *aNativePrintSession)
 {
    NS_ENSURE_ARG_POINTER(aNativePrintSession);
    *aNativePrintSession = nsnull;
    
    nsCOMPtr<nsIPrintSession> printSession;
    GetPrintSession(getter_AddRefs(printSession));
    if (!printSession)
@@ -446,16 +545,17 @@ NS_IMETHODIMP nsPrintSettingsX::WritePag
   free(frozenHandle);
   if (!encodedData.get())
     return NS_ERROR_OUT_OF_MEMORY;
 
   return prefBranch->SetCharPref(MAC_OS_X_PAGE_SETUP_PREFNAME, encodedData);
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
+#endif
 
 nsresult nsPrintSettingsX::_Clone(nsIPrintSettings **_retval)
 {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = nsnull;
   
   nsPrintSettingsX *newSettings = new nsPrintSettingsX(*this);
   if (!newSettings)
@@ -469,16 +569,17 @@ NS_IMETHODIMP nsPrintSettingsX::_Assign(
 {
   nsPrintSettingsX *printSettingsX = static_cast<nsPrintSettingsX*>(aPS);
   if (!printSettingsX)
     return NS_ERROR_UNEXPECTED;
   *this = *printSettingsX;
   return NS_OK;
 }
 
+#ifndef MOZ_COCOA_PRINTING
 OSStatus nsPrintSettingsX::CreateDefaultPageFormat(PMPrintSession aSession, PMPageFormat& outFormat)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   OSStatus status;
   PMPageFormat pageFormat;
   
   outFormat = kPMNoPageFormat;
@@ -526,8 +627,9 @@ NS_IMETHODIMP nsPrintSettingsX::CleanUpA
   } else {
     nsMenuBarX* hiddenWindowMenuBar = nsMenuUtilsX::GetHiddenWindowMenuBar();
     if (hiddenWindowMenuBar)
       hiddenWindowMenuBar->Paint();
   }
   
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
+#endif
--- a/widget/src/cocoa/nsWidgetFactory.mm
+++ b/widget/src/cocoa/nsWidgetFactory.mm
@@ -59,34 +59,45 @@
 
 #include "nsAccelerometerX.h"
 #include "nsSound.h"
 #include "nsIdleServiceX.h"
 
 #include "nsScreenManagerCocoa.h"
 #include "nsDeviceContextSpecX.h"
 #include "nsPrintOptionsX.h"
+
+#ifdef MOZ_COCOA_PRINTING
+#include "nsPrintDialogX.h"
+#include "nsPrintSession.h"
+#else
 #include "nsPrintSessionX.h"
+#endif
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCocoaWindow)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsChildView)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAccelerometerX)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerCocoa)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsX, Init)
+#ifdef MOZ_COCOA_PRINTING
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceX, Init)
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
+#else
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSessionX, Init)
+#endif
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceX)
 
 #include "nsMenuBarX.h"
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeMenuServiceX)
 
 #include "nsBidiKeyboard.h"
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
 
@@ -162,24 +173,35 @@ static const nsModuleComponentInfo gComp
   { "nsScreenManager",
     NS_SCREENMANAGER_CID,
     "@mozilla.org/gfx/screenmanager;1",
     nsScreenManagerCocoaConstructor },
   { "nsDeviceContextSpec",
      NS_DEVICE_CONTEXT_SPEC_CID,
      "@mozilla.org/gfx/devicecontextspec;1",
      nsDeviceContextSpecXConstructor },
+#ifdef MOZ_COCOA_PRINTING
+  { "Native Print Dialog",
+    NS_PRINTDIALOGSERVICE_CID,
+    NS_PRINTDIALOGSERVICE_CONTRACTID,
+    nsPrintDialogServiceXConstructor },
+  { "Print Session",
+    NS_PRINTSESSION_CID,
+    "@mozilla.org/gfx/printsession;1",
+    nsPrintSessionConstructor },
+#else
+  { "Print Session",
+    NS_PRINTSESSION_CID,
+    "@mozilla.org/gfx/printsession;1",
+    nsPrintSessionXConstructor },
+#endif
   { "PrintSettings Service",
      NS_PRINTSETTINGSSERVICE_CID,
      "@mozilla.org/gfx/printsettings-service;1",
      nsPrintOptionsXConstructor },
-  { "Print Session",
-    NS_PRINTSESSION_CID,
-    "@mozilla.org/gfx/printsession;1",
-    nsPrintSessionXConstructor },
   { "User Idle Service",
     NS_IDLE_SERVICE_CID,
     "@mozilla.org/widget/idleservice;1",
     nsIdleServiceXConstructor },
   { "Native Menu Service",
     NS_NATIVEMENUSERVICE_CID,
     "@mozilla.org/widget/nativemenuservice;1",
     nsNativeMenuServiceXConstructor },
--- a/widget/src/gtk2/nsPrintDialogGTK.cpp
+++ b/widget/src/gtk2/nsPrintDialogGTK.cpp
@@ -130,17 +130,17 @@ ShowCustomDialog(GtkComboBox *changed_bo
     g_object_set_data(G_OBJECT(changed_box), "previous-active", GINT_TO_POINTER(gtk_combo_box_get_active(changed_box)));
     return;
   }
 
   nsCOMPtr<nsIStringBundleService> bundleSvc =
        do_GetService(NS_STRINGBUNDLE_CONTRACTID);
 
   nsCOMPtr<nsIStringBundle> printBundle;
-  bundleSvc->CreateBundle("chrome://global/locale/gnomeprintdialog.properties", getter_AddRefs(printBundle));
+  bundleSvc->CreateBundle("chrome://global/locale/printdialog.properties", getter_AddRefs(printBundle));
   nsXPIDLString intlString;
 
   printBundle->GetStringFromName(NS_LITERAL_STRING("headerFooterCustom").get(), getter_Copies(intlString));
   GtkWidget* prompt_dialog = gtk_dialog_new_with_buttons(NS_ConvertUTF16toUTF8(intlString).get(), NULL,
                                                          GTK_DIALOG_MODAL,
                                                          GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
                                                          GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
                                                          NULL);
@@ -225,35 +225,35 @@ class nsPrintDialogWidgetGTK {
 };
 
 nsPrintDialogWidgetGTK::nsPrintDialogWidgetGTK(nsIDOMWindow *aParent, nsIPrintSettings *aSettings)
 {
   GtkWindow* gtkParent = get_gtk_window_for_nsiwidget(DOMWindowToWidget(aParent));
   NS_ASSERTION(gtkParent, "Need a GTK window for dialog to be modal.");
 
   nsCOMPtr<nsIStringBundleService> bundleSvc = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
-  bundleSvc->CreateBundle("chrome://global/locale/gnomeprintdialog.properties", getter_AddRefs(printBundle));
+  bundleSvc->CreateBundle("chrome://global/locale/printdialog.properties", getter_AddRefs(printBundle));
 
-  dialog = gtk_print_unix_dialog_new(GetUTF8FromBundle("printTitle").get(), gtkParent);
+  dialog = gtk_print_unix_dialog_new(GetUTF8FromBundle("printTitleGTK").get(), gtkParent);
 
   gtk_print_unix_dialog_set_manual_capabilities(GTK_PRINT_UNIX_DIALOG(dialog),
                     GtkPrintCapabilities(
                         GTK_PRINT_CAPABILITY_PAGE_SET
                       | GTK_PRINT_CAPABILITY_COPIES
                       | GTK_PRINT_CAPABILITY_COLLATE
                       | GTK_PRINT_CAPABILITY_REVERSE
                       | GTK_PRINT_CAPABILITY_SCALE
                     )
                   );
 
   // The vast majority of magic numbers in this widget construction are padding. e.g. for
   // the set_border_width below, 12px matches that of just about every other window.
   GtkWidget* custom_options_tab = gtk_vbox_new(FALSE, 0);
   gtk_container_set_border_width(GTK_CONTAINER(custom_options_tab), 12);
-  GtkWidget* tab_label = gtk_label_new(GetUTF8FromBundle("optionsTabLabel").get());
+  GtkWidget* tab_label = gtk_label_new(GetUTF8FromBundle("optionsTabLabelGTK").get());
 
   PRInt16 frameUIFlag;
   aSettings->GetHowToEnableFrameUI(&frameUIFlag);
   radio_as_laid_out = gtk_radio_button_new_with_mnemonic(NULL, GetUTF8FromBundle("asLaidOut").get());
   if (frameUIFlag == nsIPrintSettings::kFrameEnableNone)
     gtk_widget_set_sensitive(radio_as_laid_out, FALSE);
 
   radio_selected_frame = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(radio_as_laid_out),
@@ -264,17 +264,17 @@ nsPrintDialogWidgetGTK::nsPrintDialogWid
 
   radio_separate_frames = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(radio_as_laid_out),
                                                                          GetUTF8FromBundle("separateFrames").get());
   if (frameUIFlag == nsIPrintSettings::kFrameEnableNone)
     gtk_widget_set_sensitive(radio_separate_frames, FALSE);
 
   // "Print Frames" options label, bold and center-aligned
   GtkWidget* print_frames_label = gtk_label_new(NULL);
-  char* pangoMarkup = g_markup_printf_escaped("<b>%s</b>", GetUTF8FromBundle("printFramesTitle").get());
+  char* pangoMarkup = g_markup_printf_escaped("<b>%s</b>", GetUTF8FromBundle("printFramesTitleGTK").get());
   gtk_label_set_markup(GTK_LABEL(print_frames_label), pangoMarkup);
   g_free(pangoMarkup);
   gtk_misc_set_alignment(GTK_MISC(print_frames_label), 0, 0);
 
   // Align the radio buttons slightly so they appear to fall under the aforementioned label as per the GNOME HIG
   GtkWidget* frames_radio_container = gtk_alignment_new(0, 0, 0, 0);
   gtk_alignment_set_padding(GTK_ALIGNMENT(frames_radio_container), 8, 0, 12, 0);