Fix dialog-less printing

We were sometimes ending printer enumeration prematurely,
and the code was confused about the meaning of found_printer.

The new setup follows these rules:
- We *only* end the search prematurely if found_printer
  is set, which indicates that we found the right printer
- We *always* call find_printer_idle exactly once, and
  make it return less than perfect matches like the
  default printer, or the first printer we found

Fixes: #4439
This commit is contained in:
Matthias Clasen 2021-11-30 22:07:02 -05:00
parent 935c6aade0
commit c6a68f3de2

View File

@ -1112,8 +1112,10 @@ printer_added_cb (GtkPrintBackend *backend,
finder->found_printer = TRUE;
}
else
if (finder->first_printer == NULL)
finder->first_printer = g_object_ref (printer);
{
if (finder->first_printer == NULL)
finder->first_printer = g_object_ref (printer);
}
if (finder->found_printer)
g_idle_add (find_printer_idle, finder);
@ -1131,7 +1133,7 @@ printer_list_done_cb (GtkPrintBackend *backend,
gtk_print_backend_destroy (backend);
g_object_unref (backend);
if (finder->backends == NULL && !finder->found_printer)
if (finder->backends == NULL)
g_idle_add (find_printer_idle, finder);
}
@ -1228,10 +1230,8 @@ find_printer (const char *printer,
find_printer_init (finder, GTK_PRINT_BACKEND (node->data));
}
if (finder->backends == NULL && !finder->found_printer)
if (finder->backends == NULL)
g_idle_add (find_printer_idle, finder);
else
printer_finder_free (finder);
}