2 * Copyright 2002-2006, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
12 #include "ObjectList.h"
18 BString fMimeType
; // application signature
19 BString fPrinter
; // printer used by application (default == empty string)
22 AppSettings(const char* mimeType
, const char* printer
= NULL
);
24 const char* GetMimeType() const { return fMimeType
.String(); }
25 bool UsesDefaultPrinter() const { return fMimeType
.Length() == 0; }
26 const char* GetPrinter() const { return fPrinter
.String(); }
27 void SetPrinter(const char* printer
) { fPrinter
= printer
; }
28 void SetDefaultPrinter() { fPrinter
= ""; }
32 class PrinterSettings
{
35 BMessage fPageSettings
; // default page settings
36 BMessage fJobSettings
; // default job settings
39 PrinterSettings(const char* printer
, BMessage
* pageSettings
= NULL
, BMessage
* jobSettings
= NULL
);
41 const char* GetPrinter() const { return fPrinter
.String(); }
42 BMessage
* GetPageSettings() { return &fPageSettings
; }
43 BMessage
* GetJobSettings() { return &fJobSettings
; }
45 void SetPrinter(const char* p
) { fPrinter
= p
; }
46 void SetPageSettings(BMessage
* s
) { fPageSettings
= *s
; }
47 void SetJobSettings(BMessage
* s
) { fJobSettings
= *s
; }
52 BObjectList
<AppSettings
> fApps
;
53 BObjectList
<PrinterSettings
> fPrinters
;
54 bool fUseConfigWindow
;
55 BRect fConfigWindowFrame
;
56 BString fDefaultPrinter
;
58 static Settings
* sSingleton
;
62 static Settings
* GetSettings();
65 int AppSettingsCount() const { return fApps
.CountItems(); }
66 AppSettings
* AppSettingsAt(int i
) { return fApps
.ItemAt(i
); }
67 void AddAppSettings(AppSettings
* s
) { fApps
.AddItem(s
); }
68 void RemoveAppSettings(int i
);
69 AppSettings
* FindAppSettings(const char* mimeType
);
71 int PrinterSettingsCount() const { return fPrinters
.CountItems(); }
72 PrinterSettings
* PrinterSettingsAt(int i
) { return fPrinters
.ItemAt(i
); }
73 void AddPrinterSettings(PrinterSettings
* s
) { fPrinters
.AddItem(s
); }
74 void RemovePrinterSettings(int i
);
75 PrinterSettings
* FindPrinterSettings(const char* printer
);
77 bool UseConfigWindow() const { return fUseConfigWindow
; }
78 void SetUseConfigWindow(bool b
) { fUseConfigWindow
= b
; }
79 BRect
ConfigWindowFrame() const { return fConfigWindowFrame
; }
80 void SetConfigWindowFrame(BRect r
) { fConfigWindowFrame
= r
; }
81 const char* DefaultPrinter() const { return fDefaultPrinter
.String(); }
82 void SetDefaultPrinter(const char* n
) { fDefaultPrinter
= n
; }
84 void Save(BFile
* settings_file
);
85 void Load(BFile
* settings_file
);