Skip to content

Commit ee94c82

Browse files
committed
print: add two new capabilities (n-copies and number-up)
Both the app and the printer may be able to do copies. If the printer can do it, then it is likely more efficient and it should not be done in the app, so the app needs to know that the printer will do it. In the print dialog, the n-copies and number-up settings must be available if either the printer or the app can do it.
1 parent c0086cb commit ee94c82

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

data/org.freedesktop.portal.Print.xml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
to print the formatted document. It is expected that high-level toolkit
3535
APIs such as GtkPrintOperation will hide most of this complexity.
3636
37-
This documentation describes version 4 of this interface.
37+
This documentation describes version 5 of this interface.
3838
-->
3939
<interface name="org.freedesktop.portal.Print">
4040
<!--
@@ -86,6 +86,19 @@
8686
8787
This option was added in version 4.
8888
89+
* ``has_n_copies`` (``b``)
90+
91+
Whether the app is able to manually implement the n-copies and collate settings.
92+
93+
This option was added in version 5.
94+
95+
* ``has_number_up`` (``b``)
96+
97+
Whether the app is able to manually implement the number-up and number-up-layout setting.
98+
99+
This option was added in version 5.
100+
101+
89102
The @settings and @page_setup vardict contain hints for the initial state of the print dialog.
90103
91104
The following keys are supported in the @settings vardict:
@@ -254,7 +267,22 @@
254267
255268
Print settings as set up by the user in the print dialog. The same keys as in @settings
256269
are supported (see above).
270+
* ``printer-info`` (``a{sv}``)
271+
272+
Printer information with the following keys:
273+
274+
* ``has-n-copies`` (``b``)
275+
276+
Whether the printer has the n-copies capability. In this case, the app should not provide
277+
a document with multiple copies if it has set has_n_copies to true in @options.
278+
279+
* ``has-number-up`` (``b``)
257280
281+
Whether the printer has the n-up capability. In this case, the app should not provide
282+
a document with pages per side if it has set has_n_up to true in @options.
283+
284+
This option was added in version 5.
285+
258286
* ``page-setup`` (``a{sv}``)
259287
260288
Page setup as set up by the user in the print dialog. The same keys as in @page_setup

src/print.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ handle_print (XdpDbusPrint *object,
210210
static XdpOptionKey response_options[] = {
211211
{ "settings", G_VARIANT_TYPE_VARDICT, NULL },
212212
{ "page-setup", G_VARIANT_TYPE_VARDICT, NULL },
213+
{ "printer-info", G_VARIANT_TYPE_VARDICT, NULL },
213214
{ "token", G_VARIANT_TYPE_UINT32, NULL }
214215
};
215216

@@ -259,6 +260,8 @@ static XdpOptionKey prepare_print_options[] = {
259260
{ "supported_output_file_formats", G_VARIANT_TYPE_STRING_ARRAY, validate_supported_output_file_formats },
260261
{ "has_current_page", G_VARIANT_TYPE_BOOLEAN },
261262
{ "has_selected_pages", G_VARIANT_TYPE_BOOLEAN },
263+
{ "has_n_copies", G_VARIANT_TYPE_BOOLEAN },
264+
{ "has_number_up", G_VARIANT_TYPE_BOOLEAN },
262265
};
263266

264267
static gboolean
@@ -364,7 +367,7 @@ print_new (XdpDbusImplPrint *impl,
364367
print->impl = g_object_ref (impl);
365368
print->lockdown_impl = g_object_ref (lockdown_impl);
366369

367-
xdp_dbus_print_set_version (XDP_DBUS_PRINT (print), 3);
370+
xdp_dbus_print_set_version (XDP_DBUS_PRINT (print), 5);
368371

369372
g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (print->impl), G_MAXINT);
370373

0 commit comments

Comments
 (0)