Add portal support to GtkPrintOperation
Make GtkPrintOperation talk to org.freedesktop.portal.Print when running in a sandbox. https://bugzilla.gnome.org/show_bug.cgi?id=768499
This commit is contained in:
@ -30,6 +30,7 @@
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
#include "gtkprintoperation-private.h"
|
||||
#include "gtkprintoperation-portal.h"
|
||||
#include "gtkmessagedialog.h"
|
||||
|
||||
#include <cairo-pdf.h>
|
||||
@ -199,11 +200,11 @@ shell_command_substitute_file (const gchar *cmd,
|
||||
return g_string_free (final, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
|
||||
cairo_surface_t *surface,
|
||||
GtkWindow *parent,
|
||||
const gchar *filename)
|
||||
static void
|
||||
gtk_print_operation_unix_launch_preview (GtkPrintOperation *op,
|
||||
cairo_surface_t *surface,
|
||||
GtkWindow *parent,
|
||||
const gchar *filename)
|
||||
{
|
||||
GAppInfo *appinfo;
|
||||
GdkAppLaunchContext *context;
|
||||
@ -703,11 +704,11 @@ found_printer (GtkPrinter *printer,
|
||||
g_object_unref (page_setup);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_print_operation_platform_backend_run_dialog_async (GtkPrintOperation *op,
|
||||
gboolean show_dialog,
|
||||
GtkWindow *parent,
|
||||
GtkPrintOperationPrintFunc print_cb)
|
||||
static void
|
||||
gtk_print_operation_unix_run_dialog_async (GtkPrintOperation *op,
|
||||
gboolean show_dialog,
|
||||
GtkWindow *parent,
|
||||
GtkPrintOperationPrintFunc print_cb)
|
||||
{
|
||||
GtkWidget *pd;
|
||||
PrintResponseData *rdata;
|
||||
@ -778,12 +779,12 @@ close_preview (void *data)
|
||||
close (fd);
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
_gtk_print_operation_platform_backend_create_preview_surface (GtkPrintOperation *op,
|
||||
GtkPageSetup *page_setup,
|
||||
gdouble *dpi_x,
|
||||
gdouble *dpi_y,
|
||||
gchar **target)
|
||||
static cairo_surface_t *
|
||||
gtk_print_operation_unix_create_preview_surface (GtkPrintOperation *op,
|
||||
GtkPageSetup *page_setup,
|
||||
gdouble *dpi_x,
|
||||
gdouble *dpi_y,
|
||||
gchar **target)
|
||||
{
|
||||
gchar *filename;
|
||||
gint fd;
|
||||
@ -815,25 +816,25 @@ _gtk_print_operation_platform_backend_create_preview_surface (GtkPrintOperation
|
||||
return surface;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_print_operation_platform_backend_preview_start_page (GtkPrintOperation *op,
|
||||
cairo_surface_t *surface,
|
||||
cairo_t *cr)
|
||||
static void
|
||||
gtk_print_operation_unix_preview_start_page (GtkPrintOperation *op,
|
||||
cairo_surface_t *surface,
|
||||
cairo_t *cr)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_print_operation_platform_backend_preview_end_page (GtkPrintOperation *op,
|
||||
cairo_surface_t *surface,
|
||||
cairo_t *cr)
|
||||
static void
|
||||
gtk_print_operation_unix_preview_end_page (GtkPrintOperation *op,
|
||||
cairo_surface_t *surface,
|
||||
cairo_t *cr)
|
||||
{
|
||||
cairo_show_page (cr);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_print_operation_platform_backend_resize_preview_surface (GtkPrintOperation *op,
|
||||
GtkPageSetup *page_setup,
|
||||
cairo_surface_t *surface)
|
||||
static void
|
||||
gtk_print_operation_unix_resize_preview_surface (GtkPrintOperation *op,
|
||||
GtkPageSetup *page_setup,
|
||||
cairo_surface_t *surface)
|
||||
{
|
||||
gdouble w, h;
|
||||
|
||||
@ -842,12 +843,11 @@ _gtk_print_operation_platform_backend_resize_preview_surface (GtkPrintOperation
|
||||
cairo_pdf_surface_set_size (surface, w, h);
|
||||
}
|
||||
|
||||
|
||||
GtkPrintOperationResult
|
||||
_gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *op,
|
||||
gboolean show_dialog,
|
||||
GtkWindow *parent,
|
||||
gboolean *do_print)
|
||||
static GtkPrintOperationResult
|
||||
gtk_print_operation_unix_run_dialog (GtkPrintOperation *op,
|
||||
gboolean show_dialog,
|
||||
GtkWindow *parent,
|
||||
gboolean *do_print)
|
||||
{
|
||||
GtkWidget *pd;
|
||||
PrintResponseData rdata;
|
||||
@ -1218,3 +1218,73 @@ find_printer (const gchar *printer,
|
||||
if (finder->backends == NULL && !finder->found_printer)
|
||||
g_idle_add (find_printer_idle, finder);
|
||||
}
|
||||
|
||||
|
||||
GtkPrintOperationResult
|
||||
_gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *op,
|
||||
gboolean show_dialog,
|
||||
GtkWindow *parent,
|
||||
gboolean *do_print)
|
||||
{
|
||||
if (gtk_should_use_portal ())
|
||||
return gtk_print_operation_portal_run_dialog (op, show_dialog, parent, do_print);
|
||||
else
|
||||
return gtk_print_operation_unix_run_dialog (op, show_dialog, parent, do_print);
|
||||
}
|
||||
void
|
||||
_gtk_print_operation_platform_backend_run_dialog_async (GtkPrintOperation *op,
|
||||
gboolean show_dialog,
|
||||
GtkWindow *parent,
|
||||
GtkPrintOperationPrintFunc print_cb)
|
||||
{
|
||||
if (gtk_should_use_portal ())
|
||||
gtk_print_operation_portal_run_dialog_async (op, show_dialog, parent, print_cb);
|
||||
else
|
||||
gtk_print_operation_unix_run_dialog_async (op, show_dialog, parent, print_cb);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
|
||||
cairo_surface_t *surface,
|
||||
GtkWindow *parent,
|
||||
const gchar *filename)
|
||||
{
|
||||
if (gtk_should_use_portal ())
|
||||
gtk_print_operation_portal_launch_preview (op, surface, parent, filename);
|
||||
else
|
||||
gtk_print_operation_unix_launch_preview (op, surface, parent, filename);
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
_gtk_print_operation_platform_backend_create_preview_surface (GtkPrintOperation *op,
|
||||
GtkPageSetup *page_setup,
|
||||
gdouble *dpi_x,
|
||||
gdouble *dpi_y,
|
||||
gchar **target)
|
||||
{
|
||||
return gtk_print_operation_unix_create_preview_surface (op, page_setup, dpi_x, dpi_y, target);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_print_operation_platform_backend_resize_preview_surface (GtkPrintOperation *op,
|
||||
GtkPageSetup *page_setup,
|
||||
cairo_surface_t *surface)
|
||||
{
|
||||
gtk_print_operation_unix_resize_preview_surface (op, page_setup, surface);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_print_operation_platform_backend_preview_start_page (GtkPrintOperation *op,
|
||||
cairo_surface_t *surface,
|
||||
cairo_t *cr)
|
||||
{
|
||||
gtk_print_operation_unix_preview_start_page (op, surface, cr);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_print_operation_platform_backend_preview_end_page (GtkPrintOperation *op,
|
||||
cairo_surface_t *surface,
|
||||
cairo_t *cr)
|
||||
{
|
||||
gtk_print_operation_unix_preview_end_page (op, surface, cr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user