Commit fad69ba0 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Add gtkprintoperationpreview.[ch] Set default preview command. Hardcoded

2006-06-02  Alexander Larsson  <alexl@redhat.com>

	* gtk/Makefile.am:
	Add gtkprintoperationpreview.[ch]
	Set default preview command. Hardcoded for now.

	* gtk/gtkmarshalers.list:
	Add BOOLEAN:OBJECT,OBJECT,OBJECT

	* gtk/gtkprintbackend.c:
	Add preview command property.

	* gtk/gtkprintcontext.[ch]:
	Make less dependent on PrintOperation for output settings
	Externally set cairo_t and dpi. Resettable.
	Create fontmap without metrics hinting (so that print preview
	text layout doesn't depend on zoom level).

	* gtk/gtkprintoperation-private.h:
	* gtk/gtkprintoperation-unix.c:
	* gtk/gtkprintoperation.[ch]:
	Initial work on print preview API and default implementation
	using an external preview app.

	* gtk/gtkprintoperation-win32.c:
	Some needed updates. Not done, needs more work.

	* gtk/gtkprintoperationpreview.[ch]:
	New interface used in print preview api.

	* gtk/gtkprintunixdialog.c:
	Add print preview dialog.

	* tests/print-editor.c:
	Test using an custom print preview widget.
parent caf6c419
2006-06-02 Alexander Larsson <alexl@redhat.com>
* gtk/Makefile.am:
Add gtkprintoperationpreview.[ch]
Set default preview command. Hardcoded for now.
* gtk/gtkmarshalers.list:
Add BOOLEAN:OBJECT,OBJECT,OBJECT
* gtk/gtkprintbackend.c:
Add preview command property.
* gtk/gtkprintcontext.[ch]:
Make less dependent on PrintOperation for output settings
Externally set cairo_t and dpi. Resettable.
Create fontmap without metrics hinting (so that print preview
text layout doesn't depend on zoom level).
* gtk/gtkprintoperation-private.h:
* gtk/gtkprintoperation-unix.c:
* gtk/gtkprintoperation.[ch]:
Initial work on print preview API and default implementation
using an external preview app.
* gtk/gtkprintoperation-win32.c:
Some needed updates. Not done, needs more work.
* gtk/gtkprintoperationpreview.[ch]:
New interface used in print preview api.
* gtk/gtkprintunixdialog.c:
Add print preview dialog.
* tests/print-editor.c:
Test using an custom print preview widget.
2006-06-02 Emmanuele Bassi <ebassi@gnome.org>
* gtk/gtkrecentmanager.c
......
2006-06-02 Alexander Larsson <alexl@redhat.com>
* gtk/Makefile.am:
Add gtkprintoperationpreview.[ch]
Set default preview command. Hardcoded for now.
* gtk/gtkmarshalers.list:
Add BOOLEAN:OBJECT,OBJECT,OBJECT
* gtk/gtkprintbackend.c:
Add preview command property.
* gtk/gtkprintcontext.[ch]:
Make less dependent on PrintOperation for output settings
Externally set cairo_t and dpi. Resettable.
Create fontmap without metrics hinting (so that print preview
text layout doesn't depend on zoom level).
* gtk/gtkprintoperation-private.h:
* gtk/gtkprintoperation-unix.c:
* gtk/gtkprintoperation.[ch]:
Initial work on print preview API and default implementation
using an external preview app.
* gtk/gtkprintoperation-win32.c:
Some needed updates. Not done, needs more work.
* gtk/gtkprintoperationpreview.[ch]:
New interface used in print preview api.
* gtk/gtkprintunixdialog.c:
Add print preview dialog.
* tests/print-editor.c:
Test using an custom print preview widget.
2006-06-02 Emmanuele Bassi <ebassi@gnome.org>
* gtk/gtkrecentmanager.c
......
......@@ -4,6 +4,7 @@ SUBDIRS=theme-bits
if OS_UNIX
SUBDIRS += xdgmime
GTK_PRINT_PREVIEW_COMMAND="evince %f"
endif
DIST_SUBDIRS=theme-bits xdgmime
......@@ -25,6 +26,7 @@ INCLUDES = \
-DGTK_HOST=\"$(host)\" \
-DGTK_COMPILATION \
-DGTK_PRINT_BACKENDS=\"$(GTK_PRINT_BACKENDS)\" \
-DGTK_PRINT_PREVIEW_COMMAND=\"$(GTK_PRINT_PREVIEW_COMMAND)\" \
-I$(top_builddir)/gtk \
-I$(top_srcdir) -I../gdk \
-I$(top_srcdir)/gdk \
......@@ -231,6 +233,7 @@ gtk_public_h_sources = \
gtkpreview.h \
gtkprintcontext.h \
gtkprintoperation.h \
gtkprintoperationpreview.h \
gtkprintsettings.h \
gtkprivate.h \
gtkprogress.h \
......@@ -487,6 +490,7 @@ gtk_c_sources = \
gtkpreview.c \
gtkprintcontext.c \
gtkprintoperation.c \
gtkprintoperationpreview.c \
gtkprintsettings.c \
gtkprintutils.c \
gtkprogress.c \
......
......@@ -32,6 +32,7 @@ BOOLEAN:OBJECT,INT,INT,UINT
BOOLEAN:OBJECT,STRING,STRING,BOXED
BOOLEAN:OBJECT,BOXED
BOOLEAN:OBJECT,BOXED,BOXED
BOOLEAN:OBJECT,OBJECT,OBJECT
BOOLEAN:OBJECT,STRING,STRING
BOOLEAN:INT
BOOLEAN:INT,INT
......
......@@ -191,7 +191,7 @@ _gtk_print_backend_module_create (GtkPrintBackendModule *pb_module)
return NULL;
}
GtkPrintBackend *
static GtkPrintBackend *
_gtk_print_backend_create (const char *backend_name)
{
GSList *l;
......@@ -200,7 +200,6 @@ _gtk_print_backend_create (const char *backend_name)
GtkPrintBackendModule *pb_module;
GtkPrintBackend *pb;
/* TODO: make module loading code work */
for (l = loaded_backends; l != NULL; l = l->next)
{
pb_module = l->data;
......@@ -255,6 +254,11 @@ gtk_print_backend_initialize (void)
GTK_PRINT_BACKENDS,
GTK_PARAM_READWRITE));
gtk_settings_install_property (g_param_spec_string ("gtk-print-preview-command",
P_("Default command to run when displaying a print preview"),
P_("Command to run when displaying a print preview"),
GTK_PRINT_PREVIEW_COMMAND,
GTK_PARAM_READWRITE));
initialized = TRUE;
}
}
......
......@@ -40,6 +40,9 @@ struct _GtkPrintContext
GtkPageSetup *page_setup;
PangoFontMap *fontmap;
gdouble surface_dpi_x;
gdouble surface_dpi_y;
gdouble pixels_per_unit_x;
gdouble pixels_per_unit_y;
};
......@@ -60,8 +63,8 @@ gtk_print_context_finalize (GObject *object)
if (context->page_setup)
g_object_unref (context->page_setup);
cairo_destroy (context->cr);
if (context->cr)
cairo_destroy (context->cr);
G_OBJECT_CLASS (gtk_print_context_parent_class)->finalize (object);
}
......@@ -83,15 +86,31 @@ gtk_print_context_class_init (GtkPrintContextClass *class)
GtkPrintContext *
_gtk_print_context_new (GtkPrintOperation *op)
{
GtkPrintOperationPrivate *priv = op->priv;
GtkPrintContext *context;
context = g_object_new (GTK_TYPE_PRINT_CONTEXT, NULL);
context->op = op;
context->cr = cairo_create (priv->surface);
context->cr = NULL;
context->fontmap = pango_cairo_font_map_new ();
return context;
}
void
gtk_print_context_set_cairo_context (GtkPrintContext *context,
cairo_t *cr,
double dpi_x,
double dpi_y)
{
if (context->cr)
cairo_destroy (context->cr);
context->cr = cairo_reference (cr);
context->surface_dpi_x = dpi_x;
context->surface_dpi_y = dpi_y;
switch (priv->unit)
switch (context->op->priv->unit)
{
default:
case GTK_UNIT_PIXEL:
......@@ -100,34 +119,31 @@ _gtk_print_context_new (GtkPrintOperation *op)
context->pixels_per_unit_y = 1.0;
break;
case GTK_UNIT_POINTS:
context->pixels_per_unit_x = priv->dpi_x / POINTS_PER_INCH;
context->pixels_per_unit_y = priv->dpi_y / POINTS_PER_INCH;
context->pixels_per_unit_x = dpi_x / POINTS_PER_INCH;
context->pixels_per_unit_y = dpi_y / POINTS_PER_INCH;
break;
case GTK_UNIT_INCH:
context->pixels_per_unit_x = priv->dpi_x;
context->pixels_per_unit_y = priv->dpi_y;
context->pixels_per_unit_x = dpi_x;
context->pixels_per_unit_y = dpi_y;
break;
case GTK_UNIT_MM:
context->pixels_per_unit_x = priv->dpi_x / MM_PER_INCH;
context->pixels_per_unit_y = priv->dpi_y / MM_PER_INCH;
context->pixels_per_unit_x = dpi_x / MM_PER_INCH;
context->pixels_per_unit_y = dpi_y / MM_PER_INCH;
break;
}
cairo_scale (context->cr,
context->pixels_per_unit_x,
context->pixels_per_unit_y);
context->fontmap = pango_cairo_font_map_new ();
/* We use the unit-scaled resolution, as we still want fonts given in points to work */
pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (context->fontmap),
priv->dpi_y / context->pixels_per_unit_y);
return context;
dpi_y / context->pixels_per_unit_y);
}
void
_gtk_print_context_rotate_according_to_orientation (GtkPrintContext *context)
{
GtkPrintOperationPrivate *priv = context->op->priv;
cairo_t *cr = context->cr;
cairo_matrix_t matrix;
GtkPaperSize *paper_size;
......@@ -136,9 +152,9 @@ _gtk_print_context_rotate_according_to_orientation (GtkPrintContext *context)
paper_size = gtk_page_setup_get_paper_size (context->page_setup);
width = gtk_paper_size_get_width (paper_size, GTK_UNIT_INCH);
width = width * priv->dpi_x / context->pixels_per_unit_x;
width = width * context->surface_dpi_x / context->pixels_per_unit_x;
height = gtk_paper_size_get_height (paper_size, GTK_UNIT_INCH);
height = height * priv->dpi_y / context->pixels_per_unit_y;
height = height * context->surface_dpi_y / context->pixels_per_unit_y;
switch (gtk_page_setup_get_orientation (context->page_setup))
{
......@@ -188,8 +204,8 @@ _gtk_print_context_translate_into_margin (GtkPrintContext *context)
top = gtk_page_setup_get_top_margin (context->page_setup, GTK_UNIT_INCH);
cairo_translate (context->cr,
left * priv->dpi_x / context->pixels_per_unit_x,
top * priv->dpi_y / context->pixels_per_unit_y);
left * context->surface_dpi_x / context->pixels_per_unit_x,
top * context->surface_dpi_y / context->pixels_per_unit_y);
}
void
......@@ -272,7 +288,7 @@ gtk_print_context_get_width (GtkPrintContext *context)
width = gtk_page_setup_get_page_width (context->page_setup, GTK_UNIT_INCH);
/* Really dpi_x? What about landscape? what does dpi_x mean in that case? */
return width * priv->dpi_x / context->pixels_per_unit_x;
return width * context->surface_dpi_x / context->pixels_per_unit_x;
}
/**
......@@ -300,8 +316,8 @@ gtk_print_context_get_height (GtkPrintContext *context)
else
height = gtk_page_setup_get_page_height (context->page_setup, GTK_UNIT_INCH);
/* Really dpi_x? What about landscape? what does dpi_x mean in that case? */
return height * priv->dpi_y / context->pixels_per_unit_y;
/* Really dpi_y? What about landscape? what does dpi_y mean in that case? */
return height * context->surface_dpi_y / context->pixels_per_unit_y;
}
/**
......@@ -320,7 +336,7 @@ gtk_print_context_get_dpi_x (GtkPrintContext *context)
{
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), 0);
return context->op->priv->dpi_x;
return context->surface_dpi_x;
}
/**
......@@ -339,7 +355,7 @@ gtk_print_context_get_dpi_y (GtkPrintContext *context)
{
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), 0);
return context->op->priv->dpi_y;
return context->surface_dpi_y;
}
/**
......@@ -376,10 +392,16 @@ PangoContext *
gtk_print_context_create_pango_context (GtkPrintContext *context)
{
PangoContext *pango_context;
cairo_font_options_t *options;
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), NULL);
pango_context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (context->fontmap));
options = cairo_font_options_create ();
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF);
pango_cairo_context_set_font_options (pango_context, options);
cairo_font_options_destroy (options);
return pango_context;
}
......
......@@ -51,6 +51,11 @@ PangoFontMap *gtk_print_context_get_pango_fontmap (GtkPrintContext *context);
PangoContext *gtk_print_context_create_pango_context (GtkPrintContext *context);
PangoLayout *gtk_print_context_create_pango_layout (GtkPrintContext *context);
/* Needed for preview implementations */
void gtk_print_context_set_cairo_context (GtkPrintContext *context,
cairo_t *cr,
double dpi_x,
double dpi_y);
G_END_DECLS
......
......@@ -46,9 +46,11 @@ struct _GtkPrintOperationPrivate
guint print_pages_idle_id;
guint show_progress_timeout_id;
GtkPrintContext *print_context;
/* Data for the print job: */
cairo_surface_t *surface;
gdouble dpi_x, dpi_y;
/* cairo_surface_t *surface; */
/* gdouble dpi_x, dpi_y; */
GtkPrintPages print_pages;
GtkPageRange *page_ranges;
......@@ -78,17 +80,29 @@ struct _GtkPrintOperationPrivate
gboolean cancelled);
};
GtkPrintOperationResult _gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *operation,
GtkWindow *parent,
gboolean *do_print,
GError **error);
typedef void (* GtkPrintOperationPrintFunc) (GtkPrintOperation *op,
GtkWindow *parent);
void _gtk_print_operation_platform_backend_run_dialog_async (GtkPrintOperation *op,
GtkWindow *parent,
GtkPrintOperationPrintFunc print_cb);
GtkWindow *parent,
gboolean is_preview);
GtkPrintOperationResult _gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *operation,
GtkWindow *parent,
gboolean *do_print,
GError **error);
void _gtk_print_operation_platform_backend_run_dialog_async (GtkPrintOperation *op,
GtkWindow *parent,
GtkPrintOperationPrintFunc print_cb);
void _gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
GtkWindow *parent,
const char *filename);
cairo_surface_t * _gtk_print_operation_platform_backend_create_preview_surface (GtkPrintOperation *op,
GtkPageSetup *page_setup,
gdouble *dpi_x,
gdouble *dpi_y,
const gchar *target);
void _gtk_print_operation_platform_backend_resize_preview_surface (GtkPrintOperation *op,
GtkPageSetup *page_setup,
cairo_surface_t *surface);
void _gtk_print_operation_set_status (GtkPrintOperation *op,
GtkPrintStatus status,
......
......@@ -25,6 +25,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include "gtkprintoperation-private.h"
#include "gtkmarshal.h"
......@@ -41,13 +44,17 @@
#include "gtkalias.h"
#include "gtkintl.h"
typedef struct {
GtkPrintJob *job; /* the job we are sending to the printer */
gulong job_status_changed_tag;
GtkWindow *parent; /* just in case we need to throw error dialogs */
GMainLoop *loop;
gboolean data_sent;
/* Real printing (not preview: */
GtkPrintJob *job; /* the job we are sending to the printer */
cairo_surface_t *surface;
gulong job_status_changed_tag;
} GtkPrintOperationUnix;
typedef struct _PrinterFinder PrinterFinder;
......@@ -62,21 +69,24 @@ unix_start_page (GtkPrintOperation *op,
GtkPrintContext *print_context,
GtkPageSetup *page_setup)
{
GtkPrintOperationUnix *op_unix;
GtkPaperSize *paper_size;
cairo_surface_type_t type;
double w, h;
op_unix = op->priv->platform_data;
paper_size = gtk_page_setup_get_paper_size (page_setup);
w = gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS);
h = gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS);
type = cairo_surface_get_type (op->priv->surface);
type = cairo_surface_get_type (op_unix->surface);
if (type == CAIRO_SURFACE_TYPE_PS)
cairo_ps_surface_set_size (op->priv->surface, w, h);
cairo_ps_surface_set_size (op_unix->surface, w, h);
else if (type == CAIRO_SURFACE_TYPE_PDF)
cairo_pdf_surface_set_size (op->priv->surface, w, h);
cairo_pdf_surface_set_size (op_unix->surface, w, h);
}
static void
......@@ -102,6 +112,112 @@ op_unix_free (GtkPrintOperationUnix *op_unix)
g_free (op_unix);
}
static char *
shell_command_substitute_file (const gchar *cmd,
const gchar *filename)
{
const char *inptr, *start;
char *result;
GString *final;
g_return_val_if_fail (cmd != NULL, NULL);
g_return_val_if_fail (filename != NULL, NULL);
result = NULL;
final = g_string_new (NULL);
start = inptr = cmd;
while ((inptr = strchr (inptr, '%')) != NULL)
{
g_string_append_len (final, start, inptr - start);
inptr++;
switch (*inptr)
{
case 'f':
g_string_append (final, filename ? filename : "");
break;
case '%':
g_string_append_c (final, '%');
break;
default:
g_string_append_c (final, '%');
if (*inptr)
g_string_append_c (final, *inptr);
break;
}
if (*inptr)
inptr++;
start = inptr;
}
g_string_append (final, start);
result = final->str;
g_string_free (final, FALSE);
return result;
}
void
_gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
GtkWindow *parent,
const char *filename)
{
int argc;
gchar **argv;
gchar *cmd;
gchar *preview_cmd;
GtkSettings *settings;
gchar *quoted_filename;
GdkScreen *screen;
GError *error = NULL;
settings = gtk_settings_get_default ();
g_object_get (settings, "gtk-print-preview-command", &preview_cmd, NULL);
quoted_filename = g_shell_quote (filename);
cmd = shell_command_substitute_file (preview_cmd, quoted_filename);
g_shell_parse_argv (cmd, &argc, &argv, &error);
if (error !=NULL)
goto out;
if (parent)
screen = gtk_window_get_screen (parent);
else
screen = gdk_screen_get_default ();
gdk_spawn_on_screen (screen, NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error);
out:
if (error != NULL)
{
GtkWidget *edialog;
edialog = gtk_message_dialog_new (parent,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
_("Error launching preview") /* FIXME better text */);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (edialog),
"%s", error->message);
gtk_window_set_modal (GTK_WINDOW (edialog), TRUE);
g_signal_connect (edialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
gtk_window_present (GTK_WINDOW (edialog));
g_error_free (error);
}
g_free (cmd);
g_free (quoted_filename);
g_free (preview_cmd);
g_strfreev (argv);
}
static void
unix_finish_send (GtkPrintJob *job,
void *user_data,
......@@ -129,6 +245,7 @@ unix_finish_send (GtkPrintJob *job,
}
op_unix->data_sent = TRUE;
if (op_unix->loop)
g_main_loop_quit (op_unix->loop);
}
......@@ -140,6 +257,8 @@ unix_end_run (GtkPrintOperation *op,
{
GtkPrintOperationUnix *op_unix = op->priv->platform_data;
cairo_surface_finish (op_unix->surface);
if (cancelled)
return;
......@@ -147,10 +266,11 @@ unix_end_run (GtkPrintOperation *op,
op_unix->loop = g_main_loop_new (NULL, FALSE);
/* TODO: Check for error */
gtk_print_job_send (op_unix->job,
unix_finish_send,
op_unix, NULL,
NULL);
if (op_unix->job != NULL)
gtk_print_job_send (op_unix->job,
unix_finish_send,
op_unix, NULL,
NULL);
if (wait)
{
......@@ -253,64 +373,70 @@ finish_print (PrintResponseData *rdata,
{
GtkPrintOperation *op = rdata->op;
GtkPrintOperationPrivate *priv = op->priv;
gboolean is_preview;
priv->start_page = unix_start_page;
priv->end_page = unix_end_page;
priv->end_run = unix_end_run;
is_preview = rdata->result == GTK_PRINT_OPERATION_RESULT_PREVIEW;
if (rdata->do_print)
{
GtkPrintOperationUnix *op_unix;
gtk_print_operation_set_print_settings (op, settings);
op_unix = g_new0 (GtkPrintOperationUnix, 1);
op_unix->job = gtk_print_job_new (priv->job_name,
printer,
settings,
page_setup);
priv->print_context = _gtk_print_context_new (op);
_gtk_print_context_set_page_setup (priv->print_context, page_setup);
gtk_print_job_set_track_print_status (op_unix->job, priv->track_print_status);
rdata->op->priv->surface = gtk_print_job_get_surface (op_unix->job, rdata->error);
if (op->priv->surface == NULL)
if (!is_preview)
{
rdata->do_print = FALSE;
op_unix_free (op_unix);
rdata->result = GTK_PRINT_OPERATION_RESULT_ERROR;
goto out;
}
_gtk_print_operation_set_status (op, gtk_print_job_get_status (op_unix->job), NULL);
op_unix->job_status_changed_tag =
g_signal_connect (op_unix->job, "status-changed",
G_CALLBACK (job_status_changed_cb), op);
op_unix->parent = rdata->parent;
priv->dpi_x = 72;
priv->dpi_y = 72;
priv->platform_data = op_unix;
priv->free_platform_data = (GDestroyNotify) op_unix_free;
priv->print_pages = op_unix->job->print_pages;
priv->page_ranges = op_unix->job->page_ranges;
priv->num_page_ranges = op_unix->job->num_page_ranges;
priv->manual_num_copies = op_unix->job->num_copies;
priv->manual_collation = op_unix->job->collate;
priv->manual_reverse = op_unix->job->reverse;
priv->manual_page_set = op_unix->job->page_set;
priv->manual_scale = op_unix->job->scale;
priv->manual_orientation = op_unix->job->rotate_to_orientation;
GtkPrintOperationUnix *op_unix;
cairo_t *cr;
op_unix = g_new0 (GtkPrintOperationUnix, 1);
priv->platform_data = op_unix;
priv->free_platform_data = (GDestroyNotify) op_unix_free;
op_unix->parent = rdata->parent;
priv->start_page = unix_start_page;
priv->end_page = unix_end_page;
priv->end_run = unix_end_run;
op_unix->job = gtk_print_job_new (priv->job_name,
printer,
settings,
page_setup);
gtk_print_job_set_track_print_status (op_unix->job, priv->track_print_status);
op_unix->surface = gtk_print_job_get_surface (op_unix->job, rdata->error);
if (op_unix->surface == NULL) {
rdata->do_print = FALSE;
goto out;
}
cr = cairo_create (op_unix->surface);
gtk_print_context_set_cairo_context (op->priv->print_context,
cr, 72, 72);
cairo_destroy (cr);
_gtk_print_operation_set_status (op, gtk_print_job_get_status (op_unix->job), NULL);
op_unix->job_status_changed_tag =
g_signal_connect (op_unix->job, "status-changed",
G_CALLBACK (job_status_changed_cb), op);
priv->print_pages = op_unix->job->print_pages;
priv->page_ranges = op_unix->job->page_ranges;
priv->num_page_ranges = op_unix->job->num_page_ranges;
priv->manual_num_copies = op_unix->job->num_copies;
priv->manual_collation = op_unix->job->collate;
priv->manual_reverse = op_unix->job->reverse;
priv->manual_page_set = op_unix->job->page_set;
priv->manual_scale = op_unix->job->scale;
priv->manual_orientation = op_unix->job->rotate_to_orientation;
}
}
out:
out:
if (rdata->print_cb)
{
if (rdata->do_print)
rdata->print_cb (op, rdata->parent);
rdata->print_cb (op, rdata->parent, is_preview);
else
_gtk_print_operation_set_status (op, GTK_PRINT_STATUS_FINISHED_ABORTED, NULL);
}
......@@ -319,7 +445,7 @@ finish_print (PrintResponseData *rdata,
rdata->destroy (rdata);
}
static void
static void
handle_print_response (GtkWidget *dialog,
gint response,
gpointer data)
......@@ -335,24 +461,31 @@ handle_print_response (GtkWidget *dialog,
rdata->result = GTK_PRINT_OPERATION_RESULT_APPLY;
printer = gtk_print_unix_dialog_get_selected_printer (GTK_PRINT_UNIX_DIALOG (pd));
if (printer == NULL)
goto out;
if (printer != NULL)
rdata->do_print = TRUE;
}
else if (response == GTK_RESPONSE_APPLY)
{
/* print preview */
rdata->result = GTK_PRINT_OPERATION_RESULT_PREVIEW;
rdata->do_print = TRUE;
}
if (rdata->do_print)
{
settings = gtk_print_unix_dialog_get_settings (GTK_PRINT_UNIX_DIALOG (pd));
page_setup = gtk_print_unix_dialog_get_page_setup (GTK_PRINT_UNIX_DIALOG (pd));
g_signal_emit_by_name (rdata->op, "custom-widget-apply", rdata->op->priv->custom_widget);
}
out:
}
finish_print (rdata, printer, page_setup, settings);