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

« back to all changes in this revision

Viewing changes to panels/printers/pp-new-printer-dialog.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:
112
112
 
113
113
  UserResponseCallback user_callback;
114
114
  gpointer             user_data;
 
115
 
 
116
  GCancellable *cancellable;
115
117
};
116
118
 
117
119
static void
198
200
}
199
201
 
200
202
static void
201
 
devices_get_cb (GObject *source_object,
 
203
devices_get_cb (GObject      *source_object,
202
204
                GAsyncResult *res,
203
 
                gpointer user_data)
 
205
                gpointer      user_data)
204
206
{
205
 
  PpNewPrinterDialog *pp = (PpNewPrinterDialog *) user_data;
 
207
  PpNewPrinterDialog *pp = user_data;
206
208
  GHashTable         *devices = NULL;
207
209
  GtkWidget          *widget = NULL;
208
210
  GVariant           *dg_output = NULL;
214
216
                                        res,
215
217
                                        &error);
216
218
 
217
 
  if (dg_output && g_variant_n_children (dg_output) == 2)
218
 
    {
219
 
      GVariant *devices_variant = NULL;
220
 
 
221
 
      g_variant_get (dg_output, "(&s@a{ss})",
222
 
                     &ret_error,
223
 
                     &devices_variant);
224
 
 
225
 
      if (devices_variant)
226
 
        {
227
 
          if (g_variant_is_of_type (devices_variant, G_VARIANT_TYPE ("a{ss}")))
228
 
            {
229
 
              GVariantIter *iter;
230
 
              GVariant *item;
231
 
              g_variant_get (devices_variant,
232
 
                             "a{ss}",
233
 
                             &iter);
234
 
              devices = g_hash_table_new (g_str_hash, g_str_equal);
235
 
              while ((item = g_variant_iter_next_value (iter)))
236
 
                {
237
 
                  gchar *key;
238
 
                  gchar *value;
239
 
                  g_variant_get (item,
240
 
                                 "{ss}",
241
 
                                 &key,
242
 
                                 &value);
243
 
  
244
 
                  g_hash_table_insert (devices, key, value);
245
 
                }
246
 
            }
247
 
          g_variant_unref (devices_variant);
248
 
        }
249
 
      g_variant_unref (dg_output);
250
 
    }
251
 
  g_object_unref (source_object);
252
 
 
253
 
  if (error || (ret_error && ret_error[0] != '\0'))
254
 
    {
255
 
      if (error)
256
 
        g_warning ("%s", error->message);
257
 
 
258
 
      if (ret_error && ret_error[0] != '\0')
259
 
        g_warning ("%s", ret_error);
260
 
    }
261
 
 
262
 
  free_devices (pp);
263
 
  if (devices)
264
 
    {
265
 
      GList *keys;
266
 
      GList *iter;
267
 
      gchar *cut;
268
 
      gint   max_index = -1;
269
 
      gint   index;
270
 
 
271
 
      keys = g_hash_table_get_keys (devices);
272
 
      for (iter = keys; iter; iter = iter->next)
273
 
        {
274
 
          index = -1;
275
 
 
276
 
          cut = g_strrstr ((gchar *)iter->data, ":");
277
 
          if (cut)
278
 
            index = atoi (cut + 1);
279
 
 
280
 
          if (index > max_index)
281
 
            max_index = index;
282
 
        }
283
 
 
284
 
      if (max_index >= 0)
285
 
        {
286
 
          pp->num_devices = max_index + 1;
287
 
          pp->devices = g_new0 (CupsDevice, pp->num_devices);
288
 
 
289
 
          g_hash_table_foreach (devices, store_device_parameter, pp);
290
 
 
291
 
          /* Assign names to devices */
292
 
          for (i = 0; i < pp->num_devices; i++)
293
 
            {
294
 
              gchar *name = NULL;
295
 
 
296
 
              if (pp->devices[i].device_id)
297
 
                {
298
 
                  name = get_tag_value (pp->devices[i].device_id, "mdl");
299
 
                  name = g_strcanon (name, ALLOWED_CHARACTERS, '-');
300
 
                }
301
 
              else if (pp->devices[i].device_info)
302
 
                {
303
 
                  name = g_strdup (pp->devices[i].device_info);
304
 
                  name = g_strcanon (name, ALLOWED_CHARACTERS, '-');
305
 
                }
306
 
 
307
 
              pp->devices[i].display_name = name;
308
 
            }
309
 
 
310
 
          /* Set show bool
311
 
           * Don't show duplicates.
312
 
           * Show devices with device-id.
313
 
           * Other preferences should apply here.
314
 
           */
315
 
          for (i = 0; i < pp->num_devices; i++)
316
 
            {
317
 
              for (j = 0; j < pp->num_devices; j++)
318
 
                {
319
 
                  if (i != j)
320
 
                    {
321
 
                      if (g_strcmp0 (pp->devices[i].display_name, pp->devices[j].display_name) == 0)
 
219
  if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
 
220
    {
 
221
      if (dg_output && g_variant_n_children (dg_output) == 2)
 
222
        {
 
223
          GVariant *devices_variant = NULL;
 
224
 
 
225
          g_variant_get (dg_output, "(&s@a{ss})",
 
226
                         &ret_error,
 
227
                         &devices_variant);
 
228
 
 
229
          if (devices_variant)
 
230
            {
 
231
              if (g_variant_is_of_type (devices_variant, G_VARIANT_TYPE ("a{ss}")))
 
232
                {
 
233
                  GVariantIter *iter;
 
234
                  GVariant *item;
 
235
                  g_variant_get (devices_variant,
 
236
                                 "a{ss}",
 
237
                                 &iter);
 
238
                  devices = g_hash_table_new (g_str_hash, g_str_equal);
 
239
                  while ((item = g_variant_iter_next_value (iter)))
 
240
                    {
 
241
                      gchar *key;
 
242
                      gchar *value;
 
243
                      g_variant_get (item,
 
244
                                     "{ss}",
 
245
                                     &key,
 
246
                                     &value);
 
247
 
 
248
                      g_hash_table_insert (devices, key, value);
 
249
                    }
 
250
                }
 
251
              g_variant_unref (devices_variant);
 
252
            }
 
253
          g_variant_unref (dg_output);
 
254
        }
 
255
      g_object_unref (source_object);
 
256
 
 
257
      if (error || (ret_error && ret_error[0] != '\0'))
 
258
        {
 
259
          if (error)
 
260
            g_warning ("%s", error->message);
 
261
 
 
262
          if (ret_error && ret_error[0] != '\0')
 
263
            g_warning ("%s", ret_error);
 
264
        }
 
265
 
 
266
      free_devices (pp);
 
267
      if (devices)
 
268
        {
 
269
          GList *keys;
 
270
          GList *iter;
 
271
          gchar *cut;
 
272
          gint   max_index = -1;
 
273
          gint   index;
 
274
 
 
275
          keys = g_hash_table_get_keys (devices);
 
276
          for (iter = keys; iter; iter = iter->next)
 
277
            {
 
278
              index = -1;
 
279
 
 
280
              cut = g_strrstr ((gchar *)iter->data, ":");
 
281
              if (cut)
 
282
                index = atoi (cut + 1);
 
283
 
 
284
              if (index > max_index)
 
285
                max_index = index;
 
286
            }
 
287
 
 
288
          if (max_index >= 0)
 
289
            {
 
290
              pp->num_devices = max_index + 1;
 
291
              pp->devices = g_new0 (CupsDevice, pp->num_devices);
 
292
 
 
293
              g_hash_table_foreach (devices, store_device_parameter, pp);
 
294
 
 
295
              /* Assign names to devices */
 
296
              for (i = 0; i < pp->num_devices; i++)
 
297
                {
 
298
                  gchar *name = NULL;
 
299
 
 
300
                  if (pp->devices[i].device_id)
 
301
                    {
 
302
                      name = get_tag_value (pp->devices[i].device_id, "mdl");
 
303
                      name = g_strcanon (name, ALLOWED_CHARACTERS, '-');
 
304
                    }
 
305
                  else if (pp->devices[i].device_info)
 
306
                    {
 
307
                      name = g_strdup (pp->devices[i].device_info);
 
308
                      name = g_strcanon (name, ALLOWED_CHARACTERS, '-');
 
309
                    }
 
310
 
 
311
                  pp->devices[i].display_name = name;
 
312
                }
 
313
 
 
314
              /* Set show bool
 
315
               * Don't show duplicates.
 
316
               * Show devices with device-id.
 
317
               * Other preferences should apply here.
 
318
               */
 
319
              for (i = 0; i < pp->num_devices; i++)
 
320
                {
 
321
                  for (j = 0; j < pp->num_devices; j++)
 
322
                    {
 
323
                      if (i != j)
322
324
                        {
323
 
                          if (pp->devices[i].device_id && !pp->devices[j].show)
 
325
                          if (g_strcmp0 (pp->devices[i].display_name, pp->devices[j].display_name) == 0)
324
326
                            {
325
 
                              pp->devices[i].show = TRUE;
 
327
                              if (pp->devices[i].device_id && !pp->devices[j].show)
 
328
                                {
 
329
                                  pp->devices[i].show = TRUE;
 
330
                                }
326
331
                            }
327
332
                        }
328
333
                    }
329
334
                }
330
335
            }
331
 
        }
332
 
 
333
 
      g_hash_table_destroy (devices);
334
 
      actualize_devices_list (pp);
 
336
 
 
337
          g_hash_table_destroy (devices);
 
338
          actualize_devices_list (pp);
 
339
        }
 
340
 
 
341
      widget = (GtkWidget*)
 
342
        gtk_builder_get_object (pp->builder, "get-devices-status-label");
 
343
      gtk_label_set_text (GTK_LABEL (widget), " ");
 
344
 
 
345
      widget = (GtkWidget*)
 
346
        gtk_builder_get_object (pp->builder, "spinner");
 
347
      gtk_spinner_stop (GTK_SPINNER (widget));
 
348
      gtk_widget_set_sensitive (widget, FALSE);
 
349
 
 
350
      if (pp->cancellable != NULL)
 
351
        {
 
352
          g_object_unref (pp->cancellable);
 
353
          pp->cancellable = NULL;
 
354
        }
 
355
 
 
356
      g_clear_error (&error);
335
357
    }
336
 
 
337
 
  widget = (GtkWidget*)
338
 
    gtk_builder_get_object (pp->builder, "get-devices-status-label");
339
 
  gtk_label_set_text (GTK_LABEL (widget), " ");
340
 
 
341
 
  widget = (GtkWidget*)
342
 
    gtk_builder_get_object (pp->builder, "spinner");
343
 
  gtk_spinner_stop (GTK_SPINNER (widget));
344
 
  gtk_widget_set_sensitive (widget, FALSE);
345
 
 
346
 
  g_clear_error (&error);
347
358
}
348
359
 
349
360
static void
385
396
      gtk_spinner_start (GTK_SPINNER (widget));
386
397
      gtk_widget_set_sensitive (widget, TRUE);
387
398
 
 
399
      pp->cancellable = g_cancellable_new ();
 
400
 
388
401
      g_dbus_proxy_call (proxy,
389
402
                         "DevicesGet",
390
403
                         dg_input,
391
404
                         G_DBUS_CALL_FLAGS_NONE,
392
405
                         60000,
393
 
                         NULL,
 
406
                         pp->cancellable,
394
407
                         devices_get_cb,
395
408
                         pp);
396
409
 
731
744
  GtkTreeModel       *model;
732
745
  GtkTreeIter         iter;
733
746
  GtkWidget          *treeview;
 
747
  gboolean            success = FALSE;
734
748
  gchar              *device_name = NULL;
735
749
  gchar              *ppd_name = NULL;
736
750
  gint                device_id = -1;
737
751
  gint                device_type = -1;
 
752
  gint                i, j, k;
738
753
 
739
754
  treeview = (GtkWidget*)
740
755
    gtk_builder_get_object (pp->builder, "device-types-treeview");
821
836
                          g_clear_error (&error);
822
837
                        }
823
838
                      else
824
 
                        {
825
 
                          ret_error = NULL;
826
 
 
827
 
                          dbus_g_proxy_call (proxy, "PrinterSetAcceptJobs", &error,
828
 
                                             G_TYPE_STRING, pp->devices[device_id].display_name,
829
 
                                             G_TYPE_BOOLEAN, TRUE,
830
 
                                             G_TYPE_STRING, NULL,
831
 
                                             G_TYPE_INVALID,
832
 
                                             G_TYPE_STRING, &ret_error,
833
 
                                             G_TYPE_INVALID);
834
 
 
835
 
                          dbus_g_proxy_call (proxy, "PrinterSetEnabled", &error,
836
 
                                             G_TYPE_STRING, pp->devices[device_id].display_name,
837
 
                                             G_TYPE_BOOLEAN, TRUE,
838
 
                                             G_TYPE_INVALID,
839
 
                                             G_TYPE_STRING, &ret_error,
840
 
                                             G_TYPE_INVALID);
841
 
 
842
 
                          if (error || (ret_error && ret_error[0] != '\0'))
843
 
                            {
844
 
                              if (error)
845
 
                                g_warning ("%s", error->message);
846
 
 
847
 
                              if (ret_error && ret_error[0] != '\0')
848
 
                                g_warning ("%s", ret_error);
849
 
 
850
 
                              g_clear_error (&error);
851
 
                            }
852
 
                          else
853
 
                            {
854
 
                              if (g_strcmp0 (pp->devices[device_id].device_class, "direct") == 0)
855
 
                                {
856
 
                                  gchar *commands = get_dest_attr (pp->devices[device_id].display_name, "printer-commands");
857
 
                                  gchar *commands_lowercase = g_ascii_strdown (commands, -1);
858
 
                                  ipp_t *response = NULL;
859
 
 
860
 
                                  if (g_strrstr (commands_lowercase, "AutoConfigure"))
861
 
                                    {
862
 
                                      response = execute_maintenance_command (pp->devices[device_id].display_name,
863
 
                                                                              "AutoConfigure",
864
 
                                      /* Translators: Name of job which makes printer to autoconfigure itself */
865
 
                                                                              _("Automatic configuration"));
866
 
                                      if (response)
867
 
                                        {
868
 
                                          if (response->state == IPP_ERROR)
869
 
                                          /* Translators: An error has occured during execution of AutoConfigure CUPS maintenance command */
870
 
                                            g_warning ("An error has occured during automatic configuration of new printer.");
871
 
                                          ippDelete (response);
872
 
                                        }
873
 
                                    }
874
 
                                  g_free (commands);
875
 
                                  g_free (commands_lowercase);
876
 
                                }
877
 
                            }
878
 
                        }
 
839
                        success = TRUE;
 
840
 
879
841
                      g_object_unref (proxy);
880
842
                    }
881
843
 
989
951
                      g_clear_error (&error);
990
952
                    }
991
953
                  else
 
954
                    success = TRUE;
 
955
 
 
956
                  g_object_unref (proxy);
 
957
                }
 
958
            }
 
959
        }
 
960
 
 
961
      /* Set some options of the new printer */
 
962
      if (success)
 
963
        {
 
964
          DBusGProxy *proxy;
 
965
          GError     *error = NULL;
 
966
          char       *ret_error = NULL;
 
967
          char       *locale = NULL;
 
968
 
 
969
          proxy = get_dbus_proxy (MECHANISM_BUS,
 
970
                                  "/",
 
971
                                  MECHANISM_BUS,
 
972
                                  TRUE);
 
973
 
 
974
          if (proxy)
 
975
            {
 
976
              dbus_g_proxy_call (proxy, "PrinterSetAcceptJobs", &error,
 
977
                                 G_TYPE_STRING, pp->devices[device_id].display_name,
 
978
                                 G_TYPE_BOOLEAN, TRUE,
 
979
                                 G_TYPE_STRING, NULL,
 
980
                                 G_TYPE_INVALID,
 
981
                                 G_TYPE_STRING, &ret_error,
 
982
                                 G_TYPE_INVALID);
 
983
 
 
984
              if (error)
 
985
                {
 
986
                  g_warning ("%s", error->message);
 
987
                  g_clear_error (&error);
 
988
                }
 
989
 
 
990
              if (ret_error && ret_error[0] != '\0')
 
991
                g_warning ("%s", ret_error);
 
992
 
 
993
 
 
994
              dbus_g_proxy_call (proxy, "PrinterSetEnabled", &error,
 
995
                                 G_TYPE_STRING, pp->devices[device_id].display_name,
 
996
                                 G_TYPE_BOOLEAN, TRUE,
 
997
                                 G_TYPE_INVALID,
 
998
                                 G_TYPE_STRING, &ret_error,
 
999
                                 G_TYPE_INVALID);
 
1000
 
 
1001
              if (error)
 
1002
                {
 
1003
                  g_warning ("%s", error->message);
 
1004
                  g_clear_error (&error);
 
1005
                }
 
1006
 
 
1007
              if (ret_error && ret_error[0] != '\0')
 
1008
                g_warning ("%s", ret_error);
 
1009
 
 
1010
 
 
1011
              if (g_strcmp0 (pp->devices[device_id].device_class, "direct") == 0)
 
1012
                {
 
1013
                  gchar *commands = get_dest_attr (pp->devices[device_id].display_name, "printer-commands");
 
1014
                  gchar *commands_lowercase = g_ascii_strdown (commands, -1);
 
1015
                  ipp_t *response = NULL;
 
1016
 
 
1017
                  if (g_strrstr (commands_lowercase, "AutoConfigure"))
992
1018
                    {
993
 
                      ret_error = NULL;
994
 
 
995
 
                      dbus_g_proxy_call (proxy, "PrinterSetAcceptJobs", &error,
996
 
                                         G_TYPE_STRING, pp->devices[device_id].display_name,
997
 
                                         G_TYPE_BOOLEAN, TRUE,
998
 
                                         G_TYPE_STRING, NULL,
999
 
                                         G_TYPE_INVALID,
1000
 
                                         G_TYPE_STRING, &ret_error,
1001
 
                                         G_TYPE_INVALID);
1002
 
 
1003
 
                      dbus_g_proxy_call (proxy, "PrinterSetEnabled", &error,
1004
 
                                         G_TYPE_STRING, pp->devices[device_id].display_name,
1005
 
                                         G_TYPE_BOOLEAN, TRUE,
1006
 
                                         G_TYPE_INVALID,
1007
 
                                         G_TYPE_STRING, &ret_error,
1008
 
                                         G_TYPE_INVALID);
1009
 
 
1010
 
                      if (error || (ret_error && ret_error[0] != '\0'))
 
1019
                      response = execute_maintenance_command (pp->devices[device_id].display_name,
 
1020
                                                              "AutoConfigure",
 
1021
                      /* Translators: Name of job which makes printer to autoconfigure itself */
 
1022
                                                              _("Automatic configuration"));
 
1023
                      if (response)
1011
1024
                        {
1012
 
                          if (error)
1013
 
                            g_warning ("%s", error->message);
1014
 
 
1015
 
                          if (ret_error && ret_error[0] != '\0')
1016
 
                            g_warning ("%s", ret_error);
1017
 
 
1018
 
                          g_clear_error (&error);
 
1025
                          if (response->state == IPP_ERROR)
 
1026
                            g_warning ("An error has occured during automatic configuration of new printer.");
 
1027
                          ippDelete (response);
1019
1028
                        }
1020
 
                      else
 
1029
                    }
 
1030
                  g_free (commands);
 
1031
                  g_free (commands_lowercase);
 
1032
                }
 
1033
 
 
1034
 
 
1035
              /* Set default PaperSize according to the locale */
 
1036
              locale = setlocale (LC_PAPER, NULL);
 
1037
              if (locale == NULL)
 
1038
                locale = setlocale (LC_MESSAGES, NULL);
 
1039
 
 
1040
              if (locale)
 
1041
                {
 
1042
                  const char  *ppd_file_name = NULL;
 
1043
                  ppd_file_t  *ppd_file = NULL;
 
1044
                  gchar      **value = NULL;
 
1045
                  gchar       *paper_size;
 
1046
 
 
1047
                  /* CLDR 2.0 alpha
 
1048
                   * http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/territory_language_information.html
 
1049
                   */
 
1050
                  if (g_regex_match_simple ("[^_.@]{2,3}_(BZ|CA|CL|CO|CR|GT|MX|NI|PA|PH|PR|SV|US|VE)",
 
1051
                                            locale, G_REGEX_ANCHORED, G_REGEX_MATCH_ANCHORED))
 
1052
                    paper_size = g_strdup ("Letter");
 
1053
                  else
 
1054
                    paper_size = g_strdup ("A4");
 
1055
 
 
1056
                  ppd_file_name = cupsGetPPD (pp->devices[device_id].display_name);
 
1057
                  if (ppd_file_name)
 
1058
                    {
 
1059
                      ppd_file = ppdOpenFile (ppd_file_name);
 
1060
                      if (ppd_file)
1021
1061
                        {
1022
 
                          if (g_strcmp0 (pp->devices[device_id].device_class, "direct") == 0)
1023
 
                            {
1024
 
                              gchar *commands = get_dest_attr (pp->devices[device_id].display_name, "printer-commands");
1025
 
                              gchar *commands_lowercase = g_ascii_strdown (commands, -1);
1026
 
                              ipp_t *response = NULL;
1027
 
 
1028
 
                              if (g_strrstr (commands_lowercase, "AutoConfigure"))
 
1062
                          ppdMarkDefaults (ppd_file);
 
1063
                          for (i = 0; i < ppd_file->num_groups; i++)
 
1064
                            for (j = 0; j < ppd_file->groups[i].num_options; j++)
 
1065
                              if (g_strcmp0 ("PageSize", ppd_file->groups[i].options[j].keyword) == 0)
1029
1066
                                {
1030
 
                                  response = execute_maintenance_command (pp->devices[device_id].display_name,
1031
 
                                                                          "AutoConfigure",
1032
 
                                  /* Translators: Name of job which makes printer to autoconfigure itself */
1033
 
                                                                          _("Automatic configuration"));
1034
 
                                  if (response)
 
1067
                                  for (k = 0; k < ppd_file->groups[i].options[j].num_choices; k++)
1035
1068
                                    {
1036
 
                                      if (response->state == IPP_ERROR)
1037
 
                                      /* Translators: An error has occured during execution of AutoConfigure CUPS maintenance command */
1038
 
                                        g_warning ("An error has occured during automatic configuration of new printer.");
1039
 
                                      ippDelete (response);
 
1069
                                      if (g_ascii_strncasecmp (paper_size,
 
1070
                                                               ppd_file->groups[i].options[j].choices[k].choice,
 
1071
                                                               strlen (paper_size)) == 0 &&
 
1072
                                          !ppd_file->groups[i].options[j].choices[k].marked)
 
1073
                                        {
 
1074
                                          value = g_new0 (gchar *, 2);
 
1075
                                          value[0] = g_strdup (ppd_file->groups[i].options[j].choices[k].choice);
 
1076
                                          break;
 
1077
                                        }
1040
1078
                                    }
 
1079
                                  break;
1041
1080
                                }
1042
 
                              g_free (commands);
1043
 
                              g_free (commands_lowercase);
1044
 
                            }
1045
 
                        }
1046
 
                    }
1047
 
                  g_object_unref (proxy);
 
1081
                          ppdClose (ppd_file);
 
1082
                        }
 
1083
                      g_unlink (ppd_file_name);
 
1084
                    }
 
1085
 
 
1086
                  if (value)
 
1087
                    {
 
1088
                      dbus_g_proxy_call (proxy, "PrinterAddOptionDefault", &error,
 
1089
                                         G_TYPE_STRING, pp->devices[device_id].display_name,
 
1090
                                         G_TYPE_STRING, "PageSize-default",
 
1091
                                         G_TYPE_STRV, value,
 
1092
                                         G_TYPE_INVALID,
 
1093
                                         G_TYPE_STRING, &ret_error,
 
1094
                                         G_TYPE_INVALID);
 
1095
 
 
1096
                      if (error)
 
1097
                        {
 
1098
                          g_warning ("%s", error->message);
 
1099
                          g_clear_error (&error);
 
1100
                        }
 
1101
 
 
1102
                      if (ret_error && ret_error[0] != '\0')
 
1103
                        g_warning ("%s", ret_error);
 
1104
 
 
1105
                      g_strfreev (value);
 
1106
                    }
 
1107
                  g_free (paper_size);
1048
1108
                }
 
1109
              g_object_unref (proxy);
1049
1110
            }
1050
1111
        }
1051
1112
    }
1101
1162
  pp->user_callback = user_callback;
1102
1163
  pp->user_data = user_data;
1103
1164
 
 
1165
  pp->cancellable = NULL;
 
1166
 
1104
1167
  /* connect signals */
1105
1168
  g_signal_connect (pp->dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
1106
1169
 
1145
1208
  g_object_unref (pp->builder);
1146
1209
  pp->builder = NULL;
1147
1210
 
 
1211
  if (pp->cancellable)
 
1212
    {
 
1213
      g_cancellable_cancel (pp->cancellable);
 
1214
      g_object_unref (pp->cancellable);
 
1215
    }
 
1216
 
1148
1217
  g_free (pp);
1149
1218
}
1150
1219