[gnome-settings-daemon] Ignore 'Printer-added' notifications for queues created by cups-browsed



commit 5574f6ee1ce9a45b96ea9da6ec33b55b6dd9a37d
Author: Zdenek Dohnal <zdohnal redhat com>
Date:   Tue Jun 23 13:52:31 2020 +0200

    Ignore 'Printer-added' notifications for queues created by cups-browsed

 .../gsd-print-notifications-manager.c              | 31 +++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
---
diff --git a/plugins/print-notifications/gsd-print-notifications-manager.c 
b/plugins/print-notifications/gsd-print-notifications-manager.c
index 395fdd7c..4e0b3ab1 100644
--- a/plugins/print-notifications/gsd-print-notifications-manager.c
+++ b/plugins/print-notifications/gsd-print-notifications-manager.c
@@ -146,6 +146,34 @@ get_dest_attr (const char *dest_name,
         return ret;
 }
 
+static gboolean
+is_cupsbrowsed_dest (const char *name)
+{
+        const char  *val = NULL;
+        gboolean     is_cupsbrowsed = FALSE;
+        cups_dest_t *found_dest = NULL;
+
+        found_dest = cupsGetNamedDest (CUPS_HTTP_DEFAULT, name, NULL);
+        if (found_dest == NULL) {
+                goto out;
+        }
+
+        val = cupsGetOption ("cups-browsed", found_dest->num_options, found_dest->options);
+        if (val == NULL) {
+                goto out;
+        }
+
+        if (g_str_equal (val, "yes") || g_str_equal (val, "on") || g_str_equal (val, "true")) {
+                is_cupsbrowsed = TRUE;
+        }
+out:
+        if (found_dest != NULL) {
+                cupsFreeDests (1, found_dest);
+        }
+
+        return is_cupsbrowsed;
+}
+
 static gboolean
 is_local_dest (const char  *name,
                cups_dest_t *dests,
@@ -665,7 +693,8 @@ process_cups_notification (GsdPrintNotificationsManager *manager,
 
                 if (is_local_dest (printer_name,
                                    manager->dests,
-                                   manager->num_dests)) {
+                                   manager->num_dests) &&
+                    !is_cupsbrowsed_dest (printer_name)) {
                         /* Translators: New printer has been added */
                         primary_text = g_strdup (_("Printer added"));
                         secondary_text = g_strdup (printer_name);


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