Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef nsDeviceContextSpecGTK_h___
7 : #define nsDeviceContextSpecGTK_h___
8 :
9 : #include "nsIDeviceContextSpec.h"
10 : #include "nsIPrintSettings.h"
11 : #include "nsIPrinterEnumerator.h"
12 : #include "nsCOMPtr.h"
13 : #include "nsString.h"
14 : #include "mozilla/Attributes.h"
15 :
16 : #include "nsCRT.h" /* should be <limits.h>? */
17 :
18 : #include <gtk/gtk.h>
19 : #include <gtk/gtkunixprint.h>
20 :
21 : #define NS_PORTRAIT 0
22 : #define NS_LANDSCAPE 1
23 :
24 : class nsPrintSettingsGTK;
25 :
26 : class nsDeviceContextSpecGTK : public nsIDeviceContextSpec
27 : {
28 : public:
29 : nsDeviceContextSpecGTK();
30 :
31 : NS_DECL_ISUPPORTS
32 :
33 : virtual already_AddRefed<PrintTarget> MakePrintTarget() final;
34 :
35 : NS_IMETHOD Init(nsIWidget *aWidget, nsIPrintSettings* aPS,
36 : bool aIsPrintPreview) override;
37 : NS_IMETHOD BeginDocument(const nsAString& aTitle,
38 : const nsAString& aPrintToFileName,
39 : int32_t aStartPage, int32_t aEndPage) override;
40 : NS_IMETHOD EndDocument() override;
41 0 : NS_IMETHOD BeginPage() override { return NS_OK; }
42 0 : NS_IMETHOD EndPage() override { return NS_OK; }
43 :
44 : protected:
45 : virtual ~nsDeviceContextSpecGTK();
46 : nsCOMPtr<nsPrintSettingsGTK> mPrintSettings;
47 : bool mToPrinter : 1; /* If true, print to printer */
48 : bool mIsPPreview : 1; /* If true, is print preview */
49 : char mPath[PATH_MAX]; /* If toPrinter = false, dest file */
50 : char mPrinter[256]; /* Printer name */
51 : GtkPrintSettings* mGtkPrintSettings;
52 : GtkPageSetup* mGtkPageSetup;
53 :
54 : nsCString mSpoolName;
55 : nsCOMPtr<nsIFile> mSpoolFile;
56 : nsCString mTitle;
57 :
58 : private:
59 : void EnumeratePrinters();
60 : void StartPrintJob();
61 : static gboolean PrinterEnumerator(GtkPrinter *aPrinter, gpointer aData);
62 : };
63 :
64 : //-------------------------------------------------------------------------
65 : // Printer Enumerator
66 : //-------------------------------------------------------------------------
67 : class nsPrinterEnumeratorGTK final : public nsIPrinterEnumerator
68 : {
69 0 : ~nsPrinterEnumeratorGTK() {}
70 : public:
71 : nsPrinterEnumeratorGTK();
72 : NS_DECL_ISUPPORTS
73 : NS_DECL_NSIPRINTERENUMERATOR
74 : };
75 :
76 : #endif /* !nsDeviceContextSpecGTK_h___ */
|