Changeset 228

Show
Ignore:
Timestamp:
06/12/06 17:10:08 (2 years ago)
Author:
jordi
Message:

The PrintPter? now gets and sets the default page size when a printer is selected.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/PrintPter.cxx

    r222 r228  
    163163 
    164164    gchar *printerName = view.getSelectedPrinterName (); 
     165 
    165166    if ( NULL != printerName ) 
    166167    { 
     168        cups_dest_t *destinations; 
     169        guint numDestinations = cupsGetDests (&destinations); 
     170        if ( NULL == destinations ) 
     171        { 
     172            g_free (printerName); 
     173            return; 
     174        } 
     175        cups_dest_t *destination = cupsGetDest (printerName, NULL, 
     176                                                numDestinations, destinations); 
     177        if ( NULL == destinations ) 
     178        { 
     179            g_free (printerName); 
     180            cupsFreeDests (numDestinations, destinations); 
     181            return; 
     182        } 
     183 
    167184        const gchar *printerPPDName = cupsGetPPD (printerName); 
    168185        if ( NULL != printerPPDName ) 
     
    171188            if ( NULL != printerPPD ) 
    172189            { 
     190                ppdMarkDefaults (printerPPD); 
     191                cupsMarkOptions (printerPPD, destination->num_options, 
     192                                 destination->options); 
     193 
     194                // Get the default page size. 
     195                ppd_option_t *pageSizeOption = ppdFindOption (printerPPD, 
     196                                                             "PageSize"); 
     197                gchar *defaultPageSize = NULL; 
     198                if ( NULL != pageSizeOption ) 
     199                { 
     200                    defaultPageSize = pageSizeOption->defchoice; 
     201                } 
     202 
    173203                view.clearPageSizeList (); 
    174                 int pageSizeToSelect = 1; 
     204                int pageSizeToSelect = 0; 
    175205                for ( int currentSize = 0 ; 
    176206                      currentSize < printerPPD->num_sizes ; 
     
    179209                    const gchar *sizeName = printerPPD->sizes[currentSize].name; 
    180210                    view.addPageSize (_(sizeName), sizeName); 
     211                    if ( NULL != defaultPageSize && 
     212                         0 == g_ascii_strcasecmp (defaultPageSize, sizeName) ) 
     213                    { 
     214                        pageSizeToSelect = currentSize; 
     215                    } 
    181216                } 
    182217                view.selectPageSize (pageSizeToSelect); 
     
    184219            } 
    185220        } 
     221        cupsFreeDests (numDestinations, destinations); 
    186222        g_free (printerName); 
    187223    }