Changeset 12

Timestamp:
Nov 14, 2011, 3:30:15 PM (14 years ago)
Author:
Alex Taylor
Message:

Printer list is now split by manufacturer/model, and model names are more concise. Only 'Simplified' drivers are shown by default. ECUPS-HP and PSPRINT drivers now supported.

Location:
trunk/gui/printer/cupswiz
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/printer/cupswiz/cupswiz.VRP

    r11 r12  
    11VX-REXX OS/2 V2.14 Build B3
    22VRX: cupswiz.VRX
    3 MacroPath: VRM:G:\netlabs\svn\ecups\trunk\gui\printer\cupswiz
     3MacroPath: VRM:\cupswiz
    44EXEPath:
    55RunParameters: f:\cups
     
    77VRXWindow: __VREMainWindow,1,602,2554,5770,9106
    88VRXWindow: __VRESectionListWindow,1,662,11804,4529,3891
    9 VRXWindow: __VREToolsWindow,1,1674,9877,4989,1667
     9VRXWindow: __VREToolsWindow,1,1674,9877,49,1667
    1010VRXWindow: __VREWindListWindow,1,5215,11804,2650,3891
    1111UserFile: 1
     
    1414UserWindow: SW_CREATE,1
    1515UserWindow: SW_MODEL,1
     16
  • trunk/gui/printer/cupswiz/cupswiz.VRX

    r11 r12  
    412412            IF _queue == '' THEN _desc = '('_protocol')'
    413413            ELSE _desc = _queue '('_protocol')'
    414             devices.i = 'Detected network printer' _desc 'at' _host 
     414            devices.i = 'Detected network printer' _desc 'at' _host
    415415        END
    416416        ELSE IF _type <> 'direct' THEN ITERATE
     
    439439/*:VRX         GetCupsPrinters
    440440*/
    441 GetCupsPrinters: PROCEDURE EXPOSE globals.
     441GetCupsPrinters: PROCEDURE EXPOSE globals.
    442442
    443443    CALL VRSet 'DT_INFO', 'Caption', 'Getting list of supported printers.  Please wait...'
     
    452452    ADDRESS CMD '@' lpinfo_cmd listqueue
    453453    i = 0
     454
    454455    DO QUEUED()
    455456        PARSE PULL line
    456457        IF LEFT( line, 6 ) == 'drv://' THEN ITERATE
     458
    457459        PARSE VAR line _ppd '.ppd.gz ' _name
    458460        _ppd = _ppd'.ppd.gz'
     
    465467        END
    466468        IF _name <> '' THEN DO
     469
     470
    467471            i = i + 1
    468472            ppds.i   = _ppd
     
    477481    CALL DIRECTORY _od
    478482
    479     CALL VRSet    'LB_SELECT', 'Painting', 0
    480     CALL VRMethod 'LB_SELECT', 'AddString', '-- Other printer (requires PPD) --',, ''
    481     CALL VRMethod 'LB_SELECT', 'AddStringList', 'models.',, 'ppds.'
    482     CALL VRSet    'LB_SELECT', 'Selected', 1
    483     CALL VRSet    'LB_SELECT', 'Painting', 1
    484 
    485     CALL VRSet 'DT_INFO', 'Caption', 'Select your printer model.'
     483/* Now build the 'manufacturers' stem.
     484 * This stem takes the following format:
     485 *    manufacturers.0                         number of manufacturers
     486 *    manufacturers.i.!name                   manufacturer name (e.g. 'Apple')
     487 *    manufacturers.i.!printers.0             number of printer models
     488 *    manufacturers.i.!printers.j.!model      printer model name, short form (e.g. 'LaserWriter 330')
     489 *    manufacturers.i.!printers.j.!type       driver version/type (e.g. 'Gutenprint v5.2.7')
     490 *    manufacturers.i.!printers.j.!driver     the internal CUPS printer driver name (PPD or URI)
     491 *                                            - by preference this is the "simplified" version if available
     492 *    manufacturers.i.!printers.j.!remark     any distinguishing remarks (e.g. 'Simplified')
     493 *    manufacturers.i.!printers.j.!driver2    alternate driver in case there is more than one (PPD or URI)
     494 *                                            - if defined this is usually the non-"simplified" driver
     495 *    manufacturers.i.!printers.j.!remark2    any distinguishing remarks for the alternate driver
     496 */
     497
     498    manufacturers.0 = WORDS( makers )
     499    DO i = 1 TO manufacturers.0
     500        manufacturers.i.!name = WORD( makers, i )
     501        manufacturers.i.!printers.0 = 0
     502    END
     503
     504    DO i = 1 TO models.0
     505        PARSE VAR models.i _brand _model ' - CUPS+' _type
     506        man = WORDPOS( _brand, makers )
     507        IF man == 0 THEN ITERATE
     508
     509        PARSE VAR _type _version 'Simplified' .
     510        _version = STRIP( _version )
     511        _flag    = RIGHT( _type, 10 )
     512
     513        count = manufacturers.man.!printers.0
     514        IF count > 0 THEN DO
     515            /* If there are two or more printers defined with the same model
     516             * name and driver version, keep the first and last as the regular
     517             * and alternate drivers; if one if them is 'Simplified', make that
     518             * the regular driver by preference.
     519             */
     520            IF ( manufacturers.man.!printers.count.!model == _model ) & ,
     521               ( manufacturers.man.!printers.count.!type  == _version ) THEN
     522            DO
     523                IF ( WORD( _version, 1 ) == 'Gutenprint') & ( _flag == 'Simplified') THEN DO
     524                    manufacturers.man.!printers.count.!driver2 = manufacturers.man.!printers.count.!driver
     525                    manufacturers.man.!printers.count.!remark2 = manufacturers.man.!printers.count.!remark
     526                    manufacturers.man.!printers.count.!driver  = ppds.i
     527                    manufacturers.man.!printers.count.!remark  = 'Simplified'
     528                END
     529                ELSE DO
     530                    manufacturers.man.!printers.count.!driver2 = ppds.i
     531                    IF _flag == 'Simplified' THEN
     532                        manufacturers.man.!printers.count.!remark2 = 'Simplified'
     533                    ELSE
     534                        manufacturers.man.!printers.count.!remark2 = ''
     535                END
     536                ITERATE
     537            END
     538        END
     539        count = count + 1
     540        manufacturers.man.!printers.count.!model   = _model
     541        manufacturers.man.!printers.count.!type    = _version
     542        manufacturers.man.!printers.count.!driver  = ppds.i
     543        IF _flag == 'Simplified' THEN
     544            manufacturers.man.!printers.count.!remark = 'Simplified'
     545        ELSE
     546            manufacturers.man.!printers.count.!remark = ''
     547        manufacturers.man.!printers.count.!driver2 = ''
     548        manufacturers.man.!printers.count.!remark2 = ''
     549        manufacturers.man.!printers.0 = count
     550    END
     551
     552    /* Add one more category for special items ...
     553     */
     554    count = manufacturers.0 + 1
     555    manufacturers.count.!name = '-- Custom --'
     556    manufacturers.count.!printers.0 = 1
     557    manufacturers.count.!printers.1.!model   = '-- Other printer (requires PPD) --'
     558    manufacturers.count.!printers.1.!driver  = ''
     559    manufacturers.count.!printers.1.!type    = ''
     560    manufacturers.count.!printers.1.!remark  = '-- Other printer (requires PPD) --'
     561    manufacturers.count.!printers.1.!driver2 = ''
     562    manufacturers.count.!printers.1.!remark2 = ''
     563    manufacturers.0 = count
    486564
    487565RETURN
     
    835913RETURN
    836914
     915
     916
     917
     918
     919
     920
     921
     922
     923
     924
     925
     926
     927
     928
     929
     930
     931
     932
     933
     934
     935
     936
     937
     938
     939
     940
     941
     942
     943
     944
     945
     946
     947
     948
     949
     950
     951
     952
     953
     954
     955
     956
     957
     958
     959
     960
     961
     962
     963
     964
     965
     966
     967
     968
     969
     970
     971
     972
     973
     974
     975
     976
     977
     978
     979
     980
     981
     982
     983
     984
     985
     986
     987
     988
     989
     990
    837991/*:VRX         LoadSettings
    838992*/
     
    9041058RETURN lo_name
    9051059
     1060
     1061
     1062
     1063
     1064
     1065
    9061066/*:VRX         PB_CANCEL_Click
    9071067*/
     
    10141174/*:VRX         PB_NEXT_Click
    10151175*/
    1016 PB_NEXT_Click: PROCEDURE EXPOSE globals.
     1176PB_NEXT_Click: PROCEDURE EXPOSE globals.
    10171177
    10181178    SELECT
    10191179        WHEN globals.!page == 1 THEN DO
     1180
     1181
    10201182            selected = VRGet('LB_SELECT', 'Selected')
    10211183            IF selected == 0 THEN RETURN
    10221184
    1023             ppd = VRMethod('LB_SELECT', 'GetItemData', selected )
    1024             IF ppd == '' THEN DO
     1185            CALL VRSet 'WN_MAIN', 'StatusText', ''
     1186
     1187            which = VRMethod('LB_SELECT', 'GetItemData', selected )
     1188            IF which == '' THEN DO
    10251189                globals.!mode = 2   /* Mode 2: user-selected PPD file */
    10261190                ppd = VRFileDialog( VRWindow(), 'Select PPD', 'O', '*.ppd')
     
    10311195            END
    10321196            ELSE DO
     1197
     1198
     1199
     1200
     1201
     1202
    10331203                globals.!mode = 1   /* Mode 1: CUPS-included model */
    10341204                IF POS('exe://', ppd ) > 0 THEN DO
    10351205                    globals.!prt_ppd  = ''
    10361206                    globals.!prt_dev  = ppd
    1037                     sel_name = VRMethod('LB_SELECT', 'GetString', selected )
     1207                    sel_brand = VRGet('LB_BRAND', 'SelectedString')
     1208                    sel_name = sel_brand VRMethod('LB_SELECT', 'GetString', selected )
    10381209                    PARSE VAR sel_name _nick ' - CUPS' .
    10391210                    IF _nick == '' THEN
     
    10511222
    10521223            CALL InitMessageLog
    1053             IF globals.!mode ==2 THEN
     1224            IF globals.!mode ==2 THEN
    10541225                CALL LINEOUT globals.!log1, 'Starting printer install with user-provided PPD:'
    10551226            ELSE
     
    11331304RETURN
    11341305
     1306
     1307
     1308
     1309
     1310
     1311
    11351312/*:VRX         PromptForPMName
    11361313*/
     
    11661343/*:VRX         SetPage1
    11671344*/
    1168 SetPage1: PROCEDURE EXPOSE globals.
    1169 
    1170     CALL VRSet 'LB_SELECT',   'Visible', 1
    1171     CALL VRSet 'GB_INFO',     'Visible', 0
     1345SetPage1: PROCEDURE EXPOSE globals. manufacturers.
     1346
     1347    CALL VRSet 'LB_BRAND', 'Visible', 1
     1348
     1349    /* Resize LB_SELECT if necessary to make room for LB_BRAND */
     1350    lb_x = VRGet('LB_BRAND', 'Left') + VRGet('LB_BRAND', 'Width') + 60
     1351    lb_w = VRGet('GB_INFO', 'Width') - lb_x + VRGet('GB_INFO', 'Left')
     1352    CALL VRSet 'LB_SELECT', 'Left', lb_x
     1353    CALL VRSet 'LB_SELECT', 'Width', lb_w
     1354
     1355    CALL VRSet 'LB_SELECT', 'Visible', 1
     1356    CALL VRSet 'GB_INFO',   'Visible', 0
    11721357
    11731358    globals.!page = 1
    11741359    CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
    11751360    CALL GetCupsPrinters
     1361
     1362
     1363
     1364
     1365
     1366
     1367
     1368
     1369
     1370
     1371
     1372
     1373
     1374
    11761375    CALL VRMethod 'LB_SELECT', 'SetFocus'
    11771376    CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
     1377
    11781378RETURN
    11791379
     
    11831383
    11841384    globals.!page = 2
     1385
     1386
     1387
     1388
     1389
     1390
     1391
     1392
     1393
    11851394    CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
    11861395    CALL GetCupsPorts
     
    12231432
    12241433    globals.!page = 4
    1225     CALL VRSet 'LB_SELECT',   'Visible', 0
    1226     CALL VRSet 'GB_INFO',     'Visible', 0
    1227 
    1228 RETURN
     1434    CALL VRSet 'LB_SELECT', 'Visible',    0
     1435    CALL VRSet 'GB_INFO',   'Visible',    0
     1436    CALL VRSet 'WN_MAIN',   'StatusText', ''
     1437
     1438RETURN
     1439
     1440/*:VRX         SW_ABOUT_Close
     1441*/
     1442SW_ABOUT_Close:
     1443    call SW_ABOUT_Fini
     1444return
     1445
     1446/*:VRX         SW_ABOUT_Create
     1447*/
     1448SW_ABOUT_Create:
     1449    call SW_ABOUT_Init
     1450return
     1451
     1452/*:VRX         SW_ABOUT_Fini
     1453*/
     1454SW_ABOUT_Fini:
     1455    window = VRInfo( "Window" )
     1456    call VRDestroy window
     1457    drop window
     1458return
     1459/*:VRX         SW_ABOUT_Init
     1460*/
     1461SW_ABOUT_Init:
     1462
     1463    CALL VRSet 'DT_BOOTDRIVE',  'Caption', 'System boot volume:' TRANSLATE( globals.!bootdrv )
     1464    CALL VRSet 'DT_CUPSPATH',   'Caption', 'Local CUPS directory:' TRANSLATE( globals.!cupsdir )
     1465    CALL VRSet 'DT_REPOSITORY', 'Caption', 'Local driver repository:' TRANSLATE( globals.!repository )
     1466
     1467    window = VRInfo( "Object" )
     1468    if( \VRIsChildOf( window, "Notebook" ) ) then do
     1469        call VRMethod window, "CenterWindow"
     1470        call VRSet window, "Visible", 1
     1471        call VRMethod window, "Activate"
     1472    end
     1473    drop window
     1474return
    12291475
    12301476/*:VRX         SW_CREATE_Close
  • trunk/gui/printer/cupswiz/readme.1st

    r11 r12  
    11CUPSWIZ - prototype CUPS printer-creation wizard
    2 Test release x
     2Test release
    33
    44Make sure cupsport.exe is either in the current directory or in the PATH.
     
    2222Current limitations:
    2323 - The CUPS printer is always created with default job options.
    24  - The GUI is still somewhat unpolished.  All printer models are currently
    25    displayed in one massive list (not broken down by manufacturer yet).
    2624 - If your %TMP% directory has spaces in the pathname, the program will
    2725   almost certainly fail to work properly.  The same applies to your
  • trunk/gui/printer/cupswiz/todo

    r11 r12  
    11- Check to make sure CUPS.PDR is installed, and (offer to) install if missing.
    22- Ditto for gzip.exe, rinstprn.exe and cupsport.exe
    3 - Split first-page printer list into manufacturer-model lists.
    43- Use OS2.INI eCups::CUPS ||'\cups' for cups path if found.
    54- How to support total remote CUPS (i.e. no local CUPS install)?
     5
Note: See TracChangeset for help on using the changeset viewer.