How to read the values from UI control

Michael R Sweet msweet at apple.com
Wed Jul 16 09:56:50 PDT 2008


keens312 wrote:
> Hi Michael,
> 
> In my Drv, wrote like this:
> 
> // Setup tab
> Group InstallableOptions
>     Option "DuplexMode/Duplex Mode" PickOne AnySetup 10
>     *Choice "AutoDuplex/Auto Duplex" ""
>     Choise "ManualDuplex/Manual Duplex" ""
> 
> The code above can add a combobox control to select duplex mode.
> 
> The question is in filter, how can i read the value of DuplexMode?
> 
> I have tried cupsGetOption("DuplexMode", _numOptions, _options), but does not work.

For installable options, load the PPD, mark the defaults, and look up
the marked choice.  The usual method in a filter is:

     int
     main(int argc, char *argv[])
     {
       int num_options;
       cups_options_t *options;
       ppd_file_t *ppd;
       ppd_choice_t *choice;


      /*
       * Load the PPD and options and mark them on the PPD structure.
       */

       num_options = cupsParseOptions(argv[5], 0, &options);
       ppd         = ppdOpenFile(getenv("PPD"));

       ppdMarkDefaults(ppd);
       cupsMarkOptions(ppd, num_options, options);

      /*
       * Get the DuplexMode installable option selection...
       */

       choice = ppdFindChoice(ppd, "DuplexMode");
       if (choice && !strcmp(choice->choice, "AutoDuplex"))
       {
        /*
         * Do AutoDuplex stuff...
         */
       }

       ...
     }

.....

Also, as a comment - the word "Duplex" is not recommended as UI
text on Mac OS X.  Use "2-sided printing", "automatic", and "manual"
since most users do not know what "duplex" means.

-- 
______________________________________________________________________
Michael R Sweet                        Senior Printing System Engineer





More information about the cups mailing list