[gnome-control-center] printers: Use g_error_matches where appropriate



commit fb09d9c090218aa5309388a793603733264d5f60
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue Jun 26 10:48:46 2018 +1200

    printers: Use g_error_matches where appropriate

 panels/printers/pp-new-printer-dialog.c | 25 +++++++--------------
 panels/printers/pp-new-printer.c        | 39 ++++++++++-----------------------
 panels/printers/pp-utils.c              | 11 +++++-----
 3 files changed, 25 insertions(+), 50 deletions(-)
---
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index 77576d529..3bf4a7368 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -1033,14 +1033,11 @@ DBus method \"GroupPhysicalDevices\" to group duplicates in device list.");
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
     }
 
-  if (!error ||
-      error->domain != G_IO_ERROR ||
-      error->code != G_IO_ERROR_CANCELLED)
+  if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
     group_physical_devices_cb (result, user_data);
 }
 
@@ -1228,8 +1225,7 @@ get_snmp_devices_cb (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         {
           dialog = PP_NEW_PRINTER_DIALOG (user_data);
           priv = dialog->priv;
@@ -1274,8 +1270,7 @@ get_remote_cups_devices_cb (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         {
           dialog = PP_NEW_PRINTER_DIALOG (user_data);
           priv = dialog->priv;
@@ -1320,8 +1315,7 @@ get_samba_host_devices_cb (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         {
           dialog = PP_NEW_PRINTER_DIALOG (user_data);
           priv = dialog->priv;
@@ -1365,8 +1359,7 @@ get_samba_devices_cb (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         {
           dialog = PP_NEW_PRINTER_DIALOG (user_data);
           priv = dialog->priv;
@@ -1948,8 +1941,7 @@ cups_get_dests_cb (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         {
           dialog = PP_NEW_PRINTER_DIALOG (user_data);
 
@@ -2126,8 +2118,7 @@ printer_add_async_cb (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         {
           dialog = PP_NEW_PRINTER_DIALOG (user_data);
 
diff --git a/panels/printers/pp-new-printer.c b/panels/printers/pp-new-printer.c
index 3c144c1f0..8b037f836 100644
--- a/panels/printers/pp-new-printer.c
+++ b/panels/printers/pp-new-printer.c
@@ -426,14 +426,11 @@ printer_add_real_async_dbus_cb (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
     }
 
-  if (!error ||
-      error->domain != G_IO_ERROR ||
-      error->code != G_IO_ERROR_CANCELLED)
+  if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
     {
       get_named_dest_async (priv->name,
                             printer_add_real_async_cb,
@@ -564,14 +561,11 @@ printer_add_async_scb3 (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
     }
 
-  if ((!error ||
-      error->domain != G_IO_ERROR ||
-      error->code != G_IO_ERROR_CANCELLED) &&
+  if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) &&
       ppd_item && ppd_item->ppd_name)
     {
       priv->ppd_name = g_strdup (ppd_item->ppd_name);
@@ -610,14 +604,11 @@ install_printer_drivers_cb (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
     }
 
-  if (!error ||
-      error->domain != G_IO_ERROR ||
-      error->code != G_IO_ERROR_CANCELLED)
+  if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
     {
       GDBusConnection  *bus;
       g_autoptr(GError) bus_error = NULL;
@@ -837,8 +828,7 @@ printer_set_accepting_jobs_cb (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
     }
 
@@ -866,8 +856,7 @@ printer_set_enabled_cb (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
     }
 
@@ -937,8 +926,7 @@ install_package_names_cb (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
     }
 
@@ -975,8 +963,7 @@ search_files_cb (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
     }
 
@@ -1100,8 +1087,7 @@ DBus method \"MissingExecutables\" to find missing executables and filters.");
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
     }
 
@@ -1197,8 +1183,7 @@ pp_maintenance_command_execute_cb (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         {
           data = (PCData *) user_data;
 
diff --git a/panels/printers/pp-utils.c b/panels/printers/pp-utils.c
index f677a38c9..c0814444e 100644
--- a/panels/printers/pp-utils.c
+++ b/panels/printers/pp-utils.c
@@ -1499,7 +1499,7 @@ printer_set_ppd_async_dbus_cb (GObject      *source_object,
     }
   else
     {
-      if (error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
     }
 
@@ -1993,7 +1993,7 @@ get_ppd_names_async_dbus_scb (GObject      *source_object,
     }
   else
     {
-      if (error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
     }
 
@@ -2264,7 +2264,7 @@ get_device_attributes_async_dbus_cb (GObject      *source_object,
     }
   else
     {
-      if (error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
     }
 
@@ -3232,7 +3232,7 @@ printer_add_option_async_dbus_cb (GObject      *source_object,
     }
   else
     {
-      if (error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
     }
 
@@ -3437,8 +3437,7 @@ get_cups_devices_async_dbus_cb (GObject      *source_object,
     }
   else
     {
-      if (error->domain != G_IO_ERROR ||
-          error->code != G_IO_ERROR_CANCELLED)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
 
       data->callback (result,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]