xref: /haiku/src/add-ons/print/drivers/gutenprint/GPPrinterDriver.cpp (revision 95c9effd68127df2dce202d5e254a7c86560010a)
1 /*
2  * GPEntry.cpp
3  * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
4  * Copyright 2010 Michael Pfeiffer.
5  */
6 
7 
8 #include <Debug.h>
9 
10 #include "GPDriver.h"
11 #include "GPCapabilities.h"
12 #include "GPData.h"
13 #include "PrinterDriver.h"
14 #include "SelectPrinterDialog.h"
15 
16 
17 class GPPrinterDriver : public PrinterDriver
18 {
19 public:
20 	GPPrinterDriver(BNode* printerFolder)
21 		:
22 		PrinterDriver(printerFolder)
23 		{
24 		}
25 
26 	const char*	GetSignature() const
27 				{
28 					return "application/x-vnd.gutenprint";
29 				}
30 
31 	const char*	GetDriverName() const
32 				{
33 					return "Gutenprint";
34 				}
35 
36 	const char*	GetVersion() const
37 				{
38 					return "1.0";
39 				}
40 
41 	const char*	GetCopyright() const
42 				{
43 					return "Gutenprint driver "
44 						"Copyright © 2010 Michael Pfeiffer.\n";
45 				}
46 
47 	char* 		AddPrinter(char *printerName)
48 				{
49 					GPData* data = dynamic_cast<GPData*>(GetPrinterData());
50 					ASSERT(data != NULL);
51 
52 					SelectPrinterDialog* dialog =
53 						new SelectPrinterDialog(data);
54 
55 					if (dialog->Go() != B_OK)
56 						return NULL;
57 
58 					return printerName;
59 				}
60 
61 	PrinterData*	InstantiatePrinterData(BNode* node)
62 				{
63 					return new GPData(node);
64 				}
65 
66 	PrinterCap* InstantiatePrinterCap(PrinterData* printerData)
67 				{
68 					return new GPCapabilities(printerData);
69 				}
70 
71 	GraphicsDriver* InstantiateGraphicsDriver(BMessage* settings,
72 		PrinterData* printerData, PrinterCap* printerCap)
73 				{
74 					return new GPDriver(settings, printerData, printerCap);
75 				}
76 };
77 
78 
79 PrinterDriver* instantiate_printer_driver(BNode* printerFolder)
80 {
81 	return new GPPrinterDriver(printerFolder);
82 }
83