]> Pileus Git - ~andy/gtk/blobdiff - modules/printbackends/cups/gtkprintercups.c
printing: List Avahi printers
[~andy/gtk] / modules / printbackends / cups / gtkprintercups.c
index 128b3b38542c0d7b6dd0e304fbddedadfdbcbc39..f2adb0ce5b0225253c0507aee25c9e80da747d7e 100644 (file)
@@ -114,6 +114,17 @@ gtk_printer_cups_init (GtkPrinterCups *printer)
   printer->remote_cups_connection_test = NULL;
   printer->auth_info_required = NULL;
   printer->default_number_up = 1;
+#ifdef HAVE_AVAHI_BROWSING
+  printer->avahi_browsed = FALSE;
+  printer->avahi_name = NULL;
+  printer->avahi_type = NULL;
+  printer->avahi_domain = NULL;
+#endif
+  printer->ipp_version_major = 1;
+  printer->ipp_version_minor = 1;
+  printer->supports_copies = FALSE;
+  printer->supports_collate = FALSE;
+  printer->supports_number_up = FALSE;
 }
 
 static void
@@ -134,8 +145,11 @@ gtk_printer_cups_finalize (GObject *object)
   g_strfreev (printer->auth_info_required);
 
 #ifdef HAVE_COLORD
-  g_cancellable_cancel (printer->colord_cancellable);
-  g_object_unref (printer->colord_cancellable);
+  if (printer->colord_cancellable)
+    {
+      g_cancellable_cancel (printer->colord_cancellable);
+      g_object_unref (printer->colord_cancellable);
+    }
   g_free (printer->colord_title);
   g_free (printer->colord_qualifier);
   if (printer->colord_client)
@@ -146,6 +160,12 @@ gtk_printer_cups_finalize (GObject *object)
     g_object_unref (printer->colord_profile);
 #endif
 
+#ifdef HAVE_AVAHI_BROWSING
+  g_free (printer->avahi_name);
+  g_free (printer->avahi_type);
+  g_free (printer->avahi_domain);
+#endif
+
   if (printer->ppd_file)
     ppdClose (printer->ppd_file);
 
@@ -512,7 +532,8 @@ colord_printer_details_aquired_cb (GtkPrinterCups *printer,
                                    gpointer user_data)
 {
   /* refresh the device */
-  colord_update_device (printer);
+  if (printer->colord_client)
+    colord_update_device (printer);
 }
 #endif
 
@@ -565,6 +586,14 @@ gtk_printer_cups_new (const char      *name,
                       G_CALLBACK (colord_printer_details_aquired_cb),
                       printer);
 #endif
+
+  /*
+   * IPP version 1.1 has to be supported
+   * by all implementations according to rfc 2911
+   */
+  printer->ipp_version_major = 1;
+  printer->ipp_version_minor = 1;
+
   return printer;
 }