Fixed some style violations (max 80 chars per line).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35640 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer
2010-02-27 20:09:19 +00:00
parent 80dd024309
commit d90d29facd
3 changed files with 75 additions and 40 deletions
+29 -17
View File
@@ -88,8 +88,10 @@ static void GetPageFormat(float w, float h, BString& label)
w = floor(w + 0.5); h = floor(h + 0.5);
for (uint i = 0; i < sizeof(pageFormat) / sizeof(struct PageFormat); i ++) {
struct PageFormat& pf = pageFormat[i];
if (pf.width == w && pf.height == h || pf.width == h && pf.height == w) {
label = TR(pf.label); return;
if (pf.width == w && pf.height == h || pf.width == h
&& pf.height == w) {
label = be_catalog->GetString(pf.label, TR_CONTEXT);
return;
}
}
@@ -110,7 +112,8 @@ LeftAlign(BView* view)
ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
BMessage* settings, AutoReply* sender)
: BWindow(ConfigWindow::GetWindowFrame(), TR("Page setup"),
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
, fKind(kind)
, fDefaultPrinter(defaultPrinter)
, fSettings(settings)
@@ -125,7 +128,7 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
if (kind == kJobSetup)
SetTitle(TR("Print setup"));
BView* panel = new BBox(Bounds(), "temporary", B_FOLLOW_ALL, B_WILL_DRAW);
BView* panel = new BBox(Bounds(), "temporary", B_FOLLOW_ALL, B_WILL_DRAW);
AddChild(panel);
BRect dummyRect(0, 0, 1, 1);
@@ -137,26 +140,28 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
fPrinters = new BMenuField(TR("Printer:"), menu, NULL);
// page format button
fPageSetup = AddPictureButton(panel, dummyRect, "Paper setup", "PAGE_SETUP_ON",
"PAGE_SETUP_OFF", MSG_PAGE_SETUP);
fPageSetup = AddPictureButton(panel, dummyRect, "Paper setup",
"PAGE_SETUP_ON", "PAGE_SETUP_OFF", MSG_PAGE_SETUP);
// add description to button
BStringView *pageFormatTitle = new BStringView("paperSetupTitle", TR("Paper setup:"));
BStringView *pageFormatTitle = new BStringView("paperSetupTitle",
TR("Paper setup:"));
fPageFormatText = new BStringView("paperSetupText", "");
// page selection button
fJobSetup = NULL;
BStringView* jobSetupTitle = NULL;
if (kind == kJobSetup) {
fJobSetup = AddPictureButton(panel, dummyRect, "Page setup", "JOB_SETUP_ON",
"JOB_SETUP_OFF", MSG_JOB_SETUP);
fJobSetup = AddPictureButton(panel, dummyRect, "Page setup",
"JOB_SETUP_ON", "JOB_SETUP_OFF", MSG_JOB_SETUP);
// add description to button
jobSetupTitle = new BStringView("jobSetupTitle", TR("Page setup:"));
fJobSetupText = new BStringView("jobSetupText", "");
}
// separator line
BBox* separator = new BBox(dummyRect, "line", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
BBox* separator = new BBox(dummyRect, "line",
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
// Cancel & OK button
@@ -254,7 +259,8 @@ void ConfigWindow::MessageReceived(BMessage* m)
case MSG_PRINTER_SELECTED: {
BString printer;
if (m->FindString("name", &printer) == B_OK) {
UpdateAppSettings(fSenderMimeType.String(), printer.String());
UpdateAppSettings(fSenderMimeType.String(),
printer.String());
PrinterForMimeType();
UpdateSettings(true);
}
@@ -262,7 +268,10 @@ void ConfigWindow::MessageReceived(BMessage* m)
break;
case MSG_OK:
UpdateSettings(false);
fSender->SetReply(fKind == kPageSetup ? &fPageSettings : &fJobSettings);
if (fKind == kPageSetup)
fSender->SetReply(&fPageSettings);
else
fSender->SetReply(&fJobSettings);
Quit();
break;
case B_ABOUT_REQUESTED: AboutRequested();
@@ -329,12 +338,13 @@ BPictureButton* ConfigWindow::AddPictureButton(BView* panel, BRect frame,
BPictureButton* button = NULL;
if (onPict != NULL && offPict != NULL) {
button = new BPictureButton(frame, name, onPict, offPict, new BMessage(what));
button = new BPictureButton(frame, name, onPict, offPict,
new BMessage(what));
button->SetViewColor(B_TRANSPARENT_COLOR);
panel->AddChild(button);
onBM->Lock();
int32 width = onBM->Bounds().Width();
int32 height = onBM->Bounds().Height();
int32 width = (int32)onBM->Bounds().Width();
int32 height = (int32)onBM->Bounds().Height();
button->ResizeTo(width, height);
button->SetExplicitMaxSize(BSize(width, height));
onBM->Unlock();
@@ -454,7 +464,8 @@ void ConfigWindow::UpdateUI()
fPageSetup->SetEnabled(true);
if (fJobSetup)
fJobSetup->SetEnabled(fKind == kJobSetup && !fPageSettings.IsEmpty());
fJobSetup->SetEnabled(fKind == kJobSetup
&& !fPageSettings.IsEmpty());
fOk->SetEnabled(fKind == kJobSetup && !fJobSettings.IsEmpty() ||
fKind == kPageSetup && !fPageSettings.IsEmpty());
@@ -483,7 +494,8 @@ void ConfigWindow::UpdateUI()
if (fJobSettings.FindInt32(PSRV_FIELD_FIRST_PAGE, &first) == B_OK &&
fJobSettings.FindInt32(PSRV_FIELD_LAST_PAGE, &last) == B_OK) {
if (first >= 1 && first <= last && last != INT_MAX) {
job << TR("Page") << " " << first << " " << TR("to") << " " << last;
job << TR("Page") << " " << first << " " << TR("to") << " "
<< last;
} else {
job << TR("All pages");
}
+17 -8
View File
@@ -85,7 +85,8 @@ status_t PrintServerApp::async_thread(void* data)
int32 count = Printer::CountPrinters();
BString alertText(TR("There are no printers set up."));
if (count > 0)
alertText.SetTo(TR("There is no default printer set up."));
alertText.SetTo(
TR("There is no default printer set up."));
alertText.Append(" ");
alertText.Append(TR("Would you like to set one up now?"));
@@ -128,9 +129,12 @@ status_t PrintServerApp::async_thread(void* data)
// then create the actual printer
if (p->app->CreatePrinter(printerName.String(),
driverName.String(), connection.String(),
transportName.String(), transportPath.String()) == B_OK) {
// If printer was created ok, ask if it needs to be the default
BString text(TR("Would you like to make @ the default printer?"));
transportName.String(),
transportPath.String()) == B_OK) {
// If printer was created ok,
// ask if it needs to be the default
BString text(TR("Would you like to make @ "
"the default printer?"));
text.ReplaceFirst("@", printerName.String());
BAlert* alert = new BAlert("", text.String(), TR("No"),
TR("Yes"));
@@ -151,7 +155,8 @@ void PrintServerApp::AsyncHandleMessage(BMessage* msg)
{
AsyncThreadParams* data = new AsyncThreadParams(this, fDefaultPrinter, msg);
thread_id tid = spawn_thread(async_thread, "async", B_NORMAL_PRIORITY, (void*)data);
thread_id tid = spawn_thread(async_thread, "async", B_NORMAL_PRIORITY,
(void*)data);
if (tid > 0) {
resume_thread(tid);
@@ -166,14 +171,18 @@ void PrintServerApp::Handle_BeOSR5_Message(BMessage* msg)
// Get currently selected printer
case PSRV_GET_ACTIVE_PRINTER: {
BMessage reply('okok');
BString printerName = fDefaultPrinter ? fDefaultPrinter->Name() : "";
BString printerName;
if (fDefaultPrinter)
printerName = fDefaultPrinter->Name();
BString mime;
if (fUseConfigWindow && MimeTypeForSender(msg, mime)) {
BAutolock lock(gLock);
if (lock.IsLocked()) {
// override with printer for application
PrinterSettings* p = fSettings->FindPrinterSettings(mime.String());
if (p) printerName = p->GetPrinter();
PrinterSettings* p = fSettings->FindPrinterSettings(
mime.String());
if (p)
printerName = p->GetPrinter();
}
}
reply.AddString("printer_name", printerName);
+29 -15
View File
@@ -200,7 +200,8 @@ PrintServerApp::RegisterPrinter(BDirectory* printer)
BString transport, address, connection, state;
if (printer->ReadAttrString(PSRV_PRINTER_ATTR_TRANSPORT, &transport) == B_OK
&& printer->ReadAttrString(PSRV_PRINTER_ATTR_TRANSPORT_ADDR, &address) == B_OK
&& printer->ReadAttrString(PSRV_PRINTER_ATTR_TRANSPORT_ADDR, &address)
== B_OK
&& printer->ReadAttrString(PSRV_PRINTER_ATTR_CNX, &connection) == B_OK
&& printer->ReadAttrString(PSRV_PRINTER_ATTR_STATE, &state) == B_OK
&& state == "free") {
@@ -216,7 +217,8 @@ PrintServerApp::RegisterPrinter(BDirectory* printer)
return;
// register new printer
Resource* r = fResourceManager.Allocate(transport.String(), address.String(), connection.String());
Resource* r = fResourceManager.Allocate(transport.String(),
address.String(), connection.String());
AddHandler(new Printer(printer, r));
Acquire();
}
@@ -318,7 +320,8 @@ PrintServerApp::SetupPrinterList()
BDirectory node(&entry);
BNodeInfo info(&node);
char buffer[256];
if (info.GetType(buffer) == B_OK && strcmp(buffer, PSRV_PRINTER_FILETYPE) == 0) {
if (info.GetType(buffer) == B_OK
&& strcmp(buffer, PSRV_PRINTER_FILETYPE) == 0) {
RegisterPrinter(&node);
}
}
@@ -391,7 +394,8 @@ PrintServerApp::MessageReceived(BMessage* msg)
// ---------------------------------------------------------------
status_t
PrintServerApp::CreatePrinter(const char* printerName, const char* driverName,
const char* connection, const char* transportName, const char* transportPath)
const char* connection, const char* transportName,
const char* transportPath)
{
status_t rc;
@@ -424,14 +428,17 @@ PrintServerApp::CreatePrinter(const char* printerName, const char* driverName,
// the printer exists, but no default at all
return B_OK;
} else {
info.SetTo(TR("There already exists a printer you are going to create, but it's driver could not be found! Replace?"));
info.SetTo(TR("There already exists a printer you are going to "
"create, but it's driver could not be found! Replace?"));
}
} else {
info.SetTo(TR("There already exists a printer you are going to create, but it's not usable at all! Replace?"));
info.SetTo(TR("There already exists a printer you are going to "
"create, but it's not usable at all! Replace?"));
}
if (info.Length() != 0) {
BAlert *alert = new BAlert("Info", info.String(), TR("Cancel"), TR("OK"));
BAlert *alert = new BAlert("Info", info.String(), TR("Cancel"),
TR("OK"));
alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() == 0)
return rc;
@@ -449,8 +456,8 @@ PrintServerApp::CreatePrinter(const char* printerName, const char* driverName,
::strlen(printerName) + 1);
printer.WriteAttr(PSRV_PRINTER_ATTR_DRV_NAME, B_STRING_TYPE, 0, driverName,
::strlen(driverName) + 1);
printer.WriteAttr(PSRV_PRINTER_ATTR_TRANSPORT, B_STRING_TYPE, 0, transportName,
::strlen(transportName) + 1);
printer.WriteAttr(PSRV_PRINTER_ATTR_TRANSPORT, B_STRING_TYPE, 0,
transportName, ::strlen(transportName) + 1);
printer.WriteAttr(PSRV_PRINTER_ATTR_TRANSPORT_ADDR, B_STRING_TYPE, 0,
transportPath, ::strlen(transportPath) + 1);
printer.WriteAttr(PSRV_PRINTER_ATTR_CNX, B_STRING_TYPE, 0, connection,
@@ -479,7 +486,8 @@ PrintServerApp::CreatePrinter(const char* printerName, const char* driverName,
if ((*func)(printerName) == NULL)
rc = B_ERROR;
else
printer.WriteAttr(PSRV_PRINTER_ATTR_STATE, B_STRING_TYPE, 0, "free", ::strlen("free")+1);
printer.WriteAttr(PSRV_PRINTER_ATTR_STATE, B_STRING_TYPE, 0, "free",
::strlen("free")+1);
error:
if (rc != B_OK) {
@@ -646,17 +654,23 @@ PrintServerApp::FindPrinterNode(const char* name, BNode& node)
status_t
PrintServerApp::FindPrinterDriver(const char* name, BPath& outPath)
{
if (::TestForAddonExistence(name, B_USER_ADDONS_DIRECTORY, "Print", outPath) != B_OK
&& TestForAddonExistence(name, B_COMMON_ADDONS_DIRECTORY, "Print", outPath) != B_OK)
return ::TestForAddonExistence(name, B_BEOS_ADDONS_DIRECTORY, "Print", outPath);
if (::TestForAddonExistence(name, B_USER_ADDONS_DIRECTORY, "Print", outPath)
!= B_OK
&& TestForAddonExistence(name, B_COMMON_ADDONS_DIRECTORY, "Print",
outPath) != B_OK)
return ::TestForAddonExistence(name, B_BEOS_ADDONS_DIRECTORY, "Print",
outPath);
return B_OK;
}
bool PrintServerApp::OpenSettings(BFile& file, const char* name, bool forReading) {
bool PrintServerApp::OpenSettings(BFile& file, const char* name,
bool forReading)
{
BPath path;
uint32 openMode = forReading ? B_READ_ONLY : B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY;
uint32 openMode = forReading ? B_READ_ONLY : B_CREATE_FILE | B_ERASE_FILE
| B_WRITE_ONLY;
return find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK
&& path.Append(name) == B_OK
&& file.SetTo(path.Path(), openMode) == B_OK;