Add a GtkPrintSettings parameter to the printer_create_cairo_surface

2006-06-16  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkprintbackend.h: Add a GtkPrintSettings parameter to the
	printer_create_cairo_surface method.

	* modules/printbackends/pdf/gtkprintbackendpdf.c:
	* modules/printbackends/cups/gtkprintbackendcups.c:
	* modules/printbackends/lpr/gtkprintbackendlpr.c:
	* gtk/gtkprinter.c (_gtk_printer_create_cairo_surface):
	* gtk/gtkprinter-private.h:
	* gtk/gtkprintjob.c (gtk_print_job_get_surface): Adapt all users.
This commit is contained in:
Matthias Clasen 2006-06-16 18:29:09 +00:00 committed by Matthias Clasen
parent a0063d39d2
commit 956bcb4393
8 changed files with 277 additions and 216 deletions

View File

@ -1,5 +1,15 @@
2006-06-16 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkprintbackend.h: Add a GtkPrintSettings parameter to the
printer_create_cairo_surface method.
* modules/printbackends/pdf/gtkprintbackendpdf.c:
* modules/printbackends/cups/gtkprintbackendcups.c:
* modules/printbackends/lpr/gtkprintbackendlpr.c:
* gtk/gtkprinter.c (_gtk_printer_create_cairo_surface):
* gtk/gtkprinter-private.h:
* gtk/gtkprintjob.c (gtk_print_job_get_surface): Adapt all users.
* gtk/gtkentrycompletion.c (gtk_entry_completion_finalize): Don't
leak match data. (#345107, Christian Weiske)

View File

@ -1,5 +1,15 @@
2006-06-16 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkprintbackend.h: Add a GtkPrintSettings parameter to the
printer_create_cairo_surface method.
* modules/printbackends/pdf/gtkprintbackendpdf.c:
* modules/printbackends/cups/gtkprintbackendcups.c:
* modules/printbackends/lpr/gtkprintbackendlpr.c:
* gtk/gtkprinter.c (_gtk_printer_create_cairo_surface):
* gtk/gtkprinter-private.h:
* gtk/gtkprintjob.c (gtk_print_job_get_surface): Adapt all users.
* gtk/gtkentrycompletion.c (gtk_entry_completion_finalize): Don't
leak match data. (#345107, Christian Weiske)

View File

@ -70,49 +70,50 @@ struct _GtkPrintBackendClass
GObjectClass parent_class;
/* Global backend methods: */
void (*request_printer_list) (GtkPrintBackend *backend);
void (*print_stream) (GtkPrintBackend *backend,
GtkPrintJob *job,
gint data_fd,
GtkPrintJobCompleteFunc callback,
gpointer user_data,
GDestroyNotify dnotify);
void (*request_printer_list) (GtkPrintBackend *backend);
void (*print_stream) (GtkPrintBackend *backend,
GtkPrintJob *job,
gint data_fd,
GtkPrintJobCompleteFunc callback,
gpointer user_data,
GDestroyNotify dnotify);
/* Printer methods: */
void (*printer_request_details) (GtkPrinter *printer);
cairo_surface_t * (*printer_create_cairo_surface) (GtkPrinter *printer,
gdouble height,
gdouble width,
gint cache_fd);
GtkPrinterOptionSet * (*printer_get_options) (GtkPrinter *printer,
GtkPrintSettings *settings,
GtkPageSetup *page_setup);
gboolean (*printer_mark_conflicts) (GtkPrinter *printer,
void (*printer_request_details) (GtkPrinter *printer);
cairo_surface_t * (*printer_create_cairo_surface) (GtkPrinter *printer,
GtkPrintSettings *settings,
gdouble height,
gdouble width,
gint cache_fd);
GtkPrinterOptionSet * (*printer_get_options) (GtkPrinter *printer,
GtkPrintSettings *settings,
GtkPageSetup *page_setup);
gboolean (*printer_mark_conflicts) (GtkPrinter *printer,
GtkPrinterOptionSet *options);
void (*printer_get_settings_from_options) (GtkPrinter *printer,
void (*printer_get_settings_from_options) (GtkPrinter *printer,
GtkPrinterOptionSet *options,
GtkPrintSettings *settings);
void (*printer_prepare_for_print) (GtkPrinter *printer,
GtkPrintJob *print_job,
GtkPrintSettings *settings,
GtkPageSetup *page_setup);
GList * (*printer_list_papers) (GtkPrinter *printer);
void (*printer_get_hard_margins) (GtkPrinter *printer,
double *top,
double *bottom,
double *left,
double *right);
GtkPrintCapabilities (*printer_get_capabilities) (GtkPrinter *printer);
GtkPrintSettings *settings);
void (*printer_prepare_for_print) (GtkPrinter *printer,
GtkPrintJob *print_job,
GtkPrintSettings *settings,
GtkPageSetup *page_setup);
GList * (*printer_list_papers) (GtkPrinter *printer);
void (*printer_get_hard_margins) (GtkPrinter *printer,
double *top,
double *bottom,
double *left,
double *right);
GtkPrintCapabilities (*printer_get_capabilities) (GtkPrinter *printer);
/* Signals */
void (*printer_list_changed) (GtkPrintBackend *backend);
void (*printer_list_done) (GtkPrintBackend *backend);
void (*printer_added) (GtkPrintBackend *backend,
GtkPrinter *printer);
void (*printer_removed) (GtkPrintBackend *backend,
GtkPrinter *printer);
void (*printer_status_changed) (GtkPrintBackend *backend,
GtkPrinter *printer);
void (*printer_list_changed) (GtkPrintBackend *backend);
void (*printer_list_done) (GtkPrintBackend *backend);
void (*printer_added) (GtkPrintBackend *backend,
GtkPrinter *printer);
void (*printer_removed) (GtkPrintBackend *backend,
GtkPrinter *printer);
void (*printer_status_changed) (GtkPrintBackend *backend,
GtkPrinter *printer);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);

View File

@ -45,6 +45,7 @@ void _gtk_printer_prepare_for_print (GtkPrinter
GtkPrintSettings *settings,
GtkPageSetup *page_setup);
cairo_surface_t * _gtk_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
gdouble width,
gdouble height,
gint cache_fd);

View File

@ -749,14 +749,16 @@ _gtk_printer_prepare_for_print (GtkPrinter *printer,
}
cairo_surface_t *
_gtk_printer_create_cairo_surface (GtkPrinter *printer,
gdouble width,
gdouble height,
gint cache_fd)
_gtk_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
gdouble width,
gdouble height,
gint cache_fd)
{
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend);
return backend_class->printer_create_cairo_surface (printer, width, height, cache_fd);
return backend_class->printer_create_cairo_surface (printer, settings,
width, height, cache_fd);
}
GList *

View File

@ -248,30 +248,38 @@ gtk_print_backend_cups_class_init (GtkPrintBackendCupsClass *class)
}
static cairo_status_t
_cairo_write_to_cups (void *cache_fd_as_pointer,
_cairo_write_to_cups (void *closure,
const unsigned char *data,
unsigned int length)
{
cairo_status_t result;
gint cache_fd;
cache_fd = GPOINTER_TO_INT (cache_fd_as_pointer);
result = CAIRO_STATUS_WRITE_ERROR;
gint fd = GPOINTER_TO_INT (closure);
gssize written;
/* write out the buffer */
if (write (cache_fd, data, length) != -1)
result = CAIRO_STATUS_SUCCESS;
return result;
while (length > 0)
{
written = write (fd, data, length);
if (written == -1)
{
if (errno == EAGAIN || errno == EINTR)
continue;
return CAIRO_STATUS_WRITE_ERROR;
}
data += written;
length -= written;
}
return CAIRO_STATUS_SUCCESS;
}
static cairo_surface_t *
cups_printer_create_cairo_surface (GtkPrinter *printer,
cups_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
gdouble width,
gdouble height,
gint cache_fd)
gdouble width,
gdouble height,
gint cache_fd)
{
cairo_surface_t *surface;
@ -303,8 +311,8 @@ cups_free_print_stream_data (CupsPrintStreamData *data)
static void
cups_print_cb (GtkPrintBackendCups *print_backend,
GtkCupsResult *result,
gpointer user_data)
GtkCupsResult *result,
gpointer user_data)
{
GError *error = NULL;
CupsPrintStreamData *ps = user_data;
@ -362,12 +370,12 @@ add_cups_options (const char *key,
}
static void
gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
GtkPrintJob *job,
gint data_fd,
GtkPrintJobCompleteFunc callback,
gpointer user_data,
GDestroyNotify dnotify)
gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
GtkPrintJob *job,
gint data_fd,
GtkPrintJobCompleteFunc callback,
gpointer user_data,
GDestroyNotify dnotify)
{
GError *error;
GtkPrinterCups *cups_printer;
@ -503,7 +511,7 @@ cups_dispatch_watch_check (GSource *source)
static gboolean
cups_dispatch_watch_prepare (GSource *source,
gint *timeout_)
gint *timeout_)
{
GtkPrintCupsDispatchWatch *dispatch;
@ -515,9 +523,9 @@ cups_dispatch_watch_prepare (GSource *source,
}
static gboolean
cups_dispatch_watch_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data)
cups_dispatch_watch_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data)
{
GtkPrintCupsDispatchWatch *dispatch;
GtkPrintCupsResponseCallbackFunc ep_callback;
@ -576,12 +584,12 @@ static GSourceFuncs _cups_dispatch_watch_funcs = {
static void
cups_request_execute (GtkPrintBackendCups *print_backend,
GtkCupsRequest *request,
GtkPrintCupsResponseCallbackFunc callback,
gpointer user_data,
GDestroyNotify notify,
GError **err)
cups_request_execute (GtkPrintBackendCups *print_backend,
GtkCupsRequest *request,
GtkPrintCupsResponseCallbackFunc callback,
gpointer user_data,
GDestroyNotify notify,
GError **err)
{
GtkPrintCupsDispatchWatch *dispatch;
@ -600,8 +608,8 @@ cups_request_execute (GtkPrintBackendCups *print_backend,
static void
cups_request_printer_info_cb (GtkPrintBackendCups *backend,
GtkCupsResult *result,
gpointer user_data)
GtkCupsResult *result,
gpointer user_data)
{
ipp_attribute_t *attr;
ipp_t *response;
@ -671,7 +679,7 @@ cups_request_printer_info_cb (GtkPrintBackendCups *backend,
static void
cups_request_printer_info (GtkPrintBackendCups *print_backend,
const gchar *printer_name)
const gchar *printer_name)
{
GError *error;
GtkCupsRequest *request;
@ -723,7 +731,7 @@ typedef struct {
} CupsJobPollData;
static void
job_object_died (gpointer user_data,
job_object_died (gpointer user_data,
GObject *where_the_object_was)
{
CupsJobPollData *data = user_data;
@ -741,8 +749,8 @@ cups_job_poll_data_free (CupsJobPollData *data)
static void
cups_request_job_info_cb (GtkPrintBackendCups *print_backend,
GtkCupsResult *result,
gpointer user_data)
GtkCupsResult *result,
gpointer user_data)
{
CupsJobPollData *data = user_data;
ipp_attribute_t *attr;
@ -858,8 +866,8 @@ cups_job_info_poll_timeout (gpointer user_data)
static void
cups_begin_polling_info (GtkPrintBackendCups *print_backend,
GtkPrintJob *job,
int job_id)
GtkPrintJob *job,
int job_id)
{
CupsJobPollData *data;
@ -876,7 +884,7 @@ cups_begin_polling_info (GtkPrintBackendCups *print_backend,
}
static void
mark_printer_inactive (GtkPrinter *printer,
mark_printer_inactive (GtkPrinter *printer,
GtkPrintBackend *backend)
{
gtk_printer_set_is_active (printer, FALSE);
@ -885,9 +893,10 @@ mark_printer_inactive (GtkPrinter *printer,
}
static gint
find_printer (GtkPrinter *printer, const char *find_name)
find_printer (GtkPrinter *printer,
const gchar *find_name)
{
const char *printer_name;
const gchar *printer_name;
printer_name = gtk_printer_get_name (printer);
return g_ascii_strcasecmp (printer_name, find_name);
@ -895,8 +904,8 @@ find_printer (GtkPrinter *printer, const char *find_name)
static void
cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
GtkCupsResult *result,
gpointer user_data)
GtkCupsResult *result,
gpointer user_data)
{
ipp_attribute_t *attr;
ipp_t *response;
@ -1147,8 +1156,8 @@ get_ppd_data_free (GetPPDData *data)
static void
cups_request_ppd_cb (GtkPrintBackendCups *print_backend,
GtkCupsResult *result,
GetPPDData *data)
GtkCupsResult *result,
GetPPDData *data)
{
ipp_t *response;
GtkPrinter *printer;
@ -1170,7 +1179,7 @@ cups_request_ppd_cb (GtkPrintBackendCups *print_backend,
}
static void
cups_request_ppd (GtkPrinter *printer)
cups_request_ppd (GtkPrinter *printer)
{
GError *error;
GtkPrintBackend *print_backend;
@ -1234,8 +1243,8 @@ cups_request_ppd (GtkPrinter *printer)
static void
cups_request_default_printer_cb (GtkPrintBackendCups *print_backend,
GtkCupsResult *result,
gpointer user_data)
GtkCupsResult *result,
gpointer user_data)
{
ipp_t *response;
ipp_attribute_t *attr;
@ -1498,7 +1507,8 @@ static const char *cups_option_blacklist[] = {
};
static char *
get_option_text (ppd_file_t *ppd_file, ppd_option_t *option)
get_option_text (ppd_file_t *ppd_file,
ppd_option_t *option)
{
int i;
char *utf8;
@ -1518,7 +1528,8 @@ get_option_text (ppd_file_t *ppd_file, ppd_option_t *option)
}
static char *
get_choice_text (ppd_file_t *ppd_file, ppd_choice_t *choice)
get_choice_text (ppd_file_t *ppd_file,
ppd_choice_t *choice)
{
int i;
ppd_option_t *option = choice->option;
@ -1534,7 +1545,8 @@ get_choice_text (ppd_file_t *ppd_file, ppd_choice_t *choice)
}
static gboolean
group_has_option (ppd_group_t *group, ppd_option_t *option)
group_has_option (ppd_group_t *group,
ppd_option_t *option)
{
int i;
@ -1572,10 +1584,10 @@ value_is_off (const char *value)
}
static int
available_choices (ppd_file_t *ppd,
ppd_option_t *option,
available_choices (ppd_file_t *ppd,
ppd_option_t *option,
ppd_choice_t ***available,
gboolean keep_if_only_one_option)
gboolean keep_if_only_one_option)
{
ppd_option_t *other_option;
int i, j;
@ -1735,9 +1747,9 @@ available_choices (ppd_file_t *ppd,
}
static GtkPrinterOption *
create_pickone_option (ppd_file_t *ppd_file,
create_pickone_option (ppd_file_t *ppd_file,
ppd_option_t *ppd_option,
const char *gtk_name)
const gchar *gtk_name)
{
GtkPrinterOption *option;
ppd_choice_t **available;
@ -1784,9 +1796,9 @@ create_pickone_option (ppd_file_t *ppd_file,
}
static GtkPrinterOption *
create_boolean_option (ppd_file_t *ppd_file,
create_boolean_option (ppd_file_t *ppd_file,
ppd_option_t *ppd_option,
const char *gtk_name)
const gchar *gtk_name)
{
GtkPrinterOption *option;
ppd_choice_t **available;
@ -1822,8 +1834,8 @@ create_boolean_option (ppd_file_t *ppd_file,
return option;
}
static char *
get_option_name (const char *keyword)
static gchar *
get_option_name (const gchar *keyword)
{
int i;
@ -1835,7 +1847,8 @@ get_option_name (const char *keyword)
}
static int
strptr_cmp (const void *a, const void *b)
strptr_cmp (const void *a,
const void *b)
{
char **aa = (char **)a;
char **bb = (char **)b;
@ -1844,7 +1857,9 @@ strptr_cmp (const void *a, const void *b)
static gboolean
string_in_table (char *str, const char *table[], int table_len)
string_in_table (gchar *str,
const gchar *table[],
gint table_len)
{
return bsearch (&str, table, table_len, sizeof (char *), (void *)strptr_cmp) != NULL;
}
@ -1853,10 +1868,10 @@ string_in_table (char *str, const char *table[], int table_len)
static void
handle_option (GtkPrinterOptionSet *set,
ppd_file_t *ppd_file,
ppd_option_t *ppd_option,
ppd_group_t *toplevel_group,
GtkPrintSettings *settings)
ppd_file_t *ppd_file,
ppd_option_t *ppd_option,
ppd_group_t *toplevel_group,
GtkPrintSettings *settings)
{
GtkPrinterOption *option;
char *name;
@ -1917,12 +1932,12 @@ handle_option (GtkPrinterOptionSet *set,
static void
handle_group (GtkPrinterOptionSet *set,
ppd_file_t *ppd_file,
ppd_group_t *group,
ppd_group_t *toplevel_group,
GtkPrintSettings *settings)
ppd_file_t *ppd_file,
ppd_group_t *group,
ppd_group_t *toplevel_group,
GtkPrintSettings *settings)
{
int i;
gint i;
/* Ignore installable options */
if (strcmp (toplevel_group->name, "InstallableOptions") == 0)
@ -1937,9 +1952,9 @@ handle_group (GtkPrinterOptionSet *set,
}
static GtkPrinterOptionSet *
cups_printer_get_options (GtkPrinter *printer,
GtkPrintSettings *settings,
GtkPageSetup *page_setup)
cups_printer_get_options (GtkPrinter *printer,
GtkPrintSettings *settings,
GtkPageSetup *page_setup)
{
GtkPrinterOptionSet *set;
GtkPrinterOption *option;
@ -2040,8 +2055,8 @@ cups_printer_get_options (GtkPrinter *printer,
static void
mark_option_from_set (GtkPrinterOptionSet *set,
ppd_file_t *ppd_file,
ppd_option_t *ppd_option)
ppd_file_t *ppd_file,
ppd_option_t *ppd_option)
{
GtkPrinterOption *option;
char *name = get_option_name (ppd_option->keyword);
@ -2057,8 +2072,8 @@ mark_option_from_set (GtkPrinterOptionSet *set,
static void
mark_group_from_set (GtkPrinterOptionSet *set,
ppd_file_t *ppd_file,
ppd_group_t *group)
ppd_file_t *ppd_file,
ppd_group_t *group)
{
int i;
@ -2071,8 +2086,8 @@ mark_group_from_set (GtkPrinterOptionSet *set,
static void
set_conflicts_from_option (GtkPrinterOptionSet *set,
ppd_file_t *ppd_file,
ppd_option_t *ppd_option)
ppd_file_t *ppd_file,
ppd_option_t *ppd_option)
{
GtkPrinterOption *option;
char *name;
@ -2092,8 +2107,8 @@ set_conflicts_from_option (GtkPrinterOptionSet *set,
static void
set_conflicts_from_group (GtkPrinterOptionSet *set,
ppd_file_t *ppd_file,
ppd_group_t *group)
ppd_file_t *ppd_file,
ppd_group_t *group)
{
int i;
@ -2146,12 +2161,12 @@ typedef struct {
} NameMapping;
static void
map_settings_to_option (GtkPrinterOption *option,
const NameMapping table[],
int n_elements,
GtkPrintSettings *settings,
const char *standard_name,
const char *cups_name)
map_settings_to_option (GtkPrinterOption *option,
const NameMapping table[],
gint n_elements,
GtkPrintSettings *settings,
const gchar *standard_name,
const gchar *cups_name)
{
int i;
char *name;
@ -2196,12 +2211,12 @@ map_settings_to_option (GtkPrinterOption *option,
}
static void
map_option_to_settings (const char *value,
const NameMapping table[],
int n_elements,
GtkPrintSettings *settings,
const char *standard_name,
const char *cups_name)
map_option_to_settings (const gchar *value,
const NameMapping table[],
gint n_elements,
GtkPrintSettings *settings,
const gchar *standard_name,
const gchar *cups_name)
{
int i;
char *name;
@ -2376,7 +2391,7 @@ set_option_from_settings (GtkPrinterOption *option,
}
static void
foreach_option_get_settings (GtkPrinterOption *option,
foreach_option_get_settings (GtkPrinterOption *option,
gpointer user_data)
{
struct OptionData *data = user_data;
@ -2428,9 +2443,9 @@ foreach_option_get_settings (GtkPrinterOption *option,
}
static void
cups_printer_get_settings_from_options (GtkPrinter *printer,
cups_printer_get_settings_from_options (GtkPrinter *printer,
GtkPrinterOptionSet *options,
GtkPrintSettings *settings)
GtkPrintSettings *settings)
{
struct OptionData data;
const char *print_at, *print_at_time;
@ -2465,10 +2480,10 @@ cups_printer_get_settings_from_options (GtkPrinter *printer,
}
static void
cups_printer_prepare_for_print (GtkPrinter *printer,
GtkPrintJob *print_job,
cups_printer_prepare_for_print (GtkPrinter *printer,
GtkPrintJob *print_job,
GtkPrintSettings *settings,
GtkPageSetup *page_setup)
GtkPageSetup *page_setup)
{
GtkPageSet page_set;
GtkPaperSize *paper_size;
@ -2582,10 +2597,10 @@ cups_printer_list_papers (GtkPrinter *printer)
static void
cups_printer_get_hard_margins (GtkPrinter *printer,
double *top,
double *bottom,
double *left,
double *right)
gdouble *top,
gdouble *bottom,
gdouble *left,
gdouble *right)
{
ppd_file_t *ppd_file;

View File

@ -74,6 +74,7 @@ static void lpr_printer_prepare_for_print (GtkPrinter
GtkPrintSettings *settings,
GtkPageSetup *page_setup);
static cairo_surface_t * lpr_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
gdouble width,
gdouble height,
gint cache_fd);
@ -163,36 +164,46 @@ gtk_print_backend_lpr_class_init (GtkPrintBackendLprClass *class)
}
static cairo_status_t
_cairo_write (void *cache_fd_as_pointer,
_cairo_write (void *closure,
const unsigned char *data,
unsigned int length)
{
cairo_status_t result;
gint cache_fd;
cache_fd = GPOINTER_TO_INT (cache_fd_as_pointer);
gint fd = GPOINTER_TO_INT (closure);
gssize written;
result = CAIRO_STATUS_WRITE_ERROR;
/* write out the buffer */
if (write (cache_fd, data, length) != -1)
result = CAIRO_STATUS_SUCCESS;
return result;
while (length > 0)
{
written = write (fd, data, length);
if (written == -1)
{
if (errno == EAGAIN || errno == EINTR)
continue;
return CAIRO_STATUS_WRITE_ERROR;
}
data += written;
length -= written;
}
return CAIRO_STATUS_SUCCESS;
}
static cairo_surface_t *
lpr_printer_create_cairo_surface (GtkPrinter *printer,
gdouble width,
gdouble height,
gint cache_fd)
lpr_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
gdouble width,
gdouble height,
gint cache_fd)
{
cairo_surface_t *surface;
surface = cairo_ps_surface_create_for_stream (_cairo_write, GINT_TO_POINTER (cache_fd), width, height);
surface = cairo_ps_surface_create_for_stream (_cairo_write, GINT_TO_POINTER (cache_fd), width, height);
/* TODO: DPI from settings object? */
cairo_ps_surface_set_dpi (surface, 300, 300);
cairo_surface_set_fallback_resolution (surface, 300, 300);
return surface;
}
@ -212,8 +223,8 @@ typedef struct {
static void
lpr_print_cb (GtkPrintBackendLpr *print_backend,
GError *error,
gpointer user_data)
GError *error,
gpointer user_data)
{
_PrintStreamData *ps = (_PrintStreamData *) user_data;
@ -242,9 +253,9 @@ lpr_print_cb (GtkPrintBackendLpr *print_backend,
}
static gboolean
lpr_write (GIOChannel *source,
GIOCondition con,
gpointer user_data)
lpr_write (GIOChannel *source,
GIOCondition con,
gpointer user_data)
{
gchar buf[_LPR_MAX_CHUNK_SIZE];
gsize bytes_read;
@ -289,12 +300,12 @@ lpr_write (GIOChannel *source,
#define LPR_COMMAND "lpr"
static void
gtk_print_backend_lpr_print_stream (GtkPrintBackend *print_backend,
GtkPrintJob *job,
gint data_fd,
gtk_print_backend_lpr_print_stream (GtkPrintBackend *print_backend,
GtkPrintJob *job,
gint data_fd,
GtkPrintJobCompleteFunc callback,
gpointer user_data,
GDestroyNotify dnotify)
gpointer user_data,
GDestroyNotify dnotify)
{
GError *error;
GtkPrinter *printer;
@ -382,9 +393,9 @@ gtk_print_backend_lpr_init (GtkPrintBackendLpr *backend)
}
static GtkPrinterOptionSet *
lpr_printer_get_options (GtkPrinter *printer,
lpr_printer_get_options (GtkPrinter *printer,
GtkPrintSettings *settings,
GtkPageSetup *page_setup)
GtkPageSetup *page_setup)
{
GtkPrinterOptionSet *set;
GtkPrinterOption *option;
@ -413,9 +424,9 @@ lpr_printer_get_options (GtkPrinter *printer,
}
static void
lpr_printer_get_settings_from_options (GtkPrinter *printer,
lpr_printer_get_settings_from_options (GtkPrinter *printer,
GtkPrinterOptionSet *options,
GtkPrintSettings *settings)
GtkPrintSettings *settings)
{
GtkPrinterOption *option;
@ -424,10 +435,10 @@ lpr_printer_get_settings_from_options (GtkPrinter *printer,
}
static void
lpr_printer_prepare_for_print (GtkPrinter *printer,
GtkPrintJob *print_job,
lpr_printer_prepare_for_print (GtkPrinter *printer,
GtkPrintJob *print_job,
GtkPrintSettings *settings,
GtkPageSetup *page_setup)
GtkPageSetup *page_setup)
{
double scale;

View File

@ -81,6 +81,7 @@ static void gtk_print_backend_pdf_print_stream (GtkPrintBacke
gpointer user_data,
GDestroyNotify dnotify);
static cairo_surface_t * pdf_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
gdouble width,
gdouble height,
gint cache_fd);
@ -164,29 +165,39 @@ gtk_print_backend_pdf_class_init (GtkPrintBackendPdfClass *class)
}
static cairo_status_t
_cairo_write (void *cache_fd_as_pointer,
_cairo_write (void *closure,
const unsigned char *data,
unsigned int length)
{
cairo_status_t result;
gint cache_fd;
cache_fd = GPOINTER_TO_INT (cache_fd_as_pointer);
gint fd = GPOINTER_TO_INT (closure);
gssize written;
result = CAIRO_STATUS_WRITE_ERROR;
/* write out the buffer */
if (write (cache_fd, data, length) != -1)
result = CAIRO_STATUS_SUCCESS;
return result;
while (length > 0)
{
written = write (fd, data, length);
if (written == -1)
{
if (errno == EAGAIN || errno == EINTR)
continue;
return CAIRO_STATUS_WRITE_ERROR;
}
data += written;
length -= written;
}
return CAIRO_STATUS_SUCCESS;
}
static cairo_surface_t *
pdf_printer_create_cairo_surface (GtkPrinter *printer,
gdouble width,
gdouble height,
gint cache_fd)
pdf_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
gdouble width,
gdouble height,
gint cache_fd)
{
cairo_surface_t *surface;
@ -209,8 +220,8 @@ typedef struct {
static void
pdf_print_cb (GtkPrintBackendPdf *print_backend,
GError *error,
gpointer user_data)
GError *error,
gpointer user_data)
{
_PrintStreamData *ps = (_PrintStreamData *) user_data;
@ -233,9 +244,9 @@ pdf_print_cb (GtkPrintBackendPdf *print_backend,
}
static gboolean
pdf_write (GIOChannel *source,
GIOCondition con,
gpointer user_data)
pdf_write (GIOChannel *source,
GIOCondition con,
gpointer user_data)
{
gchar buf[_PDF_MAX_CHUNK_SIZE];
gsize bytes_read;
@ -280,12 +291,12 @@ pdf_write (GIOChannel *source,
}
static void
gtk_print_backend_pdf_print_stream (GtkPrintBackend *print_backend,
GtkPrintJob *job,
gint data_fd,
gtk_print_backend_pdf_print_stream (GtkPrintBackend *print_backend,
GtkPrintJob *job,
gint data_fd,
GtkPrintJobCompleteFunc callback,
gpointer user_data,
GDestroyNotify dnotify)
gpointer user_data,
GDestroyNotify dnotify)
{
GError *error;
GtkPrinter *printer;
@ -356,9 +367,9 @@ gtk_print_backend_pdf_init (GtkPrintBackendPdf *backend)
}
static GtkPrinterOptionSet *
pdf_printer_get_options (GtkPrinter *printer,
pdf_printer_get_options (GtkPrinter *printer,
GtkPrintSettings *settings,
GtkPageSetup *page_setup)
GtkPageSetup *page_setup)
{
GtkPrinterOptionSet *set;
GtkPrinterOption *option;
@ -387,9 +398,9 @@ pdf_printer_get_options (GtkPrinter *printer,
}
static void
pdf_printer_get_settings_from_options (GtkPrinter *printer,
pdf_printer_get_settings_from_options (GtkPrinter *printer,
GtkPrinterOptionSet *options,
GtkPrintSettings *settings)
GtkPrintSettings *settings)
{
GtkPrinterOption *option;
@ -398,10 +409,10 @@ pdf_printer_get_settings_from_options (GtkPrinter *printer,
}
static void
pdf_printer_prepare_for_print (GtkPrinter *printer,
GtkPrintJob *print_job,
pdf_printer_prepare_for_print (GtkPrinter *printer,
GtkPrintJob *print_job,
GtkPrintSettings *settings,
GtkPageSetup *page_setup)
GtkPageSetup *page_setup)
{
double scale;