[gtk+/portal: 17/18] print job: Add api to send data from an fd



commit f828cf320516bc30df0f6594f3e2289029942a7f
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jul 4 00:04:38 2016 -0400

    print job: Add api to send data from an fd
    
    This will be useful for portalized print support.

 gtk/gtkprintjob.c |   34 ++++++++++++++++++++++++++++++++++
 gtk/gtkprintjob.h |    4 ++++
 2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkprintjob.c b/gtk/gtkprintjob.c
index 71a09f5..b53f46f 100644
--- a/gtk/gtkprintjob.c
+++ b/gtk/gtkprintjob.c
@@ -444,6 +444,40 @@ 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);
+
+  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 09cddd9..3748650 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]