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:

committed by
Matthias Clasen

parent
a0063d39d2
commit
956bcb4393
10
ChangeLog
10
ChangeLog
@ -1,5 +1,15 @@
|
|||||||
2006-06-16 Matthias Clasen <mclasen@redhat.com>
|
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
|
* gtk/gtkentrycompletion.c (gtk_entry_completion_finalize): Don't
|
||||||
leak match data. (#345107, Christian Weiske)
|
leak match data. (#345107, Christian Weiske)
|
||||||
|
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
2006-06-16 Matthias Clasen <mclasen@redhat.com>
|
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
|
* gtk/gtkentrycompletion.c (gtk_entry_completion_finalize): Don't
|
||||||
leak match data. (#345107, Christian Weiske)
|
leak match data. (#345107, Christian Weiske)
|
||||||
|
|
||||||
|
@ -81,6 +81,7 @@ struct _GtkPrintBackendClass
|
|||||||
/* Printer methods: */
|
/* Printer methods: */
|
||||||
void (*printer_request_details) (GtkPrinter *printer);
|
void (*printer_request_details) (GtkPrinter *printer);
|
||||||
cairo_surface_t * (*printer_create_cairo_surface) (GtkPrinter *printer,
|
cairo_surface_t * (*printer_create_cairo_surface) (GtkPrinter *printer,
|
||||||
|
GtkPrintSettings *settings,
|
||||||
gdouble height,
|
gdouble height,
|
||||||
gdouble width,
|
gdouble width,
|
||||||
gint cache_fd);
|
gint cache_fd);
|
||||||
|
@ -45,6 +45,7 @@ void _gtk_printer_prepare_for_print (GtkPrinter
|
|||||||
GtkPrintSettings *settings,
|
GtkPrintSettings *settings,
|
||||||
GtkPageSetup *page_setup);
|
GtkPageSetup *page_setup);
|
||||||
cairo_surface_t * _gtk_printer_create_cairo_surface (GtkPrinter *printer,
|
cairo_surface_t * _gtk_printer_create_cairo_surface (GtkPrinter *printer,
|
||||||
|
GtkPrintSettings *settings,
|
||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height,
|
gdouble height,
|
||||||
gint cache_fd);
|
gint cache_fd);
|
||||||
|
@ -750,13 +750,15 @@ _gtk_printer_prepare_for_print (GtkPrinter *printer,
|
|||||||
|
|
||||||
cairo_surface_t *
|
cairo_surface_t *
|
||||||
_gtk_printer_create_cairo_surface (GtkPrinter *printer,
|
_gtk_printer_create_cairo_surface (GtkPrinter *printer,
|
||||||
|
GtkPrintSettings *settings,
|
||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height,
|
gdouble height,
|
||||||
gint cache_fd)
|
gint cache_fd)
|
||||||
{
|
{
|
||||||
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend);
|
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 *
|
GList *
|
||||||
|
@ -248,23 +248,31 @@ gtk_print_backend_cups_class_init (GtkPrintBackendCupsClass *class)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static cairo_status_t
|
static cairo_status_t
|
||||||
_cairo_write_to_cups (void *cache_fd_as_pointer,
|
_cairo_write_to_cups (void *closure,
|
||||||
const unsigned char *data,
|
const unsigned char *data,
|
||||||
unsigned int length)
|
unsigned int length)
|
||||||
{
|
{
|
||||||
cairo_status_t result;
|
gint fd = GPOINTER_TO_INT (closure);
|
||||||
gint cache_fd;
|
gssize written;
|
||||||
cache_fd = GPOINTER_TO_INT (cache_fd_as_pointer);
|
|
||||||
|
|
||||||
result = CAIRO_STATUS_WRITE_ERROR;
|
while (length > 0)
|
||||||
|
{
|
||||||
|
written = write (fd, data, length);
|
||||||
|
|
||||||
/* write out the buffer */
|
if (written == -1)
|
||||||
if (write (cache_fd, data, length) != -1)
|
{
|
||||||
result = CAIRO_STATUS_SUCCESS;
|
if (errno == EAGAIN || errno == EINTR)
|
||||||
|
continue;
|
||||||
|
|
||||||
return result;
|
return CAIRO_STATUS_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data += written;
|
||||||
|
length -= written;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CAIRO_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static cairo_surface_t *
|
static cairo_surface_t *
|
||||||
cups_printer_create_cairo_surface (GtkPrinter *printer,
|
cups_printer_create_cairo_surface (GtkPrinter *printer,
|
||||||
@ -885,9 +893,10 @@ mark_printer_inactive (GtkPrinter *printer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
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);
|
printer_name = gtk_printer_get_name (printer);
|
||||||
return g_ascii_strcasecmp (printer_name, find_name);
|
return g_ascii_strcasecmp (printer_name, find_name);
|
||||||
@ -1498,7 +1507,8 @@ static const char *cups_option_blacklist[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static char *
|
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;
|
int i;
|
||||||
char *utf8;
|
char *utf8;
|
||||||
@ -1518,7 +1528,8 @@ get_option_text (ppd_file_t *ppd_file, ppd_option_t *option)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
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;
|
int i;
|
||||||
ppd_option_t *option = choice->option;
|
ppd_option_t *option = choice->option;
|
||||||
@ -1534,7 +1545,8 @@ get_choice_text (ppd_file_t *ppd_file, ppd_choice_t *choice)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
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;
|
int i;
|
||||||
|
|
||||||
@ -1737,7 +1749,7 @@ available_choices (ppd_file_t *ppd,
|
|||||||
static GtkPrinterOption *
|
static GtkPrinterOption *
|
||||||
create_pickone_option (ppd_file_t *ppd_file,
|
create_pickone_option (ppd_file_t *ppd_file,
|
||||||
ppd_option_t *ppd_option,
|
ppd_option_t *ppd_option,
|
||||||
const char *gtk_name)
|
const gchar *gtk_name)
|
||||||
{
|
{
|
||||||
GtkPrinterOption *option;
|
GtkPrinterOption *option;
|
||||||
ppd_choice_t **available;
|
ppd_choice_t **available;
|
||||||
@ -1786,7 +1798,7 @@ create_pickone_option (ppd_file_t *ppd_file,
|
|||||||
static GtkPrinterOption *
|
static GtkPrinterOption *
|
||||||
create_boolean_option (ppd_file_t *ppd_file,
|
create_boolean_option (ppd_file_t *ppd_file,
|
||||||
ppd_option_t *ppd_option,
|
ppd_option_t *ppd_option,
|
||||||
const char *gtk_name)
|
const gchar *gtk_name)
|
||||||
{
|
{
|
||||||
GtkPrinterOption *option;
|
GtkPrinterOption *option;
|
||||||
ppd_choice_t **available;
|
ppd_choice_t **available;
|
||||||
@ -1822,8 +1834,8 @@ create_boolean_option (ppd_file_t *ppd_file,
|
|||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static gchar *
|
||||||
get_option_name (const char *keyword)
|
get_option_name (const gchar *keyword)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1835,7 +1847,8 @@ get_option_name (const char *keyword)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
strptr_cmp (const void *a, const void *b)
|
strptr_cmp (const void *a,
|
||||||
|
const void *b)
|
||||||
{
|
{
|
||||||
char **aa = (char **)a;
|
char **aa = (char **)a;
|
||||||
char **bb = (char **)b;
|
char **bb = (char **)b;
|
||||||
@ -1844,7 +1857,9 @@ strptr_cmp (const void *a, const void *b)
|
|||||||
|
|
||||||
|
|
||||||
static gboolean
|
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;
|
return bsearch (&str, table, table_len, sizeof (char *), (void *)strptr_cmp) != NULL;
|
||||||
}
|
}
|
||||||
@ -1922,7 +1937,7 @@ handle_group (GtkPrinterOptionSet *set,
|
|||||||
ppd_group_t *toplevel_group,
|
ppd_group_t *toplevel_group,
|
||||||
GtkPrintSettings *settings)
|
GtkPrintSettings *settings)
|
||||||
{
|
{
|
||||||
int i;
|
gint i;
|
||||||
|
|
||||||
/* Ignore installable options */
|
/* Ignore installable options */
|
||||||
if (strcmp (toplevel_group->name, "InstallableOptions") == 0)
|
if (strcmp (toplevel_group->name, "InstallableOptions") == 0)
|
||||||
@ -2148,10 +2163,10 @@ typedef struct {
|
|||||||
static void
|
static void
|
||||||
map_settings_to_option (GtkPrinterOption *option,
|
map_settings_to_option (GtkPrinterOption *option,
|
||||||
const NameMapping table[],
|
const NameMapping table[],
|
||||||
int n_elements,
|
gint n_elements,
|
||||||
GtkPrintSettings *settings,
|
GtkPrintSettings *settings,
|
||||||
const char *standard_name,
|
const gchar *standard_name,
|
||||||
const char *cups_name)
|
const gchar *cups_name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *name;
|
char *name;
|
||||||
@ -2196,12 +2211,12 @@ map_settings_to_option (GtkPrinterOption *option,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
map_option_to_settings (const char *value,
|
map_option_to_settings (const gchar *value,
|
||||||
const NameMapping table[],
|
const NameMapping table[],
|
||||||
int n_elements,
|
gint n_elements,
|
||||||
GtkPrintSettings *settings,
|
GtkPrintSettings *settings,
|
||||||
const char *standard_name,
|
const gchar *standard_name,
|
||||||
const char *cups_name)
|
const gchar *cups_name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *name;
|
char *name;
|
||||||
@ -2582,10 +2597,10 @@ cups_printer_list_papers (GtkPrinter *printer)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
cups_printer_get_hard_margins (GtkPrinter *printer,
|
cups_printer_get_hard_margins (GtkPrinter *printer,
|
||||||
double *top,
|
gdouble *top,
|
||||||
double *bottom,
|
gdouble *bottom,
|
||||||
double *left,
|
gdouble *left,
|
||||||
double *right)
|
gdouble *right)
|
||||||
{
|
{
|
||||||
ppd_file_t *ppd_file;
|
ppd_file_t *ppd_file;
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ static void lpr_printer_prepare_for_print (GtkPrinter
|
|||||||
GtkPrintSettings *settings,
|
GtkPrintSettings *settings,
|
||||||
GtkPageSetup *page_setup);
|
GtkPageSetup *page_setup);
|
||||||
static cairo_surface_t * lpr_printer_create_cairo_surface (GtkPrinter *printer,
|
static cairo_surface_t * lpr_printer_create_cairo_surface (GtkPrinter *printer,
|
||||||
|
GtkPrintSettings *settings,
|
||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height,
|
gdouble height,
|
||||||
gint cache_fd);
|
gint cache_fd);
|
||||||
@ -163,26 +164,36 @@ gtk_print_backend_lpr_class_init (GtkPrintBackendLprClass *class)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static cairo_status_t
|
static cairo_status_t
|
||||||
_cairo_write (void *cache_fd_as_pointer,
|
_cairo_write (void *closure,
|
||||||
const unsigned char *data,
|
const unsigned char *data,
|
||||||
unsigned int length)
|
unsigned int length)
|
||||||
{
|
{
|
||||||
cairo_status_t result;
|
gint fd = GPOINTER_TO_INT (closure);
|
||||||
gint cache_fd;
|
gssize written;
|
||||||
cache_fd = GPOINTER_TO_INT (cache_fd_as_pointer);
|
|
||||||
|
|
||||||
result = CAIRO_STATUS_WRITE_ERROR;
|
while (length > 0)
|
||||||
|
{
|
||||||
|
written = write (fd, data, length);
|
||||||
|
|
||||||
/* write out the buffer */
|
if (written == -1)
|
||||||
if (write (cache_fd, data, length) != -1)
|
{
|
||||||
result = CAIRO_STATUS_SUCCESS;
|
if (errno == EAGAIN || errno == EINTR)
|
||||||
|
continue;
|
||||||
|
|
||||||
return result;
|
return CAIRO_STATUS_WRITE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
data += written;
|
||||||
|
length -= written;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CAIRO_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static cairo_surface_t *
|
static cairo_surface_t *
|
||||||
lpr_printer_create_cairo_surface (GtkPrinter *printer,
|
lpr_printer_create_cairo_surface (GtkPrinter *printer,
|
||||||
|
GtkPrintSettings *settings,
|
||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height,
|
gdouble height,
|
||||||
gint cache_fd)
|
gint cache_fd)
|
||||||
@ -192,7 +203,7 @@ lpr_printer_create_cairo_surface (GtkPrinter *printer,
|
|||||||
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? */
|
/* TODO: DPI from settings object? */
|
||||||
cairo_ps_surface_set_dpi (surface, 300, 300);
|
cairo_surface_set_fallback_resolution (surface, 300, 300);
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,7 @@ static void gtk_print_backend_pdf_print_stream (GtkPrintBacke
|
|||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GDestroyNotify dnotify);
|
GDestroyNotify dnotify);
|
||||||
static cairo_surface_t * pdf_printer_create_cairo_surface (GtkPrinter *printer,
|
static cairo_surface_t * pdf_printer_create_cairo_surface (GtkPrinter *printer,
|
||||||
|
GtkPrintSettings *settings,
|
||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height,
|
gdouble height,
|
||||||
gint cache_fd);
|
gint cache_fd);
|
||||||
@ -164,26 +165,36 @@ gtk_print_backend_pdf_class_init (GtkPrintBackendPdfClass *class)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static cairo_status_t
|
static cairo_status_t
|
||||||
_cairo_write (void *cache_fd_as_pointer,
|
_cairo_write (void *closure,
|
||||||
const unsigned char *data,
|
const unsigned char *data,
|
||||||
unsigned int length)
|
unsigned int length)
|
||||||
{
|
{
|
||||||
cairo_status_t result;
|
gint fd = GPOINTER_TO_INT (closure);
|
||||||
gint cache_fd;
|
gssize written;
|
||||||
cache_fd = GPOINTER_TO_INT (cache_fd_as_pointer);
|
|
||||||
|
|
||||||
result = CAIRO_STATUS_WRITE_ERROR;
|
while (length > 0)
|
||||||
|
{
|
||||||
|
written = write (fd, data, length);
|
||||||
|
|
||||||
/* write out the buffer */
|
if (written == -1)
|
||||||
if (write (cache_fd, data, length) != -1)
|
{
|
||||||
result = CAIRO_STATUS_SUCCESS;
|
if (errno == EAGAIN || errno == EINTR)
|
||||||
|
continue;
|
||||||
|
|
||||||
return result;
|
return CAIRO_STATUS_WRITE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
data += written;
|
||||||
|
length -= written;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CAIRO_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static cairo_surface_t *
|
static cairo_surface_t *
|
||||||
pdf_printer_create_cairo_surface (GtkPrinter *printer,
|
pdf_printer_create_cairo_surface (GtkPrinter *printer,
|
||||||
|
GtkPrintSettings *settings,
|
||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height,
|
gdouble height,
|
||||||
gint cache_fd)
|
gint cache_fd)
|
||||||
|
Reference in New Issue
Block a user