Fixed FolderListener interface,
broken since the no-functional :-) changing r36750 : the three hooks were renamed. Now added/removed print spoolers show up live again. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37838 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -70,7 +70,7 @@ PrinterListView::BuildPrinterList()
|
|||||||
BDirectory printer(&entry);
|
BDirectory printer(&entry);
|
||||||
_AddPrinter(printer, false);
|
_AddPrinter(printer, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
_LayoutPrinterItems();
|
_LayoutPrinterItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +151,40 @@ PrinterListView::SelectedItem() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FolderListener interface
|
||||||
|
|
||||||
|
void
|
||||||
|
PrinterListView::EntryCreated(node_ref* node, entry_ref* entry)
|
||||||
|
{
|
||||||
|
BDirectory printer(node);
|
||||||
|
_AddPrinter(printer, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PrinterListView::EntryRemoved(node_ref* node)
|
||||||
|
{
|
||||||
|
PrinterItem* item = _FindItem(node);
|
||||||
|
if (item) {
|
||||||
|
if (item == fActivePrinter)
|
||||||
|
fActivePrinter = NULL;
|
||||||
|
|
||||||
|
RemoveItem(item);
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PrinterListView::AttributeChanged(node_ref* node)
|
||||||
|
{
|
||||||
|
BDirectory printer(node);
|
||||||
|
_AddPrinter(printer, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// private methods
|
||||||
|
|
||||||
void
|
void
|
||||||
PrinterListView::_AddPrinter(BDirectory& printer, bool calculateLayout)
|
PrinterListView::_AddPrinter(BDirectory& printer, bool calculateLayout)
|
||||||
{
|
{
|
||||||
@@ -169,7 +203,7 @@ PrinterListView::_AddPrinter(BDirectory& printer, bool calculateLayout)
|
|||||||
if (info.GetType(buffer) == B_OK
|
if (info.GetType(buffer) == B_OK
|
||||||
&& strcmp(buffer, PSRV_PRINTER_FILETYPE) == 0) {
|
&& strcmp(buffer, PSRV_PRINTER_FILETYPE) == 0) {
|
||||||
// Yes, it is a printer definition node
|
// Yes, it is a printer definition node
|
||||||
AddItem(new PrinterItem(dynamic_cast<PrintersWindow*>(Window()),
|
AddItem(new PrinterItem(dynamic_cast<PrintersWindow*>(Window()),
|
||||||
printer, fLayoutData));
|
printer, fLayoutData));
|
||||||
if (calculateLayout)
|
if (calculateLayout)
|
||||||
_LayoutPrinterItems();
|
_LayoutPrinterItems();
|
||||||
@@ -183,20 +217,20 @@ PrinterListView::_LayoutPrinterItems()
|
|||||||
{
|
{
|
||||||
float& leftColumnMaximumWidth = fLayoutData.fLeftColumnMaximumWidth;
|
float& leftColumnMaximumWidth = fLayoutData.fLeftColumnMaximumWidth;
|
||||||
float& rightColumnMaximumWidth = fLayoutData.fRightColumnMaximumWidth;
|
float& rightColumnMaximumWidth = fLayoutData.fRightColumnMaximumWidth;
|
||||||
|
|
||||||
for (int32 i = 0; i < CountItems(); i ++) {
|
for (int32 i = 0; i < CountItems(); i ++) {
|
||||||
PrinterItem* item = dynamic_cast<PrinterItem*>(ItemAt(i));
|
PrinterItem* item = dynamic_cast<PrinterItem*>(ItemAt(i));
|
||||||
|
|
||||||
float leftColumnWidth = 0;
|
float leftColumnWidth = 0;
|
||||||
float rightColumnWidth = 0;
|
float rightColumnWidth = 0;
|
||||||
item->GetColumnWidth(this, leftColumnWidth, rightColumnWidth);
|
item->GetColumnWidth(this, leftColumnWidth, rightColumnWidth);
|
||||||
|
|
||||||
leftColumnMaximumWidth = MAX(leftColumnMaximumWidth,
|
leftColumnMaximumWidth = MAX(leftColumnMaximumWidth,
|
||||||
leftColumnWidth);
|
leftColumnWidth);
|
||||||
rightColumnMaximumWidth = MAX(rightColumnMaximumWidth,
|
rightColumnMaximumWidth = MAX(rightColumnMaximumWidth,
|
||||||
rightColumnWidth);
|
rightColumnWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,37 +248,6 @@ PrinterListView::_FindItem(node_ref* node) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PrinterListView::_EntryCreated(node_ref* node, entry_ref* entry)
|
|
||||||
{
|
|
||||||
BDirectory printer(node);
|
|
||||||
_AddPrinter(printer, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PrinterListView::_EntryRemoved(node_ref* node)
|
|
||||||
{
|
|
||||||
PrinterItem* item = _FindItem(node);
|
|
||||||
if (item) {
|
|
||||||
if (item == fActivePrinter)
|
|
||||||
fActivePrinter = NULL;
|
|
||||||
|
|
||||||
RemoveItem(item);
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PrinterListView::_AttributeChanged(node_ref* node)
|
|
||||||
{
|
|
||||||
BDirectory printer(node);
|
|
||||||
_AddPrinter(printer, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -- PrinterItem
|
// #pragma mark -- PrinterItem
|
||||||
|
|
||||||
@@ -325,10 +328,10 @@ PrinterItem::GetColumnWidth(BView* view, float& leftColumn, float& rightColumn)
|
|||||||
{
|
{
|
||||||
BFont font;
|
BFont font;
|
||||||
view->GetFont(&font);
|
view->GetFont(&font);
|
||||||
|
|
||||||
leftColumn = font.StringWidth(fName.String());
|
leftColumn = font.StringWidth(fName.String());
|
||||||
leftColumn = MAX(leftColumn, font.StringWidth(fDriverName.String()));
|
leftColumn = MAX(leftColumn, font.StringWidth(fDriverName.String()));
|
||||||
|
|
||||||
rightColumn = font.StringWidth(fPendingJobs.String());
|
rightColumn = font.StringWidth(fPendingJobs.String());
|
||||||
rightColumn = MAX(rightColumn, font.StringWidth(fTransport.String()));
|
rightColumn = MAX(rightColumn, font.StringWidth(fTransport.String()));
|
||||||
rightColumn = MAX(rightColumn, font.StringWidth(fComments.String()));
|
rightColumn = MAX(rightColumn, font.StringWidth(fComments.String()));
|
||||||
@@ -413,7 +416,7 @@ PrinterItem::DrawItem(BView *owner, BRect /*bounds*/, bool complete)
|
|||||||
} else {
|
} else {
|
||||||
width = fLayoutData.fRightColumnMaximumWidth;
|
width = fLayoutData.fRightColumnMaximumWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
BPoint pendingPt(bounds.right - width - 8.0, namePt.y);
|
BPoint pendingPt(bounds.right - width - 8.0, namePt.y);
|
||||||
BPoint transportPt(bounds.right - width - 8.0, driverPt.y);
|
BPoint transportPt(bounds.right - width - 8.0, driverPt.y);
|
||||||
BPoint commentPt(bounds.right - width - 8.0, defaultPt.y);
|
BPoint commentPt(bounds.right - width - 8.0, defaultPt.y);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
|
|
||||||
PrinterItem *ActivePrinter() const;
|
PrinterItem *ActivePrinter() const;
|
||||||
void SetActivePrinter(PrinterItem* item);
|
void SetActivePrinter(PrinterItem* item);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef BListView Inherited;
|
typedef BListView Inherited;
|
||||||
|
|
||||||
@@ -55,10 +55,10 @@ private:
|
|||||||
void _LayoutPrinterItems();
|
void _LayoutPrinterItems();
|
||||||
PrinterItem *_FindItem(node_ref* node) const;
|
PrinterItem *_FindItem(node_ref* node) const;
|
||||||
|
|
||||||
void _EntryCreated(node_ref *node,
|
void EntryCreated(node_ref *node,
|
||||||
entry_ref *entry);
|
entry_ref *entry);
|
||||||
void _EntryRemoved(node_ref *node);
|
void EntryRemoved(node_ref *node);
|
||||||
void _AttributeChanged(node_ref *node);
|
void AttributeChanged(node_ref *node);
|
||||||
|
|
||||||
FolderWatcher *fFolder;
|
FolderWatcher *fFolder;
|
||||||
PrinterItem *fActivePrinter;
|
PrinterItem *fActivePrinter;
|
||||||
@@ -73,9 +73,9 @@ public:
|
|||||||
PrinterListLayoutData& layoutData);
|
PrinterListLayoutData& layoutData);
|
||||||
~PrinterItem();
|
~PrinterItem();
|
||||||
|
|
||||||
void GetColumnWidth(BView* view, float& leftColumn,
|
void GetColumnWidth(BView* view, float& leftColumn,
|
||||||
float& rightColumn);
|
float& rightColumn);
|
||||||
|
|
||||||
void DrawItem(BView *owner, BRect bounds,
|
void DrawItem(BView *owner, BRect bounds,
|
||||||
bool complete);
|
bool complete);
|
||||||
void Update(BView *owner, const BFont *font);
|
void Update(BView *owner, const BFont *font);
|
||||||
|
|||||||
Reference in New Issue
Block a user