~ubuntu-branches/ubuntu/precise/gnome-control-center/precise-updates

« back to all changes in this revision

Viewing changes to panels/printers/pp-new-printer-dialog.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher, Jeremy Bicha, Ken VanDine
  • Date: 2012-02-15 23:16:31 UTC
  • mfrom: (1.1.56)
  • Revision ID: package-import@ubuntu.com-20120215231631-vk7me0mhofpsq0hp
Tags: 1:3.3.5-0ubuntu1
* Upload the new serie, that will bring in quite some fixes, we revert
  some problematic or risky changes as well
* The new version includes those fixes:
  - "Change Password in User Accounts panel focuses "New password" field, 
     skipping "Current password"" (lp: #821759)
  - The dialog to add online accounts should have a title 
    (lp: #822380)
  - "Remove Profile" button clickable in Color panel when 
     no profile selected (lp: #869603)
  - Move Removable Media into System Info (lp: #835880)
  - Sound preferences: mouse scrolling balance only works for right.
    (lp: #918017)
  - gnome-control-center SIGSEGV in actualize_printers_list() 
    (lp: #903009)
  - selecting preffered applications is not an info (lp: #890143)
  - Add a keyboard shortcut by default for take screenshot of a selection"
    (lp: #625518)
* debian/patches/revert_git_datetime_port.patch:
  - revert use of datetimed, we don't use systemd and ubuntu-system-service 
    doesn't support it yet
* debian/patches/revert_git_drop_library.patch:
  - consolidate "01_allow_external_panels.patch", don't drop the library
    we use it from other components on ubuntu, the patch will be improved
    later to not use a copy of files like it does in that version
* debian/patches/revert_git_stop_using_gconf.patch,
  debian/patches/revert_ua_gsettings.patch,
  debian/patches/revert_git_keyboard_gsettings.patch:
  - revert keyboard porting to gsettings, compiz still use gconf and we
    didn't update gnome-shell to the new serie (yet)

[ Jeremy Bicha ]
* New upstream release (Thanks Rico Tzchichholz!)
* debian/control.in:
  - Bump minimum dependency versions and add libwacom dependency
* debian/rules: Build without -Wl,-z,defs
* debian/watch: Watch for unstable releases
* Refreshed patches:
  - 01_allow_external_panels.patch
  - 04_add_theme_selection.patch
  - 50_ubuntu_systemwide_prefs.patch
  - 58_ubuntu_icon_views_redesign.patch
  - 59_install_gcm_components_on_demand.patch
  - 91_configure_cheese.patch
* Dropped upstream patches:
  - 00git_handle_media_dialog_close.patch
  - 03_show_wacom_under_unity.patch
  - 90_git_sound_tab_order.patch
  - 91_git_build_use_fontconfig.patch
  - 92_git_minimal_output_height.patch
  - 93_change_window_role_on_panel_change.patch
  - 94_git_adding_shortcuts.patch
  - 95_git_ctrlw_shortcut.patch
  - git_extra_keywords.patch

[ Ken VanDine ]
* debian/patches/96_sound_nua_panel.patch
  - refreshed with latest changes from ronoc

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
 
132
132
  gchar    *warning;
133
133
  gboolean  show_warning;
 
134
  gboolean  searching;
134
135
};
135
136
 
136
137
static void
337
338
                                        res,
338
339
                                        &error);
339
340
 
340
 
  if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
341
 
    {
342
 
      if (dg_output && g_variant_n_children (dg_output) == 2)
 
341
  /* Do nothing if cancelled */
 
342
  if (!dg_output && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
 
343
    {
 
344
      g_error_free (error);
 
345
      return;
 
346
    }
 
347
 
 
348
  if (dg_output)
 
349
    {
 
350
      if (g_variant_n_children (dg_output) == 2)
343
351
        {
344
352
          GVariant *devices_variant = NULL;
345
353
 
371
379
                }
372
380
              g_variant_unref (devices_variant);
373
381
            }
374
 
          g_variant_unref (dg_output);
375
 
        }
376
 
      g_object_unref (source_object);
377
 
 
378
 
      if (error || (ret_error && ret_error[0] != '\0'))
379
 
        {
 
382
        }
 
383
      g_variant_unref (dg_output);
 
384
    }
 
385
  else
 
386
    {
 
387
      g_warning ("%s", error->message);
 
388
      g_error_free (error);
 
389
    }
 
390
 
 
391
  g_object_unref (source_object);
 
392
 
 
393
  if (ret_error && ret_error[0] != '\0')
 
394
    g_warning ("%s", ret_error);
 
395
 
 
396
  free_devices (pp);
 
397
  if (devices)
 
398
    {
 
399
      GList *keys;
 
400
      GList *iter;
 
401
      gchar *cut;
 
402
      gint   max_index = -1;
 
403
      gint   index;
 
404
 
 
405
      keys = g_hash_table_get_keys (devices);
 
406
      for (iter = keys; iter; iter = iter->next)
 
407
        {
 
408
          index = -1;
 
409
 
 
410
          cut = g_strrstr ((gchar *)iter->data, ":");
 
411
          if (cut)
 
412
            index = atoi (cut + 1);
 
413
 
 
414
          if (index > max_index)
 
415
            max_index = index;
 
416
        }
 
417
 
 
418
      if (max_index >= 0)
 
419
        {
 
420
          pp->num_devices = max_index + 1;
 
421
          pp->devices = g_new0 (CupsDevice, pp->num_devices);
 
422
 
 
423
          g_hash_table_foreach (devices, store_device_parameter, pp);
 
424
 
 
425
          /* Assign names to devices */
 
426
          for (i = 0; i < pp->num_devices; i++)
 
427
            {
 
428
              gchar *name = NULL;
 
429
 
 
430
              if (pp->devices[i].device_id)
 
431
                {
 
432
                  name = get_tag_value (pp->devices[i].device_id, "mdl");
 
433
                  if (!name)
 
434
                    name = get_tag_value (pp->devices[i].device_id, "model");
 
435
 
 
436
                  if (name)
 
437
                    name = g_strcanon (name, ALLOWED_CHARACTERS, '-');
 
438
                }
 
439
 
 
440
              if (!name &&
 
441
                  pp->devices[i].device_info)
 
442
                {
 
443
                  name = g_strdup (pp->devices[i].device_info);
 
444
                  if (name)
 
445
                    name = g_strcanon (name, ALLOWED_CHARACTERS, '-');
 
446
                }
 
447
 
 
448
              name_index = 2;
 
449
              already_present = FALSE;
 
450
              num_dests = cupsGetDests (&dests);
 
451
              do
 
452
                {
 
453
                  if (already_present)
 
454
                    {
 
455
                      new_name = g_strdup_printf ("%s-%d", name, name_index);
 
456
                      name_index++;
 
457
                    }
 
458
                  else
 
459
                    new_name = g_strdup (name);
 
460
 
 
461
                  already_present = FALSE;
 
462
                  for (j = 0; j < num_dests; j++)
 
463
                    if (g_strcmp0 (dests[j].name, new_name) == 0)
 
464
                      already_present = TRUE;
 
465
 
 
466
                  if (already_present)
 
467
                    g_free (new_name);
 
468
                  else
 
469
                    {
 
470
                      g_free (name);
 
471
                      name = new_name;
 
472
                    }
 
473
                } while (already_present);
 
474
              cupsFreeDests (num_dests, dests);
 
475
 
 
476
              pp->devices[i].display_name = name;
 
477
            }
 
478
 
 
479
          /* Set show bool
 
480
           * Don't show duplicates.
 
481
           * Show devices with device-id.
 
482
           * Other preferences should apply here.
 
483
           */
 
484
          proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
 
485
                                                 G_DBUS_PROXY_FLAGS_NONE,
 
486
                                                 NULL,
 
487
                                                 SCP_BUS,
 
488
                                                 SCP_PATH,
 
489
                                                 SCP_IFACE,
 
490
                                                 NULL,
 
491
                                                 &error);
 
492
 
 
493
          if (proxy)
 
494
            {
 
495
              GVariantBuilder  device_list;
 
496
              GVariantBuilder  device_hash;
 
497
              GVariant        *input = NULL;
 
498
              GVariant        *output = NULL;
 
499
              GVariant        *array = NULL;
 
500
              GVariant        *subarray = NULL;
 
501
 
 
502
              g_variant_builder_init (&device_list, G_VARIANT_TYPE ("a{sv}"));
 
503
 
 
504
              for (i = 0; i < pp->num_devices; i++)
 
505
                {
 
506
                  if (pp->devices[i].device_uri)
 
507
                    {
 
508
                      g_variant_builder_init (&device_hash, G_VARIANT_TYPE ("a{ss}"));
 
509
 
 
510
                      if (pp->devices[i].device_id)
 
511
                        g_variant_builder_add (&device_hash,
 
512
                                               "{ss}",
 
513
                                               "device-id",
 
514
                                               pp->devices[i].device_id);
 
515
 
 
516
                      if (pp->devices[i].device_make_and_model)
 
517
                        g_variant_builder_add (&device_hash,
 
518
                                               "{ss}",
 
519
                                               "device-make-and-model",
 
520
                                               pp->devices[i].device_make_and_model);
 
521
 
 
522
                      if (pp->devices[i].device_class)
 
523
                        g_variant_builder_add (&device_hash,
 
524
                                               "{ss}",
 
525
                                               "device-class",
 
526
                                               pp->devices[i].device_class);
 
527
 
 
528
                      g_variant_builder_add (&device_list,
 
529
                                             "{sv}",
 
530
                                             pp->devices[i].device_uri,
 
531
                                             g_variant_builder_end (&device_hash));
 
532
                    }
 
533
                }
 
534
 
 
535
              input = g_variant_new ("(v)", g_variant_builder_end (&device_list));
 
536
 
 
537
              output = g_dbus_proxy_call_sync (proxy,
 
538
                                               "GroupPhysicalDevices",
 
539
                                               input,
 
540
                                               G_DBUS_CALL_FLAGS_NONE,
 
541
                                               60000,
 
542
                                               NULL,
 
543
                                               &error);
 
544
 
 
545
              if (output && g_variant_n_children (output) == 1)
 
546
                {
 
547
                  array = g_variant_get_child_value (output, 0);
 
548
                  if (array)
 
549
                    {
 
550
                      for (i = 0; i < g_variant_n_children (array); i++)
 
551
                        {
 
552
                          subarray = g_variant_get_child_value (array, i);
 
553
                          if (subarray)
 
554
                            {
 
555
                              device_uri = g_strdup (g_variant_get_string (
 
556
                                             g_variant_get_child_value (subarray, 0),
 
557
                                             NULL));
 
558
 
 
559
                              for (k = 0; k < pp->num_devices; k++)
 
560
                                if (g_str_has_prefix (pp->devices[k].device_uri, device_uri))
 
561
                                  pp->devices[k].show = TRUE;
 
562
 
 
563
                              g_free (device_uri);
 
564
                            }
 
565
                        }
 
566
                    }
 
567
                }
 
568
 
 
569
              if (output)
 
570
                g_variant_unref (output);
 
571
              g_variant_unref (input);
 
572
              g_object_unref (proxy);
 
573
            }
 
574
 
380
575
          if (error)
381
 
            g_warning ("%s", error->message);
382
 
 
383
 
          if (ret_error && ret_error[0] != '\0')
384
 
            g_warning ("%s", ret_error);
385
 
        }
386
 
 
387
 
      free_devices (pp);
388
 
      if (devices)
389
 
        {
390
 
          GList *keys;
391
 
          GList *iter;
392
 
          gchar *cut;
393
 
          gint   max_index = -1;
394
 
          gint   index;
395
 
 
396
 
          keys = g_hash_table_get_keys (devices);
397
 
          for (iter = keys; iter; iter = iter->next)
398
 
            {
399
 
              index = -1;
400
 
 
401
 
              cut = g_strrstr ((gchar *)iter->data, ":");
402
 
              if (cut)
403
 
                index = atoi (cut + 1);
404
 
 
405
 
              if (index > max_index)
406
 
                max_index = index;
407
 
            }
408
 
 
409
 
          if (max_index >= 0)
410
 
            {
411
 
              pp->num_devices = max_index + 1;
412
 
              pp->devices = g_new0 (CupsDevice, pp->num_devices);
413
 
 
414
 
              g_hash_table_foreach (devices, store_device_parameter, pp);
415
 
 
416
 
              /* Assign names to devices */
417
 
              for (i = 0; i < pp->num_devices; i++)
418
 
                {
419
 
                  gchar *name = NULL;
420
 
 
421
 
                  if (pp->devices[i].device_id)
422
 
                    {
423
 
                      name = get_tag_value (pp->devices[i].device_id, "mdl");
424
 
                      if (!name)
425
 
                        name = get_tag_value (pp->devices[i].device_id, "model");
426
 
 
427
 
                      if (name)
428
 
                        name = g_strcanon (name, ALLOWED_CHARACTERS, '-');
429
 
                    }
430
 
 
431
 
                  if (!name &&
432
 
                      pp->devices[i].device_info)
433
 
                    {
434
 
                      name = g_strdup (pp->devices[i].device_info);
435
 
                      if (name)
436
 
                        name = g_strcanon (name, ALLOWED_CHARACTERS, '-');
437
 
                    }
438
 
 
439
 
                  name_index = 2;
440
 
                  already_present = FALSE;
441
 
                  num_dests = cupsGetDests (&dests);
442
 
                  do
443
 
                    {
444
 
                      if (already_present)
445
 
                        {
446
 
                          new_name = g_strdup_printf ("%s-%d", name, name_index);
447
 
                          name_index++;
448
 
                        }
449
 
                      else
450
 
                        new_name = g_strdup (name);
451
 
 
452
 
                      already_present = FALSE;
453
 
                      for (j = 0; j < num_dests; j++)
454
 
                        if (g_strcmp0 (dests[j].name, new_name) == 0)
455
 
                          already_present = TRUE;
456
 
 
457
 
                      if (already_present)
458
 
                        g_free (new_name);
459
 
                      else
460
 
                        {
461
 
                          g_free (name);
462
 
                          name = new_name;
463
 
                        }
464
 
                    } while (already_present);
465
 
                  cupsFreeDests (num_dests, dests);
466
 
 
467
 
                  pp->devices[i].display_name = name;
468
 
                }
469
 
 
470
 
              /* Set show bool
471
 
               * Don't show duplicates.
472
 
               * Show devices with device-id.
473
 
               * Other preferences should apply here.
474
 
               */
475
 
              proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
476
 
                                                     G_DBUS_PROXY_FLAGS_NONE,
477
 
                                                     NULL,
478
 
                                                     SCP_BUS,
479
 
                                                     SCP_PATH,
480
 
                                                     SCP_IFACE,
481
 
                                                     NULL,
482
 
                                                     &error);
483
 
 
484
 
              if (proxy)
485
 
                {
486
 
                  GVariantBuilder  device_list;
487
 
                  GVariantBuilder  device_hash;
488
 
                  GVariant        *input = NULL;
489
 
                  GVariant        *output = NULL;
490
 
                  GVariant        *array = NULL;
491
 
                  GVariant        *subarray = NULL;
492
 
 
493
 
                  g_variant_builder_init (&device_list, G_VARIANT_TYPE ("a{sv}"));
494
 
 
495
 
                  for (i = 0; i < pp->num_devices; i++)
496
 
                    {
497
 
                      if (pp->devices[i].device_uri)
498
 
                        {
499
 
                          g_variant_builder_init (&device_hash, G_VARIANT_TYPE ("a{ss}"));
500
 
 
501
 
                          if (pp->devices[i].device_id)
502
 
                            g_variant_builder_add (&device_hash,
503
 
                                                   "{ss}",
504
 
                                                   "device-id",
505
 
                                                   pp->devices[i].device_id);
506
 
 
507
 
                          if (pp->devices[i].device_make_and_model)
508
 
                            g_variant_builder_add (&device_hash,
509
 
                                                   "{ss}",
510
 
                                                   "device-make-and-model",
511
 
                                                   pp->devices[i].device_make_and_model);
512
 
 
513
 
                          if (pp->devices[i].device_class)
514
 
                            g_variant_builder_add (&device_hash,
515
 
                                                   "{ss}",
516
 
                                                   "device-class",
517
 
                                                   pp->devices[i].device_class);
518
 
 
519
 
                          g_variant_builder_add (&device_list,
520
 
                                                 "{sv}",
521
 
                                                 pp->devices[i].device_uri,
522
 
                                                 g_variant_builder_end (&device_hash));
523
 
                        }
524
 
                    }
525
 
 
526
 
                  input = g_variant_new ("(v)", g_variant_builder_end (&device_list));
527
 
 
528
 
                  output = g_dbus_proxy_call_sync (proxy,
529
 
                                                   "GroupPhysicalDevices",
530
 
                                                   input,
531
 
                                                   G_DBUS_CALL_FLAGS_NONE,
532
 
                                                   60000,
533
 
                                                   NULL,
534
 
                                                   &error);
535
 
 
536
 
                  if (output && g_variant_n_children (output) == 1)
537
 
                    {
538
 
                      array = g_variant_get_child_value (output, 0);
539
 
                      if (array)
540
 
                        {
541
 
                          for (i = 0; i < g_variant_n_children (array); i++)
542
 
                            {
543
 
                              subarray = g_variant_get_child_value (array, i);
544
 
                              if (subarray)
545
 
                                {
546
 
                                  device_uri = g_strdup (g_variant_get_string (
547
 
                                                 g_variant_get_child_value (subarray, 0),
548
 
                                                 NULL));
549
 
 
550
 
                                  for (k = 0; k < pp->num_devices; k++)
551
 
                                    if (g_str_has_prefix (pp->devices[k].device_uri, device_uri))
552
 
                                      pp->devices[k].show = TRUE;
553
 
 
554
 
                                  g_free (device_uri);
555
 
                                }
556
 
                            }
557
 
                        }
558
 
                    }
559
 
 
560
 
                  if (output)
561
 
                    g_variant_unref (output);
562
 
                  g_variant_unref (input);
563
 
                  g_object_unref (proxy);
564
 
                }
565
 
 
566
 
              if (error)
567
 
                {
568
 
                  if (proxy == NULL ||
569
 
                      (error->domain == G_DBUS_ERROR &&
570
 
                       (error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
571
 
                        error->code == G_DBUS_ERROR_UNKNOWN_METHOD)))
572
 
                    g_warning ("Install system-config-printer which provides \
 
576
            {
 
577
              if (proxy == NULL ||
 
578
                  (error->domain == G_DBUS_ERROR &&
 
579
                   (error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
 
580
                    error->code == G_DBUS_ERROR_UNKNOWN_METHOD)))
 
581
                g_warning ("Install system-config-printer which provides \
573
582
DBus method \"GroupPhysicalDevices\" to group duplicates in device list.");
574
583
 
575
 
                  for (i = 0; i < pp->num_devices; i++)
576
 
                    pp->devices[i].show = TRUE;
577
 
                }
578
 
 
579
584
              for (i = 0; i < pp->num_devices; i++)
580
 
                if (!pp->devices[i].device_id)
581
 
                  pp->devices[i].show = FALSE;
 
585
                pp->devices[i].show = TRUE;
582
586
            }
583
587
 
584
 
          g_hash_table_destroy (devices);
585
 
          actualize_devices_list (pp);
586
 
        }
587
 
 
588
 
      widget = (GtkWidget*)
589
 
        gtk_builder_get_object (pp->builder, "get-devices-status-label");
590
 
      gtk_label_set_text (GTK_LABEL (widget), " ");
591
 
 
592
 
      widget = (GtkWidget*)
593
 
        gtk_builder_get_object (pp->builder, "spinner");
594
 
      gtk_spinner_stop (GTK_SPINNER (widget));
595
 
      gtk_widget_set_sensitive (widget, FALSE);
596
 
      gtk_widget_hide (widget);
597
 
 
598
 
      if (pp->cancellable != NULL)
599
 
        {
600
 
          g_object_unref (pp->cancellable);
601
 
          pp->cancellable = NULL;
602
 
        }
603
 
 
604
 
      g_clear_error (&error);
 
588
          for (i = 0; i < pp->num_devices; i++)
 
589
            if (!pp->devices[i].device_id)
 
590
              pp->devices[i].show = FALSE;
 
591
        }
 
592
 
 
593
      g_hash_table_destroy (devices);
 
594
      actualize_devices_list (pp);
 
595
    }
 
596
 
 
597
  widget = (GtkWidget*)
 
598
    gtk_builder_get_object (pp->builder, "get-devices-status-label");
 
599
  gtk_label_set_text (GTK_LABEL (widget), " ");
 
600
 
 
601
  widget = (GtkWidget*)
 
602
    gtk_builder_get_object (pp->builder, "spinner");
 
603
  gtk_spinner_stop (GTK_SPINNER (widget));
 
604
  gtk_widget_set_sensitive (widget, FALSE);
 
605
  gtk_widget_hide (widget);
 
606
 
 
607
  if (pp->cancellable != NULL)
 
608
    {
 
609
      g_object_unref (pp->cancellable);
 
610
      pp->cancellable = NULL;
605
611
    }
606
612
}
607
613
 
615
621
  GVariantBuilder *in_exclude = NULL;
616
622
  GtkWidget *widget = NULL;
617
623
 
 
624
  pp->searching = TRUE;
 
625
 
618
626
  proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
619
627
                                         G_DBUS_PROXY_FLAGS_NONE,
620
628
                                         NULL,
624
632
                                         NULL,
625
633
                                         &error);
626
634
 
627
 
  if (proxy)
628
 
    {
629
 
      if (pp->show_warning)
630
 
        {
631
 
          widget = (GtkWidget*)
632
 
            gtk_builder_get_object (pp->builder, "local-devices-notebook");
633
 
          gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), WARNING_TAB);
634
 
 
635
 
          widget = (GtkWidget*)
636
 
            gtk_builder_get_object (pp->builder, "network-devices-notebook");
637
 
          gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), WARNING_TAB);
638
 
        }
639
 
 
640
 
      in_include = g_variant_builder_new (G_VARIANT_TYPE ("as"));
641
 
      in_exclude = g_variant_builder_new (G_VARIANT_TYPE ("as"));
642
 
 
643
 
      dg_input = g_variant_new ("(iiasas)",
644
 
                                0,
645
 
                                60,
646
 
                                in_include,
647
 
                                in_exclude);
648
 
 
649
 
      widget = (GtkWidget*)
650
 
        gtk_builder_get_object (pp->builder, "get-devices-status-label");
651
 
      gtk_label_set_text (GTK_LABEL (widget), _("Getting devices..."));
652
 
 
653
 
      widget = (GtkWidget*)
654
 
        gtk_builder_get_object (pp->builder, "spinner");
655
 
      gtk_spinner_start (GTK_SPINNER (widget));
656
 
      gtk_widget_set_sensitive (widget, TRUE);
657
 
      gtk_widget_show (widget);
658
 
 
659
 
      pp->cancellable = g_cancellable_new ();
660
 
 
661
 
      g_dbus_proxy_call (proxy,
662
 
                         "DevicesGet",
663
 
                         dg_input,
664
 
                         G_DBUS_CALL_FLAGS_NONE,
665
 
                         60000,
666
 
                         pp->cancellable,
667
 
                         devices_get_cb,
668
 
                         pp);
669
 
 
670
 
      g_variant_builder_unref (in_exclude);
671
 
      g_variant_builder_unref (in_include);
672
 
      g_variant_unref (dg_input);
673
 
    }
 
635
  if (!proxy)
 
636
    {
 
637
      g_warning ("%s", error->message);
 
638
      g_error_free (error);
 
639
      pp->searching = FALSE;
 
640
      return;
 
641
    }
 
642
 
 
643
  if (pp->show_warning)
 
644
    {
 
645
      widget = (GtkWidget*)
 
646
        gtk_builder_get_object (pp->builder, "local-devices-notebook");
 
647
      gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), WARNING_TAB);
 
648
 
 
649
      widget = (GtkWidget*)
 
650
        gtk_builder_get_object (pp->builder, "network-devices-notebook");
 
651
      gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), WARNING_TAB);
 
652
    }
 
653
 
 
654
  in_include = g_variant_builder_new (G_VARIANT_TYPE ("as"));
 
655
  in_exclude = g_variant_builder_new (G_VARIANT_TYPE ("as"));
 
656
 
 
657
  dg_input = g_variant_new ("(iiasas)",
 
658
                            0,
 
659
                            60,
 
660
                            in_include,
 
661
                            in_exclude);
 
662
 
 
663
  widget = (GtkWidget*)
 
664
    gtk_builder_get_object (pp->builder, "get-devices-status-label");
 
665
  gtk_label_set_text (GTK_LABEL (widget), _("Getting devices..."));
 
666
 
 
667
  widget = (GtkWidget*)
 
668
    gtk_builder_get_object (pp->builder, "spinner");
 
669
  gtk_spinner_start (GTK_SPINNER (widget));
 
670
  gtk_widget_set_sensitive (widget, TRUE);
 
671
  gtk_widget_show (widget);
 
672
 
 
673
  pp->cancellable = g_cancellable_new ();
 
674
 
 
675
  g_dbus_proxy_call (proxy,
 
676
                     "DevicesGet",
 
677
                     dg_input,
 
678
                     G_DBUS_CALL_FLAGS_NONE,
 
679
                     60000,
 
680
                     pp->cancellable,
 
681
                     devices_get_cb,
 
682
                     pp);
 
683
 
 
684
  g_variant_builder_unref (in_exclude);
 
685
  g_variant_builder_unref (in_include);
 
686
  g_variant_unref (dg_input);
 
687
 
 
688
  pp->searching = FALSE;
674
689
}
675
690
 
676
691
static gchar **
765
780
  GVariant   *input = NULL;
766
781
  GVariant   *output = NULL;
767
782
  GError     *error = NULL;
768
 
  gint        result;
769
783
 
770
784
  proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
771
785
                                         G_DBUS_PROXY_FLAGS_NONE,
776
790
                                         NULL,
777
791
                                         &error);
778
792
 
779
 
  if (proxy)
780
 
    {
781
 
      input = g_variant_new ("(si)",
782
 
                             service_name,
783
 
                             service_timeout);
784
 
 
785
 
      output = g_dbus_proxy_call_sync (proxy,
786
 
                                       "enableService",
787
 
                                       input,
788
 
                                       G_DBUS_CALL_FLAGS_NONE,
789
 
                                       60000,
790
 
                                       NULL,
791
 
                                       &error);
792
 
 
793
 
      if (output && g_variant_n_children (output) == 1)
794
 
        g_variant_get (output, "(i)", &result);
795
 
 
796
 
      if (output)
797
 
        g_variant_unref (output);
798
 
      g_variant_unref (input);
799
 
      g_object_unref (proxy);
 
793
  if (!proxy)
 
794
    {
 
795
      g_warning ("%s", error->message);
 
796
      g_error_free (error);
 
797
      return;
 
798
    }
 
799
 
 
800
  input = g_variant_new ("(si)",
 
801
                         service_name,
 
802
                         service_timeout);
 
803
 
 
804
  output = g_dbus_proxy_call_sync (proxy,
 
805
                                   "enableService",
 
806
                                   input,
 
807
                                   G_DBUS_CALL_FLAGS_NONE,
 
808
                                   60000,
 
809
                                   NULL,
 
810
                                   &error);
 
811
 
 
812
  g_variant_unref (input);
 
813
  g_object_unref (proxy);
 
814
 
 
815
  if (output)
 
816
    {
 
817
      g_variant_unref (output);
 
818
    }
 
819
  else
 
820
    {
 
821
      g_warning ("%s", error->message);
 
822
      g_error_free (error);
800
823
    }
801
824
}
802
825
 
807
830
  GVariant   *input = NULL;
808
831
  GVariant   *output = NULL;
809
832
  GError     *error = NULL;
810
 
  gint        result;
811
833
 
812
834
  proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
813
835
                                         G_DBUS_PROXY_FLAGS_NONE,
818
840
                                         NULL,
819
841
                                         &error);
820
842
 
821
 
  if (proxy)
822
 
    {
823
 
      input = g_variant_new ("(s)", service_name);
824
 
 
825
 
      output = g_dbus_proxy_call_sync (proxy,
826
 
                                       "disableService",
827
 
                                       input,
828
 
                                       G_DBUS_CALL_FLAGS_NONE,
829
 
                                       60000,
830
 
                                       NULL,
831
 
                                       &error);
832
 
 
833
 
      if (output && g_variant_n_children (output) == 1)
834
 
        g_variant_get (output, "(i)", &result);
835
 
 
836
 
      if (output)
837
 
        g_variant_unref (output);
838
 
      g_variant_unref (input);
839
 
      g_object_unref (proxy);
 
843
  if (!proxy)
 
844
    {
 
845
      g_warning ("%s", error->message);
 
846
      g_error_free (error);
 
847
      return;
 
848
    }
 
849
 
 
850
  input = g_variant_new ("(s)", service_name);
 
851
 
 
852
  output = g_dbus_proxy_call_sync (proxy,
 
853
                                   "disableService",
 
854
                                   input,
 
855
                                   G_DBUS_CALL_FLAGS_NONE,
 
856
                                   60000,
 
857
                                   NULL,
 
858
                                   &error);
 
859
 
 
860
  g_variant_unref (input);
 
861
  g_object_unref (proxy);
 
862
 
 
863
  if (output)
 
864
    {
 
865
      g_variant_unref (output);
 
866
    }
 
867
  else
 
868
    {
 
869
      g_warning ("%s", error->message);
 
870
      g_error_free (error);
840
871
    }
841
872
}
842
873
 
858
889
                                         NULL,
859
890
                                         &error);
860
891
 
861
 
  if (proxy)
862
 
    {
863
 
      input = g_variant_new ("(s)",
864
 
                             service_name);
865
 
 
866
 
      output = g_dbus_proxy_call_sync (proxy,
867
 
                                       "queryService",
868
 
                                       input,
869
 
                                       G_DBUS_CALL_FLAGS_NONE,
870
 
                                       60000,
871
 
                                       NULL,
872
 
                                       &error);
873
 
 
874
 
      if (output && g_variant_n_children (output) == 1)
 
892
  if (!proxy)
 
893
    {
 
894
      g_warning ("%s", error->message);
 
895
      g_error_free (error);
 
896
      return FALSE;
 
897
    }
 
898
 
 
899
  input = g_variant_new ("(s)",
 
900
                         service_name);
 
901
 
 
902
  output = g_dbus_proxy_call_sync (proxy,
 
903
                                   "queryService",
 
904
                                   input,
 
905
                                   G_DBUS_CALL_FLAGS_NONE,
 
906
                                   60000,
 
907
                                   NULL,
 
908
                                   &error);
 
909
 
 
910
  g_variant_unref (input);
 
911
  g_object_unref (proxy);
 
912
 
 
913
  if (output)
 
914
    {
 
915
      if (g_variant_n_children (output) == 1)
875
916
        g_variant_get (output, "(i)", &query_result);
876
 
 
877
 
      if (output)
878
 
        g_variant_unref (output);
879
 
      g_variant_unref (input);
880
 
      g_object_unref (proxy);
 
917
      g_variant_unref (output);
 
918
    }
 
919
  else
 
920
    {
 
921
      g_warning ("%s", error->message);
 
922
      g_error_free (error);
 
923
      return FALSE;
881
924
    }
882
925
 
883
926
  if (query_result > 0)
906
949
                                         NULL,
907
950
                                         NULL);
908
951
 
909
 
  if (proxy)
910
 
    {
911
 
      output = g_dbus_proxy_call_sync (proxy,
912
 
                                       method,
913
 
                                       NULL,
914
 
                                       G_DBUS_CALL_FLAGS_NONE,
915
 
                                       60000,
916
 
                                       NULL,
917
 
                                       &error);
918
 
 
919
 
      if (error &&
920
 
          error->domain == G_DBUS_ERROR &&
 
952
  if (!proxy)
 
953
    {
 
954
      g_warning ("%s", error->message);
 
955
      g_error_free (error);
 
956
      return FALSE;
 
957
    }
 
958
 
 
959
  output = g_dbus_proxy_call_sync (proxy,
 
960
                                   method,
 
961
                                   NULL,
 
962
                                   G_DBUS_CALL_FLAGS_NONE,
 
963
                                   60000,
 
964
                                   NULL,
 
965
                                   &error);
 
966
 
 
967
  g_object_unref (proxy);
 
968
 
 
969
  if (output)
 
970
    {
 
971
      g_variant_unref (output);
 
972
      result = TRUE;
 
973
    }
 
974
  else
 
975
    {
 
976
      if (error->domain == G_DBUS_ERROR &&
921
977
          error->code == G_DBUS_ERROR_SERVICE_UNKNOWN)
922
978
        result = FALSE;
923
979
      else
924
980
        result = TRUE;
925
 
 
926
 
      if (output)
927
 
        g_variant_unref (output);
928
 
      g_object_unref (proxy);
929
981
    }
930
982
 
931
983
  return result;
939
991
  GtkWidget *widget;
940
992
  gint i;
941
993
 
 
994
  pp->searching = TRUE;
 
995
 
942
996
  widget = (GtkWidget*)
943
997
    gtk_builder_get_object (pp->builder, "search-by-address-checkbutton");
944
998
 
1105
1159
                }
1106
1160
              else
1107
1161
                {
1108
 
                  if (error)
1109
 
                    g_warning ("%s", error->message);
 
1162
                  g_warning ("%s", error->message);
 
1163
                  g_error_free (error);
1110
1164
                }
1111
1165
 
1112
1166
              g_free (command);
1150
1204
      pp->num_devices = length;
1151
1205
    }
1152
1206
 
 
1207
  pp->searching = FALSE;
 
1208
 
1153
1209
  actualize_devices_list (pp);
1154
1210
}
1155
1211
 
1166
1222
  GtkWidget    *widget;
1167
1223
  GtkWidget    *local_notebook;
1168
1224
  GtkWidget    *network_notebook;
 
1225
  gboolean      no_local_device = TRUE;
 
1226
  gboolean      no_network_device = TRUE;
1169
1227
  gint          i;
1170
1228
  gint          device_type = -1;
1171
1229
 
1196
1254
                                  DEVICE_NAME_COLUMN, pp->devices[i].display_name,
1197
1255
                                  -1);
1198
1256
              pp->show_warning = FALSE;
 
1257
              no_network_device = FALSE;
1199
1258
            }
1200
1259
          else if (g_strcmp0 (pp->devices[i].device_class, "direct") == 0)
1201
1260
            {
1204
1263
                                  DEVICE_ID_COLUMN, i,
1205
1264
                                  DEVICE_NAME_COLUMN, pp->devices[i].display_name,
1206
1265
                                  -1);
 
1266
              no_local_device = FALSE;
1207
1267
            }
1208
1268
        }
1209
1269
    }
1210
1270
 
 
1271
  if (no_local_device && !pp->searching)
 
1272
    {
 
1273
      gtk_list_store_append (local_store, &iter);
 
1274
      gtk_list_store_set (local_store, &iter,
 
1275
                          DEVICE_ID_COLUMN, 0,
 
1276
      /* Translators: No localy connected printers were found */
 
1277
                          DEVICE_NAME_COLUMN, _("No local printers found"),
 
1278
                          -1);
 
1279
      gtk_widget_set_sensitive (GTK_WIDGET (local_treeview), FALSE);
 
1280
    }
 
1281
  else
 
1282
    gtk_widget_set_sensitive (GTK_WIDGET (local_treeview), TRUE);
 
1283
 
 
1284
  if (no_network_device && !pp->show_warning && !pp->searching)
 
1285
    {
 
1286
      gtk_list_store_append (network_store, &iter);
 
1287
      gtk_list_store_set (network_store, &iter,
 
1288
                          DEVICE_ID_COLUMN, 0,
 
1289
      /* Translators: No network printers were found */
 
1290
                          DEVICE_NAME_COLUMN, _("No network printers found"),
 
1291
                          -1);
 
1292
      gtk_widget_set_sensitive (GTK_WIDGET (network_treeview), FALSE);
 
1293
    }
 
1294
  else
 
1295
    gtk_widget_set_sensitive (GTK_WIDGET (network_treeview), TRUE);
 
1296
 
1211
1297
  gtk_tree_view_set_model (network_treeview, GTK_TREE_MODEL (network_store));
1212
1298
  gtk_tree_view_set_model (local_treeview, GTK_TREE_MODEL (local_store));
1213
1299
 
1214
 
  if (gtk_tree_model_get_iter_first ((GtkTreeModel *) network_store, &iter))
 
1300
  if (!no_network_device &&
 
1301
      gtk_tree_model_get_iter_first ((GtkTreeModel *) network_store, &iter))
1215
1302
    gtk_tree_selection_select_iter (
1216
1303
      gtk_tree_view_get_selection (GTK_TREE_VIEW (network_treeview)),
1217
1304
      &iter);
1218
1305
 
1219
 
  if (gtk_tree_model_get_iter_first ((GtkTreeModel *) local_store, &iter))
 
1306
  if (!no_local_device &&
 
1307
      gtk_tree_model_get_iter_first ((GtkTreeModel *) local_store, &iter))
1220
1308
    gtk_tree_selection_select_iter (
1221
1309
      gtk_tree_view_get_selection (GTK_TREE_VIEW (local_treeview)),
1222
1310
      &iter);
1397
1485
  gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
1398
1486
}
1399
1487
 
1400
 
static void
1401
 
dialog_closed (GtkWidget          *dialog,
1402
 
               gint                response_id,
1403
 
               PpNewPrinterDialog *pp)
1404
 
{
1405
 
  gtk_widget_destroy (dialog);
1406
 
}
1407
 
 
1408
1488
static GList *
1409
1489
glist_uniq (GList *list)
1410
1490
{
1498
1578
              if (ppd_file_name)
1499
1579
                {
1500
1580
                  DBusGProxy *proxy;
 
1581
                  gboolean    result;
1501
1582
                  GError     *error = NULL;
1502
1583
                  char       *ret_error = NULL;
1503
1584
 
1507
1588
                                          TRUE);
1508
1589
                  if (proxy)
1509
1590
                    {
1510
 
                      dbus_g_proxy_call (proxy, "PrinterAddWithPpdFile", &error,
1511
 
                                         G_TYPE_STRING, pp->devices[device_id].display_name,
1512
 
                                         G_TYPE_STRING, pp->devices[device_id].device_uri,
1513
 
                                         G_TYPE_STRING, ppd_file_name,
1514
 
                                         G_TYPE_STRING, pp->devices[device_id].device_info,
1515
 
                                         G_TYPE_STRING, pp->devices[device_id].device_location,
1516
 
                                         G_TYPE_INVALID,
1517
 
                                         G_TYPE_STRING, &ret_error,
1518
 
                                         G_TYPE_INVALID);
1519
 
 
1520
 
                      if (error || (ret_error && ret_error[0] != '\0'))
1521
 
                        {
1522
 
                          dialog_response = GTK_RESPONSE_REJECT;
1523
 
 
1524
 
                          if (error)
1525
 
                            g_warning ("%s", error->message);
1526
 
 
1527
 
                          if (ret_error && ret_error[0] != '\0')
1528
 
                            g_warning ("%s", ret_error);
1529
 
 
1530
 
                          g_clear_error (&error);
1531
 
                        }
1532
 
                      else
 
1591
                      result = dbus_g_proxy_call (proxy, "PrinterAddWithPpdFile", &error,
 
1592
                                                  G_TYPE_STRING, pp->devices[device_id].display_name,
 
1593
                                                  G_TYPE_STRING, pp->devices[device_id].device_uri,
 
1594
                                                  G_TYPE_STRING, ppd_file_name,
 
1595
                                                  G_TYPE_STRING, pp->devices[device_id].device_info,
 
1596
                                                  G_TYPE_STRING, pp->devices[device_id].device_location,
 
1597
                                                  G_TYPE_INVALID,
 
1598
                                                  G_TYPE_STRING, &ret_error,
 
1599
                                                  G_TYPE_INVALID);
 
1600
 
 
1601
                      if (!result)
 
1602
                        {
 
1603
                          g_warning ("%s", error->message);
 
1604
                          g_error_free (error);
 
1605
                          dialog_response = GTK_RESPONSE_REJECT;
 
1606
                        }
 
1607
 
 
1608
                      if (ret_error && ret_error[0] != '\0')
 
1609
                        {
 
1610
                          g_warning ("%s", ret_error);
 
1611
                          dialog_response = GTK_RESPONSE_REJECT;
 
1612
                        }
 
1613
 
 
1614
                      if (result && (!ret_error || ret_error[0] == '\0'))
1533
1615
                        success = TRUE;
1534
1616
 
1535
1617
                      g_object_unref (proxy);
1558
1640
            {
1559
1641
              /* Try PackageKit to install printer driver */
1560
1642
              DBusGProxy *proxy;
 
1643
              gboolean    result;
1561
1644
              GError     *error = NULL;
1562
1645
 
1563
1646
              proxy = get_dbus_proxy (PACKAGE_KIT_BUS,
1573
1656
                  device_ids[0] = pp->devices[device_id].device_id;
1574
1657
                  device_ids[1] = NULL;
1575
1658
 
1576
 
                  dbus_g_proxy_call_with_timeout (proxy,
 
1659
                  result = dbus_g_proxy_call_with_timeout (proxy,
1577
1660
                    "InstallPrinterDrivers",
1578
1661
                    3600000,
1579
1662
                    &error,
1589
1672
 
1590
1673
                  g_object_unref (proxy);
1591
1674
 
1592
 
                  if (error)
1593
 
                    g_warning ("%s", error->message);
1594
 
 
1595
 
                  g_clear_error (&error);
 
1675
                  if (!result)
 
1676
                    {
 
1677
                      g_warning ("%s", error->message);
 
1678
                      g_error_free (error);
 
1679
                    }
1596
1680
 
1597
1681
                  if (ppd_name)
1598
1682
                    {
1613
1697
          if (ppd_name && ppd_name->ppd_name)
1614
1698
            {
1615
1699
              DBusGProxy *proxy;
 
1700
              gboolean    result;
1616
1701
              GError     *error = NULL;
1617
1702
              char       *ret_error = NULL;
1618
1703
 
1622
1707
                                      TRUE);
1623
1708
              if (proxy)
1624
1709
                {
1625
 
                  dbus_g_proxy_call (proxy, "PrinterAdd", &error,
1626
 
                                     G_TYPE_STRING, pp->devices[device_id].display_name,
1627
 
                                     G_TYPE_STRING, pp->devices[device_id].device_uri,
1628
 
                                     G_TYPE_STRING, ppd_name->ppd_name,
1629
 
                                     G_TYPE_STRING, pp->devices[device_id].device_info,
1630
 
                                     G_TYPE_STRING, pp->devices[device_id].device_location,
1631
 
                                     G_TYPE_INVALID,
1632
 
                                     G_TYPE_STRING, &ret_error,
1633
 
                                     G_TYPE_INVALID);
1634
 
 
1635
 
                  if (error || (ret_error && ret_error[0] != '\0'))
1636
 
                    {
1637
 
                      dialog_response = GTK_RESPONSE_REJECT;
1638
 
 
1639
 
                      if (error)
1640
 
                        g_warning ("%s", error->message);
1641
 
 
1642
 
                      if (ret_error && ret_error[0] != '\0')
1643
 
                        g_warning ("%s", ret_error);
1644
 
 
1645
 
                      g_clear_error (&error);
 
1710
                  result = dbus_g_proxy_call (proxy, "PrinterAdd", &error,
 
1711
                             G_TYPE_STRING, pp->devices[device_id].display_name,
 
1712
                             G_TYPE_STRING, pp->devices[device_id].device_uri,
 
1713
                             G_TYPE_STRING, ppd_name->ppd_name,
 
1714
                             G_TYPE_STRING, pp->devices[device_id].device_info,
 
1715
                             G_TYPE_STRING, pp->devices[device_id].device_location,
 
1716
                             G_TYPE_INVALID,
 
1717
                             G_TYPE_STRING, &ret_error,
 
1718
                             G_TYPE_INVALID);
 
1719
 
 
1720
                  if (!result)
 
1721
                    {
 
1722
                      g_warning ("%s", error->message);
 
1723
                      g_error_free (error);
 
1724
                      dialog_response = GTK_RESPONSE_REJECT;
 
1725
                    }
 
1726
 
 
1727
                  if (ret_error && ret_error[0] != '\0')
 
1728
                    {
 
1729
                      g_warning ("%s", ret_error);
 
1730
                      dialog_response = GTK_RESPONSE_REJECT;
1646
1731
                    }
1647
1732
 
1648
1733
                  g_object_unref (proxy);
1664
1749
        {
1665
1750
          const char *ppd_file_name = NULL;
1666
1751
          DBusGProxy *proxy;
 
1752
          gboolean    result;
1667
1753
          GError     *error = NULL;
1668
1754
          char       *ret_error = NULL;
1669
1755
          ppd_file_t  *ppd_file = NULL;
1743
1829
 
1744
1830
              if (value)
1745
1831
                {
1746
 
                  dbus_g_proxy_call (proxy, "PrinterAddOptionDefault", &error,
1747
 
                                     G_TYPE_STRING, pp->devices[device_id].display_name,
1748
 
                                     G_TYPE_STRING, "PageSize",
1749
 
                                     G_TYPE_STRV, value,
1750
 
                                     G_TYPE_INVALID,
1751
 
                                     G_TYPE_STRING, &ret_error,
1752
 
                                     G_TYPE_INVALID);
 
1832
                  result = dbus_g_proxy_call (proxy, "PrinterAddOptionDefault", &error,
 
1833
                             G_TYPE_STRING, pp->devices[device_id].display_name,
 
1834
                             G_TYPE_STRING, "PageSize",
 
1835
                             G_TYPE_STRV, value,
 
1836
                             G_TYPE_INVALID,
 
1837
                             G_TYPE_STRING, &ret_error,
 
1838
                             G_TYPE_INVALID);
1753
1839
 
1754
 
                  if (error)
 
1840
                  if (!result)
1755
1841
                    {
1756
1842
                      g_warning ("%s", error->message);
1757
 
                      g_clear_error (&error);
 
1843
                      g_error_free (error);
1758
1844
                    }
1759
1845
 
1760
1846
                  if (ret_error && ret_error[0] != '\0')
1761
 
                    g_warning ("%s", ret_error);
 
1847
                    {
 
1848
                      g_warning ("%s", ret_error);
 
1849
                    }
1762
1850
 
1763
1851
                  g_strfreev (value);
1764
1852
                }
1811
1899
              GList      *executables = NULL;
1812
1900
              GList      *packages = NULL;
1813
1901
 
1814
 
              g_clear_error (&error);
1815
1902
              error = NULL;
1816
1903
 
1817
1904
              proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
1836
1923
                                                   NULL,
1837
1924
                                                   &error);
1838
1925
 
1839
 
                  if (output && g_variant_n_children (output) == 1)
 
1926
                  g_variant_unref (input);
 
1927
                  g_object_unref (proxy);
 
1928
 
 
1929
                  if (output)
1840
1930
                    {
1841
 
                      array = g_variant_get_child_value (output, 0);
1842
 
                      if (array)
 
1931
                      if (g_variant_n_children (output) == 1)
1843
1932
                        {
1844
 
                          for (i = 0; i < g_variant_n_children (array); i++)
 
1933
                          array = g_variant_get_child_value (output, 0);
 
1934
                          if (array)
1845
1935
                            {
1846
 
                              executables = g_list_append (
1847
 
                                              executables,
1848
 
                                                g_strdup (g_variant_get_string (
1849
 
                                                  g_variant_get_child_value (array, i),
1850
 
                                                  NULL)));
 
1936
                              for (i = 0; i < g_variant_n_children (array); i++)
 
1937
                                {
 
1938
                                  executables = g_list_append (
 
1939
                                                  executables,
 
1940
                                                    g_strdup (g_variant_get_string (
 
1941
                                                      g_variant_get_child_value (array, i),
 
1942
                                                      NULL)));
 
1943
                                }
1851
1944
                            }
1852
1945
                        }
 
1946
                      g_variant_unref (output);
1853
1947
                    }
1854
 
 
1855
 
                  if (output)
1856
 
                    g_variant_unref (output);
1857
 
                  g_variant_unref (input);
1858
 
                  g_object_unref (proxy);
1859
1948
                }
1860
1949
 
1861
1950
              if (proxy == NULL ||
1863
1952
                   error->domain == G_DBUS_ERROR &&
1864
1953
                   (error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
1865
1954
                    error->code == G_DBUS_ERROR_UNKNOWN_METHOD)))
1866
 
                g_warning ("Install system-config-printer which provides \
 
1955
                {
 
1956
                  g_warning ("Install system-config-printer which provides \
1867
1957
DBus method \"MissingExecutables\" to find missing executables and filters.");
 
1958
                  g_error_free (error);
 
1959
                }
1868
1960
 
1869
1961
              executables = g_list_sort (executables, (GCompareFunc) g_strcmp0);
1870
1962
              executables = glist_uniq (executables);
1896
1988
                                                           NULL,
1897
1989
                                                           &error);
1898
1990
 
1899
 
                          if (error)
1900
 
                            g_warning ("%s", error->message);
 
1991
                          g_variant_unref (input);
1901
1992
 
1902
1993
                          if (output)
1903
1994
                            {
1910
2001
                                             &package);
1911
2002
                              if (!installed)
1912
2003
                                packages = g_list_append (packages, g_strdup (package));
1913
 
                            }
1914
 
 
1915
 
                          if (output)
1916
 
                            g_variant_unref (output);
1917
 
                          g_variant_unref (input);
 
2004
                              g_variant_unref (output);
 
2005
                            }
 
2006
                          else
 
2007
                            {
 
2008
                              g_warning ("%s", error->message);
 
2009
                              g_error_free (error);
 
2010
                            }
1918
2011
                        }
1919
2012
 
1920
2013
                      g_object_unref (proxy);
1921
2014
                    }
 
2015
                  else
 
2016
                    {
 
2017
                      g_warning ("%s", error->message);
 
2018
                      g_error_free (error);
 
2019
                    }
1922
2020
 
1923
2021
                  g_list_free_full (executables, g_free);
1924
2022
                }
1966
2064
                                                       NULL,
1967
2065
                                                       &error);
1968
2066
 
1969
 
                      if (error)
1970
 
                        g_warning ("%s", error->message);
 
2067
                      g_variant_unref (input);
 
2068
                      g_object_unref (proxy);
1971
2069
 
1972
2070
                      if (output)
1973
 
                        g_variant_unref (output);
1974
 
                      g_variant_unref (input);
1975
 
 
1976
 
                      g_object_unref (proxy);
 
2071
                        {
 
2072
                          g_variant_unref (output);
 
2073
                        }
 
2074
                      else
 
2075
                        {
 
2076
                          g_warning ("%s", error->message);
 
2077
                          g_error_free (error);
 
2078
                        }
 
2079
                    }
 
2080
                  else
 
2081
                    {
 
2082
                      g_warning ("%s", error->message);
 
2083
                      g_error_free (error);
1977
2084
                    }
1978
2085
 
1979
2086
                  g_list_free_full (packages, g_free);
2008
2115
  GtkWidget          *widget;
2009
2116
  GError             *error = NULL;
2010
2117
  gchar              *objects[] = { "dialog", "main-vbox", NULL };
 
2118
  guint               builder_result;
2011
2119
 
2012
2120
  pp = g_new0 (PpNewPrinterDialog, 1);
2013
2121
 
2014
2122
  pp->builder = gtk_builder_new ();
2015
2123
  pp->parent = GTK_WIDGET (parent);
2016
2124
 
2017
 
  gtk_builder_add_objects_from_file (pp->builder,
2018
 
                                     DATADIR"/new-printer-dialog.ui",
2019
 
                                     objects, &error);
 
2125
  builder_result = gtk_builder_add_objects_from_file (pp->builder,
 
2126
                                                      DATADIR"/new-printer-dialog.ui",
 
2127
                                                      objects, &error);
2020
2128
 
2021
 
  if (error)
 
2129
  if (builder_result == 0)
2022
2130
    {
2023
2131
      g_warning ("Could not load ui: %s", error->message);
2024
2132
      g_error_free (error);
2061
2169
  gtk_window_present (GTK_WINDOW (pp->dialog));
2062
2170
  gtk_widget_show_all (GTK_WIDGET (pp->dialog));
2063
2171
 
 
2172
  pp->searching = TRUE;
2064
2173
  populate_device_types_list (pp);
2065
2174
  populate_devices_list (pp);
2066
2175