widget/gtk/nsPrintSettingsGTK.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 *
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef nsPrintSettingsGTK_h_
michael@0 8 #define nsPrintSettingsGTK_h_
michael@0 9
michael@0 10 #include "nsPrintSettingsImpl.h"
michael@0 11
michael@0 12 extern "C" {
michael@0 13 #include <gtk/gtk.h>
michael@0 14 #if (MOZ_WIDGET_GTK == 2)
michael@0 15 #include <gtk/gtkprinter.h>
michael@0 16 #include <gtk/gtkprintjob.h>
michael@0 17 #else
michael@0 18 #include <gtk/gtkunixprint.h>
michael@0 19 #endif
michael@0 20 }
michael@0 21
michael@0 22 #define NS_PRINTSETTINGSGTK_IID \
michael@0 23 { 0x758df520, 0xc7c3, 0x11dc, { 0x95, 0xff, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 } }
michael@0 24
michael@0 25
michael@0 26 //*****************************************************************************
michael@0 27 //*** nsPrintSettingsGTK
michael@0 28 //*****************************************************************************
michael@0 29
michael@0 30 class nsPrintSettingsGTK : public nsPrintSettings
michael@0 31 {
michael@0 32 public:
michael@0 33 NS_DECL_ISUPPORTS_INHERITED
michael@0 34 NS_DECLARE_STATIC_IID_ACCESSOR(NS_PRINTSETTINGSGTK_IID)
michael@0 35
michael@0 36 nsPrintSettingsGTK();
michael@0 37 virtual ~nsPrintSettingsGTK();
michael@0 38
michael@0 39 // We're overriding these methods because we want to read/write with GTK objects,
michael@0 40 // not local variables. This allows a simpler settings implementation between
michael@0 41 // Gecko and GTK.
michael@0 42
michael@0 43 GtkPageSetup* GetGtkPageSetup() { return mPageSetup; };
michael@0 44 void SetGtkPageSetup(GtkPageSetup *aPageSetup);
michael@0 45
michael@0 46 GtkPrintSettings* GetGtkPrintSettings() { return mPrintSettings; };
michael@0 47 void SetGtkPrintSettings(GtkPrintSettings *aPrintSettings);
michael@0 48
michael@0 49 GtkPrinter* GetGtkPrinter() { return mGTKPrinter; };
michael@0 50 void SetGtkPrinter(GtkPrinter *aPrinter);
michael@0 51
michael@0 52 bool GetForcePrintSelectionOnly() { return mPrintSelectionOnly; };
michael@0 53 void SetForcePrintSelectionOnly(bool aPrintSelectionOnly) { mPrintSelectionOnly = aPrintSelectionOnly; };
michael@0 54
michael@0 55 // If not printing the selection, this is stored in the GtkPrintSettings. Printing the
michael@0 56 // selection is stored as a protected boolean (mPrintSelectionOnly).
michael@0 57 NS_IMETHOD GetPrintRange(int16_t *aPrintRange);
michael@0 58 NS_IMETHOD SetPrintRange(int16_t aPrintRange);
michael@0 59
michael@0 60 // The page range is stored as as single range in the GtkPrintSettings object.
michael@0 61 NS_IMETHOD GetStartPageRange(int32_t *aStartPageRange);
michael@0 62 NS_IMETHOD SetStartPageRange(int32_t aStartPageRange);
michael@0 63 NS_IMETHOD GetEndPageRange(int32_t *aEndPageRange);
michael@0 64 NS_IMETHOD SetEndPageRange(int32_t aEndPageRange);
michael@0 65
michael@0 66 // Reversed, color, orientation and file name are all stored in the GtkPrintSettings.
michael@0 67 // Orientation is also stored in the GtkPageSetup and its setting takes priority when getting the orientation.
michael@0 68 NS_IMETHOD GetPrintReversed(bool *aPrintReversed);
michael@0 69 NS_IMETHOD SetPrintReversed(bool aPrintReversed);
michael@0 70
michael@0 71 NS_IMETHOD GetPrintInColor(bool *aPrintInColor);
michael@0 72 NS_IMETHOD SetPrintInColor(bool aPrintInColor);
michael@0 73
michael@0 74 NS_IMETHOD GetOrientation(int32_t *aOrientation);
michael@0 75 NS_IMETHOD SetOrientation(int32_t aOrientation);
michael@0 76
michael@0 77 NS_IMETHOD GetToFileName(char16_t * *aToFileName);
michael@0 78 NS_IMETHOD SetToFileName(const char16_t * aToFileName);
michael@0 79
michael@0 80 // Gets/Sets the printer name in the GtkPrintSettings. If no printer name is specified there,
michael@0 81 // you will get back the name of the current internal GtkPrinter.
michael@0 82 NS_IMETHOD GetPrinterName(char16_t * *aPrinter);
michael@0 83 NS_IMETHOD SetPrinterName(const char16_t * aPrinter);
michael@0 84
michael@0 85 // Number of copies is stored/gotten from the GtkPrintSettings.
michael@0 86 NS_IMETHOD GetNumCopies(int32_t *aNumCopies);
michael@0 87 NS_IMETHOD SetNumCopies(int32_t aNumCopies);
michael@0 88
michael@0 89 NS_IMETHOD GetScaling(double *aScaling);
michael@0 90 NS_IMETHOD SetScaling(double aScaling);
michael@0 91
michael@0 92 // A name recognised by GTK is strongly advised here, as this is used to create a GtkPaperSize.
michael@0 93 NS_IMETHOD GetPaperName(char16_t * *aPaperName);
michael@0 94 NS_IMETHOD SetPaperName(const char16_t * aPaperName);
michael@0 95
michael@0 96 NS_IMETHOD SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin);
michael@0 97 NS_IMETHOD SetUnwriteableMarginTop(double aUnwriteableMarginTop);
michael@0 98 NS_IMETHOD SetUnwriteableMarginLeft(double aUnwriteableMarginLeft);
michael@0 99 NS_IMETHOD SetUnwriteableMarginBottom(double aUnwriteableMarginBottom);
michael@0 100 NS_IMETHOD SetUnwriteableMarginRight(double aUnwriteableMarginRight);
michael@0 101
michael@0 102 NS_IMETHOD GetPaperWidth(double *aPaperWidth);
michael@0 103 NS_IMETHOD SetPaperWidth(double aPaperWidth);
michael@0 104
michael@0 105 NS_IMETHOD GetPaperHeight(double *aPaperHeight);
michael@0 106 NS_IMETHOD SetPaperHeight(double aPaperHeight);
michael@0 107
michael@0 108 NS_IMETHOD SetPaperSizeUnit(int16_t aPaperSizeUnit);
michael@0 109
michael@0 110 NS_IMETHOD GetEffectivePageSize(double *aWidth, double *aHeight);
michael@0 111
michael@0 112 NS_IMETHOD SetupSilentPrinting();
michael@0 113
michael@0 114 NS_IMETHOD GetPageRanges(nsTArray<int32_t> &aPages);
michael@0 115
michael@0 116 NS_IMETHOD GetResolution(int32_t *aResolution);
michael@0 117 NS_IMETHOD SetResolution(int32_t aResolution);
michael@0 118
michael@0 119 NS_IMETHOD GetDuplex(int32_t *aDuplex);
michael@0 120 NS_IMETHOD SetDuplex(int32_t aDuplex);
michael@0 121
michael@0 122 protected:
michael@0 123 nsPrintSettingsGTK(const nsPrintSettingsGTK& src);
michael@0 124 nsPrintSettingsGTK& operator=(const nsPrintSettingsGTK& rhs);
michael@0 125
michael@0 126 virtual nsresult _Clone(nsIPrintSettings **_retval);
michael@0 127 virtual nsresult _Assign(nsIPrintSettings *aPS);
michael@0 128
michael@0 129 GtkUnit GetGTKUnit(int16_t aGeckoUnit);
michael@0 130 void SaveNewPageSize();
michael@0 131
michael@0 132 /**
michael@0 133 * Re-initialize mUnwriteableMargin with values from mPageSetup.
michael@0 134 * Should be called whenever mPageSetup is initialized or overwritten.
michael@0 135 */
michael@0 136 void InitUnwriteableMargin();
michael@0 137
michael@0 138 /**
michael@0 139 * On construction:
michael@0 140 * - mPrintSettings, mPageSetup and mPaperSize are just new objects with defaults determined by GTK.
michael@0 141 * - mGTKPrinter is nullptr!!! Remember to be careful when accessing this property.
michael@0 142 */
michael@0 143 GtkPageSetup* mPageSetup;
michael@0 144 GtkPrintSettings* mPrintSettings;
michael@0 145 GtkPrinter* mGTKPrinter;
michael@0 146 GtkPaperSize* mPaperSize;
michael@0 147
michael@0 148 bool mPrintSelectionOnly;
michael@0 149 };
michael@0 150
michael@0 151 NS_DEFINE_STATIC_IID_ACCESSOR(nsPrintSettingsGTK, NS_PRINTSETTINGSGTK_IID)
michael@0 152
michael@0 153
michael@0 154 #endif // nsPrintSettingsGTK_h_

mercurial