GNOME Bugzilla – Bug 345590
get the printer's backend
Last modified: 2018-02-10 03:28:09 UTC
What I need is a way to get the name of the print backend that a given printer uses ("file", "cups"), like this: const gchar *gtk_printer_get_backend_name (GtkPrinter *)
I needed this also, so for now I used: G_OBJECT_TYPE_NAME(gtk_printer_get_backend(printer)); Of course, I get strings like: "GtkPrintBackendCups" and "GtkPrintBackendFile"... It's not very api-like or pretty, but it's ok for now. just fyi...
... and of course, totally unsupported. Don't complain if the backends change their names or if gtk_printer_get_backend stops being exported without warning in the future. The backends are called backends for a reason... Maybe you could explain what the use case for knowing the print backend is ?
Well for Epiphany, I let gecko print to a temp file which I then hand off to gtk-print. For the "file" backend, I want to cut out the temp file and print directly to the destination filename, so I need to know that that printer is the "file" printer and then I can use the OUTPUT_URI setting. For the "cups" backend I can also bypass the temp file since gecko supports cups natively.
And for SWT (eclipse) I have 3 places that I use this. Note that we have a pre-existing "cross-platform printing" API (written in Java) that I am now going to support for GTK+. So some of what I am doing is making sure that I can deliver as much of our API as possible using yours <g>. 1) we have a "printToFile" boolean that the user can set/get before and after launching the dialog, and before and after creating a "Printer" object. I need to know whether the backend is a "file" or not in order to set this boolean. 2) I also use the backend type to decide whether or not to get the filename from the printer settings (GTK_PRINT_SETTINGS_OUTPUT_URI). 3) our users create a Printer object by passing in 2 strings: "name" and "driver". On win32, the 2 strings equate to the device name, and the driver name (typically "winspool"). For Xprint, the driver string was the Xprt server (typically ":1"). On Mac, the driver string is typically "Printer" or "File". I wanted an equivalent string for a GTK+ "driver", so I randomly grabbed the backend type string. The API requested in this bug report would be a much better solution.
We're moving to gitlab! As part of this move, we are closing bugs that haven't seen activity in more than 5 years. If this issue is still imporant to you and still relevant with GTK+ 3.22 or master, please consider creating a gitlab issue for it.