Show
Ignore:
Timestamp:
06/11/06 11:05:39 (2 years ago)
Author:
jordi
Message:

When a printer is selected, the presenter clears the page sizes and fills it with the available printer's page size.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/PrintPter.cxx

    r220 r221  
    1919#include <cups/cups.h> 
    2020#include <cups/ipp.h> 
     21#include <cups/ppd.h> 
    2122#include <locale.h> 
    2223#include "epdfview.h" 
     
    99100 
    100101void 
    101 PrintPter::printActivated (void) 
    102 { 
    103     // Once done, is the same as canceled :-) 
     102PrintPter::printActivated () 
     103{ 
     104    // Once done, it's the same as canceled :-) 
    104105    cancelActivated (); 
     106} 
     107 
     108void 
     109PrintPter::printerSelectionChanged () 
     110{ 
     111    IPrintView &view = getView (); 
     112 
     113    gchar *printerName = view.getSelectedPrinterName (); 
     114    if ( NULL != printerName ) 
     115    { 
     116        const gchar *printerPPDName = cupsGetPPD (printerName); 
     117        if ( NULL != printerPPDName ) 
     118        { 
     119            ppd_file_t *printerPPD = ppdOpenFile (printerPPDName); 
     120            if ( NULL != printerPPD ) 
     121            { 
     122                view.clearPageSizeList (); 
     123                int pageSizeToSelect = 1; 
     124                for ( int currentSize = 0 ; 
     125                      currentSize < printerPPD->num_sizes ; 
     126                      ++currentSize ) 
     127                { 
     128                    const gchar *sizeName = printerPPD->sizes[currentSize].name; 
     129                    view.addPageSize (_(sizeName), sizeName); 
     130                } 
     131                view.selectPageSize (pageSizeToSelect); 
     132                ppdClose (printerPPD); 
     133            } 
     134        } 
     135        g_free (printerName); 
     136    } 
    105137} 
    106138 
     
    244276            view.selectPrinter (printerToSelect); 
    245277        } 
    246     } 
    247 } 
     278        // The selection has been changed before the 
     279        // view could connect the signals, so here we'll set the selected 
     280        // printer's page sizes "by hand". 
     281        printerSelectionChanged (); 
     282    } 
     283}