style cleanup, no functional changes
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36750 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -9,30 +9,25 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "AddPrinterDialog.h"
|
#include "AddPrinterDialog.h"
|
||||||
#include "PrinterListView.h"
|
|
||||||
#include "pr_server.h"
|
|
||||||
#include "Globals.h"
|
|
||||||
#include "Messages.h"
|
|
||||||
|
|
||||||
#include <Box.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <TextControl.h>
|
#include <FindDirectory.h>
|
||||||
#include <MenuField.h>
|
|
||||||
#include <MenuItem.h>
|
|
||||||
#include <PopUpMenu.h>
|
|
||||||
#include <StringView.h>
|
|
||||||
#include <ListView.h>
|
|
||||||
#include <ScrollView.h>
|
|
||||||
#include <Application.h>
|
|
||||||
#include <StorageKit.h>
|
|
||||||
|
|
||||||
#include <Layout.h>
|
|
||||||
#include <GridLayout.h>
|
#include <GridLayout.h>
|
||||||
#include <GridLayoutBuilder.h>
|
#include <GridLayoutBuilder.h>
|
||||||
#include <GroupLayoutBuilder.h>
|
#include <GroupLayoutBuilder.h>
|
||||||
|
#include <MenuField.h>
|
||||||
|
#include <MenuItem.h>
|
||||||
|
#include <Layout.h>
|
||||||
|
#include <NodeInfo.h>
|
||||||
|
#include <Path.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "pr_server.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
#include "Messages.h"
|
||||||
|
#include "PrinterListView.h"
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATE_CONTEXT
|
#undef B_TRANSLATE_CONTEXT
|
||||||
@@ -41,12 +36,12 @@
|
|||||||
|
|
||||||
AddPrinterDialog::AddPrinterDialog(BWindow *parent)
|
AddPrinterDialog::AddPrinterDialog(BWindow *parent)
|
||||||
:
|
:
|
||||||
Inherited(BRect(78.0, 71.0, 400, 300), B_TRANSLATE("Add printer"),
|
Inherited(BRect(78, 71, 400, 300), B_TRANSLATE("Add printer"),
|
||||||
B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
|
B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
|
||||||
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
|
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
|
||||||
fPrintersPrefletMessenger(parent)
|
fPrintersPrefletMessenger(parent)
|
||||||
{
|
{
|
||||||
BuildGUI(0);
|
_BuildGUI(0);
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
@@ -65,7 +60,7 @@ AddPrinterDialog::MessageReceived(BMessage* msg)
|
|||||||
{
|
{
|
||||||
switch(msg->what) {
|
switch(msg->what) {
|
||||||
case B_OK:
|
case B_OK:
|
||||||
AddPrinter(msg);
|
_AddPrinter(msg);
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -75,18 +70,17 @@ AddPrinterDialog::MessageReceived(BMessage* msg)
|
|||||||
|
|
||||||
case kNameChangedMsg:
|
case kNameChangedMsg:
|
||||||
fNameText = fName->Text();
|
fNameText = fName->Text();
|
||||||
Update();
|
_Update();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kPrinterSelectedMsg:
|
case kPrinterSelectedMsg:
|
||||||
StorePrinter(msg);
|
_StorePrinter(msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kTransportSelectedMsg:
|
case kTransportSelectedMsg:
|
||||||
HandleChangedTransport(msg);
|
_HandleChangedTransport(msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Inherited::MessageReceived(msg);
|
Inherited::MessageReceived(msg);
|
||||||
}
|
}
|
||||||
@@ -94,7 +88,7 @@ AddPrinterDialog::MessageReceived(BMessage* msg)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AddPrinterDialog::AddPrinter(BMessage *msg)
|
AddPrinterDialog::_AddPrinter(BMessage *msg)
|
||||||
{
|
{
|
||||||
BMessage m(PSRV_MAKE_PRINTER);
|
BMessage m(PSRV_MAKE_PRINTER);
|
||||||
BMessenger msgr;
|
BMessenger msgr;
|
||||||
@@ -120,19 +114,19 @@ AddPrinterDialog::AddPrinter(BMessage *msg)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AddPrinterDialog::StorePrinter(BMessage *msg)
|
AddPrinterDialog::_StorePrinter(BMessage *msg)
|
||||||
{
|
{
|
||||||
BString name;
|
BString name;
|
||||||
if (msg->FindString("name", &name) != B_OK)
|
if (msg->FindString("name", &name) != B_OK)
|
||||||
name = "";
|
name = "";
|
||||||
|
|
||||||
fPrinterText = name;
|
fPrinterText = name;
|
||||||
Update();
|
_Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AddPrinterDialog::HandleChangedTransport(BMessage *msg)
|
AddPrinterDialog::_HandleChangedTransport(BMessage *msg)
|
||||||
{
|
{
|
||||||
BString name;
|
BString name;
|
||||||
if (msg->FindString("name", &name) != B_OK) {
|
if (msg->FindString("name", &name) != B_OK) {
|
||||||
@@ -165,7 +159,7 @@ AddPrinterDialog::HandleChangedTransport(BMessage *msg)
|
|||||||
fTransportPathText = "";
|
fTransportPathText = "";
|
||||||
|
|
||||||
// remove mark from item in sub menu of transport sub menu
|
// remove mark from item in sub menu of transport sub menu
|
||||||
for (int32 i = fTransport->CountItems()-1; i >= 0; i --) {
|
for (int32 i = fTransport->CountItems() - 1; i >= 0; i --) {
|
||||||
BMenu* menu = fTransport->SubmenuAt(i);
|
BMenu* menu = fTransport->SubmenuAt(i);
|
||||||
if (menu != NULL) {
|
if (menu != NULL) {
|
||||||
BMenuItem* item = menu->FindMarked();
|
BMenuItem* item = menu->FindMarked();
|
||||||
@@ -174,12 +168,12 @@ AddPrinterDialog::HandleChangedTransport(BMessage *msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Update();
|
_Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AddPrinterDialog::BuildGUI(int stage)
|
AddPrinterDialog::_BuildGUI(int stage)
|
||||||
{
|
{
|
||||||
// add a "printer name" input field
|
// add a "printer name" input field
|
||||||
fName = new BTextControl("printer_name", B_TRANSLATE("Printer name:"),
|
fName = new BTextControl("printer_name", B_TRANSLATE("Printer name:"),
|
||||||
@@ -193,21 +187,22 @@ AddPrinterDialog::BuildGUI(int stage)
|
|||||||
BMenuField *printerMenuField = new BMenuField("drivers_list",
|
BMenuField *printerMenuField = new BMenuField("drivers_list",
|
||||||
B_TRANSLATE("Printer type:"), fPrinter);
|
B_TRANSLATE("Printer type:"), fPrinter);
|
||||||
printerMenuField->SetAlignment(B_ALIGN_RIGHT);
|
printerMenuField->SetAlignment(B_ALIGN_RIGHT);
|
||||||
FillMenu(fPrinter, "Print", kPrinterSelectedMsg);
|
_FillMenu(fPrinter, "Print", kPrinterSelectedMsg);
|
||||||
|
|
||||||
// add a "connected to" (aka transports list) menu field
|
// add a "connected to" (aka transports list) menu field
|
||||||
fTransport = new BPopUpMenu(B_TRANSLATE("<pick one>"));
|
fTransport = new BPopUpMenu(B_TRANSLATE("<pick one>"));
|
||||||
BMenuField *transportMenuField = new BMenuField("transports_list",
|
BMenuField *transportMenuField = new BMenuField("transports_list",
|
||||||
B_TRANSLATE("Connected to:"), fTransport);
|
B_TRANSLATE("Connected to:"), fTransport);
|
||||||
transportMenuField->SetAlignment(B_ALIGN_RIGHT);
|
transportMenuField->SetAlignment(B_ALIGN_RIGHT);
|
||||||
FillTransportMenu(fTransport);
|
_FillTransportMenu(fTransport);
|
||||||
|
|
||||||
// add a "OK" button
|
// add a "OK" button
|
||||||
fOk = new BButton(NULL, B_TRANSLATE("Add"), new BMessage((uint32)B_OK),
|
fOk = new BButton(NULL, B_TRANSLATE("Add"), new BMessage((uint32)B_OK),
|
||||||
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||||
|
|
||||||
// add a "Cancel button
|
// add a "Cancel button
|
||||||
BButton *cancel = new BButton(NULL, B_TRANSLATE("Cancel"), new BMessage(B_CANCEL));
|
BButton *cancel = new BButton(NULL, B_TRANSLATE("Cancel"),
|
||||||
|
new BMessage(B_CANCEL));
|
||||||
|
|
||||||
SetLayout(new BGridLayout());
|
SetLayout(new BGridLayout());
|
||||||
|
|
||||||
@@ -231,7 +226,7 @@ AddPrinterDialog::BuildGUI(int stage)
|
|||||||
|
|
||||||
fName->MakeFocus(true);
|
fName->MakeFocus(true);
|
||||||
|
|
||||||
Update();
|
_Update();
|
||||||
// Stage == 0
|
// Stage == 0
|
||||||
// init_icon 64x114 Add a Local or Network Printer
|
// init_icon 64x114 Add a Local or Network Printer
|
||||||
// ------------------------------
|
// ------------------------------
|
||||||
@@ -285,16 +280,18 @@ AddPrinterDialog::BuildGUI(int stage)
|
|||||||
// Cancel Add
|
// Cancel Add
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static directory_which gAddonDirs[] = {
|
static directory_which gAddonDirs[] = {
|
||||||
B_BEOS_ADDONS_DIRECTORY,
|
B_BEOS_ADDONS_DIRECTORY,
|
||||||
B_COMMON_ADDONS_DIRECTORY,
|
B_COMMON_ADDONS_DIRECTORY,
|
||||||
B_USER_ADDONS_DIRECTORY
|
B_USER_ADDONS_DIRECTORY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AddPrinterDialog::FillMenu(BMenu* menu, const char* path, uint32 what)
|
AddPrinterDialog::_FillMenu(BMenu* menu, const char* path, uint32 what)
|
||||||
{
|
{
|
||||||
for (uint32 i = 0; i < sizeof(gAddonDirs) / sizeof(directory_which); i ++) {
|
for (uint32 i = 0; i < sizeof(gAddonDirs) / sizeof(directory_which); i++) {
|
||||||
BPath addonPath;
|
BPath addonPath;
|
||||||
if (find_directory(gAddonDirs[i], &addonPath) != B_OK)
|
if (find_directory(gAddonDirs[i], &addonPath) != B_OK)
|
||||||
continue;
|
continue;
|
||||||
@@ -335,16 +332,18 @@ AddPrinterDialog::FillMenu(BMenu* menu, const char* path, uint32 what)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddPrinterDialog::FillTransportMenu(BMenu* menu)
|
|
||||||
|
void
|
||||||
|
AddPrinterDialog::_FillTransportMenu(BMenu* menu)
|
||||||
{
|
{
|
||||||
BMessenger msgr;
|
BMessenger msgr;
|
||||||
if (GetPrinterServerMessenger(msgr) != B_OK)
|
if (GetPrinterServerMessenger(msgr) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (long idx=0; ; idx++) {
|
for (long idx = 0; ; idx++) {
|
||||||
BMessage reply, msg(B_GET_PROPERTY);
|
BMessage reply, msg(B_GET_PROPERTY);
|
||||||
msg.AddSpecifier("Transport", idx);
|
msg.AddSpecifier("Transport", idx);
|
||||||
if (msgr.SendMessage(&msg,&reply) != B_OK)
|
if (msgr.SendMessage(&msg, &reply) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
BMessenger transport;
|
BMessenger transport;
|
||||||
@@ -355,11 +354,11 @@ void AddPrinterDialog::FillTransportMenu(BMenu* menu)
|
|||||||
msg.MakeEmpty();
|
msg.MakeEmpty();
|
||||||
msg.what = B_GET_PROPERTY;
|
msg.what = B_GET_PROPERTY;
|
||||||
msg.AddSpecifier("Name");
|
msg.AddSpecifier("Name");
|
||||||
if (transport.SendMessage(&msg,&reply) != B_OK)
|
if (transport.SendMessage(&msg, &reply) != B_OK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BString transportName;
|
BString transportName;
|
||||||
if (reply.FindString("result",&transportName) != B_OK)
|
if (reply.FindString("result", &transportName) != B_OK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Now get ports...
|
// Now get ports...
|
||||||
@@ -367,7 +366,7 @@ void AddPrinterDialog::FillTransportMenu(BMenu* menu)
|
|||||||
msg.MakeEmpty();
|
msg.MakeEmpty();
|
||||||
msg.what = B_GET_PROPERTY;
|
msg.what = B_GET_PROPERTY;
|
||||||
msg.AddSpecifier("Ports");
|
msg.AddSpecifier("Ports");
|
||||||
if (transport.SendMessage(&msg,&reply) != B_OK ||
|
if (transport.SendMessage(&msg, &reply) != B_OK ||
|
||||||
reply.FindString("port_id", &portId) != B_OK) {
|
reply.FindString("port_id", &portId) != B_OK) {
|
||||||
// Can't find ports; so just show transport item, no menu
|
// Can't find ports; so just show transport item, no menu
|
||||||
BMessage* menuMsg = new BMessage(kTransportSelectedMsg);
|
BMessage* menuMsg = new BMessage(kTransportSelectedMsg);
|
||||||
@@ -383,9 +382,10 @@ void AddPrinterDialog::FillTransportMenu(BMenu* menu)
|
|||||||
menu->ItemAt(menu->IndexOf(transportMenu))->
|
menu->ItemAt(menu->IndexOf(transportMenu))->
|
||||||
SetMessage(new BMessage(kTransportSelectedMsg));
|
SetMessage(new BMessage(kTransportSelectedMsg));
|
||||||
|
|
||||||
for (int32 pidx=0; reply.FindString("port_id", pidx, &portId) == B_OK; pidx++) {
|
for (int32 i = 0; reply.FindString("port_id", i, &portId) == B_OK;
|
||||||
if (reply.FindString("port_name", pidx, &portName) != B_OK ||
|
i++) {
|
||||||
!portName.Length())
|
if (reply.FindString("port_name", i, &portName) != B_OK
|
||||||
|
|| !portName.Length())
|
||||||
portName = portId;
|
portName = portId;
|
||||||
|
|
||||||
// Create menu item in submenu for port
|
// Create menu item in submenu for port
|
||||||
@@ -397,11 +397,12 @@ void AddPrinterDialog::FillTransportMenu(BMenu* menu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AddPrinterDialog::Update()
|
AddPrinterDialog::_Update()
|
||||||
{
|
{
|
||||||
fOk->SetEnabled(fNameText != "" && fPrinterText != "" &&
|
fOk->SetEnabled(fNameText != "" && fPrinterText != ""
|
||||||
(fTransportText != "" || fPrinterText == "Preview"));
|
&& (fTransportText != "" || fPrinterText == "Preview"));
|
||||||
|
|
||||||
fTransport->SetEnabled(fPrinterText != "Preview");
|
fTransport->SetEnabled(fPrinterText != "Preview");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,57 +6,56 @@
|
|||||||
* Philippe Houdoin
|
* Philippe Houdoin
|
||||||
* Michael Pfeiffer
|
* Michael Pfeiffer
|
||||||
*/
|
*/
|
||||||
|
#ifndef _ADD_PRINTER_DIALOG_H
|
||||||
|
#define _ADD_PRINTER_DIALOG_H
|
||||||
|
|
||||||
#ifndef ADD_PRINTER_DIALOG_H
|
|
||||||
#define ADD_PRINTER_DIALOG_H
|
|
||||||
|
|
||||||
class AddPrinterDialog;
|
|
||||||
|
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <TextControl.h>
|
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
|
#include <TextControl.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
class AddPrinterDialog : public BWindow
|
|
||||||
{
|
|
||||||
typedef BWindow Inherited;
|
|
||||||
|
|
||||||
public:
|
|
||||||
AddPrinterDialog(BWindow *parent);
|
|
||||||
|
|
||||||
bool QuitRequested();
|
|
||||||
|
|
||||||
private:
|
|
||||||
enum MessageKind {
|
|
||||||
kPrinterSelectedMsg = 'adlg',
|
|
||||||
kTransportSelectedMsg,
|
|
||||||
kNameChangedMsg,
|
|
||||||
};
|
|
||||||
|
|
||||||
void MessageReceived(BMessage *msg);
|
|
||||||
|
|
||||||
void AddPrinter(BMessage *msg);
|
|
||||||
void StorePrinter(BMessage *msg);
|
|
||||||
void HandleChangedTransport(BMessage *msg);
|
|
||||||
|
|
||||||
void BuildGUI(int stage);
|
|
||||||
void FillTransportMenu(BMenu *menu);
|
|
||||||
void FillMenu(BMenu *menu, const char *path, uint32 what);
|
|
||||||
void AddPortSubMenu(BMenu *menu, const char *transport, const char *port);
|
|
||||||
void Update();
|
|
||||||
|
|
||||||
BMessenger fPrintersPrefletMessenger;
|
|
||||||
|
|
||||||
BTextControl *fName;
|
class AddPrinterDialog : public BWindow {
|
||||||
BPopUpMenu *fPrinter;
|
typedef BWindow Inherited;
|
||||||
BPopUpMenu *fTransport;
|
public:
|
||||||
BButton *fOk;
|
AddPrinterDialog(BWindow *parent);
|
||||||
|
|
||||||
BString fNameText;
|
void MessageReceived(BMessage *msg);
|
||||||
BString fPrinterText;
|
bool QuitRequested();
|
||||||
BString fTransportText;
|
|
||||||
BString fTransportPathText;
|
private:
|
||||||
|
enum MessageKind {
|
||||||
|
kPrinterSelectedMsg = 'adlg',
|
||||||
|
kTransportSelectedMsg,
|
||||||
|
kNameChangedMsg,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void _AddPrinter(BMessage *msg);
|
||||||
|
void _StorePrinter(BMessage *msg);
|
||||||
|
void _HandleChangedTransport(BMessage *msg);
|
||||||
|
|
||||||
|
void _BuildGUI(int stage);
|
||||||
|
void _FillTransportMenu(BMenu *menu);
|
||||||
|
void _FillMenu(BMenu *menu, const char *path,
|
||||||
|
uint32 what);
|
||||||
|
void _AddPortSubMenu(BMenu *menu,
|
||||||
|
const char *transport, const char *port);
|
||||||
|
void _Update();
|
||||||
|
|
||||||
|
BMessenger fPrintersPrefletMessenger;
|
||||||
|
|
||||||
|
BTextControl* fName;
|
||||||
|
BPopUpMenu* fPrinter;
|
||||||
|
BPopUpMenu* fTransport;
|
||||||
|
BButton* fOk;
|
||||||
|
|
||||||
|
BString fNameText;
|
||||||
|
BString fPrinterText;
|
||||||
|
BString fTransportText;
|
||||||
|
BString fTransportPathText;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _ADD_PRINTER_DIALOG_H
|
||||||
|
|||||||
@@ -1,37 +1,20 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// Printers Preference Application.
|
* Copyright 2001-2010, Haiku.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// This application and all source files used in its construction, except
|
*
|
||||||
// where noted, are licensed under the MIT License, and have been written
|
* Authors:
|
||||||
// and are:
|
* Michael Pfeiffer
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2001-2003 OpenBeOS Project
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "pr_server.h"
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "pr_server.h"
|
||||||
|
|
||||||
|
|
||||||
BString
|
BString
|
||||||
ActivePrinterName()
|
ActivePrinterName()
|
||||||
@@ -63,4 +46,3 @@ GetPrinterServerMessenger(BMessenger& msgr)
|
|||||||
msgr = BMessenger(PSRV_SIGNATURE_TYPE);
|
msgr = BMessenger(PSRV_SIGNATURE_TYPE);
|
||||||
return msgr.IsValid() ? B_OK : B_ERROR;
|
return msgr.IsValid() ? B_OK : B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,39 +1,20 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// Printers Preference Application.
|
* Copyright 2001-2010, Haiku.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// This application and all source files used in its construction, except
|
*
|
||||||
// where noted, are licensed under the MIT License, and have been written
|
* Authors:
|
||||||
// and are:
|
* Michael Pfeiffer
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2001-2003 OpenBeOS Project
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef GLOBALS_H
|
#ifndef GLOBALS_H
|
||||||
#define GLOBALS_H
|
#define GLOBALS_H
|
||||||
|
|
||||||
|
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
BString ActivePrinterName();
|
BString ActivePrinterName();
|
||||||
status_t GetPrinterServerMessenger(BMessenger& msgr);
|
status_t GetPrinterServerMessenger(BMessenger& msgr);
|
||||||
|
|
||||||
#endif
|
#endif // GLOBALS_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,48 +1,27 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// Printers Preference Application.
|
* Copyright 2001-2010, Haiku.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// This application and all source files used in its construction, except
|
*
|
||||||
// where noted, are licensed under the MIT License, and have been written
|
* Authors:
|
||||||
// and are:
|
* Michael Pfeiffer
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2001-2003 OpenBeOS Project
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#include "JobListView.h"
|
#include "JobListView.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <MimeType.h>
|
||||||
|
#include <Roster.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
#include "pr_server.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "Jobs.h"
|
#include "Jobs.h"
|
||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
#include "pr_server.h"
|
|
||||||
#include "SpoolFolder.h"
|
#include "SpoolFolder.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <Alert.h>
|
|
||||||
#include <Bitmap.h>
|
|
||||||
#include <Catalog.h>
|
|
||||||
#include <Messenger.h>
|
|
||||||
#include <Mime.h>
|
|
||||||
#include <Roster.h>
|
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATE_CONTEXT
|
#undef B_TRANSLATE_CONTEXT
|
||||||
#define B_TRANSLATE_CONTEXT "JobListView"
|
#define B_TRANSLATE_CONTEXT "JobListView"
|
||||||
@@ -52,7 +31,8 @@
|
|||||||
|
|
||||||
|
|
||||||
JobListView::JobListView(BRect frame)
|
JobListView::JobListView(BRect frame)
|
||||||
: Inherited(frame, "jobs_list", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL,
|
:
|
||||||
|
Inherited(frame, "jobs_list", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE)
|
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -169,9 +149,10 @@ JobListView::CancelJob()
|
|||||||
|
|
||||||
|
|
||||||
JobItem::JobItem(Job* job)
|
JobItem::JobItem(Job* job)
|
||||||
: BListItem(0, false)
|
:
|
||||||
, fJob(job)
|
BListItem(0, false),
|
||||||
, fIcon(NULL)
|
fJob(job),
|
||||||
|
fIcon(NULL)
|
||||||
{
|
{
|
||||||
fJob->Acquire();
|
fJob->Acquire();
|
||||||
Update();
|
Update();
|
||||||
@@ -204,10 +185,10 @@ JobItem::Update()
|
|||||||
be_plain_font->GetHeight(&fontHeight);
|
be_plain_font->GetHeight(&fontHeight);
|
||||||
float height = (fontHeight.ascent + fontHeight.descent
|
float height = (fontHeight.ascent + fontHeight.descent
|
||||||
+ fontHeight.leading) * 2.0;
|
+ fontHeight.leading) * 2.0;
|
||||||
BRect rect(0.0, 0.0, height, height);
|
BRect rect(0, 0, height, height);
|
||||||
fIcon = new BBitmap(rect, B_RGBA32);
|
fIcon = new BBitmap(rect, B_RGBA32);
|
||||||
#else
|
#else
|
||||||
BRect rect(0.0, 0.0, B_MINI_ICON - 1, B_MINI_ICON - 1);
|
BRect rect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1);
|
||||||
fIcon = new BBitmap(rect, B_CMAP8);
|
fIcon = new BBitmap(rect, B_CMAP8);
|
||||||
#endif
|
#endif
|
||||||
BMimeType type(mimeType.String());
|
BMimeType type(mimeType.String());
|
||||||
|
|||||||
@@ -1,91 +1,68 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// Printers Preference Application.
|
* Copyright 2001-2010, Haiku.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// This application and all source files used in its construction, except
|
*
|
||||||
// where noted, are licensed under the MIT License, and have been written
|
* Authors:
|
||||||
// and are:
|
* Michael Pfeiffer
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2001-2003 OpenBeOS Project
|
#ifndef _JOB_LISTVIEW_H
|
||||||
//
|
#define _JOB_LISTVIEW_H
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef JOBLISTVIEW_H
|
|
||||||
#define JOBLISTVIEW_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <ListView.h>
|
#include <Bitmap.h>
|
||||||
#include <ListItem.h>
|
#include <ListItem.h>
|
||||||
|
#include <ListView.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
class BBitmap;
|
|
||||||
class Job;
|
class Job;
|
||||||
class JobItem;
|
class JobItem;
|
||||||
class SpoolFolder;
|
class SpoolFolder;
|
||||||
|
|
||||||
|
|
||||||
class JobListView : public BListView
|
class JobListView : public BListView {
|
||||||
{
|
|
||||||
typedef BListView Inherited;
|
typedef BListView Inherited;
|
||||||
public:
|
public:
|
||||||
JobListView(BRect frame);
|
JobListView(BRect frame);
|
||||||
~JobListView();
|
~JobListView();
|
||||||
|
|
||||||
void AttachedToWindow();
|
void AttachedToWindow();
|
||||||
void SetSpoolFolder(SpoolFolder* folder);
|
void SetSpoolFolder(SpoolFolder* folder);
|
||||||
|
|
||||||
void AddJob(Job* job);
|
void AddJob(Job* job);
|
||||||
void RemoveJob(Job* job);
|
void RemoveJob(Job* job);
|
||||||
void UpdateJob(Job* job);
|
void UpdateJob(Job* job);
|
||||||
|
|
||||||
JobItem* SelectedItem() const;
|
JobItem* SelectedItem() const;
|
||||||
|
|
||||||
void RestartJob();
|
void RestartJob();
|
||||||
void CancelJob();
|
void CancelJob();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JobItem* FindJob(Job* job) const;
|
JobItem* FindJob(Job* job) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class JobItem : public BListItem
|
class JobItem : public BListItem {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
JobItem(Job* job);
|
JobItem(Job* job);
|
||||||
~JobItem();
|
~JobItem();
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
void Update(BView *owner, const BFont *font);
|
void Update(BView *owner, const BFont *font);
|
||||||
void DrawItem(BView *owner, BRect bounds, bool complete);
|
void DrawItem(BView *owner, BRect bounds,
|
||||||
|
bool complete);
|
||||||
|
|
||||||
Job* GetJob() const { return fJob; }
|
Job* GetJob() const { return fJob; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Job* fJob;
|
Job* fJob;
|
||||||
BBitmap* fIcon;
|
BBitmap* fIcon;
|
||||||
BString fName;
|
BString fName;
|
||||||
BString fPages;
|
BString fPages;
|
||||||
BString fStatus;
|
BString fStatus;
|
||||||
BString fSize;
|
BString fSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // _JOB_LISTVIEW_H
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -6,12 +6,13 @@
|
|||||||
* Michael Pfeiffer
|
* Michael Pfeiffer
|
||||||
* Philippe Houdoin
|
* Philippe Houdoin
|
||||||
*/
|
*/
|
||||||
|
#ifndef _MESSAGES_H
|
||||||
#ifndef MESSAGES_H
|
#define _MESSAGES_H
|
||||||
#define MESSAGES_H
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
const uint32 kMsgAddPrinter = 'AddP';
|
const uint32 kMsgAddPrinter = 'AddP';
|
||||||
const uint32 kMsgAddPrinterClosed = 'APCl';
|
const uint32 kMsgAddPrinterClosed = 'APCl';
|
||||||
const uint32 kMsgRemovePrinter = 'RemP';
|
const uint32 kMsgRemovePrinter = 'RemP';
|
||||||
@@ -21,4 +22,4 @@ const uint32 kMsgCancelJob = 'CncJ';
|
|||||||
const uint32 kMsgRestartJob = 'RstJ';
|
const uint32 kMsgRestartJob = 'RstJ';
|
||||||
const uint32 kMsgJobSelected = 'JSel';
|
const uint32 kMsgJobSelected = 'JSel';
|
||||||
|
|
||||||
#endif
|
#endif // _MESSAGES_H
|
||||||
|
|||||||
@@ -1,47 +1,27 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// Printers Preference Application.
|
* Copyright 2001-2010, Haiku.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// This application and all source files used in its construction, except
|
*
|
||||||
// where noted, are licensed under the MIT License, and have been written
|
* Authors:
|
||||||
// and are:
|
* Michael Pfeiffer
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2001-2003 OpenBeOS Project
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#include "PrinterListView.h"
|
#include "PrinterListView.h"
|
||||||
#include "pr_server.h"
|
|
||||||
|
|
||||||
|
#include <Bitmap.h>
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <Directory.h>
|
||||||
|
#include <Mime.h>
|
||||||
|
#include <NodeInfo.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
|
#include "pr_server.h"
|
||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "PrintersWindow.h"
|
#include "PrintersWindow.h"
|
||||||
#include "SpoolFolder.h"
|
#include "SpoolFolder.h"
|
||||||
|
|
||||||
#include <Messenger.h>
|
|
||||||
#include <Bitmap.h>
|
|
||||||
#include <Catalog.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <Alert.h>
|
|
||||||
#include <Mime.h>
|
|
||||||
#include <StorageKit.h>
|
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATE_CONTEXT
|
#undef B_TRANSLATE_CONTEXT
|
||||||
#define B_TRANSLATE_CONTEXT "PrinterListView"
|
#define B_TRANSLATE_CONTEXT "PrinterListView"
|
||||||
@@ -85,7 +65,7 @@ PrinterListView::BuildPrinterList()
|
|||||||
BEntry entry;
|
BEntry entry;
|
||||||
while(dir.GetNextEntry(&entry) == B_OK) {
|
while(dir.GetNextEntry(&entry) == B_OK) {
|
||||||
BDirectory printer(&entry);
|
BDirectory printer(&entry);
|
||||||
AddPrinter(printer);
|
_AddPrinter(printer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,14 +118,43 @@ PrinterListView::QuitRequested()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrinterListView::AddPrinter(BDirectory& printer)
|
PrinterListView::UpdateItem(PrinterItem* item)
|
||||||
|
{
|
||||||
|
item->UpdatePendingJobs();
|
||||||
|
InvalidateItem(IndexOf(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PrinterItem*
|
||||||
|
PrinterListView::ActivePrinter() const
|
||||||
|
{
|
||||||
|
return fActivePrinter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PrinterListView::SetActivePrinter(PrinterItem* item)
|
||||||
|
{
|
||||||
|
fActivePrinter = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PrinterItem*
|
||||||
|
PrinterListView::SelectedItem() const
|
||||||
|
{
|
||||||
|
return dynamic_cast<PrinterItem*>(ItemAt(CurrentSelection()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PrinterListView::_AddPrinter(BDirectory& printer)
|
||||||
{
|
{
|
||||||
BString state;
|
BString state;
|
||||||
node_ref node;
|
node_ref node;
|
||||||
// If the entry is a directory
|
// If the entry is a directory
|
||||||
if (printer.InitCheck() == B_OK
|
if (printer.InitCheck() == B_OK
|
||||||
&& printer.GetNodeRef(&node) == B_OK
|
&& printer.GetNodeRef(&node) == B_OK
|
||||||
&& FindItem(&node) == NULL
|
&& _FindItem(&node) == NULL
|
||||||
&& printer.ReadAttrString(PSRV_PRINTER_ATTR_STATE, &state) == B_OK
|
&& printer.ReadAttrString(PSRV_PRINTER_ATTR_STATE, &state) == B_OK
|
||||||
&& state == "free") {
|
&& state == "free") {
|
||||||
// Check it's Mime type for a spool director
|
// Check it's Mime type for a spool director
|
||||||
@@ -162,30 +171,30 @@ PrinterListView::AddPrinter(BDirectory& printer)
|
|||||||
|
|
||||||
|
|
||||||
PrinterItem*
|
PrinterItem*
|
||||||
PrinterListView::FindItem(node_ref* node) const
|
PrinterListView::_FindItem(node_ref* node) const
|
||||||
{
|
{
|
||||||
for (int32 i = CountItems()-1; i >= 0; i --) {
|
for (int32 i = CountItems() - 1; i >= 0; i--) {
|
||||||
PrinterItem* item = dynamic_cast<PrinterItem*>(ItemAt(i));
|
PrinterItem* item = dynamic_cast<PrinterItem*>(ItemAt(i));
|
||||||
node_ref ref;
|
node_ref ref;
|
||||||
if (item && item->Node()->GetNodeRef(&ref) == B_OK && ref == *node) {
|
if (item && item->Node()->GetNodeRef(&ref) == B_OK && ref == *node)
|
||||||
return item;
|
return item;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrinterListView::EntryCreated(node_ref* node, entry_ref* entry)
|
PrinterListView::_EntryCreated(node_ref* node, entry_ref* entry)
|
||||||
{
|
{
|
||||||
BDirectory printer(node);
|
BDirectory printer(node);
|
||||||
AddPrinter(printer);
|
_AddPrinter(printer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrinterListView::EntryRemoved(node_ref* node)
|
void
|
||||||
|
PrinterListView::_EntryRemoved(node_ref* node)
|
||||||
{
|
{
|
||||||
PrinterItem* item = FindItem(node);
|
PrinterItem* item = _FindItem(node);
|
||||||
if (item) {
|
if (item) {
|
||||||
if (item == fActivePrinter)
|
if (item == fActivePrinter)
|
||||||
fActivePrinter = NULL;
|
fActivePrinter = NULL;
|
||||||
@@ -197,40 +206,13 @@ void PrinterListView::EntryRemoved(node_ref* node)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrinterListView::AttributeChanged(node_ref* node)
|
PrinterListView::_AttributeChanged(node_ref* node)
|
||||||
{
|
{
|
||||||
BDirectory printer(node);
|
BDirectory printer(node);
|
||||||
AddPrinter(printer);
|
_AddPrinter(printer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PrinterListView::UpdateItem(PrinterItem* item)
|
|
||||||
{
|
|
||||||
item->UpdatePendingJobs();
|
|
||||||
InvalidateItem(IndexOf(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PrinterItem*
|
|
||||||
PrinterListView::SelectedItem() const
|
|
||||||
{
|
|
||||||
return dynamic_cast<PrinterItem*>(ItemAt(CurrentSelection()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PrinterItem*
|
|
||||||
PrinterListView::ActivePrinter() const
|
|
||||||
{
|
|
||||||
return fActivePrinter;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PrinterListView::SetActivePrinter(PrinterItem* item)
|
|
||||||
{
|
|
||||||
fActivePrinter = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -- PrinterItem
|
// #pragma mark -- PrinterItem
|
||||||
@@ -262,7 +244,8 @@ PrinterItem::PrinterItem(PrintersWindow* window, const BDirectory& node)
|
|||||||
sSelectedIcon = new BBitmap(rect, B_RGBA32, true);
|
sSelectedIcon = new BBitmap(rect, B_RGBA32, true);
|
||||||
if (sSelectedIcon && sSelectedIcon->IsValid()) {
|
if (sSelectedIcon && sSelectedIcon->IsValid()) {
|
||||||
// draw check mark at bottom left over printer icon
|
// draw check mark at bottom left over printer icon
|
||||||
BView *view = new BView(rect, "offscreen", B_FOLLOW_ALL, B_WILL_DRAW);
|
BView *view = new BView(rect, "offscreen", B_FOLLOW_ALL,
|
||||||
|
B_WILL_DRAW);
|
||||||
float y = rect.Height() - checkMark->Bounds().Height();
|
float y = rect.Height() - checkMark->Bounds().Height();
|
||||||
sSelectedIcon->Lock();
|
sSelectedIcon->Lock();
|
||||||
sSelectedIcon->AddChild(view);
|
sSelectedIcon->AddChild(view);
|
||||||
@@ -279,10 +262,10 @@ PrinterItem::PrinterItem(PrintersWindow* window, const BDirectory& node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get Name of printer
|
// Get Name of printer
|
||||||
GetStringProperty(PSRV_PRINTER_ATTR_PRT_NAME, fName);
|
_GetStringProperty(PSRV_PRINTER_ATTR_PRT_NAME, fName);
|
||||||
GetStringProperty(PSRV_PRINTER_ATTR_COMMENTS, fComments);
|
_GetStringProperty(PSRV_PRINTER_ATTR_COMMENTS, fComments);
|
||||||
GetStringProperty(PSRV_PRINTER_ATTR_TRANSPORT, fTransport);
|
_GetStringProperty(PSRV_PRINTER_ATTR_TRANSPORT, fTransport);
|
||||||
GetStringProperty(PSRV_PRINTER_ATTR_DRV_NAME, fDriverName);
|
_GetStringProperty(PSRV_PRINTER_ATTR_DRV_NAME, fDriverName);
|
||||||
|
|
||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(B_USER_PRINTERS_DIRECTORY, &path) != B_OK)
|
if (find_directory(B_USER_PRINTERS_DIRECTORY, &path) != B_OK)
|
||||||
@@ -304,13 +287,6 @@ PrinterItem::~PrinterItem()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PrinterItem::GetStringProperty(const char* propName, BString& outString)
|
|
||||||
{
|
|
||||||
fNode.ReadAttrString(propName, &outString);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrinterItem::Update(BView *owner, const BFont *font)
|
PrinterItem::Update(BView *owner, const BFont *font)
|
||||||
{
|
{
|
||||||
@@ -338,7 +314,8 @@ bool PrinterItem::Remove(BListView* view)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrinterItem::DrawItem(BView *owner, BRect /*bounds*/, bool complete)
|
void
|
||||||
|
PrinterItem::DrawItem(BView *owner, BRect /*bounds*/, bool complete)
|
||||||
{
|
{
|
||||||
BListView* list = dynamic_cast<BListView*>(owner);
|
BListView* list = dynamic_cast<BListView*>(owner);
|
||||||
if (list == NULL)
|
if (list == NULL)
|
||||||
@@ -468,3 +445,11 @@ PrinterItem::UpdatePendingJobs()
|
|||||||
}
|
}
|
||||||
fPendingJobs = B_TRANSLATE("No pending jobs.");
|
fPendingJobs = B_TRANSLATE("No pending jobs.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PrinterItem::_GetStringProperty(const char* propName, BString& outString)
|
||||||
|
{
|
||||||
|
fNode.ReadAttrString(propName, &outString);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,113 +1,95 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// Printers Preference Application.
|
* Copyright 2001-2010, Haiku.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// This application and all source files used in its construction, except
|
*
|
||||||
// where noted, are licensed under the MIT License, and have been written
|
* Authors:
|
||||||
// and are:
|
* Michael Pfeiffer
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2001-2003 OpenBeOS Project
|
#ifndef _PRINTERS_LISTVIEW_H
|
||||||
//
|
#define _PRINTERS_LISTVIEW_H
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef PRINTERSLISTVIEW_H
|
|
||||||
#define PRINTERSLISTVIEW_H
|
|
||||||
|
|
||||||
class PrinterListView;
|
|
||||||
|
|
||||||
|
#include <Directory.h>
|
||||||
|
#include <Entry.h>
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
#include <ListView.h>
|
#include <ListView.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <Directory.h>
|
|
||||||
#include <Entry.h>
|
|
||||||
|
|
||||||
#include "FolderWatcher.h"
|
#include "FolderWatcher.h"
|
||||||
|
|
||||||
|
|
||||||
class SpoolFolder;
|
class SpoolFolder;
|
||||||
class PrinterItem;
|
class PrinterItem;
|
||||||
class PrinterListView;
|
class PrinterListView;
|
||||||
|
|
||||||
class PrinterListView : public BListView, public FolderListener {
|
|
||||||
private:
|
|
||||||
typedef BListView Inherited;
|
|
||||||
|
|
||||||
void AddPrinter(BDirectory &printer);
|
|
||||||
PrinterItem *FindItem(node_ref *node) const;
|
|
||||||
|
|
||||||
void EntryCreated(node_ref *node, entry_ref *entry);
|
|
||||||
void EntryRemoved(node_ref *node);
|
|
||||||
void AttributeChanged(node_ref *node);
|
|
||||||
|
|
||||||
public:
|
|
||||||
PrinterListView(BRect frame);
|
|
||||||
~PrinterListView();
|
|
||||||
|
|
||||||
void AttachedToWindow();
|
|
||||||
bool QuitRequested();
|
|
||||||
|
|
||||||
void BuildPrinterList();
|
|
||||||
PrinterItem *SelectedItem() const;
|
|
||||||
void UpdateItem(PrinterItem *item);
|
|
||||||
|
|
||||||
PrinterItem* ActivePrinter() const;
|
|
||||||
void SetActivePrinter(PrinterItem* item);
|
|
||||||
|
|
||||||
private:
|
|
||||||
FolderWatcher *fFolder;
|
|
||||||
PrinterItem *fActivePrinter;
|
|
||||||
};
|
|
||||||
|
|
||||||
class BBitmap;
|
class BBitmap;
|
||||||
class PrintersWindow;
|
class PrintersWindow;
|
||||||
class PrinterItem : public BListItem {
|
|
||||||
public:
|
|
||||||
PrinterItem(PrintersWindow *window, const BDirectory &node);
|
|
||||||
~PrinterItem();
|
|
||||||
|
|
||||||
void DrawItem(BView *owner, BRect bounds, bool complete);
|
|
||||||
void Update(BView *owner, const BFont *font);
|
|
||||||
|
|
||||||
bool Remove(BListView *view);
|
class PrinterListView : public BListView, public FolderListener {
|
||||||
bool IsActivePrinter() const;
|
public:
|
||||||
bool HasPendingJobs() const;
|
PrinterListView(BRect frame);
|
||||||
|
~PrinterListView();
|
||||||
|
|
||||||
const char *Name() const {
|
void AttachedToWindow();
|
||||||
return fName.String();
|
bool QuitRequested();
|
||||||
}
|
|
||||||
|
|
||||||
SpoolFolder *Folder() const;
|
void BuildPrinterList();
|
||||||
BDirectory *Node();
|
PrinterItem *SelectedItem() const;
|
||||||
void UpdatePendingJobs();
|
void UpdateItem(PrinterItem *item);
|
||||||
|
|
||||||
private:
|
PrinterItem *ActivePrinter() const;
|
||||||
void GetStringProperty(const char *propName, BString &outString);
|
void SetActivePrinter(PrinterItem* item);
|
||||||
|
|
||||||
SpoolFolder *fFolder;
|
private:
|
||||||
BDirectory fNode;
|
typedef BListView Inherited;
|
||||||
BString fComments;
|
|
||||||
BString fTransport;
|
|
||||||
BString fDriverName;
|
|
||||||
BString fName;
|
|
||||||
BString fPendingJobs;
|
|
||||||
|
|
||||||
static BBitmap *sIcon;
|
void _AddPrinter(BDirectory &printer);
|
||||||
static BBitmap *sSelectedIcon;
|
PrinterItem *_FindItem(node_ref* node) const;
|
||||||
|
|
||||||
|
void _EntryCreated(node_ref *node,
|
||||||
|
entry_ref *entry);
|
||||||
|
void _EntryRemoved(node_ref *node);
|
||||||
|
void _AttributeChanged(node_ref *node);
|
||||||
|
|
||||||
|
FolderWatcher *fFolder;
|
||||||
|
PrinterItem *fActivePrinter;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
class PrinterItem : public BListItem {
|
||||||
|
public:
|
||||||
|
PrinterItem(PrintersWindow *window,
|
||||||
|
const BDirectory &node);
|
||||||
|
~PrinterItem();
|
||||||
|
|
||||||
|
void DrawItem(BView *owner, BRect bounds,
|
||||||
|
bool complete);
|
||||||
|
void Update(BView *owner, const BFont *font);
|
||||||
|
|
||||||
|
bool Remove(BListView *view);
|
||||||
|
bool IsActivePrinter() const;
|
||||||
|
bool HasPendingJobs() const;
|
||||||
|
|
||||||
|
const char *Name() const { return fName.String(); }
|
||||||
|
|
||||||
|
SpoolFolder *Folder() const;
|
||||||
|
BDirectory *Node();
|
||||||
|
void UpdatePendingJobs();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _GetStringProperty(const char *propName,
|
||||||
|
BString &outString);
|
||||||
|
|
||||||
|
SpoolFolder *fFolder;
|
||||||
|
BDirectory fNode;
|
||||||
|
BString fComments;
|
||||||
|
BString fTransport;
|
||||||
|
BString fDriverName;
|
||||||
|
BString fName;
|
||||||
|
BString fPendingJobs;
|
||||||
|
|
||||||
|
static BBitmap *sIcon;
|
||||||
|
static BBitmap *sSelectedIcon;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _PRINTERS_LISTVIEW_H
|
||||||
|
|||||||
@@ -1,59 +1,48 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// Printers Preference Application.
|
* Copyright 2001-2010, Haiku.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// This application and all source files used in its construction, except
|
*
|
||||||
// where noted, are licensed under the MIT License, and have been written
|
* Authors:
|
||||||
// and are:
|
* Michael Pfeiffer
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2001-2003 OpenBeOS Project
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#include "Printers.h"
|
#include "Printers.h"
|
||||||
|
|
||||||
|
#include <Locale.h>
|
||||||
|
|
||||||
#include "pr_server.h"
|
#include "pr_server.h"
|
||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
#include "PrintersWindow.h"
|
#include "PrintersWindow.h"
|
||||||
|
|
||||||
#include <Locale.h>
|
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main()
|
||||||
{
|
{
|
||||||
PrintersApp app;
|
PrintersApp app;
|
||||||
app.Run();
|
app.Run();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PrintersApp::PrintersApp()
|
PrintersApp::PrintersApp()
|
||||||
: Inherited(PRINTERS_SIGNATURE)
|
: Inherited(PRINTERS_SIGNATURE)
|
||||||
{
|
{
|
||||||
be_locale->GetAppCatalog(&fCatalog);
|
be_locale->GetAppCatalog(&fCatalog);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintersApp::ReadyToRun()
|
|
||||||
|
void
|
||||||
|
PrintersApp::ReadyToRun()
|
||||||
{
|
{
|
||||||
PrintersWindow* win = new PrintersWindow(BRect(78.0, 71.0, 561.0, 409.0));
|
PrintersWindow* win = new PrintersWindow(BRect(78, 71, 561, 409));
|
||||||
win->Show();
|
win->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintersApp::MessageReceived(BMessage* msg) {
|
|
||||||
|
void
|
||||||
|
PrintersApp::MessageReceived(BMessage* msg)
|
||||||
|
{
|
||||||
if (msg->what == B_PRINTER_CHANGED || msg->what == PRINTERS_ADD_PRINTER) {
|
if (msg->what == B_PRINTER_CHANGED || msg->what == PRINTERS_ADD_PRINTER) {
|
||||||
// broadcast message
|
// broadcast message
|
||||||
uint32 what = msg->what;
|
uint32 what = msg->what;
|
||||||
@@ -61,7 +50,7 @@ void PrintersApp::MessageReceived(BMessage* msg) {
|
|||||||
what = kMsgAddPrinter;
|
what = kMsgAddPrinter;
|
||||||
|
|
||||||
BWindow* w;
|
BWindow* w;
|
||||||
for (int32 i = 0; (w = WindowAt(i)) != NULL; i ++) {
|
for (int32 i = 0; (w = WindowAt(i)) != NULL; i++) {
|
||||||
BMessenger msgr(NULL, w);
|
BMessenger msgr(NULL, w);
|
||||||
msgr.SendMessage(what);
|
msgr.SendMessage(what);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +1,30 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// Printers Preference Application.
|
* Copyright 2001-2010, Haiku.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// This application and all source files used in its construction, except
|
*
|
||||||
// where noted, are licensed under the MIT License, and have been written
|
* Authors:
|
||||||
// and are:
|
* Michael Pfeiffer
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2001-2003 OpenBeOS Project
|
#ifndef _PRINTERS_H
|
||||||
//
|
#define _PRINTERS_H
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef PRINTERS_H
|
|
||||||
#define PRINTERS_H
|
|
||||||
|
|
||||||
class PrintersApp;
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
|
||||||
|
|
||||||
#define PRINTERS_SIGNATURE "application/x-vnd.Be-PRNT"
|
#define PRINTERS_SIGNATURE "application/x-vnd.Be-PRNT"
|
||||||
|
|
||||||
class PrintersApp : public BApplication
|
|
||||||
{
|
class PrintersApp : public BApplication {
|
||||||
typedef BApplication Inherited;
|
typedef BApplication Inherited;
|
||||||
public:
|
public:
|
||||||
PrintersApp();
|
PrintersApp();
|
||||||
void ReadyToRun();
|
void ReadyToRun();
|
||||||
void MessageReceived(BMessage* msg);
|
void MessageReceived(BMessage* msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BCatalog fCatalog;
|
BCatalog fCatalog;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _PRINTERS_H
|
||||||
|
|||||||
@@ -1,49 +1,29 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// Printers Preference Application.
|
* Copyright 2001-2010, Haiku.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// This application and all source files used in its construction, except
|
*
|
||||||
// where noted, are licensed under the MIT License, and have been written
|
* Authors:
|
||||||
// and are:
|
* Michael Pfeiffer
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2001-2003 OpenBeOS Project
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#include "PrintersWindow.h"
|
#include "PrintersWindow.h"
|
||||||
|
|
||||||
#include "AddPrinterDialog.h"
|
|
||||||
#include "PrinterListView.h"
|
|
||||||
#include "pr_server.h"
|
|
||||||
#include "Globals.h"
|
|
||||||
#include "Messages.h"
|
|
||||||
#include "JobListView.h"
|
|
||||||
#include "SpoolFolder.h"
|
|
||||||
|
|
||||||
// BeOS API
|
// BeOS API
|
||||||
#include <Box.h>
|
#include <Application.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
#include <FindDirectory.h>
|
||||||
#include <ListView.h>
|
#include <ListView.h>
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
#include <Application.h>
|
|
||||||
#include <FindDirectory.h>
|
#include "pr_server.h"
|
||||||
|
#include "AddPrinterDialog.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
#include "JobListView.h"
|
||||||
|
#include "Messages.h"
|
||||||
|
#include "PrinterListView.h"
|
||||||
|
#include "SpoolFolder.h"
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATE_CONTEXT
|
#undef B_TRANSLATE_CONTEXT
|
||||||
@@ -52,8 +32,8 @@
|
|||||||
|
|
||||||
PrintersWindow::PrintersWindow(BRect frame)
|
PrintersWindow::PrintersWindow(BRect frame)
|
||||||
:
|
:
|
||||||
Inherited(BRect(78.0, 71.0, 561.0, 409.0), B_TRANSLATE("Printers"),
|
Inherited(BRect(78, 71, 561, 409), B_TRANSLATE("Printers"), B_TITLED_WINDOW,
|
||||||
B_TITLED_WINDOW, 0),
|
0),
|
||||||
fSelectedPrinter(NULL),
|
fSelectedPrinter(NULL),
|
||||||
fAddingPrinter(false)
|
fAddingPrinter(false)
|
||||||
{
|
{
|
||||||
@@ -65,9 +45,8 @@ bool
|
|||||||
PrintersWindow::QuitRequested()
|
PrintersWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
bool result = Inherited::QuitRequested();
|
bool result = Inherited::QuitRequested();
|
||||||
if (result) {
|
if (result)
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -76,33 +55,29 @@ PrintersWindow::QuitRequested()
|
|||||||
void
|
void
|
||||||
PrintersWindow::MessageReceived(BMessage* msg)
|
PrintersWindow::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
switch(msg->what)
|
switch(msg->what) {
|
||||||
{
|
|
||||||
case kMsgPrinterSelected:
|
case kMsgPrinterSelected:
|
||||||
{
|
{
|
||||||
fSelectedPrinter = fPrinterListView->SelectedItem();
|
fSelectedPrinter = fPrinterListView->SelectedItem();
|
||||||
if (fSelectedPrinter)
|
if (fSelectedPrinter) {
|
||||||
{
|
fJobsBox->SetLabel((BString(B_TRANSLATE("Print jobs for "))
|
||||||
fJobsBox->SetLabel((BString(B_TRANSLATE("Print jobs for ")) <<
|
<< fSelectedPrinter->Name()).String());
|
||||||
fSelectedPrinter->Name()).String());
|
fMakeDefault->SetEnabled(true);
|
||||||
fMakeDefault->SetEnabled(true);
|
fRemove->SetEnabled(true);
|
||||||
fRemove->SetEnabled(true);
|
fJobListView->SetSpoolFolder(fSelectedPrinter->Folder());
|
||||||
fJobListView->SetSpoolFolder(fSelectedPrinter->Folder());
|
} else {
|
||||||
}
|
fJobsBox->SetLabel(
|
||||||
else
|
B_TRANSLATE("Print jobs: No printer selected"));
|
||||||
{
|
fMakeDefault->SetEnabled(false);
|
||||||
fJobsBox->SetLabel(
|
fRemove->SetEnabled(false);
|
||||||
B_TRANSLATE("Print jobs: No printer selected"));
|
fSelectedPrinter = NULL;
|
||||||
fMakeDefault->SetEnabled(false);
|
fJobListView->SetSpoolFolder(NULL);
|
||||||
fRemove->SetEnabled(false);
|
|
||||||
fSelectedPrinter = NULL;
|
|
||||||
fJobListView->SetSpoolFolder(NULL);
|
|
||||||
}
|
|
||||||
UpdateJobButtons();
|
|
||||||
UpdatePrinterButtons();
|
|
||||||
}
|
}
|
||||||
|
UpdateJobButtons();
|
||||||
|
UpdatePrinterButtons();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case kMsgAddPrinter:
|
case kMsgAddPrinter:
|
||||||
if (!fAddingPrinter) {
|
if (!fAddingPrinter) {
|
||||||
fAddingPrinter = true;
|
fAddingPrinter = true;
|
||||||
@@ -115,35 +90,39 @@ PrintersWindow::MessageReceived(BMessage* msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kMsgRemovePrinter:
|
case kMsgRemovePrinter:
|
||||||
{
|
{
|
||||||
fSelectedPrinter = fPrinterListView->SelectedItem();
|
fSelectedPrinter = fPrinterListView->SelectedItem();
|
||||||
if (fSelectedPrinter) fSelectedPrinter->Remove(fPrinterListView);
|
if (fSelectedPrinter)
|
||||||
|
fSelectedPrinter->Remove(fPrinterListView);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case kMsgMakeDefaultPrinter:
|
||||||
|
{
|
||||||
|
PrinterItem* printer = fPrinterListView->SelectedItem();
|
||||||
|
if (printer && printer == fPrinterListView->ActivePrinter())
|
||||||
|
break;
|
||||||
|
BMessenger msgr;
|
||||||
|
if (printer && GetPrinterServerMessenger(msgr) == B_OK) {
|
||||||
|
BMessage setActivePrinter(B_SET_PROPERTY);
|
||||||
|
setActivePrinter.AddSpecifier("ActivePrinter");
|
||||||
|
setActivePrinter.AddString("data", printer->Name());
|
||||||
|
msgr.SendMessage(&setActivePrinter);
|
||||||
|
UpdatePrinterButtons();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case kMsgMakeDefaultPrinter:
|
case kMsgCancelJob:
|
||||||
{
|
fJobListView->CancelJob();
|
||||||
PrinterItem* printer = fPrinterListView->SelectedItem();
|
|
||||||
if (printer && printer == fPrinterListView->ActivePrinter())
|
|
||||||
break;
|
|
||||||
|
|
||||||
BMessenger msgr;
|
|
||||||
if (printer && GetPrinterServerMessenger(msgr) == B_OK) {
|
|
||||||
BMessage setActivePrinter(B_SET_PROPERTY);
|
|
||||||
setActivePrinter.AddSpecifier("ActivePrinter");
|
|
||||||
setActivePrinter.AddString("data", printer->Name());
|
|
||||||
msgr.SendMessage(&setActivePrinter);
|
|
||||||
UpdatePrinterButtons();
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case kMsgCancelJob: fJobListView->CancelJob();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kMsgRestartJob: fJobListView->RestartJob();
|
case kMsgRestartJob:
|
||||||
|
fJobListView->RestartJob();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kMsgJobSelected: UpdateJobButtons();
|
case kMsgJobSelected:
|
||||||
|
UpdateJobButtons();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_PRINTER_CHANGED:
|
case B_PRINTER_CHANGED:
|
||||||
@@ -183,7 +162,8 @@ PrintersWindow::BuildGUI()
|
|||||||
AddChild(backdrop);
|
AddChild(backdrop);
|
||||||
|
|
||||||
// ------------------------ Next, build the printers overview box
|
// ------------------------ Next, build the printers overview box
|
||||||
BBox* printersBox = new BBox(BRect(boxInset, boxInset, r.Width()-boxInset, (r.Height()/2) - (boxInset/2)),
|
BBox* printersBox = new BBox(BRect(boxInset, boxInset,
|
||||||
|
r.Width() - boxInset, (r.Height()/2) - (boxInset/2)),
|
||||||
"printersBox", B_FOLLOW_ALL);
|
"printersBox", B_FOLLOW_ALL);
|
||||||
printersBox->SetFont(be_bold_font);
|
printersBox->SetFont(be_bold_font);
|
||||||
printersBox->SetLabel(B_TRANSLATE("Printers"));
|
printersBox->SetLabel(B_TRANSLATE("Printers"));
|
||||||
@@ -202,7 +182,8 @@ PrintersWindow::BuildGUI()
|
|||||||
|
|
||||||
// Remove button
|
// Remove button
|
||||||
fRemove = new BButton(BRect(5,30,5,30), "remove",
|
fRemove = new BButton(BRect(5,30,5,30), "remove",
|
||||||
B_TRANSLATE("Remove"), new BMessage(kMsgRemovePrinter), B_FOLLOW_RIGHT);
|
B_TRANSLATE("Remove"), new BMessage(kMsgRemovePrinter),
|
||||||
|
B_FOLLOW_RIGHT);
|
||||||
printersBox->AddChild(fRemove);
|
printersBox->AddChild(fRemove);
|
||||||
fRemove->ResizeToPreferred();
|
fRemove->ResizeToPreferred();
|
||||||
|
|
||||||
@@ -211,7 +192,8 @@ PrintersWindow::BuildGUI()
|
|||||||
|
|
||||||
// Make Default button
|
// Make Default button
|
||||||
fMakeDefault = new BButton(BRect(5,60,5,60), "default",
|
fMakeDefault = new BButton(BRect(5,60,5,60), "default",
|
||||||
B_TRANSLATE("Make default"), new BMessage(kMsgMakeDefaultPrinter), B_FOLLOW_RIGHT);
|
B_TRANSLATE("Make default"), new BMessage(kMsgMakeDefaultPrinter),
|
||||||
|
B_FOLLOW_RIGHT);
|
||||||
printersBox->AddChild(fMakeDefault);
|
printersBox->AddChild(fMakeDefault);
|
||||||
fMakeDefault->ResizeToPreferred();
|
fMakeDefault->ResizeToPreferred();
|
||||||
|
|
||||||
@@ -219,16 +201,16 @@ PrintersWindow::BuildGUI()
|
|||||||
maxWidth = fMakeDefault->Bounds().Width();
|
maxWidth = fMakeDefault->Bounds().Width();
|
||||||
|
|
||||||
// Resize all buttons to maximum width and align them to the right
|
// Resize all buttons to maximum width and align them to the right
|
||||||
float xPos = printersBox->Bounds().Width()-boxInset-maxWidth;
|
float xPos = printersBox->Bounds().Width() - boxInset - maxWidth;
|
||||||
addButton->MoveTo(xPos, boxInset +8);
|
addButton->MoveTo(xPos, boxInset + 8);
|
||||||
addButton->ResizeTo(maxWidth, addButton->Bounds().Height());
|
addButton->ResizeTo(maxWidth, addButton->Bounds().Height());
|
||||||
|
|
||||||
fRemove->MoveTo(xPos, boxInset + addButton->Bounds().Height() + boxInset +8);
|
fRemove->MoveTo(xPos,
|
||||||
|
boxInset + addButton->Bounds().Height() + boxInset + 8);
|
||||||
fRemove->ResizeTo(maxWidth, fRemove->Bounds().Height());
|
fRemove->ResizeTo(maxWidth, fRemove->Bounds().Height());
|
||||||
|
|
||||||
fMakeDefault->MoveTo(xPos, boxInset + addButton->Bounds().Height() +
|
fMakeDefault->MoveTo(xPos, boxInset + addButton->Bounds().Height() +
|
||||||
boxInset + fRemove->Bounds().Height() +
|
boxInset + fRemove->Bounds().Height() + boxInset + 8);
|
||||||
boxInset +8);
|
|
||||||
fMakeDefault->ResizeTo(maxWidth, fMakeDefault->Bounds().Height());
|
fMakeDefault->ResizeTo(maxWidth, fMakeDefault->Bounds().Height());
|
||||||
|
|
||||||
// Disable all selection-based buttons
|
// Disable all selection-based buttons
|
||||||
@@ -236,22 +218,24 @@ PrintersWindow::BuildGUI()
|
|||||||
fMakeDefault->SetEnabled(false);
|
fMakeDefault->SetEnabled(false);
|
||||||
|
|
||||||
// Create listview with scroller
|
// Create listview with scroller
|
||||||
BRect listBounds(boxInset, boxInset+8, fMakeDefault->Frame().left - boxInset - B_V_SCROLL_BAR_WIDTH,
|
BRect listBounds(boxInset, boxInset + 8,
|
||||||
printersBox->Bounds().Height()-boxInset-3);
|
fMakeDefault->Frame().left - boxInset - B_V_SCROLL_BAR_WIDTH,
|
||||||
|
printersBox->Bounds().Height()- boxInset - 3);
|
||||||
fPrinterListView = new PrinterListView(listBounds);
|
fPrinterListView = new PrinterListView(listBounds);
|
||||||
BScrollView* pscroller = new BScrollView("printer_scroller", fPrinterListView,
|
BScrollView* pscroller = new BScrollView("printer_scroller", fPrinterListView,
|
||||||
B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_FANCY_BORDER);
|
B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_FANCY_BORDER);
|
||||||
printersBox->AddChild(pscroller);
|
printersBox->AddChild(pscroller);
|
||||||
|
|
||||||
// ------------------------ Lastly, build the jobs overview box
|
// ------------------------ Lastly, build the jobs overview box
|
||||||
fJobsBox = new BBox(BRect(boxInset, (r.Height()/2)+(boxInset/2), Bounds().Width()-10, Bounds().Height() - boxInset),
|
fJobsBox = new BBox(BRect(boxInset, r.Height() / 2 + boxInset / 2,
|
||||||
"jobsBox", B_FOLLOW_LEFT_RIGHT+B_FOLLOW_BOTTOM);
|
Bounds().Width() - 10, Bounds().Height() - boxInset), "jobsBox",
|
||||||
|
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
|
||||||
fJobsBox->SetFont(be_bold_font);
|
fJobsBox->SetFont(be_bold_font);
|
||||||
fJobsBox->SetLabel(B_TRANSLATE("Print jobs: No printer selected"));
|
fJobsBox->SetLabel(B_TRANSLATE("Print jobs: No printer selected"));
|
||||||
backdrop->AddChild(fJobsBox);
|
backdrop->AddChild(fJobsBox);
|
||||||
|
|
||||||
// Cancel Job Button
|
// Cancel Job Button
|
||||||
BButton* cancelButton = new BButton(BRect(5,5,5,5), "cancel",
|
BButton* cancelButton = new BButton(BRect(5, 5, 5, 5), "cancel",
|
||||||
B_TRANSLATE("Cancel job"), new BMessage(kMsgCancelJob),
|
B_TRANSLATE("Cancel job"), new BMessage(kMsgCancelJob),
|
||||||
B_FOLLOW_RIGHT+B_FOLLOW_TOP);
|
B_FOLLOW_RIGHT+B_FOLLOW_TOP);
|
||||||
fJobsBox->AddChild(cancelButton);
|
fJobsBox->AddChild(cancelButton);
|
||||||
@@ -261,9 +245,9 @@ PrintersWindow::BuildGUI()
|
|||||||
maxWidth = cancelButton->Bounds().Width();
|
maxWidth = cancelButton->Bounds().Width();
|
||||||
|
|
||||||
// Restart Job button
|
// Restart Job button
|
||||||
BButton* restartButton = new BButton(BRect(5,30,5,30), "restart",
|
BButton* restartButton = new BButton(BRect(5, 30, 5, 30), "restart",
|
||||||
B_TRANSLATE("Restart job"), new BMessage(kMsgRestartJob),
|
B_TRANSLATE("Restart job"), new BMessage(kMsgRestartJob),
|
||||||
B_FOLLOW_RIGHT+B_FOLLOW_TOP);
|
B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
||||||
fJobsBox->AddChild(restartButton);
|
fJobsBox->AddChild(restartButton);
|
||||||
restartButton->ResizeToPreferred();
|
restartButton->ResizeToPreferred();
|
||||||
fRestart = restartButton;
|
fRestart = restartButton;
|
||||||
@@ -272,11 +256,12 @@ PrintersWindow::BuildGUI()
|
|||||||
maxWidth = restartButton->Bounds().Width();
|
maxWidth = restartButton->Bounds().Width();
|
||||||
|
|
||||||
// Resize all buttons to maximum width and align them to the right
|
// Resize all buttons to maximum width and align them to the right
|
||||||
xPos = fJobsBox->Bounds().Width()-boxInset-maxWidth;
|
xPos = fJobsBox->Bounds().Width() - boxInset - maxWidth;
|
||||||
cancelButton->MoveTo(xPos, boxInset +8);
|
cancelButton->MoveTo(xPos, boxInset + 8);
|
||||||
cancelButton->ResizeTo(maxWidth, cancelButton->Bounds().Height());
|
cancelButton->ResizeTo(maxWidth, cancelButton->Bounds().Height());
|
||||||
|
|
||||||
restartButton->MoveTo(xPos, boxInset + cancelButton->Bounds().Height() + boxInset +8);
|
restartButton->MoveTo(xPos, boxInset + cancelButton->Bounds().Height()
|
||||||
|
+ boxInset + 8);
|
||||||
restartButton->ResizeTo(maxWidth, restartButton->Bounds().Height());
|
restartButton->ResizeTo(maxWidth, restartButton->Bounds().Height());
|
||||||
|
|
||||||
// Disable all selection-based buttons
|
// Disable all selection-based buttons
|
||||||
@@ -284,17 +269,17 @@ PrintersWindow::BuildGUI()
|
|||||||
restartButton->SetEnabled(false);
|
restartButton->SetEnabled(false);
|
||||||
|
|
||||||
// Create listview with scroller
|
// Create listview with scroller
|
||||||
listBounds = BRect(boxInset, boxInset+8, cancelButton->Frame().left - boxInset - B_V_SCROLL_BAR_WIDTH,
|
listBounds = BRect(boxInset, boxInset + 8,
|
||||||
fJobsBox->Bounds().Height()-boxInset-3);
|
cancelButton->Frame().left - boxInset - B_V_SCROLL_BAR_WIDTH,
|
||||||
|
fJobsBox->Bounds().Height() - boxInset - 3);
|
||||||
fJobListView = new JobListView(listBounds);
|
fJobListView = new JobListView(listBounds);
|
||||||
BScrollView* jscroller = new BScrollView("jobs_scroller", fJobListView,
|
BScrollView* jscroller = new BScrollView("jobs_scroller", fJobListView,
|
||||||
B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_FANCY_BORDER);
|
B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_FANCY_BORDER);
|
||||||
fJobsBox->AddChild(jscroller);
|
fJobsBox->AddChild(jscroller);
|
||||||
|
|
||||||
// Determine min width
|
// Determine min width
|
||||||
float width;
|
float width = (jscroller->Bounds().Width() < pscroller->Bounds().Width())
|
||||||
width = (jscroller->Bounds().Width() < pscroller->Bounds().Width()) ?
|
? jscroller->Bounds().Width() : pscroller->Bounds().Width();
|
||||||
jscroller->Bounds().Width() : pscroller->Bounds().Width();
|
|
||||||
|
|
||||||
// Resize boxes to the same size
|
// Resize boxes to the same size
|
||||||
jscroller->ResizeTo(width, jscroller->Bounds().Height());
|
jscroller->ResizeTo(width, jscroller->Bounds().Height());
|
||||||
@@ -303,33 +288,35 @@ PrintersWindow::BuildGUI()
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PrintersWindow::IsSelected(PrinterItem* printer) {
|
PrintersWindow::IsSelected(PrinterItem* printer)
|
||||||
|
{
|
||||||
return fSelectedPrinter && fSelectedPrinter == printer;
|
return fSelectedPrinter && fSelectedPrinter == printer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintersWindow::AddJob(SpoolFolder* folder, Job* job) {
|
PrintersWindow::AddJob(SpoolFolder* folder, Job* job)
|
||||||
if (IsSelected(folder->Item())) {
|
{
|
||||||
|
if (IsSelected(folder->Item()))
|
||||||
fJobListView->AddJob(job);
|
fJobListView->AddJob(job);
|
||||||
}
|
|
||||||
fPrinterListView->UpdateItem(folder->Item());
|
fPrinterListView->UpdateItem(folder->Item());
|
||||||
UpdatePrinterButtons();
|
UpdatePrinterButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintersWindow::RemoveJob(SpoolFolder* folder, Job* job) {
|
PrintersWindow::RemoveJob(SpoolFolder* folder, Job* job)
|
||||||
if (IsSelected(folder->Item())) {
|
{
|
||||||
|
if (IsSelected(folder->Item()))
|
||||||
fJobListView->RemoveJob(job);
|
fJobListView->RemoveJob(job);
|
||||||
}
|
|
||||||
fPrinterListView->UpdateItem(folder->Item());
|
fPrinterListView->UpdateItem(folder->Item());
|
||||||
UpdatePrinterButtons();
|
UpdatePrinterButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintersWindow::UpdateJob(SpoolFolder* folder, Job* job) {
|
PrintersWindow::UpdateJob(SpoolFolder* folder, Job* job)
|
||||||
|
{
|
||||||
if (IsSelected(folder->Item())) {
|
if (IsSelected(folder->Item())) {
|
||||||
fJobListView->UpdateJob(job);
|
fJobListView->UpdateJob(job);
|
||||||
UpdateJobButtons();
|
UpdateJobButtons();
|
||||||
@@ -340,7 +327,8 @@ PrintersWindow::UpdateJob(SpoolFolder* folder, Job* job) {
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintersWindow::UpdatePrinterButtons() {
|
PrintersWindow::UpdatePrinterButtons()
|
||||||
|
{
|
||||||
PrinterItem* item = fPrinterListView->SelectedItem();
|
PrinterItem* item = fPrinterListView->SelectedItem();
|
||||||
fRemove->SetEnabled(item && !item->HasPendingJobs());
|
fRemove->SetEnabled(item && !item->HasPendingJobs());
|
||||||
fMakeDefault->SetEnabled(item && !item->IsActivePrinter());
|
fMakeDefault->SetEnabled(item && !item->IsActivePrinter());
|
||||||
@@ -348,7 +336,8 @@ PrintersWindow::UpdatePrinterButtons() {
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintersWindow::UpdateJobButtons() {
|
PrintersWindow::UpdateJobButtons()
|
||||||
|
{
|
||||||
JobItem* item = fJobListView->SelectedItem();
|
JobItem* item = fJobListView->SelectedItem();
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
Job* job = item->GetJob();
|
Job* job = item->GetJob();
|
||||||
|
|||||||
@@ -1,37 +1,18 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// Printers Preference Application.
|
* Copyright 2001-2010, Haiku.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// This application and all source files used in its construction, except
|
*
|
||||||
// where noted, are licensed under the MIT License, and have been written
|
* Authors:
|
||||||
// and are:
|
* Michael Pfeiffer
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2001-2007 Haiku Project
|
#ifndef _PRINTERS_WINDOW_H
|
||||||
//
|
#define _PRINTERS_WINDOW_H
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
/*****************************************************************************/
|
|
||||||
#ifndef PRINTERS_WINDOW_H
|
|
||||||
#define PRINTERS_WINDOW_H
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <Box.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
class BBox;
|
|
||||||
class PrintersWindow;
|
class PrintersWindow;
|
||||||
class PrinterListView;
|
class PrinterListView;
|
||||||
class JobListView;
|
class JobListView;
|
||||||
@@ -74,4 +55,4 @@ private:
|
|||||||
bool fAddingPrinter;
|
bool fAddingPrinter;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PRINTERS_WINDOW_H
|
#endif // _PRINTERS_WINDOW_H
|
||||||
|
|||||||
@@ -1,63 +1,43 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// Printers Preference Application.
|
* Copyright 2001-2010, Haiku.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// This application and all source files used in its construction, except
|
*
|
||||||
// where noted, are licensed under the MIT License, and have been written
|
* Authors:
|
||||||
// and are:
|
* Michael Pfeiffer
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2001-2003 OpenBeOS Project
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#include "SpoolFolder.h"
|
#include "SpoolFolder.h"
|
||||||
#include "JobListView.h"
|
|
||||||
#include "pr_server.h"
|
|
||||||
|
|
||||||
#include "Messages.h"
|
|
||||||
#include "Globals.h"
|
|
||||||
#include "Jobs.h"
|
#include "Jobs.h"
|
||||||
#include "PrintersWindow.h"
|
#include "PrintersWindow.h"
|
||||||
|
//#include "pr_server.h"
|
||||||
|
|
||||||
#include <Messenger.h>
|
|
||||||
#include <Bitmap.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <Alert.h>
|
|
||||||
#include <Mime.h>
|
|
||||||
#include <Roster.h>
|
|
||||||
|
|
||||||
SpoolFolder::SpoolFolder(PrintersWindow* window, PrinterItem* item, const BDirectory& spoolDir)
|
SpoolFolder::SpoolFolder(PrintersWindow* window, PrinterItem* item,
|
||||||
: Folder(NULL, window, spoolDir)
|
const BDirectory& spoolDir)
|
||||||
, fWindow(window)
|
:
|
||||||
, fItem(item)
|
Folder(NULL, window, spoolDir),
|
||||||
|
fWindow(window),
|
||||||
|
fItem(item)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpoolFolder::Notify(Job* job, int kind)
|
|
||||||
|
void
|
||||||
|
SpoolFolder::Notify(Job* job, int kind)
|
||||||
{
|
{
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case kJobAdded: fWindow->AddJob(this, job);
|
case kJobAdded:
|
||||||
|
fWindow->AddJob(this, job);
|
||||||
break;
|
break;
|
||||||
case kJobRemoved: fWindow->RemoveJob(this, job);
|
case kJobRemoved:
|
||||||
|
fWindow->RemoveJob(this, job);
|
||||||
break;
|
break;
|
||||||
case kJobAttrChanged: fWindow->UpdateJob(this, job);
|
case kJobAttrChanged:
|
||||||
|
fWindow->UpdateJob(this, job);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
default: ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,54 +1,34 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// Printers Preference Application.
|
* Copyright 2001-2010, Haiku.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// This application and all source files used in its construction, except
|
*
|
||||||
// where noted, are licensed under the MIT License, and have been written
|
* Authors:
|
||||||
// and are:
|
* Michael Pfeiffer
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2001-2003 OpenBeOS Project
|
#ifndef _SPOOL_FOLDER_H
|
||||||
//
|
#define _SPOOL_FOLDER_H
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef SPOOL_FOLDER_H
|
|
||||||
#define SPOOL_FODLER_H
|
|
||||||
|
|
||||||
#include <Messenger.h>
|
|
||||||
#include <ListView.h>
|
|
||||||
#include <String.h>
|
|
||||||
|
|
||||||
#include "Jobs.h"
|
#include "Jobs.h"
|
||||||
|
|
||||||
|
|
||||||
class PrintersWindow;
|
class PrintersWindow;
|
||||||
class PrinterItem;
|
class PrinterItem;
|
||||||
|
|
||||||
class SpoolFolder : public Folder {
|
|
||||||
protected:
|
|
||||||
void Notify(Job* job, int kind);
|
|
||||||
|
|
||||||
PrintersWindow* fWindow;
|
class SpoolFolder : public Folder {
|
||||||
PrinterItem* fItem;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpoolFolder(PrintersWindow* window, PrinterItem* item, const BDirectory& spoolDir);
|
SpoolFolder(PrintersWindow* window,
|
||||||
PrinterItem* Item() const { return fItem; }
|
PrinterItem* item,
|
||||||
|
const BDirectory& spoolDir);
|
||||||
|
PrinterItem* Item() const { return fItem; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Notify(Job* job, int kind);
|
||||||
|
|
||||||
|
PrintersWindow* fWindow;
|
||||||
|
PrinterItem* fItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif // _SPOOL_FOLDER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user