[haiku-commits] r37838 - haiku/trunk/src/preferences/print

  • From: philippe.houdoin@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 2 Aug 2010 13:26:48 +0200 (CEST)

Author: phoudoin
Date: 2010-08-02 13:26:47 +0200 (Mon, 02 Aug 2010)
New Revision: 37838
Changeset: http://dev.haiku-os.org/changeset/37838

Modified:
   haiku/trunk/src/preferences/print/PrinterListView.cpp
   haiku/trunk/src/preferences/print/PrinterListView.h
Log:
Fixed FolderListener interface,
broken since the no-functional :-) changing r36750 : the three hooks were
renamed.
Now added/removed print spoolers show up live again.


Modified: haiku/trunk/src/preferences/print/PrinterListView.cpp
===================================================================
--- haiku/trunk/src/preferences/print/PrinterListView.cpp       2010-08-02 
11:10:51 UTC (rev 37837)
+++ haiku/trunk/src/preferences/print/PrinterListView.cpp       2010-08-02 
11:26:47 UTC (rev 37838)
@@ -70,7 +70,7 @@
                BDirectory printer(&entry);
                _AddPrinter(printer, false);
        }
-       
+
        _LayoutPrinterItems();
 }
 
@@ -151,7 +151,41 @@
 }
 
 
+// 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
 PrinterListView::_AddPrinter(BDirectory& printer, bool calculateLayout)
 {
        BString state;
@@ -169,7 +203,7 @@
                if (info.GetType(buffer) == B_OK
                        && strcmp(buffer, PSRV_PRINTER_FILETYPE) == 0) {
                                // Yes, it is a printer definition node
-                       AddItem(new 
PrinterItem(dynamic_cast<PrintersWindow*>(Window()), 
+                       AddItem(new 
PrinterItem(dynamic_cast<PrintersWindow*>(Window()),
                                printer, fLayoutData));
                        if (calculateLayout)
                                _LayoutPrinterItems();
@@ -183,20 +217,20 @@
 {
        float& leftColumnMaximumWidth = fLayoutData.fLeftColumnMaximumWidth;
        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));
 
                float leftColumnWidth = 0;
                float rightColumnWidth = 0;
                item->GetColumnWidth(this, leftColumnWidth, rightColumnWidth);
-               
-               leftColumnMaximumWidth = MAX(leftColumnMaximumWidth, 
+
+               leftColumnMaximumWidth = MAX(leftColumnMaximumWidth,
                        leftColumnWidth);
-               rightColumnMaximumWidth = MAX(rightColumnMaximumWidth, 
+               rightColumnMaximumWidth = MAX(rightColumnMaximumWidth,
                        rightColumnWidth);
        }
-       
+
        Invalidate();
 }
 
@@ -214,38 +248,7 @@
 }
 
 
-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
 
 
@@ -325,10 +328,10 @@
 {
        BFont font;
        view->GetFont(&font);
-       
+
        leftColumn = font.StringWidth(fName.String());
        leftColumn = MAX(leftColumn, font.StringWidth(fDriverName.String()));
-       
+
        rightColumn = font.StringWidth(fPendingJobs.String());
        rightColumn = MAX(rightColumn, font.StringWidth(fTransport.String()));
        rightColumn = MAX(rightColumn, font.StringWidth(fComments.String()));
@@ -413,7 +416,7 @@
        } else {
                width = fLayoutData.fRightColumnMaximumWidth;
        }
-               
+
        BPoint pendingPt(bounds.right - width - 8.0, namePt.y);
        BPoint transportPt(bounds.right - width - 8.0, driverPt.y);
        BPoint commentPt(bounds.right - width - 8.0, defaultPt.y);

Modified: haiku/trunk/src/preferences/print/PrinterListView.h
===================================================================
--- haiku/trunk/src/preferences/print/PrinterListView.h 2010-08-02 11:10:51 UTC 
(rev 37837)
+++ haiku/trunk/src/preferences/print/PrinterListView.h 2010-08-02 11:26:47 UTC 
(rev 37838)
@@ -47,7 +47,7 @@
 
                        PrinterItem             *ActivePrinter() const;
                        void                            
SetActivePrinter(PrinterItem* item);
-                       
+
 private:
                typedef BListView Inherited;
 
@@ -55,10 +55,10 @@
                        void                            _LayoutPrinterItems();
                        PrinterItem                     *_FindItem(node_ref* 
node) const;
 
-                       void                            _EntryCreated(node_ref 
*node,
+                       void                            EntryCreated(node_ref 
*node,
                                                                        
entry_ref *entry);
-                       void                            _EntryRemoved(node_ref 
*node);
-                       void                            
_AttributeChanged(node_ref *node);
+                       void                            EntryRemoved(node_ref 
*node);
+                       void                            
AttributeChanged(node_ref *node);
 
                        FolderWatcher           *fFolder;
                        PrinterItem             *fActivePrinter;
@@ -73,9 +73,9 @@
                                                                        
PrinterListLayoutData& layoutData);
                                                                ~PrinterItem();
 
-                       void                            GetColumnWidth(BView* 
view, float& leftColumn, 
+                       void                            GetColumnWidth(BView* 
view, float& leftColumn,
                                                                        float& 
rightColumn);
-       
+
                        void                            DrawItem(BView *owner, 
BRect bounds,
                                                                        bool 
complete);
                        void                            Update(BView *owner, 
const BFont *font);


Other related posts:

  • » [haiku-commits] r37838 - haiku/trunk/src/preferences/print - philippe . houdoin