Write PrinterSettings in Driver.cpp instead of Page/JobSetupWindow.cpp
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5565 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -41,22 +41,6 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
static PrinterDriver *instanciate_driver(BNode *spoolDir);
|
static PrinterDriver *instanciate_driver(BNode *spoolDir);
|
||||||
|
|
||||||
/* ======== For testing only ================== */
|
|
||||||
|
|
||||||
//#include "MessagePrinter.h"
|
|
||||||
|
|
||||||
//static MessagePrinter* make_Printer();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Static initilizer function
|
|
||||||
*
|
|
||||||
* @param none
|
|
||||||
* @return MessagePrinter* instance
|
|
||||||
*/
|
|
||||||
//static MessagePrinter* make_Printer() {
|
|
||||||
// return new MessagePrinter();
|
|
||||||
//}
|
|
||||||
|
|
||||||
// ======== For testing only ==================
|
// ======== For testing only ==================
|
||||||
|
|
||||||
BMessage*
|
BMessage*
|
||||||
@@ -87,18 +71,7 @@ config_page(BNode *spoolDir, BMessage *msg)
|
|||||||
|
|
||||||
pagesetupMsg = new BMessage(*msg);
|
pagesetupMsg = new BMessage(*msg);
|
||||||
|
|
||||||
PrinterSettings::Update(spoolDir, msg);
|
PrinterSettings::Update(spoolDir, pagesetupMsg);
|
||||||
|
|
||||||
/* ======== For testing only ==================
|
|
||||||
|
|
||||||
MessagePrinter *mp = make_Printer();
|
|
||||||
if (mp->Print(pagesetupMsg) == B_OK) {
|
|
||||||
(new BAlert("", "config_page:MessagePrinter", "OK"))->Go();
|
|
||||||
} else {
|
|
||||||
(new BAlert("", "config_page:MessagePrinter", "ERROR"))->Go();
|
|
||||||
}
|
|
||||||
|
|
||||||
======== For testing only ================== */
|
|
||||||
|
|
||||||
// retrieve the printer (spool) name.
|
// retrieve the printer (spool) name.
|
||||||
printerName = NULL;
|
printerName = NULL;
|
||||||
@@ -109,6 +82,7 @@ config_page(BNode *spoolDir, BMessage *msg)
|
|||||||
driver = instanciate_driver(spoolDir);
|
driver = instanciate_driver(spoolDir);
|
||||||
if (driver->PageSetup(pagesetupMsg, printerName) == B_OK) {
|
if (driver->PageSetup(pagesetupMsg, printerName) == B_OK) {
|
||||||
pagesetupMsg->what = 'okok';
|
pagesetupMsg->what = 'okok';
|
||||||
|
PrinterSettings::Update(spoolDir, pagesetupMsg);
|
||||||
} else {
|
} else {
|
||||||
delete pagesetupMsg;
|
delete pagesetupMsg;
|
||||||
pagesetupMsg = NULL;
|
pagesetupMsg = NULL;
|
||||||
@@ -133,17 +107,6 @@ config_job(BNode *spoolDir, BMessage *msg)
|
|||||||
|
|
||||||
PrinterSettings::Update(spoolDir, jobsetupMsg);
|
PrinterSettings::Update(spoolDir, jobsetupMsg);
|
||||||
|
|
||||||
/* ======== For testing only ==================
|
|
||||||
|
|
||||||
MessagePrinter *mp = make_Printer();
|
|
||||||
if (mp->Print(jobsetupMsg) == B_OK) {
|
|
||||||
(new BAlert("", "config_job:MessagePrinter", "OK"))->Go();
|
|
||||||
} else {
|
|
||||||
(new BAlert("", "config_job:MessagePrinter", "ERROR"))->Go();
|
|
||||||
}
|
|
||||||
|
|
||||||
======== For testing only ================== */
|
|
||||||
|
|
||||||
// retrieve the printer (spool) name.
|
// retrieve the printer (spool) name.
|
||||||
printerName = NULL;
|
printerName = NULL;
|
||||||
if (spoolDir->ReadAttr("Printer Name", B_STRING_TYPE, 1, buffer, B_ATTR_NAME_LENGTH+1) > 0) {
|
if (spoolDir->ReadAttr("Printer Name", B_STRING_TYPE, 1, buffer, B_ATTR_NAME_LENGTH+1) > 0) {
|
||||||
@@ -152,6 +115,7 @@ config_job(BNode *spoolDir, BMessage *msg)
|
|||||||
driver = instanciate_driver(spoolDir);
|
driver = instanciate_driver(spoolDir);
|
||||||
if (driver->JobSetup(jobsetupMsg, printerName) == B_OK) {
|
if (driver->JobSetup(jobsetupMsg, printerName) == B_OK) {
|
||||||
jobsetupMsg->what = 'okok';
|
jobsetupMsg->what = 'okok';
|
||||||
|
PrinterSettings::Update(spoolDir, jobsetupMsg);
|
||||||
} else {
|
} else {
|
||||||
delete jobsetupMsg;
|
delete jobsetupMsg;
|
||||||
jobsetupMsg = NULL;
|
jobsetupMsg = NULL;
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ THE SOFTWARE.
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "PrinterDriver.h"
|
#include "PrinterDriver.h"
|
||||||
#include "PrinterSettings.h"
|
|
||||||
#include "JobSetupWindow.h"
|
#include "JobSetupWindow.h"
|
||||||
#include "DocInfoWindow.h"
|
#include "DocInfoWindow.h"
|
||||||
|
|
||||||
@@ -260,12 +259,6 @@ JobSetupWindow::UpdateJobMessage()
|
|||||||
fSetupMsg->ReplaceInt32("first_page", from);
|
fSetupMsg->ReplaceInt32("first_page", from);
|
||||||
fSetupMsg->ReplaceInt32("last_page", to);
|
fSetupMsg->ReplaceInt32("last_page", to);
|
||||||
AddFields(fSetupMsg, &fDocInfo);
|
AddFields(fSetupMsg, &fDocInfo);
|
||||||
|
|
||||||
// save the settings to the new defaults
|
|
||||||
PrinterSettings ps(fPrinterName.String());
|
|
||||||
if (ps.InitCheck() == B_OK) {
|
|
||||||
ps.WriteSettings(fSetupMsg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ THE SOFTWARE.
|
|||||||
#include "PageSetupWindow.h"
|
#include "PageSetupWindow.h"
|
||||||
|
|
||||||
#include "MarginView.h"
|
#include "MarginView.h"
|
||||||
#include "PrinterSettings.h"
|
|
||||||
#include "FontsWindow.h"
|
#include "FontsWindow.h"
|
||||||
#include "AdvancedSettingsWindow.h"
|
#include "AdvancedSettingsWindow.h"
|
||||||
|
|
||||||
@@ -502,12 +501,6 @@ PageSetupWindow::UpdateSetupMessage()
|
|||||||
fSetupMsg->AddInt32("close_option", i);
|
fSetupMsg->AddInt32("close_option", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// save the settings to the new defaults
|
|
||||||
PrinterSettings ps(fPrinterDirName.String());
|
|
||||||
if (ps.InitCheck() == B_OK) {
|
|
||||||
ps.WriteSettings(fSetupMsg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,6 @@ static bool InList(const char* list[], const char* name) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// copied from BeUtils.cpp
|
// copied from BeUtils.cpp
|
||||||
void AddFields(BMessage* to, const BMessage* from, bool overwrite = true, const char* excludeList[], const char* includeList[]) {
|
void AddFields(BMessage* to, const BMessage* from, bool overwrite = true, const char* excludeList[], const char* includeList[]) {
|
||||||
@@ -74,7 +72,6 @@ void AddFields(BMessage* to, const BMessage* from, bool overwrite = true, const
|
|||||||
for (int32 i = 0; from->GetInfo(B_ANY_TYPE, i, &name, &type, &count) == B_OK; i ++) {
|
for (int32 i = 0; from->GetInfo(B_ANY_TYPE, i, &name, &type, &count) == B_OK; i ++) {
|
||||||
const void* data;
|
const void* data;
|
||||||
ssize_t size;
|
ssize_t size;
|
||||||
|
|
||||||
if (excludeList && InList(excludeList, name)) continue;
|
if (excludeList && InList(excludeList, name)) continue;
|
||||||
if (includeList && !InList(includeList, name)) continue;
|
if (includeList && !InList(includeList, name)) continue;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user