Changeset 243

Show
Ignore:
Timestamp:
06/18/06 09:31:40 (2 years ago)
Author:
jordi
Message:

Printer names now include also the instance name separated by an slash and the options are correct for each instance.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/PrintPter.cxx

    r239 r243  
    105105    IPrintView &view = getView (); 
    106106    // Get the printer's name. 
    107     char *printerName = view.getSelectedPrinterName (); 
    108     if ( NULL != printerName ) 
    109     { 
     107    char *printerAndInstanceNames = view.getSelectedPrinterName (); 
     108    if ( NULL != printerAndInstanceNames ) 
     109    { 
     110        gchar *slashPosition = g_strrstr (printerAndInstanceNames, "/"); 
     111        *slashPosition = '\0'; 
     112        gchar *printerName = g_strdup (printerAndInstanceNames); 
     113        *slashPosition = '/'; 
     114  
    110115        float pageWidth; 
    111116        float pageHeight; 
     
    158163        IJob::enqueue (job); 
    159164 
     165        g_free (printerAndInstanceNames); 
    160166        g_free (printerName); 
    161167    } 
     
    169175    IPrintView &view = getView (); 
    170176 
    171     gchar *printerName = view.getSelectedPrinterName (); 
    172  
    173     if ( NULL != printerName ) 
     177    gchar *printerAndInstanceNames = view.getSelectedPrinterName (); 
     178 
     179    if ( NULL != printerAndInstanceNames ) 
    174180    { 
    175181        cups_dest_t *destinations; 
     
    177183        if ( NULL == destinations ) 
    178184        { 
    179             g_free (printerName); 
     185            g_free (printerAndInstanceNames); 
    180186            return; 
    181187        } 
    182         cups_dest_t *destination = cupsGetDest (printerName, NULL, 
     188        gchar *slashPosition = g_strrstr (printerAndInstanceNames, "/"); 
     189        gchar *printerName = NULL; 
     190        gchar *instanceName = NULL; 
     191        if ( slashPosition != NULL ) 
     192        { 
     193            *slashPosition = '\0'; 
     194            printerName = g_strdup (printerAndInstanceNames); 
     195            instanceName = g_strdup (slashPosition + 1); 
     196            *slashPosition = '/'; 
     197        } 
     198        else 
     199        { 
     200            printerName = g_strdup (printerAndInstanceNames); 
     201        } 
     202        cups_dest_t *destination = cupsGetDest (printerName, instanceName, 
    183203                                                numDestinations, destinations); 
    184204        if ( NULL == destinations ) 
     
    273293        cupsFreeDests (numDestinations, destinations); 
    274294        g_free (printerName); 
     295        g_free (instanceName); 
     296        g_free (printerAndInstanceNames); 
    275297    } 
    276298} 
     
    411433          ++currentDestination ) 
    412434    { 
    413         // Get the printer name. 
     435        // Get the printer name and the local instance, if it has any. 
    414436        gchar *printerName = destinations[currentDestination].name; 
     437        gchar *printerAndInstanceNames = NULL; 
     438        if ( NULL != destinations[currentDestination].instance ) 
     439        { 
     440            printerAndInstanceNames = g_strdup_printf ("%s/%s", 
     441                    destinations[currentDestination].name, 
     442                    destinations[currentDestination].instance ); 
     443        } 
     444        else 
     445        { 
     446            printerAndInstanceNames = 
     447                g_strdup (destinations[currentDestination].name); 
     448        } 
    415449        // Get the number of jobs the printer currently has. 
    416450        cups_job_t *destinationJobs; 
     
    420454        printerAttributes *attributes = getPrinterAttributes (printerName); 
    421455        // Set all this data to the view. 
    422         view.addPrinter (printerName, numJobs, 
     456        view.addPrinter (printerAndInstanceNames, numJobs, 
    423457                               attributes->state, attributes->location); 
     458        g_free (printerAndInstanceNames); 
    424459        g_free (attributes->location); 
    425460        g_free (attributes->state);