Show
Ignore:
Timestamp:
06/11/06 09:47:12 (2 years ago)
Author:
jordi
Message:

The Print Dialog now selects a printer (default printer or the first, if there's no default.) Also, when there's no printers available the Print button is insensitived.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/PrintPter.cxx

    r219 r220  
    192192PrintPter::listPrinters (void) 
    193193{ 
     194    IPrintView &view = getView (); 
     195 
    194196    cups_dest_t *destinations; 
    195197    int numDestinations = cupsGetDests (&destinations); 
     198    // For now we don't have any printer selected. 
     199    int printerToSelect = -1; 
    196200 
    197201    for ( int currentDestination = 0 ; currentDestination < numDestinations ; 
     
    207211        printerAttributes *attributes = getPrinterAttributes (printerName); 
    208212        // Set all this data to the view. 
    209         getView ().addPrinter (printerName, numJobs, 
     213        view.addPrinter (printerName, numJobs, 
    210214                               attributes->state, attributes->location); 
    211215        g_free (attributes->location); 
    212216        g_free (attributes->state); 
    213217        delete attributes; 
    214     } 
    215  
     218 
     219        // If the printer is the default and we don't have any printer 
     220        // selected, then we should select it. 
     221        if ( -1 == printerToSelect && 
     222             destinations[currentDestination].is_default ) 
     223        { 
     224            printerToSelect = currentDestination; 
     225        } 
     226    } 
    216227    cupsFreeDests (numDestinations, destinations); 
    217 } 
     228 
     229    // If not printer is available, insensitive the print button. 
     230    if ( 0 == numDestinations ) 
     231    { 
     232        view.sensitivePrintButton (FALSE); 
     233    } 
     234    // Otherwise select a printer: the previously used, the default or  
     235    // the first. 
     236    else 
     237    { 
     238        if ( -1 == printerToSelect ) 
     239        { 
     240            view.selectPrinter (0); 
     241        } 
     242        else 
     243        { 
     244            view.selectPrinter (printerToSelect); 
     245        } 
     246    } 
     247}