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 struct JSContext; 10 11 #include "nsIDeviceContextSpec.h" 12 #include "nsIPrinterList.h" 13 #include "nsIPrintSettings.h" 14 #include "nsCOMPtr.h" 15 #include "nsString.h" 16 #include "mozilla/Attributes.h" 17 18 #include "nsCRT.h" /* should be <limits.h>? */ 19 20 #include <gtk/gtk.h> 21 #include <gtk/gtkunixprint.h> 22 23 #define NS_PORTRAIT 0 24 #define NS_LANDSCAPE 1 25 26 class nsPrintSettingsGTK; 27 28 class nsDeviceContextSpecGTK : public nsIDeviceContextSpec { 29 public: 30 nsDeviceContextSpecGTK(); 31 32 NS_DECL_ISUPPORTS 33 34 already_AddRefed<PrintTarget> MakePrintTarget() final; 35 36 NS_IMETHOD Init(nsIWidget* aWidget, nsIPrintSettings* aPS, 37 bool aIsPrintPreview) override; 38 NS_IMETHOD BeginDocument(const nsAString& aTitle, 39 const nsAString& aPrintToFileName, 40 int32_t aStartPage, int32_t aEndPage) override; 41 NS_IMETHOD EndDocument() override; BeginPage()42 NS_IMETHOD BeginPage() override { return NS_OK; } EndPage()43 NS_IMETHOD EndPage() override { return NS_OK; } 44 45 protected: 46 virtual ~nsDeviceContextSpecGTK(); 47 nsCOMPtr<nsPrintSettingsGTK> mPrintSettings; 48 bool mToPrinter : 1; /* If true, print to printer */ 49 GtkPrintSettings* mGtkPrintSettings; 50 GtkPageSetup* mGtkPageSetup; 51 52 nsCString mSpoolName; 53 nsCOMPtr<nsIFile> mSpoolFile; 54 nsCString mTitle; 55 56 private: 57 void EnumeratePrinters(); 58 void StartPrintJob(); 59 static gboolean PrinterEnumerator(GtkPrinter* aPrinter, gpointer aData); 60 }; 61 62 #endif /* !nsDeviceContextSpecGTK_h___ */ 63