diff -ruN epdfview-0.1.8/src/PrintPter.cxx epdfview-0.1.8-cupsgetdests/src/PrintPter.cxx
old
|
new
|
|
474 | 474 | return attributes; |
475 | 475 | } |
476 | 476 | |
| 477 | typedef struct |
| 478 | { |
| 479 | int num_dests; |
| 480 | cups_dest_t *dests; |
| 481 | } all_dests_t; |
| 482 | |
| 483 | int dest_cb(all_dests_t *user_data, unsigned flags, |
| 484 | cups_dest_t *dest) |
| 485 | { |
| 486 | if (flags & CUPS_DEST_FLAGS_REMOVED) { |
| 487 | /* * Remove destination from array... */ |
| 488 | user_data->num_dests = |
| 489 | cupsRemoveDest(dest->name, dest->instance, |
| 490 | user_data->num_dests, |
| 491 | &(user_data->dests)); |
| 492 | } else { |
| 493 | /* |
| 494 | * Add destination to array... |
| 495 | */ |
| 496 | |
| 497 | user_data->num_dests = |
| 498 | cupsCopyDest(dest, user_data->num_dests, |
| 499 | &(user_data->dests)); |
| 500 | } |
| 501 | |
| 502 | return (1); |
| 503 | } |
| 504 | |
| 505 | |
477 | 506 | void |
478 | 507 | PrintPter::listPrinters (void) |
479 | 508 | { |
480 | 509 | IPrintView &view = getView (); |
481 | 510 | |
482 | 511 | cups_dest_t *destinations; |
483 | | int numDestinations = cupsGetDests (&destinations); |
| 512 | int numDestinations; |
| 513 | all_dests_t user_data = { 0, NULL }; |
| 514 | if (!cupsEnumDests(CUPS_DEST_FLAGS_NONE, 1000, NULL, CUPS_PRINTER_LOCAL, CUPS_PRINTER_DISCOVERED, (cups_dest_cb_t)dest_cb, &user_data)) { |
| 515 | cupsFreeDests(user_data.num_dests, user_data.dests); |
| 516 | fprintf(stderr,"cupsEnumDests: Error\n"); |
| 517 | numDestinations = 0; |
| 518 | destinations = NULL; |
| 519 | } else { |
| 520 | numDestinations = user_data.num_dests; |
| 521 | destinations = user_data.dests; |
| 522 | } |
| 523 | fprintf(stderr,"No printers: %d\n",numDestinations); |
484 | 524 | // For now we don't have any printer selected. |
485 | 525 | int printerToSelect = -1; |
486 | 526 | |