Back out Michael Ventnor's patch from bug 193001 for now, as it is causing crashes in bug 396024's mochitest.

This commit is contained in:
reed%reedloden.com 2008-01-17 10:13:33 +00:00
Родитель ef16acdbfb
Коммит 6f9ce8a3d1
20 изменённых файлов: 115 добавлений и 372 удалений

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

@ -250,9 +250,6 @@ gtk/gtkinvisible.h
gtk/gtkmain.h gtk/gtkmain.h
gtk/gtkmessagedialog.h gtk/gtkmessagedialog.h
gtk/gtkobject.h gtk/gtkobject.h
gtk/gtkprinter.h
gtk/gtkprintjob.h
gtk/gtkprintunixdialog.h
gtk/gtkprivate.h gtk/gtkprivate.h
gtk/gtkselection.h gtk/gtkselection.h
gtk/gtksignal.h gtk/gtksignal.h

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

@ -4597,7 +4597,7 @@ fi
if test "$COMPILE_ENVIRONMENT"; then if test "$COMPILE_ENVIRONMENT"; then
if test "$MOZ_ENABLE_GTK2" if test "$MOZ_ENABLE_GTK2"
then then
PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 gdk-x11-2.0 glib-2.0 gobject-2.0) PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gdk-x11-2.0 glib-2.0 gobject-2.0)
fi fi
fi # COMPILE_ENVIRONMENT fi # COMPILE_ENVIRONMENT

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

@ -44,7 +44,6 @@
#include "nsISupportsUtils.h" #include "nsISupportsUtils.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsString.h" #include "nsString.h"
#include "nsIPrintDialogService.h"
// Printing Progress Includes // Printing Progress Includes
#include "nsPrintProgress.h" #include "nsPrintProgress.h"
@ -110,13 +109,6 @@ nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrin
NS_ENSURE_ARG(webBrowserPrint); NS_ENSURE_ARG(webBrowserPrint);
NS_ENSURE_ARG(printSettings); NS_ENSURE_ARG(printSettings);
// Try to access a component dialog
nsCOMPtr<nsIPrintDialogService> dlgPrint(do_GetService(
NS_PRINTDIALOGSERVICE_CONTRACTID));
if (dlgPrint)
return dlgPrint->Show(printSettings);
// Show the built-in dialog instead
ParamBlock block; ParamBlock block;
nsresult rv = block.Init(); nsresult rv = block.Init();
if (NS_FAILED(rv)) if (NS_FAILED(rv))
@ -185,12 +177,6 @@ nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *p
{ {
NS_ENSURE_ARG(printSettings); NS_ENSURE_ARG(printSettings);
// Try to access a component dialog
nsCOMPtr<nsIPrintDialogService> dlgPrint(do_GetService(
NS_PRINTDIALOGSERVICE_CONTRACTID));
if (dlgPrint)
return dlgPrint->ShowPageSetup(printSettings);
ParamBlock block; ParamBlock block;
nsresult rv = block.Init(); nsresult rv = block.Init();
if (NS_FAILED(rv)) if (NS_FAILED(rv))

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

@ -597,8 +597,6 @@ nsPrintEngine::DoCommonPrint(PRBool aIsPrintPreview,
// are telling GFX we want to print silent // are telling GFX we want to print silent
printSilently = PR_TRUE; printSilently = PR_TRUE;
} }
// XXX Some platforms allow the user to change the ShrinkToFit option so change it here too
mPrt->mPrintSettings->GetShrinkToFit(&mPrt->mShrinkToFit);
} else { } else {
rv = NS_ERROR_GFX_NO_PRINTROMPTSERVICE; rv = NS_ERROR_GFX_NO_PRINTROMPTSERVICE;
} }

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

@ -1,28 +0,0 @@
printTitle=Print
optionsTabLabel=Options
printFramesTitle=Print Frames
# TRANSLATOR NOTE: For radio button labels and check button labels, an underscore _
# before a character will turn that character into an accesskey.
# e.g. "_As laid out" will make A the accesskey.
asLaidOut=_As Laid Out on the Screen
selectedFrame=The _Selected Frame
separateFrames=Each Frame on Separate _Pages
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
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

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

@ -40,7 +40,6 @@
+ locale/@AB_CD@/global/printPageSetup.dtd (%chrome/global/printPageSetup.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/printPreview.dtd (%chrome/global/printPreview.dtd)
+ locale/@AB_CD@/global/printPreviewProgress.dtd (%chrome/global/printPreviewProgress.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/printProgress.dtd (%chrome/global/printProgress.dtd) + locale/@AB_CD@/global/printProgress.dtd (%chrome/global/printProgress.dtd)
+ locale/@AB_CD@/global/regionNames.properties (%chrome/global/regionNames.properties) + locale/@AB_CD@/global/regionNames.properties (%chrome/global/regionNames.properties)
+ locale/@AB_CD@/global/dialog.properties (%chrome/global/dialog.properties) + locale/@AB_CD@/global/dialog.properties (%chrome/global/dialog.properties)

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

@ -78,12 +78,8 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),beos)
EXPORTS += nsIDragSessionBeOS.h EXPORTS += nsIDragSessionBeOS.h
endif endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2) ifneq (,$(filter gtk2,$(MOZ_WIDGET_TOOLKIT)))
EXPORTS += \ EXPORTS += nsIDragSessionGTK.h
nsIDragSessionGTK.h \
nsIPrintDialogService.h \
$(NULL)
endif endif
XPIDLSRCS = \ XPIDLSRCS = \
@ -122,10 +118,6 @@ XPIDLSRCS += nsIPrintSettingsX.idl \
nsIPrintSessionX.idl nsIPrintSessionX.idl
endif endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
XPIDLSRCS += nsIPrintSettingsGTK.idl
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),os2) ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
XPIDLSRCS += nsIRwsService.idl XPIDLSRCS += nsIRwsService.idl
endif endif

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

@ -1,97 +0,0 @@
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is
* Kenneth Herron <kherron@fmailbox.com>
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* 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
* 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 nsIPrintDialogService_h__
#define nsIPrintDialogService_h__
#include "nsISupports.h"
class nsIPrintSettings;
/*
* Interface to a print dialog accessed through the widget library.
*/
#define NS_IPRINTDIALOGSERVICE_IID \
{ 0x3715eb1a, 0xb314, 0x447c, \
{ 0x95, 0x33, 0xd0, 0x6a, 0x6d, 0xa6, 0xa6, 0xf0 } }
/**
*
*/
class nsIPrintDialogService : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRINTDIALOGSERVICE_IID)
/**
* Initialize the service.
* @return NS_OK or a suitable error.
*/
NS_IMETHOD Init() = 0;
/**
* Show the print dialog.
* @param aSettings On entry, this contains initial settings for the
* print dialog. On return, if the print operation should
* proceed then this contains settings for the print
* operation.
* @return NS_OK if the print operation should proceed
* @return NS_ERROR_ABORT if the user indicated not to proceed
* @return a suitable error for failures to show the print dialog.
*/
NS_IMETHOD Show(nsIPrintSettings *aSettings) = 0;
/**
* Show the page setup dialog. Note that there is no way to tell whether the user clicked OK or Cancel on the
* dialog.
* @param aSettings On entry, this contains initial settings for the
* page setup dialog. On return, this contains new default page setup options.
* @return NS_OK if everything is OK.
* @return a suitable error for failures to show the page setup dialog.
*/
NS_IMETHOD ShowPageSetup(nsIPrintSettings *aSettings) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIPrintDialogService, NS_IPRINTDIALOGSERVICE_IID)
#define NS_PRINTDIALOGSERVICE_CONTRACTID ("@mozilla.org/widget/printdialog-service;1")
#endif // nsIPrintDialogService_h__

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

@ -167,6 +167,3 @@
{ 0x2f977d53, 0x5485, 0x11d4, \ { 0x2f977d53, 0x5485, 0x11d4, \
{ 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 } } { 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 } }
#define NS_PRINTDIALOGSERVICE_CID \
{ 0x06beec76, 0xa183, 0x4d9f, \
{ 0x85, 0xdd, 0x08, 0x5f, 0x26, 0xda, 0x56, 0x5a } }

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

@ -108,9 +108,9 @@ CPPSRCS = \
nsPrintOptionsGTK.cpp \ nsPrintOptionsGTK.cpp \
nsImageToPixbuf.cpp \ nsImageToPixbuf.cpp \
nsAccessibilityHelper.cpp \ nsAccessibilityHelper.cpp \
nsPrintJobFactoryGTK.cpp \
nsPrintJobGTK.cpp \
nsIdleServiceGTK.cpp \ nsIdleServiceGTK.cpp \
nsPrintDialogGTK.cpp \
nsPrintSettingsGTK.cpp \
$(NULL) $(NULL)
# build our subdirs, too # build our subdirs, too

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

@ -23,7 +23,6 @@
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de> * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
* Ken Herron <kherron+mozilla@fmailbox.com> * Ken Herron <kherron+mozilla@fmailbox.com>
* Julien Lafon <julien.lafon@gmail.com> * Julien Lafon <julien.lafon@gmail.com>
* Michael Ventnor <m.ventnor@gmail.com>
* *
* 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"),
@ -67,16 +66,12 @@
#include "nsPaperPS.h" /* Paper size list */ #include "nsPaperPS.h" /* Paper size list */
#endif /* USE_POSTSCRIPT */ #endif /* USE_POSTSCRIPT */
#include "nsPrintJobFactoryGTK.h"
#include "nsIPrintJobGTK.h" #include "nsIPrintJobGTK.h"
#include "nsIPrintSettingsGTK.h"
#include "nsIFileStreams.h" #include "nsIFileStreams.h"
#include "nsILocalFile.h" #include "nsILocalFile.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
/* Ensure that the result is always equal to either PR_TRUE or PR_FALSE */ /* Ensure that the result is always equal to either PR_TRUE or PR_FALSE */
#define MAKE_PR_BOOL(val) ((val)?(PR_TRUE):(PR_FALSE)) #define MAKE_PR_BOOL(val) ((val)?(PR_TRUE):(PR_FALSE))
@ -387,11 +382,13 @@ nsStringArray* GlobalPrinters::mGlobalPrinterList = nsnull;
nsDeviceContextSpecGTK::nsDeviceContextSpecGTK() nsDeviceContextSpecGTK::nsDeviceContextSpecGTK()
{ {
DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::nsDeviceContextSpecGTK()\n")); DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::nsDeviceContextSpecGTK()\n"));
mPrintJob = nsnull;
} }
nsDeviceContextSpecGTK::~nsDeviceContextSpecGTK() nsDeviceContextSpecGTK::~nsDeviceContextSpecGTK()
{ {
DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::~nsDeviceContextSpecGTK()\n")); DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::~nsDeviceContextSpecGTK()\n"));
delete mPrintJob;
} }
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecGTK, NS_IMPL_ISUPPORTS1(nsDeviceContextSpecGTK,
@ -413,30 +410,18 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::GetSurfaceForPrinter(gfxASurface **aSurfac
height /= 20; height /= 20;
DO_PR_DEBUG_LOG(("\"%s\", %f, %f\n", path, width, height)); DO_PR_DEBUG_LOG(("\"%s\", %f, %f\n", path, width, height));
nsresult rv;
// Spool file. Use Glib's temporary file function since we're nsresult rv = nsPrintJobFactoryGTK::CreatePrintJob(this, mPrintJob);
// already dependent on the gtk software stack. if (NS_FAILED(rv))
gchar *buf; return rv;
gint fd = g_file_open_tmp("XXXXXX.tmp", &buf, nsnull);
if (-1 == fd)
return NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE;
close(fd);
rv = NS_NewNativeLocalFile(nsDependentCString(buf), PR_FALSE, nsCOMPtr<nsILocalFile> file;
getter_AddRefs(mSpoolFile)); rv = mPrintJob->GetSpoolFile(getter_AddRefs(file));
if (NS_FAILED(rv)) { if (NS_FAILED(rv))
unlink(buf); return rv;
return NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE;
}
mSpoolName = buf;
g_free(buf);
mSpoolFile->SetPermissions(0600);
nsCOMPtr<nsIFileOutputStream> stream = do_CreateInstance("@mozilla.org/network/file-output-stream;1"); nsCOMPtr<nsIFileOutputStream> stream = do_CreateInstance("@mozilla.org/network/file-output-stream;1");
rv = stream->Init(mSpoolFile, -1, -1, 0); rv = stream->Init(file, -1, -1, 0);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
@ -444,31 +429,10 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::GetSurfaceForPrinter(gfxASurface **aSurfac
mPrintSettings->GetOutputFormat(&format); mPrintSettings->GetOutputFormat(&format);
nsRefPtr<gfxASurface> surface; nsRefPtr<gfxASurface> surface;
gfxSize surfaceSize(width, height); if (nsIPrintSettings::kOutputFormatPDF == format) {
surface = new gfxPDFSurface(stream, gfxSize(width, height));
// Determine the real format with some GTK magic
if (format == nsIPrintSettings::kOutputFormatNative) {
nsCOMPtr<nsIPrintSettingsGTK> printSettingsGTK(do_QueryInterface(mPrintSettings));
GtkPrintSettings* theSettings;
printSettingsGTK->GetGtkPrintSettings(&theSettings);
const gchar* fmtGTK = gtk_print_settings_get(theSettings, GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT);
if (!fmtGTK) {
// Likely not print-to-file, check printer's capabilities
GtkPrinter* thePrinter;
printSettingsGTK->GetGtkPrinter(&thePrinter);
format = (gtk_printer_accepts_pdf(thePrinter)) ? nsIPrintSettings::kOutputFormatPDF
: nsIPrintSettings::kOutputFormatPS;
} else if (nsDependentCString(fmtGTK).EqualsIgnoreCase("pdf")) {
format = nsIPrintSettings::kOutputFormatPDF;
} else { } else {
format = nsIPrintSettings::kOutputFormatPS; surface = new gfxPSSurface(stream, gfxSize(width, height));
}
}
if (format == nsIPrintSettings::kOutputFormatPDF) {
surface = new gfxPDFSurface(stream, surfaceSize);
} else {
surface = new gfxPSSurface(stream, surfaceSize);
} }
if (!surface) if (!surface)
@ -489,28 +453,104 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::Init(nsIWidget *aWidget,
PRBool aIsPrintPreview) PRBool aIsPrintPreview)
{ {
DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::Init(aPS=%p)\n", aPS)); DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::Init(aPS=%p)\n", aPS));
nsresult rv = NS_ERROR_FAILURE;
if (gtk_major_version < 2 ||
(gtk_major_version == 2 && gtk_minor_version < 10))
return NS_ERROR_NOT_AVAILABLE; // I'm so sorry bz
mPrintSettings = aPS; mPrintSettings = aPS;
// if there is a current selection then enable the "Selection" radio button
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv)) {
return rv;
}
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
if (aPS) {
PRBool reversed = PR_FALSE;
PRBool color = PR_FALSE;
PRBool tofile = PR_FALSE;
PRInt16 printRange = nsIPrintSettings::kRangeAllPages;
PRInt32 orientation = NS_PORTRAIT;
PRInt32 fromPage = 1;
PRInt32 toPage = 1;
PRUnichar *command = nsnull;
PRInt32 copies = 1;
PRUnichar *printer = nsnull;
PRUnichar *papername = nsnull;
PRUnichar *plexname = nsnull;
PRUnichar *resolutionname = nsnull;
PRUnichar *colorspace = nsnull;
PRBool downloadfonts = PR_TRUE;
PRUnichar *printfile = nsnull;
double dleft = 0.5;
double dright = 0.5;
double dtop = 0.5;
double dbottom = 0.5;
aPS->GetPrinterName(&printer);
aPS->GetPrintReversed(&reversed);
aPS->GetPrintInColor(&color);
aPS->GetPaperName(&papername);
aPS->GetResolutionName(&resolutionname);
aPS->GetColorspace(&colorspace);
aPS->GetDownloadFonts(&downloadfonts);
aPS->GetPlexName(&plexname);
aPS->GetOrientation(&orientation);
aPS->GetPrintCommand(&command);
aPS->GetPrintRange(&printRange);
aPS->GetToFileName(&printfile);
aPS->GetPrintToFile(&tofile);
aPS->GetStartPageRange(&fromPage);
aPS->GetEndPageRange(&toPage);
aPS->GetNumCopies(&copies);
aPS->GetMarginTop(&dtop);
aPS->GetMarginLeft(&dleft);
aPS->GetMarginBottom(&dbottom);
aPS->GetMarginRight(&dright);
if (printfile)
PL_strncpyz(mPath, NS_ConvertUTF16toUTF8(printfile).get(), sizeof(mPath));
if (command)
PL_strncpyz(mCommand, NS_ConvertUTF16toUTF8(command).get(), sizeof(mCommand));
if (printer)
PL_strncpyz(mPrinter, NS_ConvertUTF16toUTF8(printer).get(), sizeof(mPrinter));
if (papername)
PL_strncpyz(mPaperName, NS_ConvertUTF16toUTF8(papername).get(), sizeof(mPaperName));
if (plexname)
PL_strncpyz(mPlexName, NS_ConvertUTF16toUTF8(plexname).get(), sizeof(mPlexName));
if (resolutionname)
PL_strncpyz(mResolutionName, NS_ConvertUTF16toUTF8(resolutionname).get(), sizeof(mResolutionName));
if (colorspace)
PL_strncpyz(mColorspace, NS_ConvertUTF16toUTF8(colorspace).get(), sizeof(mColorspace));
DO_PR_DEBUG_LOG(("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright));
DO_PR_DEBUG_LOG(("printRange %d\n", printRange));
DO_PR_DEBUG_LOG(("fromPage %d\n", fromPage));
DO_PR_DEBUG_LOG(("toPage %d\n", toPage));
DO_PR_DEBUG_LOG(("tofile %d\n", tofile));
DO_PR_DEBUG_LOG(("printfile '%s'\n", printfile? NS_ConvertUTF16toUTF8(printfile).get():"<NULL>"));
DO_PR_DEBUG_LOG(("command '%s'\n", command? NS_ConvertUTF16toUTF8(command).get():"<NULL>"));
DO_PR_DEBUG_LOG(("printer '%s'\n", printer? NS_ConvertUTF16toUTF8(printer).get():"<NULL>"));
DO_PR_DEBUG_LOG(("papername '%s'\n", papername? NS_ConvertUTF16toUTF8(papername).get():"<NULL>"));
DO_PR_DEBUG_LOG(("plexname '%s'\n", plexname? NS_ConvertUTF16toUTF8(plexname).get():"<NULL>"));
DO_PR_DEBUG_LOG(("resolution '%s'\n", resolutionname? NS_ConvertUTF16toUTF8(resolutionname).get():"<NULL>"));
DO_PR_DEBUG_LOG(("colorspace '%s'\n", colorspace? NS_ConvertUTF16toUTF8(colorspace).get():"<NULL>"));
mTop = dtop;
mBottom = dbottom;
mLeft = dleft;
mRight = dright;
mFpf = !reversed;
mDownloadFonts = downloadfonts;
mGrayscale = !color;
mOrientation = orientation;
mToPrinter = !tofile;
mCopies = copies;
mIsPPreview = aIsPrintPreview; mIsPPreview = aIsPrintPreview;
mCancel = PR_FALSE;
}
// This is only set by embedders return rv;
PRBool toFile;
aPS->GetPrintToFile(&toFile);
mToPrinter = !toFile;
nsCOMPtr<nsIPrintSettingsGTK> printSettingsGTK(do_QueryInterface(aPS));
if (!printSettingsGTK)
return NS_ERROR_NO_INTERFACE;
printSettingsGTK->GetGtkPrinter(&mGtkPrinter);
printSettingsGTK->GetGtkPrintSettings(&mGtkPrintSettings);
printSettingsGTK->GetGtkPageSetup(&mGtkPageSetup);
return NS_OK;
} }
NS_IMETHODIMP nsDeviceContextSpecGTK::GetToPrinter(PRBool &aToPrinter) NS_IMETHODIMP nsDeviceContextSpecGTK::GetToPrinter(PRBool &aToPrinter)
@ -648,64 +688,14 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::ClosePrintManager()
return NS_OK; return NS_OK;
} }
static void NS_IMETHODIMP nsDeviceContextSpecGTK::BeginDocument(PRUnichar * aTitle, PRUnichar * aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
print_callback(GtkPrintJob *aJob, gpointer aData, GError *aError) {
g_object_unref(aJob);
((nsILocalFile*) aData)->Remove(PR_FALSE);
}
static void
ns_release_macro(gpointer aData) {
nsILocalFile* spoolFile = (nsILocalFile*) aData;
NS_RELEASE(spoolFile);
}
NS_IMETHODIMP nsDeviceContextSpecGTK::BeginDocument(PRUnichar * aTitle, PRUnichar * aPrintToFileName,
PRInt32 aStartPage, PRInt32 aEndPage)
{ {
if (mToPrinter)
mPrintJob = gtk_print_job_new(NS_ConvertUTF16toUTF8(aTitle).get(), mGtkPrinter,
mGtkPrintSettings, mGtkPageSetup);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDeviceContextSpecGTK::EndDocument() NS_IMETHODIMP nsDeviceContextSpecGTK::EndDocument()
{ {
if (mToPrinter) { return mPrintJob->Submit();
if (!gtk_print_job_set_source_file(mPrintJob, mSpoolName.get(), NULL))
return NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE;
NS_ADDREF(mSpoolFile.get());
gtk_print_job_send(mPrintJob, print_callback, mSpoolFile, ns_release_macro);
} else {
// Handle print-to-file ourselves for the benefit of embedders
nsXPIDLString targetPath;
nsCOMPtr<nsILocalFile> destFile;
mPrintSettings->GetToFileName(getter_Copies(targetPath));
nsresult rv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(targetPath),
PR_FALSE, getter_AddRefs(destFile));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString destLeafName;
rv = destFile->GetLeafName(destLeafName);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> destDir;
rv = destFile->GetParent(getter_AddRefs(destDir));
NS_ENSURE_SUCCESS(rv, rv);
rv = mSpoolFile->MoveTo(destDir, destLeafName);
NS_ENSURE_SUCCESS(rv, rv);
// This is the standard way to get the UNIX umask. Ugh.
mode_t mask = umask(0);
umask(mask);
// If you're not familiar with umasks, they contain the bits of what NOT to set in the permissions
// (thats because files and directories have different numbers of bits for their permissions)
destFile->SetPermissions(0666 & ~(mask));
}
return NS_OK;
} }
/* Get prefs for printer /* Get prefs for printer

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

@ -43,14 +43,9 @@
#include "nsIPrintSettings.h" #include "nsIPrintSettings.h"
#include "nsIPrintOptions.h" #include "nsIPrintOptions.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsString.h"
#include "nsCRT.h" /* should be <limits.h>? */ #include "nsCRT.h" /* should be <limits.h>? */
#include <gtk/gtk.h>
#include <gtk/gtkprinter.h>
#include <gtk/gtkprintjob.h>
class nsIPrintJobGTK; class nsIPrintJobGTK;
#define NS_PORTRAIT 0 #define NS_PORTRAIT 0
@ -122,15 +117,7 @@ protected:
float mRight; /* right margin */ float mRight; /* right margin */
float mTop; /* top margin */ float mTop; /* top margin */
float mBottom; /* bottom margin */ float mBottom; /* bottom margin */
nsIPrintJobGTK * mPrintJob;
GtkPrintJob* mPrintJob;
GtkPrinter* mGtkPrinter;
GtkPrintSettings* mGtkPrintSettings;
GtkPageSetup* mGtkPageSetup;
nsCString mSpoolName;
nsCOMPtr<nsILocalFile> mSpoolFile;
}; };
//------------------------------------------------------------------------- //-------------------------------------------------------------------------

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

@ -1,58 +0,0 @@
/* -*- 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 GTK2 print dialog interface.
*
* The Initial Developer of the Original Code is
* Kenneth Herron <kherron@fmailbox.com>
* Portions created by the Initial Developer are Copyright (C) 2007
* 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 ***** */
#ifndef nsPrintDialog_h__
#define nsPrintDialog_h__
#include "nsIPrintDialogService.h"
class nsIPrintSettings;
class nsPrintDialogServiceGTK : public nsIPrintDialogService
{
public:
nsPrintDialogServiceGTK();
virtual ~nsPrintDialogServiceGTK();
NS_DECL_ISUPPORTS
NS_IMETHODIMP Init();
NS_IMETHODIMP Show(nsIPrintSettings *aSettings);
NS_IMETHODIMP ShowPageSetup(nsIPrintSettings *aSettings);
};
#endif

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

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

@ -35,7 +35,7 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "nsPrintOptionsGTK.h" #include "nsPrintOptionsGTK.h"
#include "nsPrintSettingsGTK.h"
/** --------------------------------------------------- /** ---------------------------------------------------
@ -55,16 +55,3 @@ nsPrintOptionsGTK::~nsPrintOptionsGTK()
{ {
} }
/* nsIPrintSettings CreatePrintSettings (); */
nsresult nsPrintOptionsGTK::_CreatePrintSettings(nsIPrintSettings **_retval)
{
*_retval = nsnull;
nsPrintSettingsGTK* printSettings = new nsPrintSettingsGTK(); // does not initially ref count
NS_ENSURE_TRUE(printSettings, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*_retval = printSettings); // ref count
return NS_OK;
}

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

@ -52,7 +52,6 @@ public:
nsPrintOptionsGTK(); nsPrintOptionsGTK();
virtual ~nsPrintOptionsGTK(); virtual ~nsPrintOptionsGTK();
virtual nsresult _CreatePrintSettings(nsIPrintSettings **_retval);
}; };

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

@ -60,7 +60,6 @@
#include "nsIPrefBranch.h" #include "nsIPrefBranch.h"
#include "nsImageToPixbuf.h" #include "nsImageToPixbuf.h"
#include "nsIdleServiceGTK.h" #include "nsIdleServiceGTK.h"
#include "nsPrintDialogGTK.h"
#ifdef NATIVE_THEME_SUPPORT #ifdef NATIVE_THEME_SUPPORT
#include "nsNativeThemeGTK.h" #include "nsNativeThemeGTK.h"
@ -98,7 +97,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageToPixbuf) NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageToPixbuf)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceGTK) NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceGTK, Init)
static NS_IMETHODIMP static NS_IMETHODIMP
nsFilePickerConstructor(nsISupports *aOuter, REFNSIID aIID, nsFilePickerConstructor(nsISupports *aOuter, REFNSIID aIID,
@ -276,10 +274,6 @@ static const nsModuleComponentInfo components[] =
NS_IDLE_SERVICE_CID, NS_IDLE_SERVICE_CID,
"@mozilla.org/widget/idleservice;1", "@mozilla.org/widget/idleservice;1",
nsIdleServiceGTKConstructor }, nsIdleServiceGTKConstructor },
{ "Native Print Dialog",
NS_PRINTDIALOGSERVICE_CID,
NS_PRINTDIALOGSERVICE_CONTRACTID,
nsPrintDialogServiceGTKConstructor },
}; };
PR_STATIC_CALLBACK(void) PR_STATIC_CALLBACK(void)