~kroq-gar78/ubuntu/precise/gnome-control-center/fix-885947

« back to all changes in this revision

Viewing changes to panels/printers/pp-utils.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette
  • Date: 2011-04-29 02:24:28 UTC
  • mfrom: (0.2.7 upstream)
  • mto: (0.3.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 165.
  • Revision ID: james.westby@ubuntu.com-20110429022428-ua1v4ck5shphkkku
Tags: 1:3.0.1.1-1
* New upstream release.
* gnome-control-center-data.install: drop GConf schemas.
* gnome-control-center-data.gconf-defaults: dropped, obsolete.

Show diffs side-by-side

added added

removed removed

Lines of Context:
359
359
}
360
360
 
361
361
gchar *
362
 
get_ppd_attribute (const gchar *printer_name, const gchar *attribute_name)
 
362
get_ppd_attribute (const gchar *ppd_file_name,
 
363
                   const gchar *attribute_name)
363
364
{
364
 
  const char *file_name = NULL;
365
365
  ppd_file_t *ppd_file = NULL;
366
366
  ppd_attr_t *ppd_attr = NULL;
367
367
  gchar *result = NULL;
368
368
 
369
 
  file_name = cupsGetPPD (printer_name);
370
 
 
371
 
  if (file_name)
 
369
  if (ppd_file_name)
372
370
    {
373
 
      ppd_file = ppdOpenFile (file_name);
 
371
      ppd_file = ppdOpenFile (ppd_file_name);
 
372
 
374
373
      if (ppd_file)
375
374
        {
376
375
          ppd_attr = ppdFindAttr (ppd_file, attribute_name, NULL);
378
377
            result = g_strdup (ppd_attr->value);
379
378
          ppdClose (ppd_file);
380
379
        }
381
 
      g_unlink (file_name);
382
380
    }
383
381
 
384
382
  return result;
480
478
 
481
479
  return result;
482
480
}
 
481
 
 
482
/*  Set default destination in ~/.cups/lpoptions.
 
483
 *  Unset default destination if "dest" is NULL.
 
484
 */
 
485
void
 
486
set_local_default_printer (gchar *printer_name)
 
487
{
 
488
  cups_dest_t *dests = NULL;
 
489
  int          num_dests = 0;
 
490
  int          i;
 
491
 
 
492
  num_dests = cupsGetDests (&dests);
 
493
 
 
494
  for (i = 0; i < num_dests; i ++)
 
495
    {
 
496
      if (printer_name && g_strcmp0 (dests[i].name, printer_name) == 0)
 
497
        dests[i].is_default = 1;
 
498
      else
 
499
        dests[i].is_default = 0;
 
500
    }
 
501
 
 
502
  cupsSetDests (num_dests, dests);
 
503
}