Commit graph gtk2-ng/modules/printbackends
Author SHA1 Message Date
d9437da8dd cups: the request flags as unsigned bit-fields
A gint of one bit holds 0 and -1, so TRUE did not fit.
2026-10-19 14:48:45 +02:00
de123d8ed5 print: PPD translations and print-to-file fixes from GTK 3
Backported from GTK 3:

- PPD options in the language of the user
- Print to File writes to Documents and adds to recent files
- the scale is applied after rotation and margins
- cancel stops a preview
- conflicts are checked for a new printer
- option widgets let go of their option
- radio options take their mnemonic

Upstream commits:

- 97ee5efb4b (Matthias Clasen)
- c85c3510e7 (Leo Wolf)
- 2c1839ae5f (Marek Kasik)
- d80953666e (Morten Welinder)
- ad764c8a58 (Alban Browaeys)
- f682aabf74 (Siegfried Gevatter (RainCT))
- 0fe9e481dd (Marek Kasik)
- da85312097 (Marek Kasik)
2026-10-18 10:18:40 +02:00
6eedf81e1e print: callback, title and driver fixes from GTK 3
Backported from GTK 3:

- a printer list callback stops when a handler destroys the backend
- CUPS job titles are cut to 255 bytes at a character boundary
- a second source file no longer leaks the first
- Windows driver settings stay with their printer

Upstream commits:

- 255225584e (Carlos Garcia Campos)
- 446659e80f (Rick Yorgason)
- 0387486407 (Marek Kasik)
- 90950b2d3d (Marek Kasik)
2026-10-18 10:18:40 +02:00
a1dec5205d cups: fix connection and request leaks
A connection and a request leaked with every job, a borrowed connection
was closed twice, and the TXT records of network printers weren't
freed. Avahi requests close their own connections now.

Upstream commits:

- 118b09c68c (Marek Kasik)
- 083f834dd7 (Marek Kasik)
- 9513d3b2a4 (Marek Kasik)
2026-10-18 10:18:40 +02:00
9caeed54ad cups: option, Kerberos and leak fixes from GTK 3
Backported from GTK 3:

- custom option values are checked before use
- Kerberos printers no longer ask for a password
- options of printer instances stay with the instance
- a resolution from the settings wins
- printer references no longer leak

Upstream commits:

- b9e91b9419 (Till Kamppeter)
- 9a0700e20c (Marek Kasik)
- e99e282b5a (Andre Heinecke)
- 315bb30220 (Matthias Clasen)
- 36effbb307 (Timothy Arceri)
2026-10-18 10:18:40 +02:00
11b04da889 cups: store job passwords in the keyring like GTK 3
Based on GTK 3 commit 382d68ff8e by Andre Heinecke.
2026-10-18 10:18:40 +02:00
cd6e01acde cups: don't leak the entered password 2026-10-17 23:59:00 +02:00
b31c0210e0 cups: get the document size without fstat() 2026-10-17 13:51:50 +02:00
d86aabf1f6 gtk: correct current time after 2038 with 32-bit time_t
Recent item ages, Today/Yesterday in the file chooser, the calendar
and the CUPS print time. Uses clock_gettime64 on Linux.
2026-10-17 13:51:50 +02:00
22e603ee99 cups: compute the UTC print time without time()
This also fixes zones with quarter hours like Nepal, which came out an
hour wrong.
2026-10-17 12:17:32 +02:00
8deebb25ac print: end the job with an error when writing fails
All backends used to loop forever on a failed write.

Backported from GTK 3 commit 2adacca119 by Carlos Garcia Campos.
2026-10-15 17:06:32 +02:00
d1ad63a098 headers: don't mark _get_type and _quark functions const
They register types as a side effect, and newer compilers drop calls
whose result isn't used.

The same change as GTK 3 commit f30efa7759 by Matthias Clasen.
2026-10-15 09:53:23 +02:00
d0c4346396 cups: use modern HTTP connection helpers when available
Detect httpConnect2 and httpReconnect2 at configure time.

Preserve blocking, encryption, timeout and reconnect semantics while retaining the legacy CUPS APIs as compile-time fallbacks.
2026-08-07 08:53:00 +02:00
42a31c8576 Clean up trailing whitespace 2026-05-03 15:16:52 +02:00
a1ab76063d lpr: mark backend printer as accepting PDF and PostScript
Construct the LPR printer with explicit is-virtual, accepts-pdf and
accepts-ps properties so the backend advertises the formats it can
handle.

This follows the GTK2 LPR backend fix referenced by OpenBSD ports and
GNOME, using GTK2's GtkPrinter:is-virtual property name and keeping the
printer non-virtual as in the referenced patch.

Make sure to enable the LPR print backend when using this feature, for
example by setting gtk-print-backends in the user's GTK2 rc file:

    gtk-print-backends = "file,cups,lpr"

For normal application startup, put this setting in ~/.gtkrc-2.0 so GTK2
applications pick it up automatically.

Ported-from: OpenBSD ports x11/gtk+2 patch-modules_printbackends_lpr_gtkprintbackendlpr_c
2026-04-30 11:28:48 +02:00
81b9e0200f build: replace deprecated INCLUDES with AM_CPPFLAGS 2026-04-28 21:14:00 +02:00
744ce7c22f Fix assorted non-deprecation compiler warnings 2026-04-24 20:58:49 +02:00
932bc82675 Fix compiler warnings and deprecated API usage 2026-04-24 15:29:59 +02:00
d77875c0af Y2038 safety: internal timestamp modernization 2026-04-23 10:18:55 +02:00
71b1ab5e77 Fix build issues on modern compilers
Resolve multiple compiler errors and warnings found on current toolchains.

Changes include:
- explicit type casts for subtype/base assignments
- legacy prototype cleanup
- test source fixes
- gail and CUPS backend build fixes

Restores successful compilation on current Linux systems.
2026-04-20 18:08:34 +02:00
Ivan Zakharyaschev
7461ceebe3 gtkprintbackendcups.c: fix \n at end of a debugging note 2018-02-17 20:19:33 +03:00
Marek Kasik
d63bee09e0 printing: Check connection to remote CUPS server on correct port
Add parameter for specification of port to gtk_cups_connection_cups_new().
Use default port returned by ippPort() if the given port is lower than 0.

https://bugzilla.gnome.org/show_bug.cgi?id=693738
2015-05-13 12:27:44 +02:00
John Ralls
825e035833 Bug 729924 - Crash trying to print in OSX 2014-08-03 11:53:43 +02:00
Marek Kasik
378ea9029f printing: Fail nicely when /tmp is not writable
Don't crash when /tmp is not writable when printing to file.
Show that getting of printer details failed for CUPS printers.

https://bugzilla.gnome.org/show_bug.cgi?id=693200
2014-03-18 16:02:04 +01:00
Marek Kasik
e84bb08ded printing: Don't crash because of missing g_clear_pointer()
g_clear_pointer() is not available in glib-2.28 which is minimal
required version for gtk+-2.24.

https://bugzilla.gnome.org/show_bug.cgi?id=708783
2014-03-12 23:47:28 -04:00
Marek Kasik
a057ed26dc printing: List Avahi printers
Show printers advertised by avahi on local network. CUPS
backend now looks for _ipps._tcp and _ipp._tcp services
offered by avahi. If it finds such a service (printer)
it requests its attributes through IPP_GET_PRINTER_ATTRIBUTES
ipp request and adds it to the list of printers. Such printer
behaves like a remote printer then.
If an avahi printer is a default printer then it is considered
default by the backend only if there is no local or remote
default printer.
This functionality is enabled when building Gtk+ with CUPS 1.6
or later because it replaces browsing protocol removed in CUPS 1.6.

https://bugzilla.gnome.org/show_bug.cgi?id=702455
2013-06-25 14:43:43 +02:00
Marek Kasik
7b5e7a72fc printing: Show correct status of a job
"job-state" is IPP_TAG_ENUM not IPP_TAG_INTEGER.
2013-06-06 11:14:21 +02:00
Christophe Fergeau
3acacc0384 Sanitize memory handling in cups_request_printer_list_cb
gtk+ was trying to display already freed strings, leaking memory,
...I noticed this because I was getting weird blinking characters
as the status of my cups printers, and valgrind confirmed something
was wrong.

https://bugzilla.gnome.org/show_bug.cgi?id=683072
2013-04-08 11:15:50 +02:00
Jan Rękorajski
85825ebaf2 print dialog: Fix authentication logic
Reset state of CUPS requests correctly during authentization and
check CUPS requests for errors.
Don't initialize variables holding password and username with empty
string (#664640).
2013-01-18 14:29:53 +01:00
Marek Kasik
d9f9925878 printing: Add "Custom." prefix only once to paper size
Check whether "Custom." prefix is already present in the name
of selected paper size. (#679883)
(cherry picked from commit be7752183eb07274b67036362f895b31aa28eb25)
2012-12-16 19:17:45 +01:00
John Ralls
63f6e92001 modules/printing/cups/gtkprintbackendcups.c won't build with CUPS 1.6
Fix up accesses of ipp structures in gtkcupsutils.c
2012-04-23 14:50:01 -07:00
John Ralls
75103b62e5 modules/printing/cups/gtkprintbackendcups.c won't build with CUPS 1.6
Having refactored cups_request_printer_list_cb so that the cups
 version-dependent block size is small enough to be handled in a single
 ifdef, make the ifdef HAVE_CUPS_API_1_6 block
2012-04-23 14:49:47 -07:00
John Ralls
7d2725e400 Move some variable declarations into the scopes in which they're used. 2012-04-23 14:49:25 -07:00
John Ralls
b7d59f73db Extract Function cups_create_printer 2012-04-23 14:48:52 -07:00
John Ralls
0d1edac55b Extract function cups_printer_handle_attribute 2012-04-23 14:48:39 -07:00
John Ralls
61dd746d51 Extract printer setup variables into a struct
So that it can be passed as a single parameter to functions as we
extract-function to make cups_request_printer_list_cb more manageable.

Note that not all of the affected variables are changed in this
changeset. Those are in extracted functions and will be addressed in the
next two changes.
2012-04-23 14:48:25 -07:00
John Ralls
399f31021c Create enum PrinterStateLevel
Fixes "magic number" in printer_state_reason_level.
2012-04-23 14:47:33 -07:00
John Ralls
3100279bf1 Extract reasons and reasons_desc arrays to file level
So that they can be used from more than one function. Rename them to
avoid naming conflicts.
2012-04-23 14:47:15 -07:00
John Ralls
0883b09086 modules/printing/cups/gtkprintbackendcups.c won't build with CUPS 1.6
The first, simple changes. Turns off the deprecation warnings and
 substitutes macros and short ifdef blocks where feasible.
2012-04-23 14:46:54 -07:00
Marek Kasik
66c99016d3 printing: Don't crash when printing
This commit fixes crash which occurs in Firefox, Thunderbird and Inkscape
during printing. This crash was caused because of wrong handling of Custom
CUPS options. (#543520)
2012-01-31 12:01:43 +01:00
Benjamin Berg
85099bf6a6 Strip "Custom." prefix when getting default options from cups. 2012-01-17 20:34:42 +01:00
Benjamin Berg
8170436e61 Set cups Custom print options correctly (bug #543520, patch by Marek Kašík)
This patch fixes the cups print backend to pass Custom options with
the "Custom." prefix to cups if neccessary.
2012-01-06 00:18:37 +01:00
Benjamin Berg
f0726904cb Fix polling for new data in cups print backend (bug #599664) 2011-08-06 10:40:36 +02:00
Matthias Clasen
ed4605e597 cups printbackend: create a pdf surface when appropriate
This should address bug 560177.
Based on a patch by Adrian Johnson.
2011-01-06 12:53:03 -05:00
Adrian Johnson
0c6d327a25 Set file GtkPrinter accepts_pdf/ps based on selected format 2011-01-06 12:52:17 -05:00
Adrian Johnson
7de568a2ae Set "accepts-pdf" property to true only if supported by the print backend 2011-01-06 12:52:09 -05:00
Benjamin Otte
9e91b6557a cups: Add hack to work around gcc warning
gcc warns if you switch on values that are not part of the enum you're
switching on. So handle those cases in the default handler by using if
statments.

PS: Someone file a bug against cups about this?
2010-11-18 17:45:14 +01:00
Marek Kasik
5045337162 Parse lpoptions correctly
Parse options job-sheets, job-hold-until and sides correctly.
Add get_lpoption_name() for translation of lpoption names to
gtk option names. Usable for options which values don't need
conversion (e.g. number-up, number-up-layout, job-billing
and job-priority).
Rename array option_names to ppd_option_names to reflect its
purpose better. Rename get_option_name() to get_ppd_option_name()
because of the same reason.
(cherry picked from commit 95e69afea83e6a43163a3c2b0d2928c9e646b77b)
2010-10-16 01:11:44 -04:00
Philip Withnall
818ef9aaf6 Miscellaneous string fixes
Mostly capitalisation fixes. Closes: bgo#528257
2010-08-29 19:05:26 +01:00
Benjamin Otte
53cf3d2edc cups: Fix cast warnings 2010-08-07 15:35:50 +02:00