diff options
author | Matthias Clasen <mclasen@redhat.com> | 2016-07-04 00:04:38 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2016-07-08 00:09:02 -0400 |
commit | 56ebfc6ca574633ffb21a0cd9de16a04e60933d2 (patch) | |
tree | a8791b7ed7dc884e3ba35cce5d716ffe231bc11e /gtk | |
parent | cc97e55f8a1c13dbf554e089a9a4ba6a43443146 (diff) | |
download | gtk+-56ebfc6ca574633ffb21a0cd9de16a04e60933d2.tar.gz |
print job: Add api to send data from an fd
This will be useful for portalized print support.
https://bugzilla.gnome.org/show_bug.cgi?id=768499
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkprintjob.c | 35 | ||||
-rw-r--r-- | gtk/gtkprintjob.h | 4 |
2 files changed, 39 insertions, 0 deletions
diff --git a/gtk/gtkprintjob.c b/gtk/gtkprintjob.c index 71a09f51b2..571d2b0572 100644 --- a/gtk/gtkprintjob.c +++ b/gtk/gtkprintjob.c @@ -444,6 +444,41 @@ gtk_print_job_set_source_file (GtkPrintJob *job, } /** + * gtk_print_job_set_source_fd: + * @job: a #GtkPrintJob + * @fd: a file descriptor + * @error: return location for errors + * + * Make the #GtkPrintJob send an existing document to the + * printing system. The file can be in any format understood + * by the platforms printing system (typically PostScript, + * but on many platforms PDF may work too). See + * gtk_printer_accepts_pdf() and gtk_printer_accepts_ps(). + * + * This is similar to gtk_print_job_set_source_file(), + * but takes expects an open file descriptor for the file, + * instead of a filename. + * + * Returns: %FALSE if an error occurred + * + * Since: 3.22 + */ +gboolean +gtk_print_job_set_source_fd (GtkPrintJob *job, + int fd, + GError **error) +{ + g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE); + g_return_val_if_fail (fd >= 0, FALSE); + + job->priv->spool_io = g_io_channel_unix_new (fd); + if (g_io_channel_set_encoding (job->priv->spool_io, NULL, error) != G_IO_STATUS_NORMAL) + return FALSE; + + return TRUE; +} + +/** * gtk_print_job_get_surface: * @job: a #GtkPrintJob * @error: (allow-none): return location for errors, or %NULL diff --git a/gtk/gtkprintjob.h b/gtk/gtkprintjob.h index 09cddd9c81..3748650898 100644 --- a/gtk/gtkprintjob.h +++ b/gtk/gtkprintjob.h @@ -95,6 +95,10 @@ GDK_AVAILABLE_IN_ALL gboolean gtk_print_job_set_source_file (GtkPrintJob *job, const gchar *filename, GError **error); +GDK_AVAILABLE_IN_3_22 +gboolean gtk_print_job_set_source_fd (GtkPrintJob *job, + int fd, + GError **error); GDK_AVAILABLE_IN_ALL cairo_surface_t *gtk_print_job_get_surface (GtkPrintJob *job, GError **error); |